Citadel API clean up.
[citadel.git] / citadel / user_ops.c
index bb803982af93da8fb8a1c23d4187079eeb86483d..9f867f9711059d67521badb68b483140ba355f66 100644 (file)
@@ -52,6 +52,8 @@
 #include "threads.h"
 #include "citadel_ldap.h"
 
+#include "ctdl_module.h"
+
 /* These pipes are used to talk to the chkpwd daemon, which is forked during startup */
 int chkpwd_write_pipe[2];
 int chkpwd_read_pipe[2];
@@ -615,8 +617,11 @@ void cmd_user(char *cmdbuf)
        char username[256];
        int a;
 
+       CtdlLogPrintf(CTDL_DEBUG, "cmd_user(%s)\n", cmdbuf);
        extract_token(username, cmdbuf, 0, '|', sizeof username);
+       CtdlLogPrintf(CTDL_DEBUG, "username: %s\n", username);
        striplt(username);
+       CtdlLogPrintf(CTDL_DEBUG, "username: %s\n", username);
 
        a = CtdlLoginExistingUser(NULL, username);
        switch (a) {
@@ -687,15 +692,16 @@ void do_login(void)
        /* Create any personal rooms required by the system.
         * (Technically, MAILROOM should be there already, but just in case...)
         */
-       create_room(MAILROOM, 4, "", 0, 1, 0, VIEW_MAILBOX);
-       create_room(SENTITEMS, 4, "", 0, 1, 0, VIEW_MAILBOX);
-       create_room(USERTRASHROOM, 4, "", 0, 1, 0, VIEW_MAILBOX);
+       CtdlCreateRoom(MAILROOM, 4, "", 0, 1, 0, VIEW_MAILBOX);
+       CtdlCreateRoom(SENTITEMS, 4, "", 0, 1, 0, VIEW_MAILBOX);
+       CtdlCreateRoom(USERTRASHROOM, 4, "", 0, 1, 0, VIEW_MAILBOX);
+       /* CtdlCreateRoom(USERDRAFTROOM, 4, "", 0, 1, 0, VIEW_MAILBOX); temporarily disabled for 7.60 */
 
        /* Run any startup routines registered by loadable modules */
        PerformSessionHooks(EVT_LOGIN);
 
        /* Enter the lobby */
-       usergoto(config.c_baseroom, 0, 0, NULL, NULL);
+       CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL);
 }
 
 
