* More vCard-related debugging
authorArt Cancro <ajc@citadel.org>
Fri, 8 Oct 1999 02:55:57 +0000 (02:55 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 8 Oct 1999 02:55:57 +0000 (02:55 +0000)
citadel/ChangeLog
citadel/dynloader.c
citadel/msgbase.c
citadel/msgbase.h
citadel/serv_icq.c
citadel/serv_upgrade.c
citadel/serv_vcard.c
citadel/server.h

index 07c480735d90ac46b2edd7cd5bd92020cde56c9d..6ef0bb94e0c5bea148967f2bec225fc247f9cd59 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 1.381  1999/10/08 02:55:57  ajc
+* More vCard-related debugging
+
 Revision 1.380  1999/10/07 02:58:46  ajc
 * Semi-broken vCard replacement implementation in place.
 * Added "Z" (Zap, supersede) field to message format
@@ -1298,3 +1301,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
+
index f6da4d7b2dad619d57c3065ee05eace4282f1272..1993328c8d60d9ce3816f9e9e0c7a71b99225aea 100644 (file)
@@ -267,6 +267,18 @@ int PerformMessageHooks(struct CtdlMessage *msg, int EventType)
        struct MessageFunctionHook *fcn;
        int total_retval = 0;
 
+       /* Other code may elect to protect this message from server-side
+        * handlers; if this is the case, don't do anything.
+        */
+       lprintf(9, "** Event type is %d, flags are %d\n",
+               EventType, msg->cm_flags);
+       if (msg->cm_flags & CM_SKIP_HOOKS) {
+               lprintf(9, "Skipping hooks\n");
+               return(0);
+       }
+
+       /* Otherwise, run all the hooks appropriate to this event type.
+        */
        for (fcn = MessageHookTable; fcn != NULL; fcn = fcn->next) {
                if (fcn->eventtype == EventType) {
                        total_retval = total_retval +
@@ -274,9 +286,15 @@ int PerformMessageHooks(struct CtdlMessage *msg, int EventType)
                }
        }
 
+       /* Return the sum of the return codes from the hook functions.  If
+        * this is an EVT_BEFORESAVE event, a nonzero return code will cause
+        * the save operation to abort.
+        */
        return total_retval;
 }
 
