finished user import
authorArt Cancro <ajc@citadel.org>
Mon, 10 Apr 2023 21:11:03 +0000 (17:11 -0400)
committerArt Cancro <ajc@citadel.org>
Mon, 10 Apr 2023 21:11:03 +0000 (17:11 -0400)
citadel/server/server.h
citadel/utils/ctdl3264.c

index 04ffc63338acfd9f21b47722141462c75c260024..62a2e9c7399e9033674891b9cc5ed03446abf437 100644 (file)
@@ -74,6 +74,8 @@ struct cdbdata {
 
 
 // Defines the relationship of a user to a particular room
+// NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
+// NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
 struct visit {
        long v_roomnum;
        long v_roomgen;
@@ -92,6 +94,8 @@ struct visit {
 // 2. They are merely caches of data which exist somewhere else, for speed.
 // DO NOT PUT BIG DATA IN HERE ... we need this struct to be tiny for lots of quick r/w
 struct MetaData {
+// NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
+// NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
        long meta_msgnum;               // Message number in *local* message base
        int meta_refcount;              // Number of rooms pointing to this msg
        char meta_content_type[64];     // Cached MIME content-type
@@ -123,6 +127,8 @@ struct UseTable {
 
 
 // User records.
+// NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
+// NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
 typedef struct ctdluser ctdluser;
 struct ctdluser {                      // User record
        int version;                    // Citadel version which created this record
@@ -145,6 +151,8 @@ struct ctdluser {                   // User record
 
 
 // Message expiration policy stuff
+// NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
+// NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
 typedef struct ExpirePolicy ExpirePolicy;
 struct ExpirePolicy {
        int expire_mode;
@@ -153,6 +161,8 @@ struct ExpirePolicy {
 
 
 // Room records.
+// NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
+// NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
 struct ctdlroom {
        char QRname[ROOMNAMELEN];       // Name of room
        char QRpasswd[10];              // Only valid if it's a private rm
@@ -174,6 +184,8 @@ struct ctdlroom {
 
 
 // Floor record.  The floor number is implicit in its location in the file.
+// NOTE: if you add fields to this, you have to also write export/import code in server/modules/migrate/serv_migrate.c
+// NOTE: if you add fields to this, you have to also write conversion code in utils/ctdl3264/*
 struct floor {
        unsigned short f_flags;         // flags
        char f_name[256];               // name of floor
index d4dfca40193fe08be48d4f573c3958c605ffe9b5..6e74f4f59566e7a58b4f935c21e498ee11eb0e3a 100644 (file)
@@ -122,16 +122,10 @@ void convert_msgmain(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT
 
        // If the msgnum is negative, we are looking at METADATA
        if (in_msgnum < 0) {
-               struct MetaData_32 meta32;
-               if (in_data->size != sizeof meta32) {
-                       printf("\033[31mmetadata: db says %d bytes , struct says %ld bytes\033[0m\n", in_data->size, sizeof meta32);
-                       abort();
-               }
-               memset(&meta32, 0, sizeof meta32);
-               memcpy(&meta32, in_data->data, in_data->size);
+               struct MetaData_32 *meta32 = (struct MetaData_32 *)in_data->data;
 
-               //printf("metadata: msgnum=%d , refcount=%d , content_type=\"%s\" , rfc822len=%d\n",
-                       //meta32.meta_msgnum, meta32.meta_refcount, meta32.meta_content_type, meta32.meta_rfc822_length);
+               printf("metadata: msgnum=%d , refcount=%d , content_type=\"%s\" , rfc822len=%d\n",
+                       meta32->meta_msgnum, meta32->meta_refcount, meta32->meta_content_type, meta32->meta_rfc822_length);
 
                out_key->size = sizeof(long);
                out_key->data = realloc(out_key->data, out_key->size);
@@ -142,10 +136,10 @@ void convert_msgmain(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT
                out_data->data = realloc(out_data->data, out_data->size);
                struct MetaData *meta64 = (struct MetaData *)out_data->data;
                memset(meta64, 0, sizeof(struct MetaData));
-               meta64->meta_msgnum             = (long)        meta32.meta_msgnum;
-               meta64->meta_refcount           = (int)         meta32.meta_refcount;
-               strcpy(meta64->meta_content_type,               meta32.meta_content_type);
-               meta64->meta_rfc822_length      = (long)        meta32.meta_rfc822_length;
+               meta64->meta_msgnum             = (long)        meta32->meta_msgnum;
+               meta64->meta_refcount           = (int)         meta32->meta_refcount;
+               strcpy(meta64->meta_content_type,               meta32->meta_content_type);
+               meta64->meta_rfc822_length      = (long)        meta32->meta_rfc822_length;
 
        }
 
@@ -169,12 +163,36 @@ void convert_msgmain(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT
 }
 
 
-// convert function for a message in msgmain
+// convert function for a user record
 void convert_users(int which_cdb, DBT *in_key, DBT *in_data, DBT *out_key, DBT *out_data) {
-       char userkey[64];
-       memcpy(userkey, in_key->data, in_key->size);
-       userkey[in_key->size] = 0;
-       //printf("users: len is %d , key is %s\n", in_key->size, userkey);
+
+       // The key is a string so we can just copy it over
+       out_key->size = in_key->size;
+       out_key->data = realloc(out_key->data, out_key->size);
+       memcpy(out_key->data, in_key->data, in_key->size);
+
+       struct ctdluser_32 *user32 = (struct ctdluser_32 *)in_data->data;
+
+       out_data->size = sizeof(struct ctdluser);
+       out_data->data = realloc(out_data->data, out_data->size);
+       struct ctdluser *user64 = (struct ctdluser *)out_data->data;
+
+       user64->version                 = (int)         user32->version;
+       user64->uid                     = (uid_t)       user32->uid;
+       strcpy(user64->password,                        user32->password);
+       user64->flags                   = (unsigned)    user32->flags;
+       user64->timescalled             = (long)        user32->timescalled;
+       user64->posted                  = (long)        user32->posted;
+       user64->axlevel                 = (cit_uint8_t) user32->axlevel;
+       user64->usernum                 = (long)        user32->usernum;
+       user64->lastcall                = (time_t)      user32->lastcall;
+       user64->USuserpurge             = (int)         user32->USuserpurge;
+       strcpy(user64->fullname,                        user32->fullname);
+       user64->msgnum_bio              = (long)        user32->msgnum_bio;
+       user64->msgnum_pic              = (long)        user32->msgnum_pic;
+       strcpy(user64->emailaddrs,                      user32->emailaddrs);
+       user64->msgnum_inboxrules       = (long)        user32->msgnum_inboxrules;
+       user64->lastproc_inboxrules     = (long)        user32->lastproc_inboxrules;
 }