@@ -766,6 +772,7 @@ void logout(void)
 static int validpw(uid_t uid, const char *pass)
 {
        char buf[256];
+       int rv = 0;
 
        if (IsEmptyStr(pass)) {
                CtdlLogPrintf(CTDL_DEBUG, "refusing to check empty password for uid=%d using chkpwd...\n", uid);
@@ -775,9 +782,9 @@ static int validpw(uid_t uid, const char *pass)
        CtdlLogPrintf(CTDL_DEBUG, "Validating password for uid=%d using chkpwd...\n", uid);
 
        begin_critical_section(S_CHKPWD);
-       write(chkpwd_write_pipe[1], &uid, sizeof(uid_t));
-       write(chkpwd_write_pipe[1], pass, 256);
-       read(chkpwd_read_pipe[0], buf, 4);
+       rv = write(chkpwd_write_pipe[1], &uid, sizeof(uid_t));
+       rv = write(chkpwd_write_pipe[1], pass, 256);
+       rv = read(chkpwd_read_pipe[0], buf, 4);
        end_critical_section(S_CHKPWD);
 
        if (!strncmp(buf, "PASS", 4)) {
@@ -930,6 +937,7 @@ void cmd_pass(char *buf)
        char password[256];
        int a;
 
+       memset(password, 0, sizeof(password));
        extract_token(password, buf, 0, '|', sizeof password);
        a = CtdlTryPassword(password);
 
@@ -1127,13 +1135,13 @@ int create_user(char *newusername, int become_user)
         * Make the latter an invisible system room.
         */
        MailboxName(mailboxname, sizeof mailboxname, &usbuf, MAILROOM);
-       create_room(mailboxname, 5, "", 0, 1, 1, VIEW_MAILBOX);
+       CtdlCreateRoom(mailboxname, 5, "", 0, 1, 1, VIEW_MAILBOX);
 
        MailboxName(mailboxname, sizeof mailboxname, &usbuf, USERCONFIGROOM);
-       create_room(mailboxname, 5, "", 0, 1, 1, VIEW_BBS);
-       if (lgetroom(&qrbuf, mailboxname) == 0) {
+       CtdlCreateRoom(mailboxname, 5, "", 0, 1, 1, VIEW_BBS);
+       if (CtdlGetRoomLock(&qrbuf, mailboxname) == 0) {
                qrbuf.QRflags2 |= QR2_SYSTEM;
-               lputroom(&qrbuf);
+               CtdlPutRoomLock(&qrbuf);
        }
 
        /* Perform any create functions registered by server extensions */
@@ -1338,7 +1346,7 @@ void cmd_creu(char *cmdbuf)
 /*
  * get user parameters
  */
-void cmd_getu(void)
+void cmd_getu(char *cmdbuf)
 {
 
        if (CtdlAccessCheck(ac_logged_in))
@@ -1523,6 +1531,8 @@ void cmd_invt_kick(char *iuser, int op) {
        return;
 }
 
+void cmd_invt(char *iuser) {cmd_invt_kick(iuser, 1);}
+void cmd_kick(char *iuser) {cmd_invt_kick(iuser, 0);}
 
 /*
  * Forget (Zap) the current room (API call)
@@ -1547,7 +1557,7 @@ int CtdlForgetThisRoom(void) {
        lputuser(&CC->user);
 
        /* Return to the Lobby, so we don't end up in an undefined room */
-       usergoto(config.c_baseroom, 0, 0, NULL, NULL);
+       CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL);
        return(0);
 
 }
@@ -1556,7 +1566,7 @@ int CtdlForgetThisRoom(void) {
 /*
  * forget (Zap) the current room
  */
-void cmd_forg(void)
+void cmd_forg(char *argbuf)
 {
 
        if (CtdlAccessCheck(ac_logged_in)) {
@@ -1574,7 +1584,7 @@ void cmd_forg(void)
 /*
  * Get Next Unregistered User
  */
-void cmd_gnur(void)
+void cmd_gnur(char *argbuf)
 {
        struct cdbdata *cdbus;
        struct ctdluser usbuf;
@@ -1727,7 +1737,7 @@ void cmd_list(char *cmdbuf)
 /*
  * assorted info we need to check at login
  */
-void cmd_chek(void)
+void cmd_chek(char *argbuf)
 {
        int mail = 0;
        int regis = 0;
@@ -1913,7 +1923,7 @@ int InitialMailCheck()
        int num_msgs = 0;
 
        MailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM);
-       if (getroom(&mailbox, mailboxname) != 0)
+       if (CtdlGetRoom(&mailbox, mailboxname) != 0)
                return (0);
        CtdlGetRelationship(&vbuf, &CC->user, &mailbox);
 
@@ -1997,3 +2007,38 @@ void cmd_renu(char *cmdbuf)
 
        cprintf("%d An unknown error occurred.\n", ERROR);
 }
+
+
+
+/*****************************************************************************/
+/*                      MODULE INITIALIZATION STUFF                          */
+/*****************************************************************************/
+
+
+CTDL_MODULE_INIT(user_ops)
+{
+       CtdlRegisterProtoHook(cmd_user, "USER", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_pass, "PASS", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_creu, "CREU", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_setp, "SETP", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_getu, "GETU", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_setu, "SETU", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_slrp, "SLRP", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_invt, "INVT", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_kick, "KICK", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_forg, "FORG", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_gnur, "GNUR", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_vali, "VALI", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_list, "LIST", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_chek, "CHEK", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_qusr, "QUSR", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_agup, "AGUP", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_asup, "ASUP", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_seen, "SEEN", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_gtsn, "GTSN", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_view, "VIEW", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_renu, "RENU", "Autoconverted. TODO: document me.");
+       CtdlRegisterProtoHook(cmd_newu, "NEWU", "Autoconverted. TODO: document me.");
+       /* return our Subversion id for the Log */
+       return "$Id$";
+}