+
+
 int PerformXmsgHooks(char *sender, char *recp, char *msg)
 {
        struct XmsgFunctionHook *fcn;
index c703009d82691b58e9ed403e6451e36e1a496eb0..796c725e7424a5fcc522a7471a16391ed5ccabc4 100644 (file)
@@ -1922,7 +1922,8 @@ void CtdlWriteObject(char *req_room,              /* Room to stuff it in */
                        char *tempfilename,     /* Where to fetch it from */
                        struct usersupp *is_mailbox,    /* Mailbox room? */
                        int is_binary,          /* Is encoding necessary? */
-                       int is_unique           /* Del others of this type? */
+                       int is_unique,          /* Del others of this type? */
+                       unsigned int flags      /* Internal save flags */
                        )
 {
 
@@ -1939,7 +1940,7 @@ void CtdlWriteObject(char *req_room,              /* Room to stuff it in */
                MailboxName(roomname, is_mailbox, req_room);
        else
                safestrncpy(roomname, req_room, sizeof(roomname));
-       lprintf(9, "CtdlWriteObject() to <%s>\n", roomname);
+       lprintf(9, "CtdlWriteObject() to <%s> (flags=%d)\n", roomname, flags);
 
        strcpy(filename, tmpnam(NULL));
        fp = fopen(filename, "w");
@@ -1982,6 +1983,7 @@ void CtdlWriteObject(char *req_room,              /* Room to stuff it in */
        msg->cm_fields['O'] = strdoop(req_room);
        msg->cm_fields['N'] = strdoop(config.c_nodename);
        msg->cm_fields['H'] = strdoop(config.c_humannode);
+       msg->cm_flags = flags;
        
        lprintf(9, "Loading\n");
        fp = fopen(filename, "rb");
index df8dec8256d6f3bd1f5b9dcdfb5d480bd3f17f49..99670f9bd064489b362fe8ebffce80623678a792 100644 (file)
@@ -50,7 +50,8 @@ void CtdlForEachMessage(int mode, long ref,
                        char *content_type,
                         void (*CallBack) (long msgnum) );
 int CtdlDeleteMessages(char *, long, char *);
-void CtdlWriteObject(char *, char *, char *, struct usersupp *, int, int);
+void CtdlWriteObject(char *, char *, char *, struct usersupp *,
+                       int, int, unsigned int);
 struct CtdlMessage *CtdlFetchMessage(long msgnum);
 void CtdlFreeMessage(struct CtdlMessage *msg);
 void serialize_message(struct ser_ret *, struct CtdlMessage *);
index 55bacae56fd4c031822aca5c78c278eb3688e583..93860e800f46ad02c85263614674fbf57f9e59db 100644 (file)
@@ -1824,7 +1824,7 @@ void CtdlICQ_Write_Config(void) {
        fclose(fp);
 
        /* this handy API function does all the work for us */
-       CtdlWriteObject(CONFIGROOM, ICQMIME, temp, &CC->usersupp, 0, 1);
+       CtdlWriteObject(CONFIGROOM, ICQMIME, temp, &CC->usersupp, 0, 1, 0);
 
        unlink(temp);
 }
@@ -1854,7 +1854,7 @@ void CtdlICQ_Write_CL(void) {
        fclose(fp);
 
        /* this handy API function does all the work for us */
-       CtdlWriteObject(CONFIGROOM, ICQCLMIME, temp, &CC->usersupp, 0, 1);
+       CtdlWriteObject(CONFIGROOM, ICQCLMIME, temp, &CC->usersupp, 0, 1, 0);
 
        unlink(temp);
 }
index cf24533404fe44e17aebb1ef27bb0eca157a1a9e..eeb997b8060d9dec188a4c99f931b2029b32fbd1 100644 (file)
@@ -60,6 +60,7 @@ void do_pre555_usersupp_upgrade(void) {
        /* ...and overwrite the records with new format records */
        rewind(fp);
        while (fread(&usbuf, sizeof(struct pre555usersupp), 1, fp) > 0) {
+           if (strlen(usbuf.fullname) > 0) {
                lprintf(9, "Upgrading <%s>\n", usbuf.fullname);
                memset(&newus, 0, sizeof(struct usersupp));
 
@@ -100,9 +101,9 @@ void do_pre555_usersupp_upgrade(void) {
                fclose(tp);
 
                CtdlWriteObject(CONFIGROOM, "text/x-vcard",
-                       tempfilename, &newus, 0, 1);    
+                       tempfilename, &newus, 0, 1, CM_SKIP_HOOKS);
                unlink(tempfilename);
-
+           }
        }
 
        fclose(fp);     /* this file deletes automatically */
index 344ab16561e40548537818d9153c0b1cab5b5fc1..d9fa1da71ddd80a0791cfeea8ff540f6847ad500 100644 (file)
@@ -74,6 +74,8 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) {
         char config_rm[ROOMNAMELEN];
        char buf[256];
 
+       lprintf(9, "entering beforesave hook\n");
+
        /* If this isn't the configuration room, or if this isn't a MIME
         * message, don't bother.
         */
@@ -267,7 +269,8 @@ void vcard_write_user(struct usersupp *u, struct vCard *v) {
                        temp,           /* temp file */
                        u,              /* which user */
                        0,              /* not binary */
-                       0);             /* don't delete others of this type */
+                       0,              /* don't delete others of this type */
+                       0);             /* no flags */
 
         unlink(temp);
 }
index f12c23fcafcff0373125b5ea81f359e47d2e88e1..94c9fce4ff9b5b848865e92d37abf32f35cd9e21 100644 (file)
@@ -6,7 +6,20 @@ typedef pthread_t THREAD;
  */
 #define DEBUG_MEMORY_LEAKS
 
-struct CtdlMessage;
+/*
+ * New format for a message in memory
+ */
+#define        CTDLMESSAGE_MAGIC               0x159d
+struct CtdlMessage {
+       int cm_magic;                   /* Self-check */
+       char cm_anon_type;              /* Anonymous or author-visible */
+       char cm_format_type;            /* Format type */
+       char *cm_fields[256];           /* Data fields */
+       unsigned int cm_flags;          /* How to handle (NOT SAVED TO DISK) */
+};
+
+#define        CM_SKIP_HOOKS   0x01            /* Don't run server-side handlers */
+
 
 /*
  * Generic per-session variable or data structure storage
@@ -363,17 +376,6 @@ struct ser_ret {
 };
 
 
-/*
- * New format for a message in memory
- */
-#define        CTDLMESSAGE_MAGIC               0x159d
-struct CtdlMessage {
-       int cm_magic;                   /* Self-check */
-       char cm_anon_type;              /* Anonymous or author-visible */
-       char cm_format_type;            /* Format type */
-       char *cm_fields[256];           /* Data fields */
-};
-
 /* Preferred field order */
 /*               *********                     Important fields */
 /*                        ****************     Semi-important fields */