From fc86ffaec2bf78ee472ed8fffc4f0a0fa9599105 Mon Sep 17 00:00:00 2001 From: Dave West Date: Sun, 25 Oct 2009 01:07:14 +0000 Subject: [PATCH] And a few more things comply with the coding style. --- citadel/include/ctdl_module.h | 10 ++++++++ citadel/modules/calendar/serv_calendar.c | 27 +++++----------------- citadel/modules/expire/serv_expire.c | 2 +- citadel/modules/extnotify/extnotify_main.c | 2 +- citadel/modules/imap/serv_imap.c | 4 ++-- citadel/modules/migrate/serv_migrate.c | 2 +- citadel/modules/newuser/serv_newuser.c | 2 +- citadel/modules/openid/serv_openid_rp.c | 6 ++--- citadel/modules/pas2/serv_pas2.c | 2 +- citadel/modules/pop3/serv_pop3.c | 6 ++--- citadel/modules/upgrade/serv_upgrade.c | 14 +++++------ citadel/modules/vcard/serv_vcard.c | 16 ++++++------- citadel/msgbase.c | 6 ++--- citadel/room_ops.c | 6 ++--- citadel/user_ops.c | 12 +++++++--- citadel/user_ops.h | 9 ++------ 16 files changed, 61 insertions(+), 65 deletions(-) diff --git a/citadel/include/ctdl_module.h b/citadel/include/ctdl_module.h index c0e24b637..9c66304a5 100644 --- a/citadel/include/ctdl_module.h +++ b/citadel/include/ctdl_module.h @@ -27,6 +27,9 @@ #include #include +#ifdef HAVE_STRINGS_H +#include +#endif #include @@ -280,6 +283,13 @@ int CtdlGetUserLock(struct ctdluser *usbuf, char *name); void CtdlPutUser(struct ctdluser *usbuf); void CtdlPutUserLock(struct ctdluser *usbuf); int CtdlGetUserByNumber(struct ctdluser *usbuf, long number); +void CtdlGetRelationship(struct visit *vbuf, + struct ctdluser *rel_user, + struct ctdlroom *rel_room); +void CtdlSetRelationship(struct visit *newvisit, + struct ctdluser *rel_user, + struct ctdlroom *rel_room); +void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix); #endif /* CTDL_MODULE_H */ diff --git a/citadel/modules/calendar/serv_calendar.c b/citadel/modules/calendar/serv_calendar.c index 2e7dc422e..0426814af 100644 --- a/citadel/modules/calendar/serv_calendar.c +++ b/citadel/modules/calendar/serv_calendar.c @@ -25,29 +25,14 @@ #define PRODID "-//Citadel//NONSGML Citadel Calendar//EN" -#include "sysdep.h" -#include -#include -#include -#include -#include -#include -#ifdef HAVE_STRINGS_H -#include -#endif +#include "ctdl_module.h" + #include -#include -#include "citadel.h" -#include "server.h" -#include "citserver.h" -#include "support.h" -#include "config.h" -#include "user_ops.h" + #include "msgbase.h" #include "internet_addressing.h" #include "serv_calendar.h" #include "euidindex.h" -#include "ctdl_module.h" #include "ical_dezonify.h" @@ -670,7 +655,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) { icalcomponent_free(original_event); /* Don't need this anymore. */ if (serialized_event == NULL) return(2); - MailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM); + CtdlMailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM); message_text = malloc(strlen(serialized_event) + SIZ); if (message_text != NULL) { @@ -1501,7 +1486,7 @@ void ical_freebusy(char *who) { return; } - MailboxName(calendar_room_name, sizeof calendar_room_name, + CtdlMailboxName(calendar_room_name, sizeof calendar_room_name, &usbuf, USERCALENDARROOM); strcpy(hold_rm, CC->room.QRname); /* save current room */ @@ -2473,7 +2458,7 @@ int ical_obj_aftersave(struct CtdlMessage *msg) */ /* First determine if this is our room */ - MailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM); + CtdlMailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM); if (strcasecmp(roomname, CC->room.QRname)) { return(0); /* Not the Calendar room -- don't do anything. */ } diff --git a/citadel/modules/expire/serv_expire.c b/citadel/modules/expire/serv_expire.c index 555a6b3c0..b0824e2fb 100644 --- a/citadel/modules/expire/serv_expire.c +++ b/citadel/modules/expire/serv_expire.c @@ -829,7 +829,7 @@ int PurgeStaleOpenIDassociations(void) { while (cdboi = cdb_next_item(CDB_OPENID), cdboi != NULL) { if (cdboi->len > sizeof(long)) { memcpy(&usernum, cdboi->ptr, sizeof(long)); - if (getuserbynumber(&usbuf, usernum) != 0) { + if (CtdlGetUserByNumber(&usbuf, usernum) != 0) { deleteme = strdup(cdboi->ptr + sizeof(long)), Put(keys, deleteme, strlen(deleteme), deleteme, generic_free_handler); } diff --git a/citadel/modules/extnotify/extnotify_main.c b/citadel/modules/extnotify/extnotify_main.c index 3255f4b16..2b2cdc648 100644 --- a/citadel/modules/extnotify/extnotify_main.c +++ b/citadel/modules/extnotify/extnotify_main.c @@ -367,7 +367,7 @@ long extNotify_getConfigMessage(char *username) { // Get the user CtdlGetUser(&user, username); - MailboxName(configRoomName, sizeof configRoomName, &user, USERCONFIGROOM); + CtdlMailboxName(configRoomName, sizeof configRoomName, &user, USERCONFIGROOM); // Fill qrbuf CtdlGetRoom(&qrbuf, configRoomName); /* Do something really, really stoopid here. Raid the room on ourselves, diff --git a/citadel/modules/imap/serv_imap.c b/citadel/modules/imap/serv_imap.c index 1322bc453..e7e9ad901 100644 --- a/citadel/modules/imap/serv_imap.c +++ b/citadel/modules/imap/serv_imap.c @@ -720,7 +720,7 @@ void imap_select(int num_parms, char *parms[]) /* Then try a mailbox name match */ if (c != 0) { - MailboxName(augmented_roomname, sizeof augmented_roomname, + CtdlMailboxName(augmented_roomname, sizeof augmented_roomname, &CC->user, towhere); c = CtdlGetRoom(&QRscratch, augmented_roomname); if (c == 0) @@ -1000,7 +1000,7 @@ int imap_grabroom(char *returned_roomname, char *foldername, int zapped_ok) /* Then try a mailbox name match */ if (c != 0) { - MailboxName(augmented_roomname, sizeof augmented_roomname, + CtdlMailboxName(augmented_roomname, sizeof augmented_roomname, &CC->user, roomname); c = CtdlGetRoom(&QRscratch, augmented_roomname); if (c == 0) diff --git a/citadel/modules/migrate/serv_migrate.c b/citadel/modules/migrate/serv_migrate.c index 7f855c5db..cf3395d50 100644 --- a/citadel/modules/migrate/serv_migrate.c +++ b/citadel/modules/migrate/serv_migrate.c @@ -719,7 +719,7 @@ void migr_xml_end(void *data, const char *el, const char **attr) { else if (!strcasecmp(el, "u_fullname")) safestrncpy(usbuf.fullname, migr_chardata, sizeof usbuf.fullname); else if (!strcasecmp(el, "user")) { - putuser(&usbuf); + CtdlPutUser(&usbuf); CtdlLogPrintf(CTDL_INFO, "Imported user: %s\n", usbuf.fullname); } diff --git a/citadel/modules/newuser/serv_newuser.c b/citadel/modules/newuser/serv_newuser.c index dae9c40cf..08cf48d7e 100644 --- a/citadel/modules/newuser/serv_newuser.c +++ b/citadel/modules/newuser/serv_newuser.c @@ -83,7 +83,7 @@ void CopyNewUserGreetings(void) { if (CC->user.timescalled != 1) return; /* This user's mailbox. */ - MailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM); + CtdlMailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM); /* Go to the source room ... bail out silently if it's not there, * or if it's not private. diff --git a/citadel/modules/openid/serv_openid_rp.c b/citadel/modules/openid/serv_openid_rp.c index a1996fb20..955d823c5 100644 --- a/citadel/modules/openid/serv_openid_rp.c +++ b/citadel/modules/openid/serv_openid_rp.c @@ -219,7 +219,7 @@ void cmd_oida(char *argbuf) { while (cdboi = cdb_next_item(CDB_OPENID), cdboi != NULL) { if (cdboi->len > sizeof(long)) { memcpy(&usernum, cdboi->ptr, sizeof(long)); - if (getuserbynumber(&usbuf, usernum) != 0) { + if (CtdlGetUserByNumber(&usbuf, usernum) != 0) { usbuf.fullname[0] = 0; } cprintf("%s|%ld|%s\n", @@ -404,7 +404,7 @@ int openid_create_user_via_sreg(char *claimed_id, HashList *sreg_keys) CtdlLogPrintf(CTDL_DEBUG, "The desired account name is <%s>\n", desired_name); - if (!getuser(&CC->user, desired_name)) { + if (!CtdlGetUser(&CC->user, desired_name)) { CtdlLogPrintf(CTDL_DEBUG, "<%s> is already taken by another user.\n", desired_name); memset(&CC->user, 0, sizeof(struct ctdluser)); return(5); @@ -438,7 +438,7 @@ int login_via_openid(char *claimed_id) memcpy(&usernum, cdboi->ptr, sizeof(long)); cdb_free(cdboi); - if (!getuserbynumber(&CC->user, usernum)) { + if (!CtdlGetUserByNumber(&CC->user, usernum)) { /* Now become the user we just created */ safestrncpy(CC->curr_user, CC->user.fullname, sizeof CC->curr_user); do_login(); diff --git a/citadel/modules/pas2/serv_pas2.c b/citadel/modules/pas2/serv_pas2.c index c6bb35b3d..bb79dbdae 100644 --- a/citadel/modules/pas2/serv_pas2.c +++ b/citadel/modules/pas2/serv_pas2.c @@ -69,7 +69,7 @@ void cmd_pas2(char *argbuf) extract_token(pw, argbuf, 0, '|', sizeof pw); - if (getuser(&CC->user, CC->curr_user)) + if (CtdlGetUser(&CC->user, CC->curr_user)) { cprintf("%d Unable to find user record for %s.\n", ERROR + NO_SUCH_USER, CC->curr_user); return; diff --git a/citadel/modules/pop3/serv_pop3.c b/citadel/modules/pop3/serv_pop3.c index c0db0ea86..612b1db98 100644 --- a/citadel/modules/pop3/serv_pop3.c +++ b/citadel/modules/pop3/serv_pop3.c @@ -265,7 +265,7 @@ void pop3_apop(char *argbuf) return; } - if (getuser(&CC->user, CC->curr_user)) + if (CtdlGetUser(&CC->user, CC->curr_user)) { cprintf("-ERR No such user.\r\n"); return; @@ -504,14 +504,14 @@ void pop3_update(void) { /* Set last read pointer */ if (POP3->num_msgs > 0) { - lgetuser(&CC->user, CC->curr_user); + CtdlGetUserLock(&CC->user, CC->curr_user); CtdlGetRelationship(&vbuf, &CC->user, &CC->room); snprintf(vbuf.v_seen, sizeof vbuf.v_seen, "*:%ld", POP3->msgs[POP3->num_msgs-1].msgnum); CtdlSetRelationship(&vbuf, &CC->user, &CC->room); - lputuser(&CC->user); + CtdlPutUserLock(&CC->user); } } diff --git a/citadel/modules/upgrade/serv_upgrade.c b/citadel/modules/upgrade/serv_upgrade.c index c7a7b7220..de3eb9ab5 100644 --- a/citadel/modules/upgrade/serv_upgrade.c +++ b/citadel/modules/upgrade/serv_upgrade.c @@ -71,12 +71,12 @@ void fix_sys_user_name(void) char usernamekey[USERNAME_SIZE]; /** If we have a user called Citadel rename them to SYS_Citadel */ - if (getuser(&usbuf, "Citadel") == 0) + if (CtdlGetUser(&usbuf, "Citadel") == 0) { rename_user("Citadel", "SYS_Citadel"); } - while (getuserbynumber(&usbuf, 0) == 0) + while (CtdlGetUserByNumber(&usbuf, 0) == 0) { /* delete user with number 0 and no name */ if (IsEmptyStr(usbuf.fullname)) @@ -84,12 +84,12 @@ void fix_sys_user_name(void) else { /* temporarily set this user to -1 */ usbuf.usernum = -1; - putuser(&usbuf); + CtdlPutUser(&usbuf); } } /** Make sure user SYS_* is user 0 */ - while (getuserbynumber(&usbuf, -1) == 0) + while (CtdlGetUserByNumber(&usbuf, -1) == 0) { if (strncmp(usbuf.fullname, "SYS_", 4)) { /** Delete any user 0 that doesn't start with SYS_ */ @@ -99,7 +99,7 @@ void fix_sys_user_name(void) else { usbuf.usernum = 0; - putuser(&usbuf); + CtdlPutUser(&usbuf); } } } @@ -185,12 +185,12 @@ void cbtm_backend(struct ctdluser *usbuf, void *data) { while (uplist != NULL) { - if (lgetuser(&us, uplist->user) == 0) { + if (CtdlGetUserLock(&us, uplist->user) == 0) { CtdlLogPrintf(CTDL_DEBUG, "Processing <%s>...\n", uplist->user); if (us.uid == CTDLUID) { us.uid = (-1); } - lputuser(&us); + CtdlPutUserLock(&us); } ptr = uplist; diff --git a/citadel/modules/vcard/serv_vcard.c b/citadel/modules/vcard/serv_vcard.c index a4e92d234..ff5c2ab47 100644 --- a/citadel/modules/vcard/serv_vcard.c +++ b/citadel/modules/vcard/serv_vcard.c @@ -379,7 +379,7 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) { memcpy(&usbuf, &CC->user, sizeof(struct ctdluser)); } - else if (getuserbynumber(&usbuf, what_user) == 0) { + else if (CtdlGetUserByNumber(&usbuf, what_user) == 0) { /* We fetched a valid user record */ } @@ -500,7 +500,7 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) { if ( (strlen(CC->room.QRname) >= 12) && (!strcasecmp(&CC->room.QRname[11], USERCONFIGROOM)) ) { is_UserConf = 1; /* It's someone's config room */ } - MailboxName(roomname, sizeof roomname, &CC->user, USERCONFIGROOM); + CtdlMailboxName(roomname, sizeof roomname, &CC->user, USERCONFIGROOM); if (!strcasecmp(CC->room.QRname, roomname)) { is_UserConf = 1; is_MY_UserConf = 1; /* It's MY config room */ @@ -553,18 +553,18 @@ int vcard_upload_aftersave(struct CtdlMessage *msg) { * Assume they don't need validating. */ if (CC->user.axlevel >= 6) { - lgetuser(&CC->user, CC->curr_user); + CtdlGetUserLock(&CC->user, CC->curr_user); CC->user.flags |= US_REGIS; - lputuser(&CC->user); + CtdlPutUserLock(&CC->user); return (0); } set_mm_valid(); /* ...which also means we need to flag the user */ - lgetuser(&CC->user, CC->curr_user); + CtdlGetUserLock(&CC->user, CC->curr_user); CC->user.flags |= (US_REGIS|US_NEEDVALID); - lputuser(&CC->user); + CtdlPutUserLock(&CC->user); return(0); } @@ -601,7 +601,7 @@ struct vCard *vcard_get_user(struct ctdluser *u) { long VCmsgnum; strcpy(hold_rm, CC->room.QRname); /* save current room */ - MailboxName(config_rm, sizeof config_rm, u, USERCONFIGROOM); + CtdlMailboxName(config_rm, sizeof config_rm, u, USERCONFIGROOM); if (CtdlGetRoom(&CC->room, config_rm) != 0) { CtdlGetRoom(&CC->room, hold_rm); @@ -754,7 +754,7 @@ void cmd_greg(char *argbuf) return; } - if (getuser(&usbuf, who) != 0) { + if (CtdlGetUser(&usbuf, who) != 0) { cprintf("%d '%s' not found.\n", ERROR + NO_SUCH_USER, who); return; } diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 357dd1162..53d0fccba 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -2927,7 +2927,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ 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); + CtdlMailboxName(actual_rm, sizeof actual_rm, &userbuf, MAILROOM); CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 0, msg); BumpNewMailCounter(userbuf.usernum); if (!IsEmptyStr(config.c_funambol_host) || !IsEmptyStr(config.c_pager_program)) { @@ -3065,7 +3065,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ if (collected_addresses != NULL) { aptr = (struct addresses_to_be_filed *) malloc(sizeof(struct addresses_to_be_filed)); - MailboxName(actual_rm, sizeof actual_rm, + CtdlMailboxName(actual_rm, sizeof actual_rm, &CCC->user, USERCONTACTSROOM); aptr->roomname = strdup(actual_rm); aptr->collected_addresses = collected_addresses; @@ -4585,7 +4585,7 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ char *encoded_message = NULL; if (is_mailbox != NULL) { - MailboxName(roomname, sizeof roomname, is_mailbox, req_room); + CtdlMailboxName(roomname, sizeof roomname, is_mailbox, req_room); } else { safestrncpy(roomname, req_room, sizeof(roomname)); diff --git a/citadel/room_ops.c b/citadel/room_ops.c index f0c5cc98e..386c3c994 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -1030,7 +1030,7 @@ void cmd_goto(char *gargs) /* Then try a mailbox name match */ if (c != 0) { - MailboxName(augmented_roomname, sizeof augmented_roomname, + CtdlMailboxName(augmented_roomname, sizeof augmented_roomname, &CC->user, towhere); c = CtdlGetRoom(&QRscratch, augmented_roomname); if (c == 0) @@ -1512,7 +1512,7 @@ void cmd_geta(char *cmdbuf) if (CtdlAccessCheck(ac_logged_in)) return; - if (getuserbynumber(&usbuf, CC->room.QRroomaide) == 0) { + if (CtdlGetUserByNumber(&usbuf, CC->room.QRroomaide) == 0) { cprintf("%d %s\n", CIT_OK, usbuf.fullname); } else { cprintf("%d \n", CIT_OK); @@ -1795,7 +1795,7 @@ unsigned CtdlCreateRoom(char *new_room_name, * name accordingly (prepend the user number) */ if (new_room_type == 4) { - MailboxName(qrbuf.QRname, sizeof qrbuf.QRname, &CC->user, new_room_name); + CtdlMailboxName(qrbuf.QRname, sizeof qrbuf.QRname, &CC->user, new_room_name); } else { safestrncpy(qrbuf.QRname, new_room_name, sizeof qrbuf.QRname); diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 7c96a1e9f..91e3d077a 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -361,6 +361,12 @@ void CtdlGetRelationship(struct visit *vbuf, } +void CtdlMailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix) +{ + snprintf(buf, n, "%010ld.%s", who->usernum, prefix); +} + + void MailboxName(char *buf, size_t n, const struct ctdluser *who, const char *prefix) { snprintf(buf, n, "%010ld.%s", who->usernum, prefix); @@ -1182,10 +1188,10 @@ int create_user(char *newusername, int become_user) * Give the user a private mailbox and a configuration room. * Make the latter an invisible system room. */ - MailboxName(mailboxname, sizeof mailboxname, &usbuf, MAILROOM); + CtdlMailboxName(mailboxname, sizeof mailboxname, &usbuf, MAILROOM); CtdlCreateRoom(mailboxname, 5, "", 0, 1, 1, VIEW_MAILBOX); - MailboxName(mailboxname, sizeof mailboxname, &usbuf, USERCONFIGROOM); + CtdlMailboxName(mailboxname, sizeof mailboxname, &usbuf, USERCONFIGROOM); CtdlCreateRoom(mailboxname, 5, "", 0, 1, 1, VIEW_BBS); if (CtdlGetRoomLock(&qrbuf, mailboxname) == 0) { qrbuf.QRflags2 |= QR2_SYSTEM; @@ -1970,7 +1976,7 @@ int InitialMailCheck() long *msglist = NULL; int num_msgs = 0; - MailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM); + CtdlMailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM); if (CtdlGetRoom(&mailbox, mailboxname) != 0) return (0); CtdlGetRelationship(&vbuf, &CC->user, &mailbox); diff --git a/citadel/user_ops.h b/citadel/user_ops.h index 1a61e34dc..5057ade2a 100644 --- a/citadel/user_ops.h +++ b/citadel/user_ops.h @@ -27,14 +27,9 @@ void ListThisUser(struct ctdluser *usbuf, void *data); int NewMailCount(void); int InitialMailCheck(void); void put_visit(struct visit *newvisit); -void CtdlGetRelationship(struct visit *vbuf, - struct ctdluser *rel_user, - struct ctdlroom *rel_room); -void CtdlSetRelationship(struct visit *newvisit, - struct ctdluser *rel_user, - struct ctdlroom *rel_room); +/* MailboxName is deprecated us CtdlMailboxName instead */ void MailboxName(char *buf, size_t n, const struct ctdluser *who, - const char *prefix); + const char *prefix) __attribute__ ((deprecated)); int GenerateRelationshipIndex( char *IndexBuf, long RoomID, long RoomGen, -- 2.30.2