gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r3501 - GNUnet/src/applications/fs/fsui


From: grothoff
Subject: [GNUnet-SVN] r3501 - GNUnet/src/applications/fs/fsui
Date: Thu, 19 Oct 2006 20:51:11 -0700 (PDT)

Author: grothoff
Date: 2006-10-19 20:51:08 -0700 (Thu, 19 Oct 2006)
New Revision: 3501

Modified:
   GNUnet/src/applications/fs/fsui/deserialize.c
   GNUnet/src/applications/fs/fsui/serialize.c
Log:
deserialize

Modified: GNUnet/src/applications/fs/fsui/deserialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/deserialize.c       2006-10-20 00:17:45 UTC 
(rev 3500)
+++ GNUnet/src/applications/fs/fsui/deserialize.c       2006-10-20 03:51:08 UTC 
(rev 3501)
@@ -57,7 +57,7 @@
   return OK;  
 }
 
-#define READLONG(a) if (OK != read_long(fd, (long long*) a)) return SYSERR;
+#define READLONG(a) if (OK != read_long(fd, (long long*) &a)) return SYSERR;
 
 static struct ECRS_URI * read_uri(struct GE_Context * ectx,
                                  int fd) {
@@ -100,6 +100,8 @@
   return buf;    
 }
 
+#define READSTRING(c, max) if (NULL == (c = read_string(fd, max))) return 
SYSERR;
+
 static void fixState(FSUI_State * state) {
   switch (*state) { /* try to correct errors */
   case FSUI_ACTIVE:
@@ -468,16 +470,86 @@
   return OK;
 }
 
+static int readUploadList(struct FSUI_Context * ctx,
+                         struct FSUI_UploadList * parent,
+                         int fd,
+                         struct FSUI_UploadShared * shared) {
+  struct FSUI_UploadList * list;
+  struct FSUI_UploadList l;
+  unsigned long long stime;
+  int big;
+  struct GE_Context * ectx;
+
+  ectx = ctx->ectx;
+  while (1) {
+    READINT(big);
+    if (big == 0) 
+      return OK;
+    memset(&l,
+          0,
+          sizeof(FSUI_UploadList));
+    READINT(l.state);
+    READLONG(l.completed);
+    READLONG(l.total);
+    READLONG(stime);
+    if (stime < get_time())
+      stime = get_time();
+    READLONG(l.start_time);
+    if (l.start_time != 0)
+      l.start_time = (get_time() - stime) + l.start_time;
+    READURI(l.uri);
+    l.filename = read_string(fd, 1024*1024);
+    if (l.filename == NULL) {
+      ECRS_freeUri(l.uri);
+      GE_BREAK(NULL, 0);
+      break;
+    }
+    list = MALLOC(sizeof(struct FSUI_UploadList));
+    list->shared = shared;
+    memcpy(list, &l, sizeof(struct FSUI_UploadList));
+    if (OK != readUploadList(ctx,
+                            list,
+                            fd,
+                            shared)) {
+      ECRS_freeUri(l.uri);
+      FREE(l.filename);
+      FREE(list);
+      GE_BREAK(NULL, 0);
+      break;
+    }
+    list->next = parent->child;
+    parent->child = list;
+  }
+  return SYSERR;
+}
+
+
 static int readUploads(int fd,
                       struct FSUI_Context * ctx) {
   int big;
+  struct FSUI_UploadShared * shared;
 
+  memset(&ctx->activeUploads,
+        0,
+        sizeof(FSUI_UploadList));
   while (1) {
     READINT(big);
-    if (big != 1) 
+    if (big == 0) 
       return OK;
-
-    /* FIXME: deserialize! */
+    if (big != 2) {
+      GE_BREAK(NULL, 0);
+      break;
+    }
+    shared = MALLOC(sizeof(FSUI_UploadShared));
+    memset(shared,
+          0,
+          sizeof(FSUI_UploadShared));   
+    shared->extractor_config = NULL;   
+    if (OK != readUploadList(ctx,
+                            &ctx->activeUploads,
+                            fd,
+                            shared)) 
+      break;
   }
   return SYSERR;
 }
@@ -485,13 +557,20 @@
 static int readUnindex(int fd,
                       struct FSUI_Context * ctx) {
   int big;
+  char * name;
+  struct FSUI_UnindexList * ul;
 
   while (1) {
     READINT(big);
     if (big != 1) 
       return OK;
-
-    /* FIXME: deserialize! */    
+    READINT(big); /* state */
+    READSTRING(name, 1024 * 1024);
+    ul = MALLOC(sizeof(struct FSUI_UnindexList));
+    ul->state = big;
+    ul->filename = name;
+    ul->next = ctx->unindexOperations;
+    ctx->unindexOperations = ul;
   }
   return SYSERR;
 }

Modified: GNUnet/src/applications/fs/fsui/serialize.c
===================================================================
--- GNUnet/src/applications/fs/fsui/serialize.c 2006-10-20 00:17:45 UTC (rev 
3500)
+++ GNUnet/src/applications/fs/fsui/serialize.c 2006-10-20 03:51:08 UTC (rev 
3501)
@@ -237,6 +237,7 @@
       WRITELONG(fd, shared->expiration);
     } else {
       WRITEINT(fd, 1);
+      WRITEINT(fd, 1);
     }
     WRITEINT(fd, upos->state);
     WRITELONG(fd, upos->completed);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]