]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_newuser.c
mk_module_init.sh now tests to see if echo supports -e and -E
[citadel.git] / citadel / serv_newuser.c
index 4d0923368a606120fa1d23810fcee322ea28a9fa..ac47feb102d71a7971e6f9184dd6d54b7844eb2b 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * $Id$
  *
- * A skeleton module to test the dynamic loader.
+ * Automaticalyl copies the contents of a "New User Greetings" room to the
+ * inbox of any new user upon account creation.
  *
  */
 
 #include <limits.h>
 #include "citadel.h"
 #include "server.h"
-#include "sysdep_decls.h"
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
-#include "serv_extensions.h"
 #include "room_ops.h"
 #include "user_ops.h"
 #include "policy.h"
 #include "database.h"
 #include "msgbase.h"
 
+
+#include "ctdl_module.h"
+
+
+
 extern struct CitContext *ContextList;
 
 
@@ -58,7 +62,6 @@ void CopyNewUserGreetings(void) {
        struct cdbdata *cdbfr;
        long *msglist = NULL;
        int num_msgs = 0;
-       int i;
        char mailboxname[ROOMNAMELEN];
 
 
@@ -77,25 +80,25 @@ void CopyNewUserGreetings(void) {
        cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
 
        if (cdbfr != NULL) {
-               msglist = mallok(cdbfr->len);
+               msglist = malloc(cdbfr->len);
                memcpy(msglist, cdbfr->ptr, cdbfr->len);
                num_msgs = cdbfr->len / sizeof(long);
                cdb_free(cdbfr);
        }
 
        if (num_msgs > 0) {
-               for (i = 0; i < num_msgs; ++i) {
-                       CtdlCopyMsgToRoom(msglist[i], mailboxname);
-               }
+               CtdlCopyMsgsToRoom(msglist, num_msgs, mailboxname);
        }
 
        /* Now free the memory we used, and go away. */
-       if (msglist != NULL) phree(msglist);
+       if (msglist != NULL) free(msglist);
 }
 
 
-char *serv_newuser_init(void)
+CTDL_MODULE_INIT(newuser)
 {
    CtdlRegisterSessionHook(CopyNewUserGreetings, EVT_LOGIN);
+
+   /* return our Subversion id for the Log */
    return "$Id$";
 }