From: Wilfried Göesgens Date: Thu, 9 Aug 2007 16:37:44 +0000 (+0000) Subject: * Holy war on strlen: use IsEmptyStr where apropriate. X-Git-Tag: v7.86~3170 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=a2a06e5d6767d0e45eeccf4032153764e8a5520f * Holy war on strlen: use IsEmptyStr where apropriate. --- diff --git a/citadel/citadel.c b/citadel/citadel.c index c374d9761..920f06cc4 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -223,7 +223,7 @@ void userlist(CtdlIPC *ipc, char *patn) pprintf(" User Name Num L LastCall Calls Posts\n"); pprintf("------------------------- ----- - ---------- ----- -----\n"); - if (listing != NULL) while (strlen(listing) > 0) { + if (listing != NULL) while (!IsEmptyStr(listing)) { extract_token(buf, listing, 0, '\n', sizeof buf); remove_token(listing, 0, '\n'); @@ -420,7 +420,7 @@ void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto) } } - if (strlen(bbb) == 0) { + if (IsEmptyStr(bbb)) { scr_printf("No room '%s'.\n", towhere); return; } @@ -484,7 +484,7 @@ void dotgoto(CtdlIPC *ipc, char *towhere, int display_name, int fromungoto) newmailcount); } color(DIM_WHITE); - if (strlen(rc_gotmail_cmd) > 0) { + if (!IsEmptyStr(rc_gotmail_cmd)) { system(rc_gotmail_cmd); } } @@ -659,7 +659,7 @@ void gotofloor(CtdlIPC *ipc, char *towhere, int mode) mptr = tmp; } } - if (strlen(targ) > 0) { + if (!IsEmptyStr(targ)) { gf_toroom(ipc, targ, mode); return; } @@ -681,7 +681,7 @@ void gotofloor(CtdlIPC *ipc, char *towhere, int mode) mptr = tmp; } } - if (strlen(targ) > 0) { + if (!IsEmptyStr(targ)) { gf_toroom(ipc, targ, mode); } else { scr_printf("There are no rooms on '%s'.\n", &floorlist[tofloor][0]); @@ -950,7 +950,7 @@ void read_config(CtdlIPC *ipc) scr_printf("Enable color support: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_COLOR)? "Yes" : "No"); color(DIM_WHITE); } scr_printf("Be unlisted in userlog: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_UNLISTED)? "Yes" : "No"); color(DIM_WHITE); - if (strlen(editor_paths[0]) > 0) { + if (!IsEmptyStr(editor_paths[0])) { scr_printf("Always enter messages with the full-screen editor: "); color(BRIGHT_CYAN); scr_printf("%s\n", (user->flags & US_EXTEDIT)? "Yes" : "No"); color(DIM_WHITE); } free(user); @@ -1076,7 +1076,7 @@ int set_password(CtdlIPC *ipc) char pass2[20]; char buf[SIZ]; - if (strlen(rc_password) > 0) { + if (!IsEmptyStr(rc_password)) { strcpy(pass1, rc_password); strcpy(pass2, rc_password); } else { @@ -1223,7 +1223,7 @@ void who_is_online(CtdlIPC *ipc, int longlist) r = CtdlIPCOnlineUsers(ipc, &listing, &timenow, buf); listing = SortOnlineUsers(listing); if (r / 100 == 1) { - while (strlen(listing) > 0) { + while (!IsEmptyStr(listing)) { int isidle = 0; /* Get another line */ @@ -1263,11 +1263,13 @@ void who_is_online(CtdlIPC *ipc, int longlist) (long) idlemins, (long) idlesecs); - if ( (strlen(actual_user)+strlen(actual_room)+strlen(actual_host)) > 0) { + if ( (!IsEmptyStr(actual_user)&& + !IsEmptyStr(actual_room)&& + !IsEmptyStr(actual_host))) { pprintf("(really "); - if (strlen(actual_user)>0) pprintf("<%s> ", actual_user); - if (strlen(actual_room)>0) pprintf("in <%s> ", actual_room); - if (strlen(actual_host)>0) pprintf("from <%s> ", actual_host); + if (!IsEmptyStr(actual_user)) pprintf("<%s> ", actual_user); + if (!IsEmptyStr(actual_room)) pprintf("in <%s> ", actual_room); + if (!IsEmptyStr(actual_host)) pprintf("from <%s> ", actual_host); pprintf(")\n"); } pprintf("\n"); @@ -1557,7 +1559,7 @@ int main(int argc, char **argv) GSTA: /* See if we have a username and password on disk */ if (rc_remember_passwords) { get_stored_password(hostbuf, portbuf, fullname, password); - if (strlen(fullname) > 0) { + if (!IsEmptyStr(fullname)) { r = CtdlIPCTryLogin(ipc, fullname, aaa); if (r / 100 == 3) { if (*nonce) { @@ -1580,7 +1582,7 @@ int main(int argc, char **argv) termn8 = 0; newnow = 0; do { - if (strlen(rc_username) > 0) { + if (!IsEmptyStr(rc_username)) { strcpy(fullname, rc_username); } else { newprompt("Enter your name: ", fullname, 29); @@ -1592,7 +1594,7 @@ int main(int argc, char **argv) } while ( (!strcasecmp(fullname, "bbs")) || (!strcasecmp(fullname, "new")) - || (strlen(fullname) == 0)); + || (IsEmptyStr(fullname))); if (!strcasecmp(fullname, "off")) { mcmd = 29; @@ -1604,7 +1606,7 @@ int main(int argc, char **argv) goto NEWUSR; /* password authentication */ - if (strlen(rc_password) > 0) { + if (!IsEmptyStr(rc_password)) { strcpy(password, rc_password); } else { newprompt("\rPlease enter your password: ", password, -19); @@ -1624,11 +1626,11 @@ int main(int argc, char **argv) goto PWOK; } scr_printf("<< wrong password >>\n"); - if (strlen(rc_password) > 0) + if (!IsEmptyStr(rc_password)) logoff(ipc, 2); goto GSTA; -NEWUSR: if (strlen(rc_password) == 0) { +NEWUSR: if (IsEmptyStr(rc_password)) { scr_printf("'%s' not found.\n", fullname); scr_printf("Type 'off' if you would like to exit.\n"); if (ipc->ServInfo.newuser_disabled == 1) { @@ -1683,7 +1685,7 @@ NEWUSR: if (strlen(rc_password) == 0) { if (b > 1) scr_printf("*** You have %d new private messages in Mail>\n", b); color(DIM_WHITE); - if (strlen(rc_gotmail_cmd) > 0) { + if (!IsEmptyStr(rc_gotmail_cmd)) { system(rc_gotmail_cmd); } } @@ -1784,13 +1786,13 @@ NEWUSR: if (strlen(rc_password) == 0) { dotgoto(ipc, "_MAIL_", 1, 0); break; case 20: - if (strlen(argbuf) > 0) { + if (!IsEmptyStr(argbuf)) { updatels(ipc); dotgoto(ipc, argbuf, 0, 0); } break; case 52: - if (strlen(argbuf) > 0) { + if (!IsEmptyStr(argbuf)) { if (rc_alt_semantics) { updatelsa(ipc); } diff --git a/citadel/citmail.c b/citadel/citmail.c index 5a2fd94d3..f5c8da25d 100644 --- a/citadel/citmail.c +++ b/citadel/citmail.c @@ -34,7 +34,7 @@ int debug = 0; void strip_trailing_nonprint(char *buf) { - while ( (strlen(buf)>0) && (!isprint(buf[strlen(buf) - 1])) ) + while ( (!IsEmptyStr(buf)) && (!isprint(buf[strlen(buf) - 1])) ) buf[strlen(buf) - 1] = 0; } @@ -263,7 +263,7 @@ int main(int argc, char **argv) { extract_token(this_recp, add_these_recipients, i, ',', sizeof this_recp); striplt(this_recp); - if (strlen(this_recp) > 0) { + if (!IsEmptyStr(this_recp)) { ++num_recipients; recipients = realloc(recipients, (num_recipients * sizeof (char *))); diff --git a/citadel/citserver.c b/citadel/citserver.c index 90a7f4f96..c221d6aaf 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -403,7 +403,7 @@ void cmd_iden(char *argbuf) safestrncpy(CC->cs_clientname, desc, sizeof CC->cs_clientname); CC->cs_clientname[31] = 0; - if (strlen(from_host) > 0) { + if (!IsEmptyStr(from_host)) { if (CC->is_local_socket) do_lookup = 1; else if (is_public_client()) do_lookup = 1; } @@ -474,12 +474,12 @@ void cmd_mesg(char *mname) /* Otherwise, look for the requested file by name. */ else { mesg_locate(targ, sizeof targ, buf2, 2, (const char **)dirs); - if (strlen(targ) == 0) { + if (IsEmptyStr(targ)) { snprintf(buf2, sizeof buf2, "%s.%d", buf, CC->cs_clientdev); mesg_locate(targ, sizeof targ, buf2, 2, (const char **)dirs); - if (strlen(targ) == 0) { + if (IsEmptyStr(targ)) { mesg_locate(targ, sizeof targ, buf, 2, (const char **)dirs); } @@ -489,7 +489,7 @@ void cmd_mesg(char *mname) free(dirs[0]); free(dirs[1]); - if (strlen(targ)==0) { + if (IsEmptyStr(targ)) { cprintf("%d '%s' not found. (Searching in %s and %s)\n", ERROR + FILE_NOT_FOUND, mname, @@ -545,7 +545,7 @@ void cmd_emsg(char *mname) free(dirs[0]); free(dirs[1]); - if (strlen(targ)==0) { + if (IsEmptyStr(targ)) { snprintf(targ, sizeof targ, "%s/%s", ctdl_hlp_dir, buf); diff --git a/citadel/client_chat.c b/citadel/client_chat.c index 08eff91d8..1cdb958f9 100644 --- a/citadel/client_chat.c +++ b/citadel/client_chat.c @@ -113,7 +113,7 @@ void chatmode(CtdlIPC *ipc) if ((ch == 10) || (ch == 13)) { send_complete_line = 1; } else if ((ch == 8) || (ch == 127)) { - if (strlen(wbuf) > 0) { + if (!IsEmptyStr(wbuf)) { wbuf[strlen(wbuf) - 1] = 0; sln_printf("%c %c", 8, 8); } diff --git a/citadel/client_passwords.c b/citadel/client_passwords.c index 603588bf7..2087f1b7a 100644 --- a/citadel/client_passwords.c +++ b/citadel/client_passwords.c @@ -53,7 +53,7 @@ void get_stored_password( strcpy(password, ""); determine_pwfilename(pwfile, sizeof pwfile); - if (strlen(pwfile)==0) return; + if (IsEmptyStr(pwfile)) return; fp = fopen(pwfile, "r"); if (fp == NULL) return; @@ -91,7 +91,7 @@ void set_stored_password( char hostbuf[256], portbuf[256], ubuf[256], pbuf[256]; determine_pwfilename(pwfile, sizeof pwfile); - if (strlen(pwfile)==0) return; + if (IsEmptyStr(pwfile)) return; oldfp = fopen(pwfile, "r"); if (oldfp == NULL) oldfp = fopen("/dev/null", "r"); @@ -113,7 +113,7 @@ void set_stored_password( fprintf(fp, "%s\n", buf64); } } - if (strlen(username) > 0) { + if (!IsEmptyStr(username)) { snprintf(buf, sizeof buf, "%s|%s|%s|%s|", host, port, username, password); CtdlEncodeBase64(buf64, buf, strlen(buf)); diff --git a/citadel/clientsocket.c b/citadel/clientsocket.c index cd375db2d..a1c93a251 100644 --- a/citadel/clientsocket.c +++ b/citadel/clientsocket.c @@ -31,6 +31,7 @@ #include "sysdep_decls.h" #include "config.h" #include "clientsocket.h" +#include "tools.h" #ifndef INADDR_NONE #define INADDR_NONE 0xffffffff @@ -45,12 +46,12 @@ int sock_connect(char *host, char *service, char *protocol) struct sockaddr_in egress_sin; int s, type; - if (host == NULL) return(-1); - if (strlen(host) == 0) return(-1); - if (service == NULL) return(-1); - if (strlen(service) == 0) return(-1); - if (protocol == NULL) return(-1); - if (strlen(protocol) == 0) return(-1); + if ((host == NULL) || IsEmptyStr(host)) + return(-1); + if ((service == NULL) || IsEmptyStr(service)) + return(-1); + if ((protocol == NULL) || IsEmptyStr(protocol)) + return(-1); memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; @@ -93,7 +94,7 @@ int sock_connect(char *host, char *service, char *protocol) */ memset(&egress_sin, 0, sizeof(egress_sin)); egress_sin.sin_family = AF_INET; - if (strlen(config.c_ip_addr) > 0) { + if (!IsEmptyStr(config.c_ip_addr)) { egress_sin.sin_addr.s_addr = inet_addr(config.c_ip_addr); if (egress_sin.sin_addr.s_addr == !INADDR_ANY) { egress_sin.sin_addr.s_addr = INADDR_ANY; @@ -209,7 +210,7 @@ int sock_gets(int sock, char *buf) /* Strip any trailing CR and LF characters. */ buf[i] = 0; - while ( (strlen(buf)>0) + while ( (!IsEmptyStr(buf)) && ((buf[strlen(buf)-1]==13) || (buf[strlen(buf)-1]==10)) ) { buf[strlen(buf)-1] = 0; diff --git a/citadel/commands.c b/citadel/commands.c index 5c92f6207..0a2042e3a 100644 --- a/citadel/commands.c +++ b/citadel/commands.c @@ -220,7 +220,7 @@ void print_instant(void) if (rc_exp_beep) { ctdl_beep(); } - if (strlen(rc_exp_cmd) == 0) { + if (IsEmptyStr(rc_exp_cmd)) { color(BRIGHT_RED); scr_printf("\r---"); } @@ -245,7 +245,7 @@ void print_instant(void) return; } - if (strlen(rc_exp_cmd) > 0) { + if (!IsEmptyStr(rc_exp_cmd)) { outpipe = popen(rc_exp_cmd, "w"); if (outpipe != NULL) { /* Header derived from flags */ @@ -582,7 +582,7 @@ void ctdl_getline(char *string, int lim) GLA: a = inkey(); /* a = (a & 127); ** commented out because it isn't just an ASCII world anymore */ - if ((a == 8 || a == 23) && (strlen(string) == 0)) + if ((a == 8 || a == 23) && (IsEmptyStr(string))) goto GLA; if ((a != 10) && (a != 8) && (strlen(string) == lim)) goto GLA; @@ -595,7 +595,7 @@ GLA: a = inkey(); do { string[strlen(string) - 1] = 0; scr_putc(8); scr_putc(32); scr_putc(8); - } while (strlen(string) && string[strlen(string) - 1] != ' '); + } while (!IsEmptyStr(string) && string[strlen(string) - 1] != ' '); goto GLA; } if ((a == 10)) { @@ -788,7 +788,7 @@ void load_command_set(void) logoff(NULL, 3); } while (fgets(buf, sizeof buf, ccfile) != NULL) { - while ((strlen(buf) > 0) ? (isspace(buf[strlen(buf) - 1])) : 0) + while ((!IsEmptyStr(buf)) ? (isspace(buf[strlen(buf) - 1])) : 0) buf[strlen(buf) - 1] = 0; if (!strncasecmp(buf, "encrypt=", 8)) { @@ -929,7 +929,7 @@ void load_command_set(void) a = 0; b = 0; buf[strlen(buf) + 1] = 0; - while (strlen(buf) > 0) { + while (!IsEmptyStr(buf)) { b = strlen(buf); for (d = strlen(buf); d >= 0; --d) if (buf[d] == ',') diff --git a/citadel/control.c b/citadel/control.c index 83c1eb086..77205b10c 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -507,7 +507,7 @@ void cmd_conf(char *argbuf) CC->curr_user); aide_message(buf,"Citadel Configuration Manager Message"); - if (strlen(config.c_logpages) > 0) + if (!IsEmptyStr(config.c_logpages)) create_room(config.c_logpages, 3, "", 0, 1, 1, VIEW_BBS); /* If full text indexing has been disabled, invalidate the diff --git a/citadel/debian/rules b/citadel/debian/rules index e8a39e310..fef1a8bf6 100755 --- a/citadel/debian/rules +++ b/citadel/debian/rules @@ -11,7 +11,7 @@ DEB_DESTDIR = $(CURDIR)/debian/tmp CFLAGS = -Wall -g #ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -ggdb + CFLAGS += -O0 -ggdb -pg #else # CFLAGS += -O2 #endif diff --git a/citadel/file_ops.c b/citadel/file_ops.c index 015e989ea..10c066a48 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -70,13 +70,13 @@ int network_talking_to(char *nodename, int operation) { case NTT_REMOVE: if (nttlist == NULL) break; - if (strlen(nttlist) == 0) break; + if (IsEmptyStr(nttlist)) break; ptr = malloc(strlen(nttlist)); if (ptr == NULL) break; strcpy(ptr, ""); for (i = 0; i < num_tokens(nttlist, '|'); ++i) { extract_token(buf, nttlist, i, '|', sizeof buf); - if ( (strlen(buf) > 0) + if ( (!IsEmptyStr(buf)) && (strcasecmp(buf, nodename)) ) { strcat(ptr, buf); strcat(ptr, "|"); @@ -88,7 +88,7 @@ int network_talking_to(char *nodename, int operation) { case NTT_CHECK: if (nttlist == NULL) break; - if (strlen(nttlist) == 0) break; + if (IsEmptyStr(nttlist)) break; for (i = 0; i < num_tokens(nttlist, '|'); ++i) { extract_token(buf, nttlist, i, '|', sizeof buf); if (!strcasecmp(buf, nodename)) ++retval; @@ -121,7 +121,7 @@ void cmd_delf(char *filename) return; } - if (strlen(filename) == 0) { + if (IsEmptyStr(filename)) { cprintf("%d You must specify a file name.\n", ERROR + FILE_NOT_FOUND); return; @@ -172,7 +172,7 @@ void cmd_movf(char *cmdbuf) return; } - if (strlen(filename) == 0) { + if (IsEmptyStr(filename)) { cprintf("%d You must specify a file name.\n", ERROR + FILE_NOT_FOUND); return; @@ -241,7 +241,7 @@ void cmd_netf(char *cmdbuf) return; } - if (strlen(filename) == 0) { + if (IsEmptyStr(filename)) { cprintf("%d You must specify a file name.\n", ERROR + FILE_NOT_FOUND); return; @@ -355,7 +355,7 @@ void cmd_open(char *cmdbuf) return; } - if (strlen(filename) == 0) { + if (IsEmptyStr(filename)) { cprintf("%d You must specify a file name.\n", ERROR + FILE_NOT_FOUND); return; @@ -402,7 +402,7 @@ void cmd_oimg(char *cmdbuf) extract_token(filename, cmdbuf, 0, '|', sizeof filename); - if (strlen(filename) == 0) { + if (IsEmptyStr(filename)) { cprintf("%d You must specify a file name.\n", ERROR + FILE_NOT_FOUND); return; @@ -473,7 +473,7 @@ void cmd_uopn(char *cmdbuf) return; } - if (strlen(CC->upl_file) == 0) { + if (IsEmptyStr(CC->upl_file)) { cprintf("%d You must specify a file name.\n", ERROR + FILE_NOT_FOUND); return; @@ -578,7 +578,7 @@ void cmd_uimg(char *cmdbuf) assoc_file_name(CC->upl_path, sizeof CC->upl_path, &CC->room, ctdl_image_dir); } - if (strlen(CC->upl_path) == 0) { + if (IsEmptyStr(CC->upl_path)) { cprintf("%d Higher access required.\n", ERROR + HIGHER_ACCESS_REQUIRED); return; @@ -766,7 +766,7 @@ void cmd_ndop(char *cmdbuf) char pathname[256]; struct stat statbuf; - if (strlen(CC->net_node) == 0) { + if (IsEmptyStr(CC->net_node)) { cprintf("%d Not authenticated as a network node.\n", ERROR + NOT_LOGGED_IN); return; @@ -815,7 +815,7 @@ void cmd_nuop(char *cmdbuf) { static int seq = 1; - if (strlen(CC->net_node) == 0) { + if (IsEmptyStr(CC->net_node)) { cprintf("%d Not authenticated as a network node.\n", ERROR + NOT_LOGGED_IN); return; diff --git a/citadel/html.c b/citadel/html.c index 6a86d323a..1bb6cd4e2 100644 --- a/citadel/html.c +++ b/citadel/html.c @@ -97,7 +97,7 @@ char *html_to_ascii(char *inputmsg, int msglen, int screenwidth, int do_citaform } /* Do some parsing */ - if (strlen(inbuf)>0) { + if (!IsEmptyStr(inbuf)) { /* Fold in all the spacing */ for (i=0; i0) for (i=0; i0) { + if (!IsEmptyStr(outbuf)) { for (i = 0; i'); /* strip anything to the left of a bang */ - while ((strlen(name) > 0) && (haschar(name, '!') > 0)) + while ((!IsEmptyStr(name)) && (haschar(name, '!') > 0)) strcpy(name, &name[1]); /* and anything to the right of a @ or % */ @@ -194,7 +194,7 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) /* but if there are a set of quotes, that supersedes everything */ if (haschar(rfc822, 34) == 2) { strcpy(name, rfc822); - while ((strlen(name) > 0) && (name[0] != 34)) { + while ((!IsEmptyStr(name)) && (name[0] != 34)) { strcpy(&name[0], &name[1]); } strcpy(&name[0], &name[1]); @@ -214,7 +214,7 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) } /* strip anything to the left of a bang */ - while ((strlen(user) > 0) && (haschar(user, '!') > 0)) + while ((!IsEmptyStr(user)) && (haschar(user, '!') > 0)) strcpy(user, &user[1]); /* and anything to the right of a @ or % */ @@ -249,15 +249,15 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) else { /* strip anything to the left of a @ */ - while ((strlen(node) > 0) && (haschar(node, '@') > 0)) + while ((!IsEmptyStr(node)) && (haschar(node, '@') > 0)) strcpy(node, &node[1]); /* strip anything to the left of a % */ - while ((strlen(node) > 0) && (haschar(node, '%') > 0)) + while ((!IsEmptyStr(node)) && (haschar(node, '%') > 0)) strcpy(node, &node[1]); /* reduce multiple system bang paths to node!user */ - while ((strlen(node) > 0) && (haschar(node, '!') > 1)) + while ((!IsEmptyStr(node)) && (haschar(node, '!') > 1)) strcpy(node, &node[1]); /* now get rid of the user portion of a node!user string */ @@ -275,7 +275,7 @@ void process_rfc822_addr(const char *rfc822, char *user, char *node, char *name) * but no name outside the brackets, we now have an empty name. In * this case, use the user portion of the address as the name. */ - if ((strlen(name) == 0) && (strlen(user) > 0)) { + if ((IsEmptyStr(name)) && (!IsEmptyStr(user))) { strcpy(name, user); } } @@ -707,7 +707,7 @@ char *harvest_collected_addresses(struct CtdlMessage *msg) { if ( (h != hostalias_localhost) && (h != hostalias_directory) ) { coll = realloc(coll, strlen(coll) + strlen(addr) + 4); if (coll == NULL) return(NULL); - if (strlen(coll) > 0) { + if (!IsEmptyStr(coll)) { strcat(coll, ","); } striplt(addr); @@ -717,7 +717,7 @@ char *harvest_collected_addresses(struct CtdlMessage *msg) { } } - if (strlen(coll) == 0) { + if (IsEmptyStr(coll)) { free(coll); return(NULL); } diff --git a/citadel/messages.c b/citadel/messages.c index a334a7fc7..79e03b1b4 100644 --- a/citadel/messages.c +++ b/citadel/messages.c @@ -272,7 +272,7 @@ void citedit(CtdlIPC *ipc, FILE * fp) } if (a == 8) { - if (strlen(wordbuf) > 0) { + if (!IsEmptyStr(wordbuf)) { wordbuf[strlen(wordbuf) - 1] = 0; scr_putc(8); scr_putc(32); @@ -284,10 +284,10 @@ void citedit(CtdlIPC *ipc, FILE * fp) scr_putc(8); scr_putc(32); scr_putc(8); - } while (strlen(wordbuf) && wordbuf[strlen(wordbuf) - 1] != ' '); + } while (!IsEmptyStr(wordbuf) && wordbuf[strlen(wordbuf) - 1] != ' '); } else if (a == 13) { scr_printf("\n"); - if (strlen(wordbuf) == 0) + if (IsEmptyStr(wordbuf)) finished = 1; else { for (b = 0; b < strlen(wordbuf); ++b) @@ -436,17 +436,17 @@ int read_message(CtdlIPC *ipc, message->nhdr ? "yes" : "no", message->author, message->type, message->msgid); - if (strlen(message->subject)) { + if (!IsEmptyStr(message->subject)) { pprintf("subj=%s\n", message->subject); } - if (strlen(message->email)) { + if (!IsEmptyStr(message->email)) { pprintf("rfca=%s\n", message->email); } pprintf("hnod=%s\nroom=%s\nnode=%s\ntime=%s", message->hnod, message->room, message->node, asctime(localtime(&message->time))); - if (strlen(message->recipient)) { + if (!IsEmptyStr(message->recipient)) { pprintf("rcpt=%s\n", message->recipient); } if (message->attachments) { @@ -486,7 +486,7 @@ int read_message(CtdlIPC *ipc, fmt_date(now, sizeof now, message->time, 0); if (dest) { fprintf(dest, "%s from %s ", now, message->author); - if (strlen(message->email)) { + if (!IsEmptyStr(message->email)) { fprintf(dest, "<%s> ", message->email); } } else { @@ -496,7 +496,7 @@ int read_message(CtdlIPC *ipc, scr_printf("from "); color(BRIGHT_CYAN); scr_printf("%s ", message->author); - if (strlen(message->email)) { + if (!IsEmptyStr(message->email)) { color(DIM_WHITE); scr_printf("<"); color(BRIGHT_BLUE); @@ -505,11 +505,11 @@ int read_message(CtdlIPC *ipc, scr_printf("> "); } } - if (strlen(message->node)) { + if (!IsEmptyStr(message->node)) { if ((room_flags & QR_NETWORK) || ((strcasecmp(message->node, ipc->ServInfo.nodename) && (strcasecmp(message->node, ipc->ServInfo.fqdn))))) { - if (strlen(message->email) == 0) { + if (IsEmptyStr(message->email)) { if (dest) { fprintf(dest, "@%s ", message->node); } else { @@ -522,7 +522,7 @@ int read_message(CtdlIPC *ipc, } } if (strcasecmp(message->hnod, ipc->ServInfo.humannode) - && (strlen(message->hnod)) && (!strlen(message->email))) { + && (!IsEmptyStr(message->hnod)) && (IsEmptyStr(message->email))) { if (dest) { fprintf(dest, "(%s) ", message->hnod); } else { @@ -534,7 +534,7 @@ int read_message(CtdlIPC *ipc, scr_printf(") "); } } - if (strcasecmp(message->room, room_name) && (strlen(message->email) == 0)) { + if (strcasecmp(message->room, room_name) && (IsEmptyStr(message->email))) { if (dest) { fprintf(dest, "in %s> ", message->room); } else { @@ -544,7 +544,7 @@ int read_message(CtdlIPC *ipc, scr_printf("%s> ", message->room); } } - if (strlen(message->recipient)) { + if (!IsEmptyStr(message->recipient)) { if (dest) { fprintf(dest, "to %s ", message->recipient); } else { @@ -564,8 +564,8 @@ int read_message(CtdlIPC *ipc, /* Set the reply-to address to an Internet e-mail address if possible */ - if (message->email != NULL) if (strlen(message->email) > 0) { - if (strlen(message->author) > 0) { + if (message->email != NULL) if (!IsEmptyStr(message->email)) { + if (!IsEmptyStr(message->author)) { snprintf(reply_to, sizeof reply_to, "%s <%s>", message->author, message->email); } else { @@ -588,7 +588,7 @@ int read_message(CtdlIPC *ipc, if (message->subject != NULL) { safestrncpy(reply_subject, message->subject, sizeof reply_subject); - if (strlen(message->subject) > 0) { + if (!IsEmptyStr(message->subject)) { if (dest) { fprintf(dest, "Subject: %s\n", message->subject); @@ -710,7 +710,7 @@ int read_message(CtdlIPC *ipc, || (!strcasecmp(ptr->disposition, "")) ) { if ( (strcasecmp(ptr->number, message->mime_chosen)) - && (strlen(ptr->mimetype) > 0) + && (!IsEmptyStr(ptr->mimetype)) ) { color(DIM_WHITE); pprintf("Part "); @@ -760,7 +760,7 @@ void replace_string(char *filename, long int startpos) scr_printf("Enter text to be replaced:\n: "); ctdl_getline(srch_str, (sizeof(srch_str)-1) ); - if (strlen(srch_str) == 0) + if (IsEmptyStr(srch_str)) return; scr_printf("Enter text to replace it with:\n: "); @@ -794,7 +794,7 @@ void replace_string(char *filename, long int startpos) } } fseek(fp, wpos, 0); - if (strlen(buf) > 0) + if (!IsEmptyStr(buf)) fwrite((char *) buf, strlen(buf), 1, fp); wpos = ftell(fp); fclose(fp); @@ -824,9 +824,9 @@ int client_make_message(CtdlIPC *ipc, if (mode >= 2) { - if((mode-2) < MAX_EDITORS && strlen(editor_paths[mode-2]) > 0) { + if((mode-2) < MAX_EDITORS && !IsEmptyStr(editor_paths[mode-2])) { editor_path = editor_paths[mode-2]; - } else if (strlen(editor_paths[0]) > 0) { + } else if (!IsEmptyStr(editor_paths[0])) { editor_path = editor_paths[0]; } else { err_printf("*** No editor available, " @@ -847,18 +847,18 @@ int client_make_message(CtdlIPC *ipc, datestr, (is_anonymous ? "[anonymous]" : fullname) ); - if (strlen(recipient) > 0) { + if (!IsEmptyStr(recipient)) { size_t tmp = strlen(header); snprintf(&header[tmp], sizeof header - tmp, " to %s", recipient); } } scr_printf("%s\n", header); - if (subject != NULL) if (strlen(subject) > 0) { + if (subject != NULL) if (!IsEmptyStr(subject)) { scr_printf("Subject: %s\n", subject); } - if ( (subject_required) && (strlen(subject) == 0) ) { + if ( (subject_required) && (IsEmptyStr(subject)) ) { newprompt("Subject: ", subject, 70); } @@ -973,11 +973,11 @@ MECR: if (mode >= 2) { if (b == 's') goto MEFIN; if (b == 'p') { scr_printf(" %s from %s", datestr, fullname); - if (strlen(recipient) > 0) { + if (!IsEmptyStr(recipient)) { scr_printf(" to %s", recipient); } scr_printf("\n"); - if (subject != NULL) if (strlen(subject) > 0) { + if (subject != NULL) if (!IsEmptyStr(subject)) { scr_printf("Subject: %s\n", subject); } fp = fopen(filename, "r"); @@ -1182,7 +1182,7 @@ int entmsg(CtdlIPC *ipc, } else { scr_printf("Enter recipient: "); ctdl_getline(buf, (SIZ-100) ); - if (strlen(buf) == 0) + if (IsEmptyStr(buf)) return (1); } } else @@ -1191,7 +1191,7 @@ int entmsg(CtdlIPC *ipc, strcpy(message.recipient, buf); if (is_reply) { - if (strlen(reply_subject) > 0) { + if (!IsEmptyStr(reply_subject)) { if (!strncasecmp(reply_subject, "Re: ", 3)) { strcpy(message.subject, reply_subject); @@ -1212,7 +1212,7 @@ int entmsg(CtdlIPC *ipc, } /* If it's mail, we've got to check the validity of the recipient... */ - if (strlen(message.recipient) > 0) { + if (!IsEmptyStr(message.recipient)) { r = CtdlIPCPostMessage(ipc, 0, &subject_required, &message, buf); if (r / 100 != 2) { scr_printf("%s\n", buf); @@ -1647,7 +1647,7 @@ RMSGREAD: scr_flush(); keyopt("ack gain uote eply ext top "); if (rc_url_cmd[0] && num_urls) keyopt("RLview "); - if (has_images > 0 && strlen(imagecmd) > 0) + if (has_images > 0 && !IsEmptyStr(imagecmd)) keyopt("mages "); keyopt("help -> "); @@ -1668,7 +1668,7 @@ RMSGREAD: scr_flush(); e = 0; } /* print only if available */ - if ((e == 'p') && (strlen(printcmd) == 0)) + if ((e == 'p') && (IsEmptyStr(printcmd))) e = 0; /* can't file if not allowed */ if ((e == 'f') @@ -1676,10 +1676,10 @@ RMSGREAD: scr_flush(); e = 0; /* link only if browser avail*/ if ((e == 'u') - && (strlen(rc_url_cmd) == 0)) + && (IsEmptyStr(rc_url_cmd))) e = 0; if ((e == 'i') - && (!strlen(imagecmd) || !has_images)) + && (IsEmptyStr(imagecmd) || !has_images)) e = 0; } while ((e != 'a') && (e != 'n') && (e != 's') && (e != 'd') && (e != 'm') && (e != 'p') @@ -1759,7 +1759,7 @@ RMSGREAD: scr_flush(); " M Move message to another room\n"); } scr_printf(" C Copy message to another room\n"); - if (strlen(printcmd) > 0) + if (!IsEmptyStr(printcmd)) scr_printf(" P Print this message\n"); scr_printf( " Q Quote portions of this message for your next post\n" @@ -1769,9 +1769,9 @@ RMSGREAD: scr_flush(); if (rc_allow_attachments) scr_printf (" F (save attachments to a file)\n"); - if (strlen(rc_url_cmd) > 0) + if (!IsEmptyStr(rc_url_cmd)) scr_printf(" U (list URL's for display)\n"); - if (strlen(imagecmd) > 0 && has_images > 0) + if (!IsEmptyStr(imagecmd) && has_images > 0) scr_printf(" I Image viewer\n"); scr_printf("\n"); goto RMSGREAD; @@ -1800,7 +1800,7 @@ RMSGREAD: scr_flush(); case 'c': newprompt("Enter target room: ", targ, ROOMNAMELEN - 1); - if (strlen(targ) > 0) { + if (!IsEmptyStr(targ)) { r = CtdlIPCMoveMessage(ipc, (e == 'c' ? 1 : 0), msg_arr[a], targ, cmd); scr_printf("%s\n", cmd); @@ -1825,7 +1825,7 @@ RMSGREAD: scr_flush(); * Part 1 won't have a filename; use the * subject of the message instead. IO */ - if (!strlen(filename)) + if (IsEmptyStr(filename)) strcpy(filename, reply_subject); destination_directory(save_to, filename); save_buffer(attachment, @@ -1935,7 +1935,7 @@ void check_message_base(CtdlIPC *ipc) return; } - while (transcript && strlen(transcript)) { + while (transcript && !IsEmptyStr(transcript)) { lines_printed = 1; extract_token(buf, transcript, 0, '\n', sizeof buf); remove_token(transcript, 0, '\n'); diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 34e11c15c..961e9acb8 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -528,7 +528,7 @@ int CtdlForEachMessage(int mode, long ref, char *search_string, int need_to_free_re = 0; regmatch_t pm; - if (content_type) if (strlen(content_type) > 0) { + if (content_type) if (!IsEmptyStr(content_type)) { regcomp(&re, content_type, 0); need_to_free_re = 1; } @@ -558,7 +558,7 @@ int CtdlForEachMessage(int mode, long ref, char *search_string, /* If the caller is looking for a specific MIME type, filter * out all messages which are not of the type requested. */ - if (content_type != NULL) if (strlen(content_type) > 0) { + if (content_type != NULL) if (!IsEmptyStr(content_type)) { /* This call to GetMetaData() sits inside this loop * so that we only do the extra database read per msg @@ -1207,7 +1207,7 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp, ma->did_print = 1; if ( (!strcasecmp(cbtype, "text/plain")) - || (strlen(cbtype)==0) ) { + || (IsEmptyStr(cbtype)) ) { wptr = content; if (length > 0) { client_write(wptr, length); @@ -1308,12 +1308,12 @@ void output_preferred(char *name, char *filename, char *partnum, char *disp, ++add_newline; } cprintf("Content-type: %s", cbtype); - if (strlen(cbcharset) > 0) { + if (!IsEmptyStr(cbcharset)) { cprintf("; charset=%s", cbcharset); } cprintf("\nContent-length: %d\n", (int)(length + add_newline) ); - if (strlen(encoding) > 0) { + if (!IsEmptyStr(encoding)) { cprintf("Content-transfer-encoding: %s\n", encoding); } else { @@ -1414,7 +1414,7 @@ int CtdlOutputMsg(long msg_num, /* message number (local) to fetch */ /* Here is the weird form of this command, to process only an * encapsulated message/rfc822 section. */ - if (section) if (strlen(section)>0) if (strcmp(section, "0")) { + if (section) if (!IsEmptyStr(section)) if (strcmp(section, "0")) { memset(&encap, 0, sizeof encap); safestrncpy(encap.desired_section, section, sizeof encap.desired_section); mime_parser(TheMessage->cm_fields['M'], @@ -1605,7 +1605,7 @@ int CtdlOutputPreLoadedMsg( */ suppress_f = 0; if (TheMessage->cm_fields['N'] != NULL) - if (strlen(TheMessage->cm_fields['N']) > 0) + if (!IsEmptyStr(TheMessage->cm_fields['N'])) if (haschar(TheMessage->cm_fields['N'], '.') == 0) { suppress_f = 1; } @@ -1820,7 +1820,7 @@ START_TEXT: buf[strlen(buf)] = ch; } } - if (strlen(buf) > 0) + if (!IsEmptyStr(buf)) cprintf("%s%s", buf, nl); } @@ -2325,7 +2325,7 @@ void ReplicationChecks(struct CtdlMessage *msg) { /* No exclusive id? Don't do anything. */ if (msg == NULL) return; if (msg->cm_fields['E'] == NULL) return; - if (strlen(msg->cm_fields['E']) == 0) return; + if (IsEmptyStr(msg->cm_fields['E'])) return; /*lprintf(CTDL_DEBUG, "Exclusive ID: <%s> for room <%s>\n", msg->cm_fields['E'], CC->room.QRname);*/ @@ -2451,7 +2451,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ } /* ...or if this message is destined for Aide> then go there. */ - if (strlen(force_room) > 0) { + if (!IsEmptyStr(force_room)) { strcpy(actual_rm, force_room); } @@ -2574,7 +2574,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ MailboxName(actual_rm, sizeof actual_rm, &userbuf, MAILROOM); CtdlSaveMsgPointerInRoom(actual_rm, newmsgid, 0, msg); BumpNewMailCounter(userbuf.usernum); - if (strlen(config.c_funambol_host) > 0) { + if (!IsEmptyStr(config.c_funambol_host)) { /* Generate a instruction message for the Funambol notification * server, in the same style as the SMTP queue */ @@ -2942,7 +2942,7 @@ struct CtdlMessage *CtdlMakeMessage( /* Path or Return-Path */ if (my_email == NULL) my_email = ""; - if (strlen(my_email) > 0) { + if (!IsEmptyStr(my_email)) { msg->cm_fields['P'] = strdup(my_email); } else { @@ -2983,10 +2983,10 @@ struct CtdlMessage *CtdlMakeMessage( msg->cm_fields['D'] = strdup(dest_node); } - if (strlen(my_email) > 0) { + if (!IsEmptyStr(my_email)) { msg->cm_fields['F'] = strdup(my_email); } - else if ( (author == &CC->user) && (strlen(CC->cs_inet_email) > 0) ) { + else if ( (author == &CC->user) && (!IsEmptyStr(CC->cs_inet_email)) ) { msg->cm_fields['F'] = strdup(CC->cs_inet_email); } @@ -3148,7 +3148,7 @@ struct recptypes *validate_recipients(char *supplied_recipients) { /* Now start extracting recipients... */ - while (strlen(recipients) > 0) { + while (!IsEmptyStr(recipients)) { for (i=0; i<=strlen(recipients); ++i) { if (recipients[i] == '\"') in_quotes = 1 - in_quotes; @@ -3185,7 +3185,7 @@ struct recptypes *validate_recipients(char *supplied_recipients) { if (!strcasecmp(this_recp, "sysop")) { ++ret->num_room; strcpy(this_recp, config.c_aideroom); - if (strlen(ret->recp_room) > 0) { + if (!IsEmptyStr(ret->recp_room)) { strcat(ret->recp_room, "|"); } strcat(ret->recp_room, this_recp); @@ -3193,7 +3193,7 @@ struct recptypes *validate_recipients(char *supplied_recipients) { else if (getuser(&tempUS, this_recp) == 0) { ++ret->num_local; strcpy(this_recp, tempUS.fullname); - if (strlen(ret->recp_local) > 0) { + if (!IsEmptyStr(ret->recp_local)) { strcat(ret->recp_local, "|"); } strcat(ret->recp_local, this_recp); @@ -3201,7 +3201,7 @@ struct recptypes *validate_recipients(char *supplied_recipients) { else if (getuser(&tempUS, this_recp_cooked) == 0) { ++ret->num_local; strcpy(this_recp, tempUS.fullname); - if (strlen(ret->recp_local) > 0) { + if (!IsEmptyStr(ret->recp_local)) { strcat(ret->recp_local, "|"); } strcat(ret->recp_local, this_recp); @@ -3209,7 +3209,7 @@ struct recptypes *validate_recipients(char *supplied_recipients) { else if ( (!strncasecmp(this_recp, "room_", 5)) && (!getroom(&tempQR, &this_recp_cooked[5])) ) { ++ret->num_room; - if (strlen(ret->recp_room) > 0) { + if (!IsEmptyStr(ret->recp_room)) { strcat(ret->recp_room, "|"); } strcat(ret->recp_room, &this_recp_cooked[5]); @@ -3232,7 +3232,7 @@ struct recptypes *validate_recipients(char *supplied_recipients) { } else { ++ret->num_internet; - if (strlen(ret->recp_internet) > 0) { + if (!IsEmptyStr(ret->recp_internet)) { strcat(ret->recp_internet, "|"); } strcat(ret->recp_internet, this_recp); @@ -3240,7 +3240,7 @@ struct recptypes *validate_recipients(char *supplied_recipients) { break; case MES_IGNET: ++ret->num_ignet; - if (strlen(ret->recp_ignet) > 0) { + if (!IsEmptyStr(ret->recp_ignet)) { strcat(ret->recp_ignet, "|"); } strcat(ret->recp_ignet, this_recp); @@ -3251,7 +3251,7 @@ struct recptypes *validate_recipients(char *supplied_recipients) { break; } if (invalid) { - if (strlen(ret->errormsg) == 0) { + if (IsEmptyStr(ret->errormsg)) { snprintf(append, sizeof append, "Invalid recipient: %s", this_recp); @@ -3264,7 +3264,7 @@ struct recptypes *validate_recipients(char *supplied_recipients) { } } else { - if (strlen(ret->display_recp) == 0) { + if (IsEmptyStr(ret->display_recp)) { strcpy(append, this_recp); } else { @@ -3382,7 +3382,7 @@ void cmd_ent0(char *entargs) /* Check some other permission type things. */ - if (strlen(newusername) == 0) { + if (IsEmptyStr(newusername)) { strcpy(newusername, CC->user.fullname); } if ( (CC->user.axlevel < 6) @@ -3397,15 +3397,15 @@ void cmd_ent0(char *entargs) } - if (strlen(newuseremail) == 0) { + if (IsEmptyStr(newuseremail)) { newuseremail_ok = 1; } - if (strlen(newuseremail) > 0) { + if (!IsEmptyStr(newuseremail)) { if (!strcasecmp(newuseremail, CC->cs_inet_email)) { newuseremail_ok = 1; } - else if (strlen(CC->cs_inet_other_emails) > 0) { + else if (!IsEmptyStr(CC->cs_inet_other_emails)) { j = num_tokens(CC->cs_inet_other_emails, '|'); for (i=0; ics_inet_other_emails, i, '|', sizeof buf); @@ -3562,7 +3562,7 @@ void cmd_ent0(char *entargs) msg = CtdlMakeMessage(&CC->user, recp, cc, CC->room.QRname, anonymous, format_type, newusername, newuseremail, subject, - ((strlen(supplied_euid) > 0) ? supplied_euid : NULL), + ((!IsEmptyStr(supplied_euid)) ? supplied_euid : NULL), NULL); /* Put together one big recipients struct containing to/cc/bcc all in @@ -3570,19 +3570,19 @@ void cmd_ent0(char *entargs) */ char *all_recps = malloc(SIZ * 3); strcpy(all_recps, recp); - if (strlen(cc) > 0) { - if (strlen(all_recps) > 0) { + if (!IsEmptyStr(cc)) { + if (!IsEmptyStr(all_recps)) { strcat(all_recps, ","); } strcat(all_recps, cc); } - if (strlen(bcc) > 0) { - if (strlen(all_recps) > 0) { + if (!IsEmptyStr(bcc)) { + if (!IsEmptyStr(all_recps)) { strcat(all_recps, ","); } strcat(all_recps, bcc); } - if (strlen(all_recps) > 0) { + if (!IsEmptyStr(all_recps)) { valid = validate_recipients(all_recps); } else { @@ -3642,7 +3642,7 @@ int CtdlDeleteMessages(char *room_name, /* which room */ regmatch_t pm; int need_to_free_re = 0; - if (content_type) if (strlen(content_type) > 0) { + if (content_type) if (!IsEmptyStr(content_type)) { regcomp(&re, content_type, 0); need_to_free_re = 1; } @@ -3685,7 +3685,7 @@ int CtdlDeleteMessages(char *room_name, /* which room */ } } - if (strlen(content_type) == 0) { + if (IsEmptyStr(content_type)) { delete_this |= 0x02; } else { GetMetaData(&smi, msglist[i]); @@ -4270,7 +4270,7 @@ char *CtdlGetSysConfig(char *sysconfname) { if (conf != NULL) 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)) ); return(conf); } diff --git a/citadel/msgform.c b/citadel/msgform.c index 16df9aeb7..3c0a6d0fa 100644 --- a/citadel/msgform.c +++ b/citadel/msgform.c @@ -31,6 +31,7 @@ #endif #include +#include "tools.h" int qwk = 0; @@ -91,7 +92,7 @@ TOP: do { if (b == 'M') { if (qwk == 0) { printf("\n"); - if (strlen(subject) != 0) + if (!IsEmptyStr(subject)) printf("Subject: %s\n", subject); } if (aflag != 1) diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 93e8b4486..340b99a38 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -588,7 +588,7 @@ void cmd_lrms_backend(struct ctdlroom *qrbuf, void *data) void cmd_lrms(char *argbuf) { int FloorBeingSearched = (-1); - if (strlen(argbuf) > 0) + if (!IsEmptyStr(argbuf)) FloorBeingSearched = extract_int(argbuf, 0); if (CtdlAccessCheck(ac_logged_in)) return; @@ -626,7 +626,7 @@ void cmd_lkra_backend(struct ctdlroom *qrbuf, void *data) void cmd_lkra(char *argbuf) { int FloorBeingSearched = (-1); - if (strlen(argbuf) > 0) + if (!IsEmptyStr(argbuf)) FloorBeingSearched = extract_int(argbuf, 0); if (CtdlAccessCheck(ac_logged_in)) return; @@ -662,7 +662,7 @@ void cmd_lprm_backend(struct ctdlroom *qrbuf, void *data) void cmd_lprm(char *argbuf) { int FloorBeingSearched = (-1); - if (strlen(argbuf) > 0) + if (!IsEmptyStr(argbuf)) FloorBeingSearched = extract_int(argbuf, 0); cprintf("%d Publiic rooms:\n", LISTING_FOLLOWS); @@ -695,7 +695,7 @@ void cmd_lkrn_backend(struct ctdlroom *qrbuf, void *data) void cmd_lkrn(char *argbuf) { int FloorBeingSearched = (-1); - if (strlen(argbuf) > 0) + if (!IsEmptyStr(argbuf)) FloorBeingSearched = extract_int(argbuf, 0); if (CtdlAccessCheck(ac_logged_in)) return; @@ -734,7 +734,7 @@ void cmd_lkro_backend(struct ctdlroom *qrbuf, void *data) void cmd_lkro(char *argbuf) { int FloorBeingSearched = (-1); - if (strlen(argbuf) > 0) + if (!IsEmptyStr(argbuf)) FloorBeingSearched = extract_int(argbuf, 0); if (CtdlAccessCheck(ac_logged_in)) return; @@ -773,7 +773,7 @@ void cmd_lzrm_backend(struct ctdlroom *qrbuf, void *data) void cmd_lzrm(char *argbuf) { int FloorBeingSearched = (-1); - if (strlen(argbuf) > 0) + if (!IsEmptyStr(argbuf)) FloorBeingSearched = extract_int(argbuf, 0); if (CtdlAccessCheck(ac_logged_in)) return; @@ -1158,7 +1158,7 @@ void cmd_rdir(void) safestrncpy(comment, "", sizeof comment); fseek(fd, 0L, 0); while ((fgets(buf, sizeof buf, fd) != NULL) - && (strlen(comment) == 0)) { + && (IsEmptyStr(comment))) { buf[strlen(buf) - 1] = 0; if ((!strncasecmp(buf, flnm, strlen(flnm))) && (buf[strlen(flnm)] == ' ')) @@ -1520,7 +1520,7 @@ void cmd_seta(char *new_ra) * the room table, otherwise it would deadlock! */ if (post_notice == 1) { - if (strlen(usbuf.fullname) > 0) + if (!IsEmptyStr(usbuf.fullname)) snprintf(buf, sizeof buf, "%s is now the room aide for \"%s\".\n", usbuf.fullname, CC->room.QRname); @@ -1551,7 +1551,7 @@ void cmd_rinf(void) } cprintf("%d Info:\n", LISTING_FOLLOWS); while (fgets(buf, sizeof buf, info_fp) != NULL) { - if (strlen(buf) > 0) + if (!IsEmptyStr(buf)) buf[strlen(buf) - 1] = 0; cprintf("%s\n", buf); } @@ -1841,7 +1841,7 @@ void cmd_cre8(char *args) new_room_pass[9] = 0; new_room_floor = 0; - if ((strlen(new_room_name) == 0) && (cre8_ok == 1)) { + if ((IsEmptyStr(new_room_name)) && (cre8_ok == 1)) { cprintf("%d Invalid room name.\n", ERROR + ILLEGAL_VALUE); return; } @@ -1876,7 +1876,7 @@ void cmd_cre8(char *args) return; } - if ((strlen(new_room_name) == 0) && (cre8_ok == 0)) { + if ((IsEmptyStr(new_room_name)) && (cre8_ok == 0)) { cprintf("%d Ok to create rooms.\n", CIT_OK); return; } @@ -2016,7 +2016,7 @@ void cmd_cflr(char *argbuf) if (CtdlAccessCheck(ac_aide)) return; - if (strlen(new_floor_name) == 0) { + if (IsEmptyStr(new_floor_name)) { cprintf("%d Blank floor name not allowed.\n", ERROR + ILLEGAL_VALUE); return; diff --git a/citadel/rooms.c b/citadel/rooms.c index 22672009f..1226455c3 100644 --- a/citadel/rooms.c +++ b/citadel/rooms.c @@ -79,7 +79,7 @@ void load_floorlist(CtdlIPC *ipc) strcpy(floorlist[0], "Main Floor"); return; } - while (*listing && strlen(listing)) { + while (*listing && !IsEmptyStr(listing)) { extract_token(buf, listing, 0, '\n', sizeof buf); remove_token(listing, 0, '\n'); extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', SIZ); @@ -518,7 +518,7 @@ void editthisroom(CtdlIPC *ipc) } else { strcpy(raide, ""); } - if (strlen(raide) == 0) { + if (IsEmptyStr(raide)) { strcpy(raide, "none"); } @@ -701,7 +701,7 @@ void dotungoto(CtdlIPC *ipc, char *towhere) scr_printf("Must specify a room to ungoto.\n"); return; } - if (strlen(towhere) == 0) + if (IsEmptyStr(towhere)) { scr_printf("Must specify a room to ungoto.\n"); return; @@ -801,7 +801,7 @@ void destination_directory(char *dest, const char *supplied_filename) { static char save_dir[SIZ] = { 0 }; - if (strlen(save_dir) == 0) { + if (IsEmptyStr(save_dir)) { if (getenv("HOME") == NULL) { strcpy(save_dir, "."); } @@ -936,7 +936,7 @@ void roomdir(CtdlIPC *ipc) extract_token(flnm, buf, 1, '|', sizeof flnm); pprintf("\nDirectory of %s on %s\n", flnm, comment); pprintf("-----------------------\n"); - while (listing && *listing && strlen(listing)) { + while (listing && *listing && !IsEmptyStr(listing)) { extract_token(buf, listing, 0, '\n', sizeof buf); remove_token(listing, 0, '\n'); @@ -1054,7 +1054,7 @@ void entroom(CtdlIPC *ipc) } newprompt("Name for new room? ", new_room_name, ROOMNAMELEN - 1); - if (strlen(new_room_name) == 0) { + if (IsEmptyStr(new_room_name)) { return; } for (a = 0; a < strlen(new_room_name); ++a) { @@ -1134,7 +1134,7 @@ void readinfo(CtdlIPC *ipc) else strcpy(raide, ""); - if (strlen(raide) > 0) + if (!IsEmptyStr(raide)) scr_printf("Room aide is %s.\n\n", raide); r = CtdlIPCRoomInfo(ipc, &text, buf); @@ -1164,7 +1164,7 @@ void whoknows(CtdlIPC *ipc) pprintf("%s\n", buf); return; } - while (strlen(listing) > 0) { + while (!IsEmptyStr(listing)) { extract_token(buf, listing, 0, '\n', sizeof buf); remove_token(listing, 0, '\n'); if (sigcaught == 0) @@ -1181,7 +1181,7 @@ void do_edit(CtdlIPC *ipc, char cmd[SIZ]; int b, cksum, editor_exit; - if (strlen(editor_paths[0]) == 0) { + if (IsEmptyStr(editor_paths[0])) { scr_printf("Do you wish to re-enter %s? ", desc); if (yesno() == 0) return; @@ -1197,7 +1197,7 @@ void do_edit(CtdlIPC *ipc, return; } - if (strlen(editor_paths[0]) > 0) { + if (!IsEmptyStr(editor_paths[0])) { CtdlIPC_chat_send(ipc, read_cmd); CtdlIPC_chat_recv(ipc, cmd); if (cmd[0] == '1') { @@ -1211,7 +1211,7 @@ void do_edit(CtdlIPC *ipc, cksum = file_checksum(temp); - if (strlen(editor_paths[0]) > 0) { + if (!IsEmptyStr(editor_paths[0])) { char tmp[SIZ]; snprintf(tmp, sizeof tmp, "WINDOW_TITLE=%s", desc); @@ -1380,7 +1380,7 @@ void kill_floor(CtdlIPC *ipc) floornum_to_delete = (-1); scr_printf("(Press return to abort)\n"); newprompt("Delete which floor? ", buf, 255); - if (strlen(buf) == 0) + if (IsEmptyStr(buf)) return; for (a = 0; a < 128; ++a) if (!strcasecmp(&floorlist[a][0], buf)) diff --git a/citadel/routines.c b/citadel/routines.c index a023dafe8..cf627a529 100644 --- a/citadel/routines.c +++ b/citadel/routines.c @@ -285,7 +285,7 @@ void enter_config(CtdlIPC *ipc, int mode) "Be unlisted in userlog", US_UNLISTED, 0); - if (strlen(editor_paths[0]) > 0) { + if (!IsEmptyStr(editor_paths[0])) { user->flags = set_attr(ipc, user->flags, "Always enter messages with the full-screen editor", US_EXTEDIT, 0); @@ -359,7 +359,7 @@ void strproc(char *string) { int a; - if (strlen(string)==0) return; + if (IsEmptyStr(string)) return; /* Convert non-printable characters to blanks */ for (a=0; aServInfo.fqdn); + if (IsEmptyStr(buf)) strcpy(hbuf, ipc->ServInfo.fqdn); else strncpy(hbuf,buf,24); #else char *tty = ttyname(0); diff --git a/citadel/routines2.c b/citadel/routines2.c index 7be0e5b37..fca08555d 100644 --- a/citadel/routines2.c +++ b/citadel/routines2.c @@ -118,7 +118,7 @@ void entregis(CtdlIPC *ipc) if (r / 100 == 1) { int a = 0; - while (reg && strlen(reg) > 0) { + while (reg && !IsEmptyStr(reg)) { extract_token(buf, reg, 0, '\n', sizeof buf); remove_token(reg, 0, '\n'); @@ -450,7 +450,7 @@ int val_user(CtdlIPC *ipc, char *user, int do_validate) scr_printf("%s\n", buf); if (a == 11) scr_printf("%s\n", buf); - } while (strlen(resp)); + } while (!IsEmptyStr(resp)); scr_printf("Current access level: %d (%s)\n", ax, axdefs[ax]); } else { scr_printf("%s\n%s\n", user, &cmd[4]); @@ -537,7 +537,7 @@ void deletefile(CtdlIPC *ipc) char buf[256]; newprompt("Filename: ", filename, 31); - if (strlen(filename) == 0) + if (IsEmptyStr(filename)) return; CtdlIPCDeleteFile(ipc, filename, buf); err_printf("%s\n", buf); @@ -551,7 +551,7 @@ void netsendfile(CtdlIPC *ipc) char filename[32], destsys[20], buf[256]; newprompt("Filename: ", filename, 31); - if (strlen(filename) == 0) + if (IsEmptyStr(filename)) return; newprompt("System to send to: ", destsys, 19); CtdlIPCNetSendFile(ipc, filename, destsys, buf); @@ -569,7 +569,7 @@ void movefile(CtdlIPC *ipc) char buf[256]; newprompt("Filename: ", filename, 63); - if (strlen(filename) == 0) + if (IsEmptyStr(filename)) return; newprompt("Enter target room: ", newroom, ROOMNAMELEN - 1); CtdlIPCMoveFile(ipc, filename, newroom, buf); @@ -629,7 +629,7 @@ void read_bio(CtdlIPC *ipc) pprintf("%s\n", buf); return; } - while (strlen(resp)) { + while (!IsEmptyStr(resp)) { extract_token(buf, resp, 0, '\n', sizeof buf); remove_token(resp, 0, '\n'); pprintf("%s\n", buf); @@ -713,7 +713,7 @@ void do_system_configuration(CtdlIPC *ipc) "Allow Aides to Zap (forget) rooms", atoi(&sc[26][0])))); - if (strlen(&sc[18][0]) > 0) logpages = 1; + if (!IsEmptyStr(&sc[18][0])) logpages = 1; else logpages = 0; logpages = boolprompt("Log all pages", logpages); if (logpages) { @@ -958,7 +958,7 @@ void do_internet_configuration(CtdlIPC *ipc) r = CtdlIPCGetSystemConfigByType(ipc, INTERNETCFG, &resp, buf); if (r / 100 == 1) { - while (strlen(resp)) { + while (!IsEmptyStr(resp)) { extract_token(buf, resp, 0, '\n', sizeof buf); remove_token(resp, 0, '\n'); ++num_recs; @@ -994,7 +994,7 @@ void do_internet_configuration(CtdlIPC *ipc) newprompt("Enter host name: ", buf, 50); striplt(buf); - if (strlen(buf) > 0) { + if (!IsEmptyStr(buf)) { ++num_recs; if (num_recs == 1) recs = malloc(sizeof(char *)); @@ -1074,7 +1074,7 @@ void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment) char *listing = NULL; int r; - if (strlen(editor_paths[0]) == 0) { + if (IsEmptyStr(editor_paths[0])) { scr_printf("You must have an external editor configured in" " order to use this function.\n"); return; @@ -1096,7 +1096,7 @@ void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment) r = CtdlIPCGetRoomNetworkConfig(ipc, &listing, buf); if (r / 100 == 1) { - while(listing && strlen(listing)) { + while(listing && !IsEmptyStr(listing)) { extract_token(buf, listing, 0, '\n', sizeof buf); remove_token(listing, 0, '\n'); extract_token(instr, buf, 0, '|', sizeof instr); @@ -1151,7 +1151,7 @@ void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment) /* Load all netconfig entries that are *not* of the type we are editing */ r = CtdlIPCGetRoomNetworkConfig(ipc, &listing, buf); if (r / 100 == 1) { - while(listing && strlen(listing)) { + while(listing && !IsEmptyStr(listing)) { extract_token(buf, listing, 0, '\n', sizeof buf); remove_token(listing, 0, '\n'); extract_token(instr, buf, 0, '|', sizeof instr); @@ -1172,7 +1172,7 @@ void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment) if (buf[i] == '#') buf[i] = 0; } striplt(buf); - if (strlen(buf) > 0) { + if (!IsEmptyStr(buf)) { fprintf(changefp, "%s|%s\n", entrytype, buf); } } @@ -1213,7 +1213,7 @@ void do_ignet_configuration(CtdlIPC *ipc) { int r; r = CtdlIPCGetSystemConfigByType(ipc, IGNETCFG, &listing, buf); - if (r / 100 == 1) while (*listing && strlen(listing)) { + if (r / 100 == 1) while (*listing && !IsEmptyStr(listing)) { extract_token(buf, listing, 0, '\n', sizeof buf); remove_token(listing, 0, '\n'); @@ -1342,7 +1342,7 @@ void do_filterlist_configuration(CtdlIPC *ipc) int r; r = CtdlIPCGetSystemConfigByType(ipc, FILTERLIST, &listing, buf); - if (r / 100 == 1) while (*listing && strlen(listing)) { + if (r / 100 == 1) while (*listing && !IsEmptyStr(listing)) { extract_token(buf, listing, 0, '\n', sizeof buf); remove_token(listing, 0, '\n'); diff --git a/citadel/sendcommand.c b/citadel/sendcommand.c index cc47df4af..4c23a6d35 100644 --- a/citadel/sendcommand.c +++ b/citadel/sendcommand.c @@ -167,7 +167,7 @@ int main(int argc, char **argv) home_specified = 1; home=1; } else { - if (strlen(cmd) > 0) + if (!IsEmptyStr(cmd)) strcat(cmd, " "); strcat(cmd, argv[a]); } @@ -206,10 +206,10 @@ int main(int argc, char **argv) do { if (fgets(buf, sizeof buf, stdin) == NULL) strcpy(buf, "000"); - if (strlen(buf) > 0) + if (!IsEmptyStr(buf)) if (buf[strlen(buf) - 1] == '\n') buf[strlen(buf) - 1] = 0; - if (strlen(buf) > 0) + if (!IsEmptyStr(buf)) if (buf[strlen(buf) - 1] == '\r') buf[strlen(buf) - 1] = 0; if (strcmp(buf, "000")) diff --git a/citadel/setup.c b/citadel/setup.c index 2415e5c4b..1e741f002 100644 --- a/citadel/setup.c +++ b/citadel/setup.c @@ -641,7 +641,7 @@ void strprompt(char *prompt_title, char *prompt_text, char *str) printf("Enter new value or press return to leave unchanged:\n"); fgets(buf, sizeof buf, stdin); buf[strlen(buf) - 1] = 0; - if (strlen(buf) != 0) + if (!IsEmptyStr(buf)) strcpy(str, buf); break; @@ -1079,11 +1079,11 @@ int main(int argc, char *argv[]) fclose(fp); /* set some sample/default values in place of blanks... */ - if (strlen(config.c_nodename) == 0) + if (IsEmptyStr(config.c_nodename)) safestrncpy(config.c_nodename, my_utsname.nodename, sizeof config.c_nodename); strtok(config.c_nodename, "."); - if (strlen(config.c_fqdn) == 0) { + if (IsEmptyStr(config.c_fqdn) ) { if ((he = gethostbyname(my_utsname.nodename)) != NULL) safestrncpy(config.c_fqdn, he->h_name, sizeof config.c_fqdn); @@ -1091,20 +1091,20 @@ int main(int argc, char *argv[]) safestrncpy(config.c_fqdn, my_utsname.nodename, sizeof config.c_fqdn); } - if (strlen(config.c_humannode) == 0) + if (IsEmptyStr(config.c_humannode)) strcpy(config.c_humannode, "My System"); - if (strlen(config.c_phonenum) == 0) + if (IsEmptyStr(config.c_phonenum)) strcpy(config.c_phonenum, "US 800 555 1212"); if (config.c_initax == 0) { config.c_initax = 4; } - if (strlen(config.c_moreprompt) == 0) + if (IsEmptyStr(config.c_moreprompt)) strcpy(config.c_moreprompt, ""); - if (strlen(config.c_twitroom) == 0) + if (IsEmptyStr(config.c_twitroom)) strcpy(config.c_twitroom, "Trashcan"); - if (strlen(config.c_baseroom) == 0) + if (IsEmptyStr(config.c_baseroom)) strcpy(config.c_baseroom, BASEROOM); - if (strlen(config.c_aideroom) == 0) + if (IsEmptyStr(config.c_aideroom)) strcpy(config.c_aideroom, "Aide"); if (config.c_port_number == 0) { config.c_port_number = 504; diff --git a/citadel/support.c b/citadel/support.c index be48c6fed..b88ee9913 100644 --- a/citadel/support.c +++ b/citadel/support.c @@ -16,7 +16,7 @@ #include "citadel.h" #include "server.h" #include "support.h" - +#include "tools.h" /* * strproc() - make a string 'nice' @@ -26,7 +26,7 @@ void strproc(char *string) int a; if (string == NULL) return; - if (strlen(string)==0) return; + if (IsEmptyStr(string)) return; /* Convert non-printable characters to blanks */ for (a=0; a0) ) + while( (string[0]<33) && (!IsEmptyStr(string)) ) strcpy(string,&string[1]); - while( (string[strlen(string)-1]<33) && (strlen(string)>0) ) + while( (string[strlen(string)-1]<33) && (!IsEmptyStr(string)) ) string[strlen(string)-1]=0; /* Remove double blanks */ diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 1ce836558..1413675ea 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -704,7 +704,7 @@ int client_getln(char *buf, int bufsize) /* Strip the trailing LF, and the trailing CR if present. */ buf[i] = 0; - while ( (strlen(buf) > 0) && ((buf[strlen(buf)-1]==10) || (buf[strlen(buf)-1] == 13)) ) { + while ( (!IsEmptyStr(buf)) && ((buf[strlen(buf)-1]==10) || (buf[strlen(buf)-1] == 13)) ) { buf[strlen(buf)-1] = 0; } if (retval < 0) safestrncpy(buf, "000", bufsize); diff --git a/citadel/tools.c b/citadel/tools.c index 5f225ccbd..af91ce78f 100644 --- a/citadel/tools.c +++ b/citadel/tools.c @@ -377,11 +377,11 @@ char *rfc2047encode(char *line, long length) */ void striplt(char *buf) { - if (strlen(buf) == 0) return; - while ((strlen(buf) > 0) && (isspace(buf[0]))) + if (IsEmptyStr(buf)) return; + while ((!IsEmptyStr(buf)) && (isspace(buf[0]))) strcpy(buf, &buf[1]); - if (strlen(buf) == 0) return; - while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1]))) + if (IsEmptyStr(buf)) return; + while ((!IsEmptyStr(buf)) && (isspace(buf[strlen(buf) - 1]))) buf[strlen(buf) - 1] = 0; } diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 02639007f..b23a4426e 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -372,7 +372,7 @@ int CtdlLoginExistingUser(char *authname, char *trythisname) safestrncpy(username, trythisname, USERNAME_SIZE); striplt(username); - if (strlen(username) == 0) { + if (IsEmptyStr(username)) { return login_not_found; } @@ -519,7 +519,7 @@ void session_startup(void) */ snprintf(CC->cs_inet_email, sizeof CC->cs_inet_email, "%s@%s", CC->user.fullname, config.c_fqdn); - for (i=0; ics_inet_email); ++i) { + for (i=0; !IsEmptyStr(&CC->cs_inet_email[i]); ++i) { if (isspace(CC->cs_inet_email[i])) { CC->cs_inet_email[i] = '_'; } @@ -585,7 +585,7 @@ void logout(struct CitContext *who) /* * If we were talking to a network node, we're not anymore... */ - if (strlen(who->net_node) > 0) { + if (!IsEmptyStr(who->net_node)) { network_talking_to(who->net_node, NTT_REMOVE); } @@ -996,7 +996,7 @@ void cmd_newu(char *cmdbuf) username[25] = 0; strproc(username); - if (strlen(username) == 0) { + if (IsEmptyStr(username)) { cprintf("%d You must supply a user name.\n", ERROR + USERNAME_REQUIRED); return; } @@ -1046,7 +1046,7 @@ void cmd_setp(char *new_pw) return; } strproc(new_pw); - if (strlen(new_pw) == 0) { + if (IsEmptyStr(new_pw)) { cprintf("%d Password unchanged.\n", CIT_OK); return; } @@ -1080,7 +1080,7 @@ void cmd_creu(char *cmdbuf) strproc(username); strproc(password); - if (strlen(username) == 0) { + if (IsEmptyStr(username)) { cprintf("%d You must supply a user name.\n", ERROR + USERNAME_REQUIRED); return; } @@ -1088,13 +1088,13 @@ void cmd_creu(char *cmdbuf) a = create_user(username, 0); if (a == 0) { - if (strlen(password) > 0) { + if (!IsEmptyStr(password)) { lgetuser(&tmp, username); safestrncpy(tmp.password, password, sizeof(tmp.password)); lputuser(&tmp); } cprintf("%d User '%s' created %s.\n", CIT_OK, username, - (strlen(password) > 0) ? "and password set" : + (!IsEmptyStr(password)) ? "and password set" : "with no password"); return; } else if (a == ERROR + ALREADY_EXISTS) { diff --git a/citadel/vcard.c b/citadel/vcard.c index 29c776959..a44117747 100644 --- a/citadel/vcard.c +++ b/citadel/vcard.c @@ -77,7 +77,7 @@ void remove_charset_attribute(char *strbuf) remove_token(strbuf, i, ';'); } } - if (strlen(strbuf) > 0) { + if (!IsEmptyStr(strbuf)) { if (strbuf[strlen(strbuf)-1] == ';') { strbuf[strlen(strbuf)-1] = 0; } @@ -124,7 +124,7 @@ struct vCard *vcard_load(char *vtext) { * To make it easier to parse, we convert CRLF to LF, and unfold any * multi-line fields into single lines. */ - for (i=0; i0) { + while (!IsEmptyStr(ptr)) { colonpos = (-1); nlpos = (-1); colonpos = pattern2(ptr, ":"); @@ -176,7 +176,7 @@ struct vCard *vcard_load(char *vtext) { } - while ( (*ptr != '\n') && (strlen(ptr)>0) ) { + while ( (*ptr != '\n') && (!IsEmptyStr(ptr)) ) { ++ptr; } if (*ptr == '\n') ++ptr; @@ -317,7 +317,7 @@ char *vcard_serialize(struct vCard *v) if (v->numprops) for (i=0; i<(v->numprops); ++i) { if ( (strcasecmp(v->prop[i].name, "end")) && (v->prop[i].value != NULL) ) { is_utf8 = 0; - for (j=0; jprop[i].value); ++j) { + for (j=0; !IsEmptyStr(&v->prop[i].value[j]); ++j) { if ( (v->prop[i].value[j] < 32) || (v->prop[i].value[j] > 126) ) { is_utf8 = 1; } diff --git a/citadel/whobbs.c b/citadel/whobbs.c index 323867103..2b86f96a9 100644 --- a/citadel/whobbs.c +++ b/citadel/whobbs.c @@ -23,22 +23,30 @@ void logoff(int code) static void escapize(char *buf, size_t n) { char hold[512]; - int i; + int i, len; + size_t tmp; strcpy(hold, buf); strcpy(buf, ""); - - for (i=0; i') + tmp += 4; + } + else if (hold[i]=='>'){ snprintf(&buf[tmp], n - tmp, ">"); - else if (hold[i]==34) + tmp += 4; + } + else if (hold[i]==34){ snprintf(&buf[tmp], n - tmp, """); - else + tmp += 6; + } + else{ snprintf(&buf[tmp], n - tmp, "%c", hold[i]); + tmp ++; + } } } @@ -135,7 +143,7 @@ int main(int argc, char **argv) } - while (strlen(listing) > 0) { + while (!IsEmptyStr(listing)) { extract_token(buf, listing, 0, '\n', sizeof buf); remove_token(listing, 0, '\n');