A few more API clean ups. Mainly revolving around user_ops.c
authorDave West <davew@uncensored.citadel.org>
Sun, 25 Oct 2009 00:26:06 +0000 (00:26 +0000)
committerDave West <davew@uncensored.citadel.org>
Sun, 25 Oct 2009 00:26:06 +0000 (00:26 +0000)
20 files changed:
citadel/file_ops.c
citadel/include/ctdl_module.h
citadel/journaling.c
citadel/modules/bio/serv_bio.c
citadel/modules/calendar/serv_calendar.c
citadel/modules/chat/serv_chat.c
citadel/modules/extnotify/extnotify_main.c
citadel/modules/imap/imap_acl.c
citadel/modules/imap/imap_search.c
citadel/modules/imap/imap_store.c
citadel/msgbase.c
citadel/room_ops.c
citadel/server_main.c
citadel/sysdep.c
citadel/user_ops.c
citadel/user_ops.h
citadel/utils/aidepost.c
citadel/utils/getmail.c
citadel/utils/sendcommand.c
citadel/utils/setup.c

index 2544077bd41b0a50101f6a13c3a02a0457ce255d..99009a1b7494b32dc1c5da90fea1fd34c4d90ac8 100644 (file)
@@ -326,7 +326,7 @@ void cmd_oimg(char *cmdbuf)
 
        if (!strcasecmp(filename, "_userpic_")) {
                extract_token(which_user, cmdbuf, 1, '|', sizeof which_user);
-               if (getuser(&usbuf, which_user) != 0) {
+               if (CtdlGetUser(&usbuf, which_user) != 0) {
                        cprintf("%d No such user.\n",
                                ERROR + NO_SUCH_USER);
                        return;
index 345a786f642086eef8e456c3022b0f3ae51d8345..c0e24b637370d4ae666d379ad5edc485c96f79a7 100644 (file)
@@ -41,6 +41,7 @@
 #include "sysdep_decls.h"
 #include "msgbase.h"
 #include "threads.h"
+#include "citadel_dirs.h"
 /*
  * define macros for module init stuff
  */
@@ -269,4 +270,16 @@ struct config {
 
 extern struct config config;
 
+
+
+/*
+ * Expose API calls from user_ops.c
+ */
+int CtdlGetUser(struct ctdluser *usbuf, char name[]);
+int CtdlGetUserLock(struct ctdluser *usbuf, char *name);
+void CtdlPutUser(struct ctdluser *usbuf);
+void CtdlPutUserLock(struct ctdluser *usbuf);
+int CtdlGetUserByNumber(struct ctdluser *usbuf, long number);
+
+
 #endif /* CTDL_MODULE_H */
index 6f5e69644378160c181c0901c53afb31bf9d040a..80122f25ab76865d751fb731df60503c74c00b96 100644 (file)
@@ -105,7 +105,7 @@ void local_to_inetemail(char *inetemail, char *localuser, size_t inetemail_len)
        struct vCard *v;
 
        strcpy(inetemail, "");
-       if (getuser(&us, localuser) != 0) {
+       if (CtdlGetUser(&us, localuser) != 0) {
                return;
        }
 
index afebe1242b4f5665f3c1b247d179c435cb9a2162..43cc0e98c15cc874aa68dbf9e9814bcdcdbf4d33 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include "sysdep.h"
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <pwd.h>
-#include <errno.h>
-#include <sys/types.h>
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
-#include <sys/wait.h>
-#include <string.h>
-#include <limits.h>
-#include <libcitadel.h>
-#include "citadel.h"
-#include "server.h"
-#include "citserver.h"
-#include "support.h"
-#include "config.h"
-#include "control.h"
-#include "user_ops.h"
-#include "policy.h"
-#include "database.h"
-#include "msgbase.h"
-#include "citadel_dirs.h"
-
 #include "ctdl_module.h"
 
+
+
 /*
  * enter user bio
  */
@@ -101,7 +66,7 @@ void cmd_rbio(char *cmdbuf)
        FILE *fp;
 
        extract_token(buf, cmdbuf, 0, '|', sizeof buf);
-       if (getuser(&ruser, buf) != 0) {
+       if (CtdlGetUser(&ruser, buf) != 0) {
                cprintf("%d No such user.\n",ERROR + NO_SUCH_USER);
                return;
        }
@@ -138,7 +103,7 @@ void cmd_lbio(char *cmdbuf) {
 
        cprintf("%d\n", LISTING_FOLLOWS);
        while (fgets(buf, sizeof buf, ls)!=NULL)
-               if (getuserbynumber(&usbuf,atol(buf))==0)
+               if (CtdlGetUserByNumber(&usbuf,atol(buf))==0)
                        cprintf("%s\n", usbuf.fullname);
        pclose(ls);
        cprintf("000\n");
index 8fc85611115269d49334da2cc490c48e6614f1bd..2e7dc422e72c99abab054b08c2c13fef72044fe5 100644 (file)
@@ -1441,7 +1441,7 @@ void ical_freebusy(char *who) {
        int config_lines = 0;
 
        /* First try an exact match. */
-       found_user = getuser(&usbuf, who);
+       found_user = CtdlGetUser(&usbuf, who);
 
        /* If not found, try it as an unqualified email address. */
        if (found_user != 0) {
@@ -1450,7 +1450,7 @@ void ical_freebusy(char *who) {
                CtdlLogPrintf(CTDL_DEBUG, "Trying <%s>\n", buf);
                if (recp != NULL) {
                        if (recp->num_local == 1) {
-                               found_user = getuser(&usbuf, recp->recp_local);
+                               found_user = CtdlGetUser(&usbuf, recp->recp_local);
                        }
                        free_recipients(recp);
                }
@@ -1465,7 +1465,7 @@ void ical_freebusy(char *who) {
                recp = validate_recipients(buf, NULL, 0);
                if (recp != NULL) {
                        if (recp->num_local == 1) {
-                               found_user = getuser(&usbuf, recp->recp_local);
+                               found_user = CtdlGetUser(&usbuf, recp->recp_local);
                        }
                        free_recipients(recp);
                }
@@ -1488,7 +1488,7 @@ void ical_freebusy(char *who) {
                                recp = validate_recipients(buf, NULL, 0);
                                if (recp != NULL) {
                                        if (recp->num_local == 1) {
-                                               found_user = getuser(&usbuf, recp->recp_local);
+                                               found_user = CtdlGetUser(&usbuf, recp->recp_local);
                                        }
                                        free_recipients(recp);
                                }
index e0515963f0a8ffb5c810cf099e0868ef2bd931a1..6b479b06aeb3a3ba2a875ccab3665314a4200238 100644 (file)
@@ -752,7 +752,7 @@ void cmd_sexp(char *argbuf)
        if (!strcmp(x_msg, "-")) {
                message_sent = PerformXmsgHooks(lun, lem, x_user, "");
                if (message_sent == 0) {
-                       if (getuser(NULL, x_user))
+                       if (CtdlGetUser(NULL, x_user))
                                cprintf("%d '%s' does not exist.\n",
                                                ERROR + NO_SUCH_USER, x_user);
                        else
@@ -790,7 +790,7 @@ void cmd_sexp(char *argbuf)
                                cprintf(" to %d users", message_sent);
                        cprintf(".\n");
                } else {
-                       if (getuser(NULL, x_user))
+                       if (CtdlGetUser(NULL, x_user))
                                cprintf("%d '%s' does not exist.\n",
                                                ERROR + NO_SUCH_USER, x_user);
                        else
index b772bbb09070913433b3041cdc2b6c94b6dcd01f..3255f4b16a5730689b6c3bea1b5cb3d170152de6 100644 (file)
@@ -365,7 +365,7 @@ long extNotify_getConfigMessage(char *username) {
        int a;
 
        // Get the user
-       getuser(&user, username);
+       CtdlGetUser(&user, username);
     
        MailboxName(configRoomName, sizeof configRoomName, &user, USERCONFIGROOM);
        // Fill qrbuf
index 7ef289db5cc069f450b5a3570b8958c660311cab..be563b7b5ba34776bc0ab765d3d6bbdb96ae254d 100644 (file)
@@ -249,7 +249,7 @@ void imap_listrights(int num_parms, char *parms[]) {
        valid = validate_recipients(parms[3], NULL, 0);
        if (valid != NULL) {
                if (valid->num_local == 1) {
-                       ret = getuser(&temp, valid->recp_local);
+                       ret = CtdlGetUser(&temp, valid->recp_local);
                }
                free_recipients(valid);
        }
index 90644b1e4efea9cc70f7a20f14a30c3d1955fffc..5241318168c4243997c1a082da58c0003884e9ea 100644 (file)
@@ -21,6 +21,9 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "ctdl_module.h"
+
+
 #include "sysdep.h"
 #include <stdlib.h>
 #include <unistd.h>
index 892933025c2fe424fc68d40e27354574e4f86950..a906d60ea334d92d394efe95dbe36acadcb99cbb 100644 (file)
@@ -21,8 +21,9 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "ctdl_module.h"
+
 
-#include "sysdep.h"
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
index e83a6d36bcca1229285cc4292bf2993202889f4e..357dd1162804ae1096002c64cd784f8ebcb486f4 100644 (file)
@@ -608,7 +608,7 @@ int CtdlForEachMessage(int mode, long ref, char *search_string,
        }
 
        /* Learn about the user and room in question */
-       getuser(&CC->user, CC->curr_user);
+       CtdlGetUser(&CC->user, CC->curr_user);
        CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
 
        /* Load the message list */
@@ -2900,9 +2900,9 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
 
        /* Bump this user's messages posted counter. */
        CtdlLogPrintf(CTDL_DEBUG, "Updating user\n");
-       lgetuser(&CCC->user, CCC->curr_user);
+       CtdlGetUserLock(&CCC->user, CCC->curr_user);
        CCC->user.posted = CCC->user.posted + 1;
-       lputuser(&CCC->user);
+       CtdlPutUserLock(&CCC->user);
 
        /* Decide where bounces need to be delivered */
        if ((recps != NULL) && (recps->bounce_to != NULL)) {
@@ -2924,7 +2924,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
                                        '|', sizeof recipient);
                CtdlLogPrintf(CTDL_DEBUG, "Delivering private local mail to <%s>\n",
                        recipient);
-               if (getuser(&userbuf, recipient) == 0) {
+               if (CtdlGetUser(&userbuf, recipient) == 0) {
                        // Add a flag so the Funambol module knows its mail
                        msg->cm_fields['W'] = strdup(recipient);
                        MailboxName(actual_rm, sizeof actual_rm, &userbuf, MAILROOM);
@@ -3655,7 +3655,7 @@ struct recptypes *validate_recipients(char *supplied_recipients,
                                        CC->room = tempQR2;
 
                                }
-                               else if (getuser(&tempUS, this_recp) == 0) {
+                               else if (CtdlGetUser(&tempUS, this_recp) == 0) {
                                        ++ret->num_local;
                                        strcpy(this_recp, tempUS.fullname);
                                        if (!IsEmptyStr(ret->recp_local)) {
@@ -3663,7 +3663,7 @@ struct recptypes *validate_recipients(char *supplied_recipients,
                                        }
                                        strcat(ret->recp_local, this_recp);
                                }
-                               else if (getuser(&tempUS, this_recp_cooked) == 0) {
+                               else if (CtdlGetUser(&tempUS, this_recp_cooked) == 0) {
                                        ++ret->num_local;
                                        strcpy(this_recp, tempUS.fullname);
                                        if (!IsEmptyStr(ret->recp_local)) {
@@ -4300,7 +4300,7 @@ void cmd_move(char *args)
                return;
        }
 
-       getuser(&CC->user, CC->curr_user);
+       CtdlGetUser(&CC->user, CC->curr_user);
        CtdlRoomAccess(&qtemp, &CC->user, &ra, NULL);
 
        /* Check for permission to perform this operation.
index 1ef9f0a94cdd1d98c81b4b9f86997af0e84c6005..f0c5cc98ea81f106f8bde29d7664df1457107ace 100644 (file)
@@ -608,7 +608,7 @@ void cmd_lrms(char *argbuf)
 
        if (CtdlAccessCheck(ac_logged_in)) return;
 
-       if (getuser(&CC->user, CC->curr_user)) {
+       if (CtdlGetUser(&CC->user, CC->curr_user)) {
                cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
                return;
        }
@@ -646,7 +646,7 @@ void cmd_lkra(char *argbuf)
 
        if (CtdlAccessCheck(ac_logged_in)) return;
        
-       if (getuser(&CC->user, CC->curr_user)) {
+       if (CtdlGetUser(&CC->user, CC->curr_user)) {
                cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
                return;
        }
@@ -715,7 +715,7 @@ void cmd_lkrn(char *argbuf)
 
        if (CtdlAccessCheck(ac_logged_in)) return;
        
-       if (getuser(&CC->user, CC->curr_user)) {
+       if (CtdlGetUser(&CC->user, CC->curr_user)) {
                cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
                return;
        }
@@ -754,7 +754,7 @@ void cmd_lkro(char *argbuf)
 
        if (CtdlAccessCheck(ac_logged_in)) return;
        
-       if (getuser(&CC->user, CC->curr_user)) {
+       if (CtdlGetUser(&CC->user, CC->curr_user)) {
                cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
                return;
        }
@@ -793,7 +793,7 @@ void cmd_lzrm(char *argbuf)
 
        if (CtdlAccessCheck(ac_logged_in)) return;
        
-       if (getuser(&CC->user, CC->curr_user)) {
+       if (CtdlGetUser(&CC->user, CC->curr_user)) {
                cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
                return;
        }
@@ -1018,7 +1018,7 @@ void cmd_goto(char *gargs)
        extract_token(password, gargs, 1, '|', sizeof password);
        transiently = extract_int(gargs, 2);
 
-       getuser(&CC->user, CC->curr_user);
+       CtdlGetUser(&CC->user, CC->curr_user);
 
        /*
         * Handle some of the macro named rooms
@@ -1133,7 +1133,7 @@ void cmd_rdir(char *cmdbuf)
        if (CtdlAccessCheck(ac_logged_in)) return;
        
        CtdlGetRoom(&CC->room, CC->room.QRname);
-       getuser(&CC->user, CC->curr_user);
+       CtdlGetUser(&CC->user, CC->curr_user);
 
        if ((CC->room.QRflags & QR_DIRECTORY) == 0) {
                cprintf("%d not here.\n", ERROR + NOT_HERE);
@@ -1532,7 +1532,7 @@ void cmd_seta(char *new_ra)
 
        if (CtdlAccessCheck(ac_room_aide)) return;
 
-       if (getuser(&usbuf, new_ra) != 0) {
+       if (CtdlGetUser(&usbuf, new_ra) != 0) {
                newu = (-1L);
        } else {
                newu = usbuf.usernum;
index d57fdcf5fa71cfdfe98f71eddf3674dfb43b6b4d..71f81feb398936e5499db698ebcc6451e099641d 100644 (file)
@@ -262,12 +262,12 @@ int main(int argc, char **argv)
 /**
  * Load the user for the masterCC or create them if they don't exist
  */
-       if (getuser(&masterCC.user, "SYS_Citadel"))
+       if (CtdlGetUser(&masterCC.user, "SYS_Citadel"))
        {
                /** User doesn't exist. We can't use create user here as the user number needs to be 0 */
                strcpy (masterCC.user.fullname, "SYS_Citadel") ;
-               putuser(&masterCC.user);
-               getuser(&masterCC.user, "SYS_Citadel"); /** Just to be safe */
+               CtdlPutUser(&masterCC.user);
+               CtdlGetUser(&masterCC.user, "SYS_Citadel"); /** Just to be safe */
        }
        
        /*
index 7cc7fd0c4900b159e3abec47b991cdde4af7f1f4..c4aa2063c062db9727e26fb0b70bf8ad65b2a4f3 100644 (file)
@@ -550,7 +550,7 @@ void CtdlFillSystemContext(struct CitContext *context, char *name)
                context->user.usernum = get_new_user_number();
                CtdlLogPrintf(CTDL_DEBUG, "Upgrading system user \"%s\" from user number 0 to user number %d\n", context->user.fullname, context->user.usernum);
                /* add user to the database */
-               putuser(&(context->user));
+               CtdlPutUser(&(context->user));
                cdb_store(CDB_USERSBYNUMBER, &(context->user.usernum), sizeof(long), context->user.fullname, strlen(context->user.fullname)+1);
        }
 }
index 580699fbeed55e8fd8510f9b88d47cf58c7ac873..7c96a1e9f5d6c7eb4c84a832aa75dfceacffbf7d 100644 (file)
@@ -84,6 +84,16 @@ INLINE void makeuserkey(char *key, char *username) {
  *            returns 0 on success
  */
 int getuser(struct ctdluser *usbuf, char name[])
+{
+       return CtdlGetUser(usbuf, name);
+}
+
+
+/*
+ * CtdlGetUser()  -  retrieve named user into supplied buffer.
+ *            returns 0 on success
+ */
+int CtdlGetUser(struct ctdluser *usbuf, char name[])
 {
 
        char usernamekey[USERNAME_SIZE];
@@ -111,13 +121,13 @@ int getuser(struct ctdluser *usbuf, char name[])
 
 
 /*
- * lgetuser()  -  same as getuser() but locks the record
+ * CtdlGetUserLock()  -  same as getuser() but locks the record
  */
-int lgetuser(struct ctdluser *usbuf, char *name)
+int CtdlGetUserLock(struct ctdluser *usbuf, char *name)
 {
        int retcode;
 
-       retcode = getuser(usbuf, name);
+       retcode = CtdlGetUser(usbuf, name);
        if (retcode == 0) {
                begin_critical_section(S_USERS);
        }
@@ -126,9 +136,18 @@ int lgetuser(struct ctdluser *usbuf, char *name)
 
 
 /*
- * putuser()  -  write user buffer into the correct place on disk
+ * lgetuser()  -  same as getuser() but locks the record
  */
-void putuser(struct ctdluser *usbuf)
+int lgetuser(struct ctdluser *usbuf, char *name)
+{
+       return CtdlGetUserLock(usbuf, name);
+}
+
+
+/*
+ * CtdlPutUser()  -  write user buffer into the correct place on disk
+ */
+void CtdlPutUser(struct ctdluser *usbuf)
 {
        char usernamekey[USERNAME_SIZE];
 
@@ -142,13 +161,31 @@ void putuser(struct ctdluser *usbuf)
 }
 
 
+/*
+ * putuser()  -  write user buffer into the correct place on disk
+ */
+void putuser(struct ctdluser *usbuf)
+{
+       CtdlPutUser(usbuf);
+}
+
+
+/*
+ * CtdlPutUserLock()  -  same as putuser() but locks the record
+ */
+void CtdlPutUserLock(struct ctdluser *usbuf)
+{
+       CtdlPutUser(usbuf);
+       end_critical_section(S_USERS);
+}
+
+
 /*
  * lputuser()  -  same as putuser() but locks the record
  */
 void lputuser(struct ctdluser *usbuf)
 {
-       putuser(usbuf);
-       end_critical_section(S_USERS);
+       CtdlPutUserLock(usbuf);
 }
 
 
@@ -180,12 +217,12 @@ int rename_user(char *oldname, char *newname) {
        /* Lock up and get going */
        begin_critical_section(S_USERS);
 
-       if (getuser(&usbuf, newname) == 0) {
+       if (CtdlGetUser(&usbuf, newname) == 0) {
                retcode = RENAMEUSER_ALREADY_EXISTS;
        }
        else {
 
-               if (getuser(&usbuf, oldname) != 0) {
+               if (CtdlGetUser(&usbuf, oldname) != 0) {
                        retcode = RENAMEUSER_NOT_FOUND;
                }
 
@@ -198,7 +235,7 @@ int rename_user(char *oldname, char *newname) {
                                CtdlLogPrintf(CTDL_DEBUG, "Renaming <%s> to <%s>\n", oldname, newname);
                                cdb_delete(CDB_USERS, oldnamekey, strlen(oldnamekey));
                                safestrncpy(usbuf.fullname, newname, sizeof usbuf.fullname);
-                               putuser(&usbuf);
+                               CtdlPutUser(&usbuf);
                                cdb_store(CDB_USERSBYNUMBER, &usbuf.usernum, sizeof(long),
                                        usbuf.fullname, strlen(usbuf.fullname)+1 );
 
@@ -361,12 +398,12 @@ int is_room_aide(void)
 }
 
 /*
- * getuserbynumber() - get user by number
+ * CtdlGetUserByNumber() -     get user by number
  *                     returns 0 if user was found
  *
  * Note: fetching a user this way requires one additional database operation.
  */
-int getuserbynumber(struct ctdluser *usbuf, long number)
+int CtdlGetUserByNumber(struct ctdluser *usbuf, long number)
 {
        struct cdbdata *cdbun;
        int r;
@@ -378,11 +415,22 @@ int getuserbynumber(struct ctdluser *usbuf, long number)
        }
 
        CtdlLogPrintf(CTDL_INFO, "User %ld maps to %s\n", number, cdbun->ptr);
-       r = getuser(usbuf, cdbun->ptr);
+       r = CtdlGetUser(usbuf, cdbun->ptr);
        cdb_free(cdbun);
        return(r);
 }
 
+/*
+ * getuserbynumber() - get user by number
+ *                     returns 0 if user was found
+ *
+ * Note: fetching a user this way requires one additional database operation.
+ */
+int getuserbynumber(struct ctdluser *usbuf, long number)
+{
+       return CtdlGetUserByNumber(usbuf, number);
+}
+
 
 
 /*
@@ -578,7 +626,7 @@ int CtdlLoginExistingUser(char *authname, char *trythisname)
                struct recptypes *valid = NULL;
        
                /* First, try to log in as if the supplied name is a display name */
-               found_user = getuser(&CC->user, username);
+               found_user = CtdlGetUser(&CC->user, username);
        
                /* If that didn't work, try to log in as if the supplied name
                * is an e-mail address
@@ -587,7 +635,7 @@ int CtdlLoginExistingUser(char *authname, char *trythisname)
                        valid = validate_recipients(username, NULL, 0);
                        if (valid != NULL) {
                                if (valid->num_local == 1) {
-                                       found_user = getuser(&CC->user, valid->recp_local);
+                                       found_user = CtdlGetUser(&CC->user, valid->recp_local);
                                }
                                free_recipients(valid);
                        }
@@ -657,7 +705,7 @@ void do_login(void)
        CC->logged_in = 1;
        CtdlLogPrintf(CTDL_NOTICE, "<%s> logged in\n", CC->curr_user);
 
-       lgetuser(&CC->user, CC->curr_user);
+       CtdlGetUserLock(&CC->user, CC->curr_user);
        ++(CC->user.timescalled);
        CC->previous_login = CC->user.lastcall;
        time(&CC->user.lastcall);
@@ -678,7 +726,7 @@ void do_login(void)
                }
        }
 
-       lputuser(&CC->user);
+       CtdlPutUserLock(&CC->user);
 
        /*
         * Populate CC->cs_inet_email with a default address.  This will be
@@ -853,7 +901,7 @@ int CtdlTryPassword(char *password)
                CtdlLogPrintf(CTDL_WARNING, "CtdlTryPassword: no user selected\n");
                return pass_no_user;
        }
-       if (getuser(&CC->user, CC->curr_user)) {
+       if (CtdlGetUser(&CC->user, CC->curr_user)) {
                CtdlLogPrintf(CTDL_ERR, "CtdlTryPassword: internal error\n");
                return pass_internal_error;
        }
@@ -882,9 +930,9 @@ int CtdlTryPassword(char *password)
                         * this is a security hazard, comment it out.
                         */
 
-                       lgetuser(&CC->user, CC->curr_user);
+                       CtdlGetUserLock(&CC->user, CC->curr_user);
                        safestrncpy(CC->user.password, password, sizeof CC->user.password);
-                       lputuser(&CC->user);
+                       CtdlPutUserLock(&CC->user);
 
                        /*
                         * (sooper-seekrit hack ends here)
@@ -977,7 +1025,7 @@ int purge_user(char pname[])
        if (IsEmptyStr(pname))
                return (ERROR + NO_SUCH_USER);
 
-       if (getuser(&usbuf, pname) != 0) {
+       if (CtdlGetUser(&usbuf, pname) != 0) {
                CtdlLogPrintf(CTDL_ERR, "Cannot purge user <%s> - not found\n", pname);
                return (ERROR + NO_SUCH_USER);
        }
@@ -996,7 +1044,7 @@ int purge_user(char pname[])
        if (user_is_logged_in == 1) {
                CtdlLogPrintf(CTDL_WARNING, "User <%s> is logged in; not deleting.\n", pname);
                usbuf.axlevel = 0;
-               putuser(&usbuf);
+               CtdlPutUser(&usbuf);
                return (1);
        }
        CtdlLogPrintf(CTDL_NOTICE, "Deleting user <%s>\n", pname);
@@ -1035,7 +1083,7 @@ int purge_user(char pname[])
 
 int internal_create_user (char *username, struct ctdluser *usbuf, uid_t uid)
 {
-       if (!getuser(usbuf, username)) {
+       if (!CtdlGetUser(usbuf, username)) {
                return (ERROR + ALREADY_EXISTS);
        }
 
@@ -1059,7 +1107,7 @@ int internal_create_user (char *username, struct ctdluser *usbuf, uid_t uid)
        usbuf->usernum = get_new_user_number();
 
        /* add user to the database */
-       putuser(usbuf);
+       CtdlPutUser(usbuf);
        cdb_store(CDB_USERSBYNUMBER, &usbuf->usernum, sizeof(long), usbuf->fullname, strlen(usbuf->fullname)+1);
 
        return 0;
@@ -1158,7 +1206,7 @@ int create_user(char *newusername, int become_user)
                do_login();
        
                /* Check to make sure we're still who we think we are */
-               if (getuser(&CC->user, CC->curr_user)) {
+               if (CtdlGetUser(&CC->user, CC->curr_user)) {
                        return (ERROR + INTERNAL_ERROR);
                }
        }
@@ -1244,9 +1292,9 @@ void cmd_newu(char *cmdbuf)
  */
 void CtdlSetPassword(char *new_pw)
 {
-       lgetuser(&CC->user, CC->curr_user);
+       CtdlGetUserLock(&CC->user, CC->curr_user);
        safestrncpy(CC->user.password, new_pw, sizeof(CC->user.password));
-       lputuser(&CC->user);
+       CtdlPutUserLock(&CC->user);
        CtdlLogPrintf(CTDL_INFO, "Password changed for user <%s>\n", CC->curr_user);
        PerformSessionHooks(EVT_SETPASS);
 }
@@ -1321,9 +1369,9 @@ void cmd_creu(char *cmdbuf)
 
        if (a == 0) {
                if (!IsEmptyStr(password)) {
-                       lgetuser(&tmp, username);
+                       CtdlGetUserLock(&tmp, username);
                        safestrncpy(tmp.password, password, sizeof(tmp.password));
-                       lputuser(&tmp);
+                       CtdlPutUserLock(&tmp);
                }
                cprintf("%d User '%s' created %s.\n", CIT_OK, username,
                                (!IsEmptyStr(password)) ? "and password set" :
@@ -1352,7 +1400,7 @@ void cmd_getu(char *cmdbuf)
        if (CtdlAccessCheck(ac_logged_in))
                return;
 
-       getuser(&CC->user, CC->curr_user);
+       CtdlGetUser(&CC->user, CC->curr_user);
        cprintf("%d %d|%d|%d|\n",
                CIT_OK,
                CC->user.USscreenwidth,
@@ -1373,14 +1421,14 @@ void cmd_setu(char *new_parms)
                cprintf("%d Usage error.\n", ERROR + ILLEGAL_VALUE);
                return;
        }
-       lgetuser(&CC->user, CC->curr_user);
+       CtdlGetUserLock(&CC->user, CC->curr_user);
        CC->user.USscreenwidth = extract_int(new_parms, 0);
        CC->user.USscreenheight = extract_int(new_parms, 1);
        CC->user.flags = CC->user.flags & (~US_USER_SET);
        CC->user.flags = CC->user.flags |
            (extract_int(new_parms, 2) & US_USER_SET);
 
-       lputuser(&CC->user);
+       CtdlPutUserLock(&CC->user);
        cprintf("%d Ok\n", CIT_OK);
 }
 
@@ -1403,7 +1451,7 @@ void cmd_slrp(char *new_ptr)
                newlr = atol(new_ptr);
        }
 
-       lgetuser(&CC->user, CC->curr_user);
+       CtdlGetUserLock(&CC->user, CC->curr_user);
 
        CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
        memcpy(&original_vbuf, &vbuf, sizeof(struct visit));
@@ -1416,7 +1464,7 @@ void cmd_slrp(char *new_ptr)
                CtdlSetRelationship(&vbuf, &CC->user, &CC->room);
        }
 
-       lputuser(&CC->user);
+       CtdlPutUserLock(&CC->user);
        cprintf("%d %ld\n", CIT_OK, newlr);
 }
 
@@ -1466,7 +1514,7 @@ int CtdlInvtKick(char *iuser, int op) {
        struct visit vbuf;
        char bbb[SIZ];
 
-       if (getuser(&USscratch, iuser) != 0) {
+       if (CtdlGetUser(&USscratch, iuser) != 0) {
                return(1);
        }
 
@@ -1547,14 +1595,14 @@ int CtdlForgetThisRoom(void) {
                return(1);
        }
 
-       lgetuser(&CC->user, CC->curr_user);
+       CtdlGetUserLock(&CC->user, CC->curr_user);
        CtdlGetRelationship(&vbuf, &CC->user, &CC->room);
 
        vbuf.v_flags = vbuf.v_flags | V_FORGET;
        vbuf.v_flags = vbuf.v_flags & ~V_ACCESS;
 
        CtdlSetRelationship(&vbuf, &CC->user, &CC->room);
-       lputuser(&CC->user);
+       CtdlPutUserLock(&CC->user);
 
        /* Return to the Lobby, so we don't end up in an undefined room */
        CtdlUserGoto(config.c_baseroom, 0, 0, NULL, NULL);
@@ -1647,7 +1695,7 @@ void cmd_vali(char *v_args)
                return;
        }
 
-       if (lgetuser(&userbuf, user) != 0) {
+       if (CtdlGetUserLock(&userbuf, user) != 0) {
                cprintf("%d '%s' not found.\n", ERROR + NO_SUCH_USER, user);
                return;
        }
@@ -1655,7 +1703,7 @@ void cmd_vali(char *v_args)
        userbuf.axlevel = newax;
        userbuf.flags = (userbuf.flags & ~US_NEEDVALID);
 
-       lputuser(&userbuf);
+       CtdlPutUserLock(&userbuf);
 
        /* If the access level was set to zero, delete the user */
        if (newax == 0) {
@@ -1747,7 +1795,7 @@ void cmd_chek(char *argbuf)
                return;
        }
 
-       getuser(&CC->user, CC->curr_user);      /* no lock is needed here */
+       CtdlGetUser(&CC->user, CC->curr_user);  /* no lock is needed here */
        if ((REGISCALL != 0) && ((CC->user.flags & US_REGIS) == 0))
                regis = 1;
 
@@ -1771,7 +1819,7 @@ void cmd_qusr(char *who)
 {
        struct ctdluser usbuf;
 
-       if (getuser(&usbuf, who) == 0) {
+       if (CtdlGetUser(&usbuf, who) == 0) {
                cprintf("%d %s\n", CIT_OK, usbuf.fullname);
        } else {
                cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
@@ -1792,7 +1840,7 @@ void cmd_agup(char *cmdbuf)
        }
 
        extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user);
-       if (getuser(&usbuf, requested_user) != 0) {
+       if (CtdlGetUser(&usbuf, requested_user) != 0) {
                cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
                return;
        }
@@ -1827,7 +1875,7 @@ void cmd_asup(char *cmdbuf)
                return;
 
        extract_token(requested_user, cmdbuf, 0, '|', sizeof requested_user);
-       if (lgetuser(&usbuf, requested_user) != 0) {
+       if (CtdlGetUserLock(&usbuf, requested_user) != 0) {
                cprintf("%d No such user.\n", ERROR + NO_SUCH_USER);
                return;
        }
@@ -1852,7 +1900,7 @@ void cmd_asup(char *cmdbuf)
        if (np > 8) {
                usbuf.USuserpurge = extract_int(cmdbuf, 8);
        }
-       lputuser(&usbuf);
+       CtdlPutUserLock(&usbuf);
        if (usbuf.axlevel == 0) {
                if (purge_user(requested_user) == 0) {
                        deleted = 1;
index 6bf604175bb08bb6c180b5a01195d92e68d4dd71..1a61e34dcd633f2223cf77a2cc345c1085590b60 100644 (file)
@@ -1,12 +1,17 @@
 /* $Id$ */
 int hash (char *str);
-int getuser (struct ctdluser *, char *);
-int lgetuser (struct ctdluser *, char *);
-void putuser (struct ctdluser *);
-void lputuser (struct ctdluser *);
+/* getuser is deprecated, use CtdlGetUser instead */
+int getuser (struct ctdluser *, char *) __attribute__ ((deprecated));
+/* lgetuser is deprecated, use CtdlGetUserLock instead */
+int lgetuser (struct ctdluser *, char *) __attribute__ ((deprecated));
+/* putuser is deprecated, use CtdlPutUser instead */
+void putuser (struct ctdluser *) __attribute__ ((deprecated));
+/* lputuser is deprecated, use CtdlPutUserLock instead */
+void lputuser (struct ctdluser *) __attribute__ ((deprecated));
 int is_aide (void);
 int is_room_aide (void);
-int getuserbynumber (struct ctdluser *usbuf, long int number);
+/* getuserbynumber is deprecated, use CtdlGetUserByNumber instead */
+int getuserbynumber (struct ctdluser *usbuf, long int number) __attribute__ ((deprecated));
 void rebuild_usersbynumber(void);
 void cmd_user (char *cmdbuf);
 void session_startup (void);
index 7b637f548233be8400ce3e426b7dabbe526d8794..e3c5c386e44eefd1da0aca8510e6951320a6172b 100644 (file)
@@ -20,6 +20,8 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "ctdl_module.h"
+
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
index 0138b01f4fd9f2e7f5e282ce3c33ce9eebfde4d1..af9780cb8bad99840da4aea3a90b0e0d0d1f55cf 100644 (file)
@@ -20,6 +20,8 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "ctdl_module.h"
+
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>
index 5012877018945538de8426e941944eb58ce1d2b6..faeb469c1bc2ee273f1996867af849d7b27a67e4 100644 (file)
@@ -5,6 +5,7 @@
  *
  */
 
+#include "ctdl_module.h"
 
 #include <stdlib.h>
 #include <unistd.h>
index 38c8be06c9ff9a5ead5fa0c04938ca71a727d059..c87563c4f7e236e90920369761041f3efe9f1863 100644 (file)
@@ -5,6 +5,9 @@
  *
  */
 
+#include "ctdl_module.h"
+
+
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>