From 81c4e76237b24b9969982b6221def3929b95fe63 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Thu, 9 Aug 2007 17:48:01 +0000 Subject: [PATCH] * more whitch-hunt on strlen with isemptystr replacement. --- citadel/.cvsignore | 78 ------------------- .../autocompletion/serv_autocompletion.c | 2 +- citadel/modules/calendar/serv_calendar.c | 4 +- citadel/modules/chat/serv_chat.c | 12 +-- citadel/modules/funambol/serv_funambol.c | 2 +- citadel/modules/imap/imap_acl.c | 4 +- citadel/modules/imap/imap_fetch.c | 34 ++++---- citadel/modules/imap/imap_list.c | 4 +- citadel/modules/imap/imap_misc.c | 2 +- citadel/modules/imap/imap_tools.c | 2 +- citadel/modules/imap/serv_imap.c | 2 +- citadel/modules/inetcfg/serv_inetcfg.c | 2 +- citadel/modules/ldap/serv_ldap.c | 10 +-- citadel/modules/listsub/serv_listsub.c | 9 ++- .../modules/managesieve/serv_managesieve.c | 6 +- citadel/modules/network/serv_network.c | 25 +++--- citadel/modules/notes/serv_notes.c | 2 +- citadel/modules/rwho/serv_rwho.c | 6 +- citadel/modules/sieve/serv_sieve.c | 6 +- citadel/modules/smtp/serv_smtp.c | 18 ++--- citadel/modules/vandelay/serv_vandelay.c | 2 +- citadel/modules/vcard/serv_vcard.c | 12 +-- 22 files changed, 86 insertions(+), 158 deletions(-) delete mode 100644 citadel/.cvsignore diff --git a/citadel/.cvsignore b/citadel/.cvsignore deleted file mode 100644 index 6977412ad..000000000 --- a/citadel/.cvsignore +++ /dev/null @@ -1,78 +0,0 @@ -*.diff -*.patch -*.d -*.lo -*.mo -*.ro -*.socket -.AppleDouble -.libs -Makefile -aclocal.m4 -aidepost -autom4te.cache -autom4te-2.53.cache -base64 -chkpwd -citadel -citadel.config -citadel.control -citadel.log -citlogin -citmail -citserver -citserver.log -config.cache -config.h.in -config.log -config.status -configure -data -icq -import -libcitserver.la -libtool -mailinglist -migratenet -msgform -netconfigs -netmailer -netpoll -netproc -netsetup -parsedate.c -proxy -qpdecode -rcit -readlog -sendcommand -setup -so_locations -stats -stress -sysdep.h -sysdep.h.in -sysoputil -useradmin -userlist -weekly -whobbs -ltmain.sh -configure.lineno -config.sub -config.guess -openldap-data -keys -bio -bitbucket -citadel-easyinstall.sum -files -gmon.out -images -info -network -network/spoolin -network/spoolout -network/systems -userpics -citadel.pid diff --git a/citadel/modules/autocompletion/serv_autocompletion.c b/citadel/modules/autocompletion/serv_autocompletion.c index 5d593e897..5aaedd8cb 100644 --- a/citadel/modules/autocompletion/serv_autocompletion.c +++ b/citadel/modules/autocompletion/serv_autocompletion.c @@ -176,7 +176,7 @@ void cmd_auto(char *argbuf) { if (CtdlAccessCheck(ac_logged_in)) return; extract_token(search_string, argbuf, 0, '|', sizeof search_string); - if (strlen(search_string) == 0) { + if (IsEmptyStr(search_string)) { cprintf("%d You supplied an empty partial.\n", ERROR + ILLEGAL_VALUE); return; diff --git a/citadel/modules/calendar/serv_calendar.c b/citadel/modules/calendar/serv_calendar.c index de3504441..619194cf0 100644 --- a/citadel/modules/calendar/serv_calendar.c +++ b/citadel/modules/calendar/serv_calendar.c @@ -1955,14 +1955,14 @@ int ical_obj_beforesave(struct CtdlMessage *msg) 0 ); - if (strlen(imm.uid) > 0) { + if (!IsEmptyStr(imm.uid)) { if (msg->cm_fields['E'] != NULL) { free(msg->cm_fields['E']); } msg->cm_fields['E'] = strdup(imm.uid); lprintf(CTDL_DEBUG, "Saving calendar UID <%s>\n", msg->cm_fields['E']); } - if (strlen(imm.subject) > 0) { + if (!IsEmptyStr(imm.subject)) { if (msg->cm_fields['U'] != NULL) { free(msg->cm_fields['U']); } diff --git a/citadel/modules/chat/serv_chat.c b/citadel/modules/chat/serv_chat.c index a34f7efc3..fff6640fe 100644 --- a/citadel/modules/chat/serv_chat.c +++ b/citadel/modules/chat/serv_chat.c @@ -184,7 +184,7 @@ void do_chat_listing(int allflag) GenerateRoomDisplay(roomname, ccptr, CC); if ((CC->user.axlevel < 6) - && (strlen(ccptr->fake_roomname)>0)) { + && (!IsEmptyStr(ccptr->fake_roomname))) { strcpy(roomname, ccptr->fake_roomname); } @@ -204,7 +204,7 @@ void do_chat_listing(int allflag) GenerateRoomDisplay(roomname, ccptr, CC); if ((CC->user.axlevel < 6) - && (strlen(ccptr->fake_roomname)>0)) { + && (!IsEmptyStr(ccptr->fake_roomname))) { strcpy(roomname, ccptr->fake_roomname); } @@ -282,7 +282,7 @@ void cmd_chat(char *argbuf) } /* if we have a complete line, do send processing */ - if (strlen(cmdbuf) > 0) + if (!IsEmptyStr(cmdbuf)) if (cmdbuf[strlen(cmdbuf) - 1] == 10) { cmdbuf[strlen(cmdbuf) - 1] = 0; time(&CC->lastcmd); @@ -644,7 +644,7 @@ int send_instant_message(char *lun, char *x_user, char *x_msg) msgnum = CtdlSubmitMsg(logmsg, NULL, PAGELOGROOM); /* Now save a copy in the global log room, if configured */ - if (strlen(config.c_logpages) > 0) { + if (!IsEmptyStr(config.c_logpages)) { create_room(config.c_logpages, 3, "", 0, 1, 1, VIEW_BBS); CtdlSaveMsgPointerInRoom(config.c_logpages, msgnum, 0, NULL); } @@ -722,7 +722,7 @@ void cmd_sexp(char *argbuf) strcmp(x_msg, "000")) { x_big_msgbuf = realloc(x_big_msgbuf, strlen(x_big_msgbuf) + strlen(x_msg) + 4); - if (strlen(x_big_msgbuf) > 0) + if (!IsEmptyStr(x_big_msgbuf)) if (x_big_msgbuf[strlen(x_big_msgbuf)] != '\n') strcat(x_big_msgbuf, "\n"); strcat(x_big_msgbuf, x_msg); @@ -735,7 +735,7 @@ void cmd_sexp(char *argbuf) message_sent = PerformXmsgHooks(lun, x_user, x_msg); if (message_sent > 0) { - if (strlen(x_msg) > 0) + if (!IsEmptyStr(x_msg)) cprintf("%d Message sent", CIT_OK); else cprintf("%d Ok to send message", CIT_OK); diff --git a/citadel/modules/funambol/serv_funambol.c b/citadel/modules/funambol/serv_funambol.c index 561be0986..827bdb717 100644 --- a/citadel/modules/funambol/serv_funambol.c +++ b/citadel/modules/funambol/serv_funambol.c @@ -112,7 +112,7 @@ void notify_funambol(long msgnum, void *userdata) { goto nuke; } /* Are we allowed to push? */ - if ( strlen(config.c_funambol_host) == 0) { + if (IsEmptyStr(config.c_funambol_host)) { goto nuke; } else { lprintf(CTDL_INFO, "Push enabled\n"); diff --git a/citadel/modules/imap/imap_acl.c b/citadel/modules/imap/imap_acl.c index 1632532db..369afce88 100644 --- a/citadel/modules/imap/imap_acl.c +++ b/citadel/modules/imap/imap_acl.c @@ -176,9 +176,9 @@ void imap_getacl(int num_parms, char *parms[]) { cdb_free(cdbus); CtdlRoomAccess(&CC->room, &temp, &ra, NULL); - if (strlen(temp.fullname) > 0) { + if (!IsEmptyStr(temp.fullname)) { imap_acl_flags(rights, ra); - if (strlen(rights) > 0) { + if (!IsEmptyStr(rights)) { cprintf(" "); imap_strout(temp.fullname); cprintf(" %s", rights); diff --git a/citadel/modules/imap/imap_fetch.c b/citadel/modules/imap/imap_fetch.c index 66d5b44ad..5c40d57a5 100644 --- a/citadel/modules/imap/imap_fetch.c +++ b/citadel/modules/imap/imap_fetch.c @@ -204,7 +204,7 @@ void imap_fetch_rfc822(long msgnum, char *whichfmt) { ptr = memreadline(ptr, buf, sizeof buf); if (*ptr != 0) { striplt(buf); - if (strlen(buf) == 0) { + if (IsEmptyStr(buf)) { headers_size = ptr - IMAP->cached_rfc822_data; } } @@ -273,16 +273,16 @@ void imap_load_part(char *name, char *filename, char *partnum, char *disp, if (!strcasecmp(desired_section, mbuf2)) { cprintf("Content-type: %s", cbtype); - if (strlen(cbcharset) > 0) + if (!IsEmptyStr(cbcharset)) cprintf("; charset=\"%s\"", cbcharset); - if (strlen(name) > 0) + if (!IsEmptyStr(name)) cprintf("; name=\"%s\"", name); cprintf("\r\n"); - if (strlen(encoding) > 0) + if (!IsEmptyStr(encoding)) cprintf("Content-Transfer-Encoding: %s\r\n", encoding); - if (strlen(encoding) > 0) { + if (!IsEmptyStr(encoding)) { cprintf("Content-Disposition: %s", disp); - if (strlen(filename) > 0) { + if (!IsEmptyStr(filename)) { cprintf("; filename=\"%s\"", filename); } cprintf("\r\n"); @@ -362,7 +362,7 @@ void imap_output_envelope_addr(char *addr) { return; } - if (strlen(addr) == 0) { + if (IsEmptyStr(addr)) { cprintf("NIL "); return; } @@ -548,7 +548,7 @@ void imap_strip_headers(char *section) { strcat(boiled_headers, "\r\n"); } - if (strlen(buf) == 0) done_headers = 1; + if (IsEmptyStr(buf)) done_headers = 1; if (buf[0]=='\r') done_headers = 1; if (buf[0]=='\n') done_headers = 1; } @@ -582,7 +582,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) { if (strchr(section, '[') != NULL) { stripallbut(section, '[', ']'); } - lprintf(CTDL_DEBUG, "Section is: %s%s\n", section, ((strlen(section)==0) ? "(empty)" : "") ); + lprintf(CTDL_DEBUG, "Section is: %s%s\n", section, ((IsEmptyStr(section)0) ? "(empty)" : "") ); if (!strncasecmp(section, "HEADER", 6)) { need_body = 0; } @@ -617,7 +617,7 @@ void imap_fetch_body(long msgnum, char *item, int is_peek) { is_partial = 1; } if (is_partial == 0) strcpy(partial, ""); - /* if (strlen(partial) > 0) lprintf(CTDL_DEBUG, "Partial is %s\n", partial); */ + /* if (!IsEmptyStr(partial)) lprintf(CTDL_DEBUG, "Partial is %s\n", partial); */ if (IMAP->cached_body == NULL) { CC->redirect_buffer = malloc(SIZ); @@ -761,7 +761,7 @@ void imap_fetch_bodystructure_part( char cbmaintype[128]; char cbsubtype[128]; - if (cbtype != NULL) if (strlen(cbtype)>0) have_cbtype = 1; + if (cbtype != NULL) if (!IsEmptyStr(cbtype)) have_cbtype = 1; if (have_cbtype) { extract_token(cbmaintype, cbtype, 0, '/', sizeof cbmaintype); extract_token(cbsubtype, cbtype, 1, '/', sizeof cbsubtype); @@ -780,7 +780,7 @@ void imap_fetch_bodystructure_part( if (cbcharset == NULL) { cprintf("(\"CHARSET\" \"US-ASCII\""); } - else if (strlen(cbcharset) == 0) { + else if (IsEmptyStr(cbcharset)) { cprintf("(\"CHARSET\" \"US-ASCII\""); } else { @@ -788,7 +788,7 @@ void imap_fetch_bodystructure_part( imap_strout(cbcharset); } - if (name != NULL) if (strlen(name)>0) { + if (name != NULL) if (!IsEmptyStr(name)) { cprintf(" \"NAME\" "); imap_strout(name); } @@ -798,7 +798,7 @@ void imap_fetch_bodystructure_part( cprintf("NIL "); /* Body ID */ cprintf("NIL "); /* Body description */ - if (encoding != NULL) if (strlen(encoding) > 0) have_encoding = 1; + if (encoding != NULL) if (!IsEmptyStr(encoding)) have_encoding = 1; if (have_encoding) { imap_strout(encoding); } @@ -838,13 +838,13 @@ void imap_fetch_bodystructure_part( if (disp == NULL) { cprintf("NIL"); } - else if (strlen(disp) == 0) { + else if (IsEmptyStr(disp)) { cprintf("NIL"); } else { cprintf("("); imap_strout(disp); - if (filename != NULL) if (strlen(filename)>0) { + if (filename != NULL) if (!IsEmptyStr(filename)) { cprintf(" (\"FILENAME\" "); imap_strout(filename); cprintf(")"); @@ -903,7 +903,7 @@ void imap_fetch_bodystructure (long msgnum, char *item, ptr = rfc822; while (ptr = memreadline(ptr, buf, sizeof buf), *ptr != 0) { ++lines; - if ((strlen(buf) == 0) && (rfc822_body == NULL)) { + if ((IsEmptyStr(buf)) && (rfc822_body == NULL)) { rfc822_body = ptr; } } diff --git a/citadel/modules/imap/imap_list.c b/citadel/modules/imap/imap_list.c index 57bb65864..e7b52710e 100644 --- a/citadel/modules/imap/imap_list.c +++ b/citadel/modules/imap/imap_list.c @@ -139,7 +139,7 @@ void imap_listroom(struct ctdlroom *qrbuf, void *data) * We'll fix this later when we have time. */ if (return_children) { - if (strlen(return_options) > 0) { + if (!IsEmptyStr(return_options)) { strcat(return_options, " "); } strcat(return_options, "\\HasChildren"); @@ -395,7 +395,7 @@ void imap_list(int num_parms, char *parms[]) * hierarchy delimiter and the root name of the name given in the * reference parameter. */ - if ( (strlen(patterns[0]) == 0) && (extended_list_in_use == 0) ) { + if ( (IsEmptyStr(patterns[0])) && (extended_list_in_use == 0) ) { cprintf("* %s (\\Noselect) \"/\" \"\"\r\n", verb); } diff --git a/citadel/modules/imap/imap_misc.c b/citadel/modules/imap/imap_misc.c index 350f9ad10..54babbf20 100644 --- a/citadel/modules/imap/imap_misc.c +++ b/citadel/modules/imap/imap_misc.c @@ -283,7 +283,7 @@ void imap_do_append_flags(long new_msgnum, char *new_message_flags) { int i; if (new_message_flags == NULL) return; - if (strlen(new_message_flags) == 0) return; + if (IsEmptyStr(new_message_flags)) return; safestrncpy(flags, new_message_flags, sizeof flags); diff --git a/citadel/modules/imap/imap_tools.c b/citadel/modules/imap/imap_tools.c index c12755015..4298610f1 100644 --- a/citadel/modules/imap/imap_tools.c +++ b/citadel/modules/imap/imap_tools.c @@ -626,7 +626,7 @@ int imap_is_message_set(char *buf) if (buf == NULL) return (0); /* stupidity checks */ - if (strlen(buf) == 0) + if (IsEmptyStr(buf)) return (0); if (!strcasecmp(buf, "ALL")) diff --git a/citadel/modules/imap/serv_imap.c b/citadel/modules/imap/serv_imap.c index a391e91ac..46b205397 100644 --- a/citadel/modules/imap/serv_imap.c +++ b/citadel/modules/imap/serv_imap.c @@ -587,7 +587,7 @@ void imap_auth_plain(char *cmd) IMAP->authstate = imap_as_normal; - if (strlen(ident) > 0) { + if (!IsEmptyStr(ident)) { result = CtdlLoginExistingUser(user, ident); } else { diff --git a/citadel/modules/inetcfg/serv_inetcfg.c b/citadel/modules/inetcfg/serv_inetcfg.c index eaab32d37..90f4431fd 100644 --- a/citadel/modules/inetcfg/serv_inetcfg.c +++ b/citadel/modules/inetcfg/serv_inetcfg.c @@ -62,7 +62,7 @@ void inetcfg_setTo(struct CtdlMessage *msg) { do { extract_token(buf, conf, 0, '\n', sizeof buf); strcpy(conf, &conf[strlen(buf)+1]); - } while ( (strlen(conf)>0) && (strlen(buf)>0) ); + } while ( (!IsEmptyStr(conf)) && (!IsEmptyStr(buf)) ); if (inetcfg != NULL) free(inetcfg); inetcfg = conf; diff --git a/citadel/modules/ldap/serv_ldap.c b/citadel/modules/ldap/serv_ldap.c index b79be37bd..41c57f9d9 100644 --- a/citadel/modules/ldap/serv_ldap.c +++ b/citadel/modules/ldap/serv_ldap.c @@ -468,7 +468,7 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { */ if ( (!strcasecmp(v->prop[i].name, "fburl")) ||(!strncasecmp(v->prop[i].name, "fburl;", 6)) ) { - if ( (strlen(calFBURL) == 0) + if ( (IsEmptyStr(calFBURL)) || (!strncasecmp(v->prop[i].name, "fburl;pref", 10)) ) { safestrncpy(calFBURL, v->prop[i].value, sizeof calFBURL); } @@ -488,8 +488,8 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { attrs[num_attrs-1]->mod_values[1] = NULL; /* "givenname" (first name) based on info in vCard */ - if (strlen(givenname) == 0) strcpy(givenname, "_"); - if (strlen(sn) == 0) strcpy(sn, "_"); + if (IsEmptyStr(givenname)) strcpy(givenname, "_"); + if (IsEmptyStr(sn)) strcpy(sn, "_"); attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); @@ -524,7 +524,7 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { } /* Add a "calFBURL" attribute if a calendar free/busy URL exists */ - if (strlen(calFBURL) > 0) { + if (!IsEmptyStr(calFBURL)) { attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); @@ -597,7 +597,7 @@ CTDL_MODULE_INIT(ldap) #ifdef HAVE_LDAP CtdlRegisterCleanupHook(serv_ldap_cleanup); - if (strlen(config.c_ldap_host) > 0) { + if (!IsEmptyStr(config.c_ldap_host)) { CtdlConnectToLdap(); } diff --git a/citadel/modules/listsub/serv_listsub.c b/citadel/modules/listsub/serv_listsub.c index 6a0374533..8b1db7788 100644 --- a/citadel/modules/listsub/serv_listsub.c +++ b/citadel/modules/listsub/serv_listsub.c @@ -450,7 +450,7 @@ void do_confirm(char *room, char *token) { * make another pass at the file, stripping out lines referring to * that address. */ - if (strlen(address_to_unsubscribe) > 0) { + if (!IsEmptyStr(address_to_unsubscribe)) { holdbuf = malloc(SIZ); begin_critical_section(S_NETCONFIGS); ncfp = fopen(filename, "r+"); @@ -506,7 +506,12 @@ void do_confirm(char *room, char *token) { */ if (success) { cprintf("%d %d operation(s) confirmed.\n", CIT_OK, success); - lprintf(CTDL_NOTICE, "Mailing list: %s %ssubscribed to %s with token %s\n", email, (strlen(address_to_unsubscribe) > 0) ? "un" : "", room, token); + lprintf(CTDL_NOTICE, + "Mailing list: %s %ssubscribed to %s with token %s\n", + email, + (!IsEmptyStr(address_to_unsubscribe)) ? "un" : "", + room, + token); } else { cprintf("%d Invalid token.\n", ERROR + ILLEGAL_VALUE); diff --git a/citadel/modules/managesieve/serv_managesieve.c b/citadel/modules/managesieve/serv_managesieve.c index 56c28a327..121cad908 100644 --- a/citadel/modules/managesieve/serv_managesieve.c +++ b/citadel/modules/managesieve/serv_managesieve.c @@ -155,12 +155,12 @@ long GetSizeToken(char * token) char *cursor = token; char *number; - while ((*cursor != '\0') && + while (!IsEmptyStr(cursor) && (*cursor != '{')) { cursor++; } - if (*cursor == '\0') + if (IsEmptyStr(cursor)) return -1; number = cursor + 1; while ((*cursor != '\0') && @@ -172,7 +172,7 @@ long GetSizeToken(char * token) if (cursor[-1] == '+') cursor--; - if (*cursor == '\0') + if (IsEmptyStr(cursor)) return -1; return atol(number); diff --git a/citadel/modules/network/serv_network.c b/citadel/modules/network/serv_network.c index 1c8260b9b..8885e5d81 100644 --- a/citadel/modules/network/serv_network.c +++ b/citadel/modules/network/serv_network.c @@ -141,8 +141,9 @@ struct FilterList *load_filter_list(void) { /* Cowardly refuse to add an any/any/any entry that would * end up filtering every single message. */ - if (strlen(nptr->fl_user) + strlen(nptr->fl_room) - + strlen(nptr->fl_node) == 0) { + if (IsEmptyStr(nptr->fl_user) && + IsEmptyStr(nptr->fl_room) && + IsEmptyStr(nptr->fl_node)) { free(nptr); } else { @@ -183,7 +184,7 @@ int network_usetable(struct CtdlMessage *msg) { if (msg->cm_fields['I'] == NULL) { return(0); } - if (strlen(msg->cm_fields['I']) == 0) { + if (IsEmptyStr(msg->cm_fields['I'])) { return(0); } @@ -257,7 +258,7 @@ void write_network_map(void) { for (nmptr = the_netmap; nmptr != NULL; nmptr = nmptr->next) { serialized_map = realloc(serialized_map, (strlen(serialized_map)+SIZ) ); - if (strlen(nmptr->nodename) > 0) { + if (!IsEmptyStr(nmptr->nodename)) { snprintf(&serialized_map[strlen(serialized_map)], SIZ, "%s|%ld|%s\n", @@ -793,7 +794,7 @@ void network_spool_msg(long msgnum, void *userdata) { if (msg->cm_fields['C'] != NULL) { free(msg->cm_fields['C']); } - if (strlen(mptr->remote_roomname) > 0) { + if (!IsEmptyStr(mptr->remote_roomname)) { msg->cm_fields['C'] = strdup(mptr->remote_roomname); } else { @@ -919,7 +920,7 @@ void network_spoolout_room(char *room_to_spool) { extract_token(roomname, buf, 2, '|', sizeof roomname); strcpy(nexthop, "xxx"); if (is_valid_node(nexthop, NULL, nodename) == 0) { - if (strlen(nexthop) == 0) { + if (IsEmptyStr(nexthop)) { mptr = (struct maplist *) malloc(sizeof(struct maplist)); mptr->next = sc.ignet_push_shares; @@ -1029,7 +1030,7 @@ void network_spoolout_room(char *room_to_spool) { } fprintf(fp, "ignet_push_share|%s", sc.ignet_push_shares->remote_nodename); - if (strlen(sc.ignet_push_shares->remote_roomname) > 0) { + if (!IsEmptyStr(sc.ignet_push_shares->remote_roomname)) { fprintf(fp, "|%s", sc.ignet_push_shares->remote_roomname); } fprintf(fp, "\n"); @@ -1307,7 +1308,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) { else { strcpy(force_room, ""); } - if ( (valid == NULL) && (strlen(force_room) == 0) ) { + if ( (valid == NULL) && IsEmptyStr(force_room) ) { strcpy(force_room, config.c_aideroom); } CtdlSubmitMsg(msg, valid, force_room); @@ -1392,7 +1393,7 @@ void network_process_buffer(char *buffer, long size) { serialize_message(&sermsg, msg); /* now send it */ - if (strlen(nexthop) == 0) { + if (IsEmptyStr(nexthop)) { strcpy(nexthop, msg->cm_fields['D']); } snprintf(filename, @@ -1629,7 +1630,7 @@ void network_purge_spoolout(void) { strcpy(nexthop, ""); i = is_valid_node(nexthop, NULL, d->d_name); - if ( (i != 0) || (strlen(nexthop) > 0) ) { + if ( (i != 0) || !IsEmptyStr(nexthop) ) { unlink(filename); } } @@ -1865,8 +1866,8 @@ void network_poll_other_citadel_nodes(int full_poll) { extract_token(secret, linebuf, 1, '|', sizeof secret); extract_token(host, linebuf, 2, '|', sizeof host); extract_token(port, linebuf, 3, '|', sizeof port); - if ( (strlen(node) > 0) && (strlen(secret) > 0) - && (strlen(host) > 0) && strlen(port) > 0) { + if ( !IsEmptyStr(node) && !IsEmptyStr(secret) + && !IsEmptyStr(host) && !IsEmptyStr(port)) { poll = full_poll; if (poll == 0) { snprintf(spoolfile, diff --git a/citadel/modules/notes/serv_notes.c b/citadel/modules/notes/serv_notes.c index 47e968b03..374cb57eb 100644 --- a/citadel/modules/notes/serv_notes.c +++ b/citadel/modules/notes/serv_notes.c @@ -83,7 +83,7 @@ int serv_notes_beforesave(struct CtdlMessage *msg) } lprintf(9, "UUID of note is: %s\n", uuid); - if (strlen(uuid) > 0) { + if (!IsEmptyStr(uuid)) { if (msg->cm_fields['E'] != NULL) { free(msg->cm_fields['E']); diff --git a/citadel/modules/rwho/serv_rwho.c b/citadel/modules/rwho/serv_rwho.c index 553049c9b..d8a1285ba 100644 --- a/citadel/modules/rwho/serv_rwho.c +++ b/citadel/modules/rwho/serv_rwho.c @@ -166,7 +166,7 @@ void cmd_rchg(char *argbuf) extract_token(newroomname, argbuf, 0, '|', sizeof newroomname); newroomname[ROOMNAMELEN-1] = 0; - if (strlen(newroomname) > 0) { + if (!IsEmptyStr(newroomname)) { safestrncpy(CC->fake_roomname, newroomname, sizeof(CC->fake_roomname) ); } @@ -184,7 +184,7 @@ void cmd_hchg(char *argbuf) char newhostname[64]; extract_token(newhostname, argbuf, 0, '|', sizeof newhostname); - if (strlen(newhostname) > 0) { + if (!IsEmptyStr(newhostname)) { safestrncpy(CC->fake_hostname, newhostname, sizeof(CC->fake_hostname) ); } @@ -207,7 +207,7 @@ void cmd_uchg(char *argbuf) if (CtdlAccessCheck(ac_aide)) return; - if (strlen(newusername) > 0) { + if (!IsEmptyStr(newusername)) { CC->cs_flags &= ~CS_STEALTH; memset(CC->fake_username, 0, 32); if (strncasecmp(newusername, CC->curr_user, diff --git a/citadel/modules/sieve/serv_sieve.c b/citadel/modules/sieve/serv_sieve.c index 508f8d218..cc6d8b172 100644 --- a/citadel/modules/sieve/serv_sieve.c +++ b/citadel/modules/sieve/serv_sieve.c @@ -230,7 +230,7 @@ int ctdl_reject(sieve2_context_t *s, void *my) lprintf(CTDL_DEBUG, "Action is REJECT\n"); /* If we don't know who sent the message, do a DISCARD instead. */ - if (strlen(cs->sender) == 0) { + if (IsEmptyStr(cs->sender)) { lprintf(CTDL_INFO, "Unknown sender. Doing DISCARD instead of REJECT.\n"); return ctdl_discard(s, my); } @@ -969,7 +969,7 @@ int msiv_setactive(struct sdm_userdata *u, char *script_name) { /* First see if the supplied value is ok */ - if (strlen(script_name) == 0) { + if (IsEmptyStr(script_name)) { ok = 1; } else { @@ -1108,7 +1108,7 @@ void cmd_msiv(char *argbuf) { if (!strcasecmp(subcmd, "putscript")) { extract_token(script_name, argbuf, 1, '|', sizeof script_name); - if (strlen(script_name) > 0) { + if (!IsEmptyStr(script_name)) { cprintf("%d Transmit script now\n", SEND_LISTING); script_content = CtdlReadMessageBody("000", config.c_maxmsglen, NULL, 0); msiv_putscript(&u, script_name, script_content); diff --git a/citadel/modules/smtp/serv_smtp.c b/citadel/modules/smtp/serv_smtp.c index a08d6be05..304344694 100644 --- a/citadel/modules/smtp/serv_smtp.c +++ b/citadel/modules/smtp/serv_smtp.c @@ -359,7 +359,7 @@ void smtp_try_plain(char *encoded_authstring) { SMTP->command_state = smtp_command; - if (strlen(ident) > 0) { + if (!IsEmptyStr(ident)) { result = CtdlLoginExistingUser(user, ident); } else { @@ -490,7 +490,7 @@ void smtp_mail(char *argbuf) { char node[SIZ]; char name[SIZ]; - if (strlen(SMTP->from) != 0) { + if (!IsEmptyStr(SMTP->from)) { cprintf("503 5.1.0 Only one sender permitted\r\n"); return; } @@ -512,7 +512,7 @@ void smtp_mail(char *argbuf) { * address so we don't have to contend with the empty string causing * other code to fail when it's expecting something there. */ - if (strlen(SMTP->from) == 0) { + if (IsEmptyStr(SMTP->from)) { strcpy(SMTP->from, "someone@somewhere.org"); } @@ -557,7 +557,7 @@ void smtp_rcpt(char *argbuf) { char message_to_spammer[SIZ]; struct recptypes *valid = NULL; - if (strlen(SMTP->from) == 0) { + if (IsEmptyStr(SMTP->from)) { cprintf("503 5.5.1 Need MAIL before RCPT\r\n"); return; } @@ -622,7 +622,7 @@ void smtp_rcpt(char *argbuf) { } cprintf("250 2.1.5 RCPT ok <%s>\r\n", recp); - if (strlen(SMTP->recipients) > 0) { + if (!IsEmptyStr(SMTP->recipients)) { strcat(SMTP->recipients, ","); } strcat(SMTP->recipients, recp); @@ -648,7 +648,7 @@ void smtp_data(void) { int i; char result[SIZ]; - if (strlen(SMTP->from) == 0) { + if (IsEmptyStr(SMTP->from)) { cprintf("503 5.5.1 Need MAIL command first.\r\n"); return; } @@ -991,7 +991,7 @@ void smtp_try(const char *key, const char *addr, int *status, scan_done = 1; } } while (scan_done == 0); - if (strlen(mailfrom)==0) strcpy(mailfrom, "someone@somewhere.org"); + if (IsEmptyStr(mailfrom)) strcpy(mailfrom, "someone@somewhere.org"); stripallbut(mailfrom, '<', '>'); /* Figure out what mail exchanger host we have to connect to */ @@ -1105,7 +1105,7 @@ void smtp_try(const char *key, const char *addr, int *status, } /* Do an AUTH command if necessary */ - if (strlen(mx_user) > 0) { + if (!IsEmptyStr(mx_user)) { char encoded[1024]; sprintf(buf, "%s%c%s%c%s", mx_user, '\0', mx_user, '\0', mx_pass); CtdlEncodeBase64(encoded, buf, strlen(mx_user) + strlen(mx_user) + strlen(mx_pass) + 2); @@ -1428,7 +1428,7 @@ void smtp_do_bounce(char *instr) { /* First try the user who sent the message */ lprintf(CTDL_DEBUG, "bounce to user? <%s>\n", bounceto); - if (strlen(bounceto) == 0) { + if (IsEmptyStr(bounceto)) { lprintf(CTDL_ERR, "No bounce address specified\n"); bounce_msgid = (-1L); } diff --git a/citadel/modules/vandelay/serv_vandelay.c b/citadel/modules/vandelay/serv_vandelay.c index b1c3630c0..8380cec4d 100644 --- a/citadel/modules/vandelay/serv_vandelay.c +++ b/citadel/modules/vandelay/serv_vandelay.c @@ -199,7 +199,7 @@ void artv_export_visits(void) { cprintf("%ld\n", vbuf.v_roomgen); cprintf("%ld\n", vbuf.v_usernum); - if (strlen(vbuf.v_seen) > 0) { + if (!IsEmptyStr(vbuf.v_seen)) { cprintf("%s\n", vbuf.v_seen); } else { diff --git a/citadel/modules/vcard/serv_vcard.c b/citadel/modules/vcard/serv_vcard.c index 06b063718..311b73dfe 100644 --- a/citadel/modules/vcard/serv_vcard.c +++ b/citadel/modules/vcard/serv_vcard.c @@ -111,7 +111,7 @@ void vcard_extract_internet_addresses(struct CtdlMessage *msg, if (s != NULL) { addr = strdup(s); striplt(addr); - if (strlen(addr) > 0) { + if (!IsEmptyStr(addr)) { if (callback != NULL) { callback(addr, citadel_address); } @@ -225,7 +225,7 @@ void extract_inet_email_addrs(char *emailaddrbuf, size_t emailaddrbuf_len, while (s = vcard_get_prop(v, "email;internet", 0, instance++, 0), s != NULL) { addr = strdup(s); striplt(addr); - if (strlen(addr) > 0) { + if (!IsEmptyStr(addr)) { if ( (IsDirectory(addr, 1)) || (!local_addrs_only) ) { ++saved_instance; @@ -923,7 +923,7 @@ void cmd_gvsn(char *argbuf) cprintf("%d valid screen names:\n", LISTING_FOLLOWS); cprintf("%s\n", CC->user.fullname); - if ( (strlen(CC->cs_inet_fn) > 0) && (strcasecmp(CC->user.fullname, CC->cs_inet_fn)) ) { + if ( (!IsEmptyStr(CC->cs_inet_fn)) && (strcasecmp(CC->user.fullname, CC->cs_inet_fn)) ) { cprintf("%s\n", CC->cs_inet_fn); } cprintf("000\n"); @@ -942,10 +942,10 @@ void cmd_gvea(char *argbuf) if (CtdlAccessCheck(ac_logged_in)) return; cprintf("%d valid email addresses:\n", LISTING_FOLLOWS); - if (strlen(CC->cs_inet_email) > 0) { + if (!IsEmptyStr(CC->cs_inet_email)) { cprintf("%s\n", CC->cs_inet_email); } - if (strlen(CC->cs_inet_other_emails) > 0) { + if (!IsEmptyStr(CC->cs_inet_other_emails)) { num_secondary_emails = num_tokens(CC->cs_inet_other_emails, '|'); for (i=0; ics_inet_other_emails,i,'|',sizeof CC->cs_inet_other_emails); @@ -1245,7 +1245,7 @@ void store_this_ha(struct addresses_to_be_filed *aptr) { CtdlForEachMessage(MSGS_ALL, 0, NULL, "^[Tt][Ee][Xx][Tt]/.*[Vv][Cc][Aa][Rr][Dd]$", NULL, strip_addresses_already_have, aptr->collected_addresses); - if (strlen(aptr->collected_addresses) > 0) + if (!IsEmptyStr(aptr->collected_addresses)) for (i=0; icollected_addresses, ','); ++i) { /* Make a vCard out of each address */ -- 2.30.2