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');
}
}
- if (strlen(bbb) == 0) {
+ if (IsEmptyStr(bbb)) {
scr_printf("No room '%s'.\n", towhere);
return;
}
newmailcount);
}
color(DIM_WHITE);
- if (strlen(rc_gotmail_cmd) > 0) {
+ if (!IsEmptyStr(rc_gotmail_cmd)) {
system(rc_gotmail_cmd);
}
}
mptr = tmp;
}
}
- if (strlen(targ) > 0) {
+ if (!IsEmptyStr(targ)) {
gf_toroom(ipc, targ, mode);
return;
}
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]);
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);
char pass2[20];
char buf[SIZ];
- if (strlen(rc_password) > 0) {
+ if (!IsEmptyStr(rc_password)) {
strcpy(pass1, rc_password);
strcpy(pass2, rc_password);
} else {
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 */
(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");
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) {
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);
} while (
(!strcasecmp(fullname, "bbs"))
|| (!strcasecmp(fullname, "new"))
- || (strlen(fullname) == 0));
+ || (IsEmptyStr(fullname)));
if (!strcasecmp(fullname, "off")) {
mcmd = 29;
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);
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) {
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);
}
}
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);
}
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;
}
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 *)));
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;
}
/* 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);
}
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,
free(dirs[0]);
free(dirs[1]);
- if (strlen(targ)==0) {
+ if (IsEmptyStr(targ)) {
snprintf(targ, sizeof targ,
"%s/%s",
ctdl_hlp_dir, buf);
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);
}
strcpy(password, "");
determine_pwfilename(pwfile, sizeof pwfile);
- if (strlen(pwfile)==0) return;
+ if (IsEmptyStr(pwfile)) return;
fp = fopen(pwfile, "r");
if (fp == NULL) return;
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");
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));
#include "sysdep_decls.h"
#include "config.h"
#include "clientsocket.h"
+#include "tools.h"
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
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;
*/
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;
/* 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;
if (rc_exp_beep) {
ctdl_beep();
}
- if (strlen(rc_exp_cmd) == 0) {
+ if (IsEmptyStr(rc_exp_cmd)) {
color(BRIGHT_RED);
scr_printf("\r---");
}
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 */
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;
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)) {
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)) {
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] == ',')
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
CFLAGS = -Wall -g
#ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0 -ggdb
+ CFLAGS += -O0 -ggdb -pg
#else
# CFLAGS += -O2
#endif
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, "|");
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;
return;
}
- if (strlen(filename) == 0) {
+ if (IsEmptyStr(filename)) {
cprintf("%d You must specify a file name.\n",
ERROR + FILE_NOT_FOUND);
return;
return;
}
- if (strlen(filename) == 0) {
+ if (IsEmptyStr(filename)) {
cprintf("%d You must specify a file name.\n",
ERROR + FILE_NOT_FOUND);
return;
return;
}
- if (strlen(filename) == 0) {
+ if (IsEmptyStr(filename)) {
cprintf("%d You must specify a file name.\n",
ERROR + FILE_NOT_FOUND);
return;
return;
}
- if (strlen(filename) == 0) {
+ if (IsEmptyStr(filename)) {
cprintf("%d You must specify a file name.\n",
ERROR + FILE_NOT_FOUND);
return;
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;
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;
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;
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;
{
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;
}
/* Do some parsing */
- if (strlen(inbuf)>0) {
+ if (!IsEmptyStr(inbuf)) {
/* Fold in all the spacing */
for (i=0; i<strlen(inbuf); ++i) {
}
/* Convert &; tags to the forbidden characters */
- if (strlen(outbuf)>0) for (i=0; i<strlen(outbuf); ++i) {
+ if (!IsEmptyStr(outbuf)) for (i=0; i<strlen(outbuf); ++i) {
/* Character entity references */
if (!strncasecmp(&outbuf[i], " ", 6)) {
/* Output any lines terminated with hard line breaks */
do {
did_out = 0;
- if (strlen(outbuf)>0) {
+ if (!IsEmptyStr(outbuf)) {
for (i = 0; i<strlen(outbuf); ++i) {
if ( (i<(screenwidth-2)) && (outbuf[i]=='\n')) {
char host[256], type[256];
if (fqdn == NULL) return(hostalias_nomatch);
- if (strlen(fqdn) == 0) return(hostalias_nomatch);
+ if (IsEmptyStr(fqdn)) return(hostalias_nomatch);
if (!strcasecmp(fqdn, "localhost")) return(hostalias_localhost);
if (!strcasecmp(fqdn, config.c_fqdn)) return(hostalias_localhost);
if (!strcasecmp(fqdn, config.c_nodename)) return(hostalias_localhost);
stripout(name, '<', '>');
/* 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 % */
/* 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]);
}
/* 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 % */
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 */
* 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);
}
}
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);
}
}
- if (strlen(coll) == 0) {
+ if (IsEmptyStr(coll)) {
free(coll);
return(NULL);
}
}
if (a == 8) {
- if (strlen(wordbuf) > 0) {
+ if (!IsEmptyStr(wordbuf)) {
wordbuf[strlen(wordbuf) - 1] = 0;
scr_putc(8);
scr_putc(32);
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)
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) {
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 {
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);
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 {
}
}
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 {
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 {
scr_printf("%s> ", message->room);
}
}
- if (strlen(message->recipient)) {
+ if (!IsEmptyStr(message->recipient)) {
if (dest) {
fprintf(dest, "to %s ", message->recipient);
} else {
/* 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 {
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);
|| (!strcasecmp(ptr->disposition, ""))
) {
if ( (strcasecmp(ptr->number, message->mime_chosen))
- && (strlen(ptr->mimetype) > 0)
+ && (!IsEmptyStr(ptr->mimetype))
) {
color(DIM_WHITE);
pprintf("Part ");
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: ");
}
}
fseek(fp, wpos, 0);
- if (strlen(buf) > 0)
+ if (!IsEmptyStr(buf))
fwrite((char *) buf, strlen(buf), 1, fp);
wpos = ftell(fp);
fclose(fp);
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, "
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);
}
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");
} else {
scr_printf("Enter recipient: ");
ctdl_getline(buf, (SIZ-100) );
- if (strlen(buf) == 0)
+ if (IsEmptyStr(buf))
return (1);
}
} else
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);
}
/* 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);
keyopt("<B>ack <A>gain <Q>uote <R>eply <N>ext <S>top ");
if (rc_url_cmd[0] && num_urls)
keyopt("<U>RLview ");
- if (has_images > 0 && strlen(imagecmd) > 0)
+ if (has_images > 0 && !IsEmptyStr(imagecmd))
keyopt("<I>mages ");
keyopt("<?>help -> ");
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')
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')
" 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"
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;
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);
* 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,
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');
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;
}
/* 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
ma->did_print = 1;
if ( (!strcasecmp(cbtype, "text/plain"))
- || (strlen(cbtype)==0) ) {
+ || (IsEmptyStr(cbtype)) ) {
wptr = content;
if (length > 0) {
client_write(wptr, length);
++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 {
/* 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'],
*/
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;
}
buf[strlen(buf)] = ch;
}
}
- if (strlen(buf) > 0)
+ if (!IsEmptyStr(buf))
cprintf("%s%s", buf, nl);
}
/* 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);*/
}
/* ...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);
}
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
*/
/* 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 {
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);
}
/* 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;
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);
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);
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);
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]);
}
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);
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);
break;
}
if (invalid) {
- if (strlen(ret->errormsg) == 0) {
+ if (IsEmptyStr(ret->errormsg)) {
snprintf(append, sizeof append,
"Invalid recipient: %s",
this_recp);
}
}
else {
- if (strlen(ret->display_recp) == 0) {
+ if (IsEmptyStr(ret->display_recp)) {
strcpy(append, this_recp);
}
else {
/* Check some other permission type things. */
- if (strlen(newusername) == 0) {
+ if (IsEmptyStr(newusername)) {
strcpy(newusername, CC->user.fullname);
}
if ( (CC->user.axlevel < 6)
}
- 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; i<j; ++i) {
extract_token(buf, CC->cs_inet_other_emails, i, '|', sizeof buf);
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
*/
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 {
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;
}
}
}
- if (strlen(content_type) == 0) {
+ if (IsEmptyStr(content_type)) {
delete_this |= 0x02;
} else {
GetMetaData(&smi, msglist[i]);
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);
}
#endif
#include <errno.h>
+#include "tools.h"
int qwk = 0;
if (b == 'M') {
if (qwk == 0) {
printf("\n");
- if (strlen(subject) != 0)
+ if (!IsEmptyStr(subject))
printf("Subject: %s\n", subject);
}
if (aflag != 1)
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;
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;
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);
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;
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;
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;
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)] == ' '))
* 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);
}
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);
}
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;
}
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;
}
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;
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);
} else {
strcpy(raide, "");
}
- if (strlen(raide) == 0) {
+ if (IsEmptyStr(raide)) {
strcpy(raide, "none");
}
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;
{
static char save_dir[SIZ] = { 0 };
- if (strlen(save_dir) == 0) {
+ if (IsEmptyStr(save_dir)) {
if (getenv("HOME") == NULL) {
strcpy(save_dir, ".");
}
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');
}
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) {
else
strcpy(raide, "");
- if (strlen(raide) > 0)
+ if (!IsEmptyStr(raide))
scr_printf("Room aide is %s.\n\n", raide);
r = CtdlIPCRoomInfo(ipc, &text, buf);
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)
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;
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') {
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);
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))
"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);
{
int a;
- if (strlen(string)==0) return;
+ if (IsEmptyStr(string)) return;
/* Convert non-printable characters to blanks */
for (a=0; a<strlen(string); ++a) {
if (buf[a]==')') buf[a] = 0;
}
- if (strlen(buf)==0) strcpy(hbuf, ipc->ServInfo.fqdn);
+ if (IsEmptyStr(buf)) strcpy(hbuf, ipc->ServInfo.fqdn);
else strncpy(hbuf,buf,24);
#else
char *tty = ttyname(0);
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');
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]);
char buf[256];
newprompt("Filename: ", filename, 31);
- if (strlen(filename) == 0)
+ if (IsEmptyStr(filename))
return;
CtdlIPCDeleteFile(ipc, filename, buf);
err_printf("%s\n", buf);
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);
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);
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);
"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) {
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;
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 *));
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;
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);
/* 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);
if (buf[i] == '#') buf[i] = 0;
}
striplt(buf);
- if (strlen(buf) > 0) {
+ if (!IsEmptyStr(buf)) {
fprintf(changefp, "%s|%s\n", entrytype, buf);
}
}
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');
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');
home_specified = 1;
home=1;
} else {
- if (strlen(cmd) > 0)
+ if (!IsEmptyStr(cmd))
strcat(cmd, " ");
strcat(cmd, argv[a]);
}
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"))
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;
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);
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, "<more>");
- 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;
#include "citadel.h"
#include "server.h"
#include "support.h"
-
+#include "tools.h"
/*
* strproc() - make a string 'nice'
int a;
if (string == NULL) return;
- if (strlen(string)==0) return;
+ if (IsEmptyStr(string)) return;
/* Convert non-printable characters to blanks */
for (a=0; a<strlen(string); ++a) {
}
/* Remove leading and trailing blanks */
- while( (string[0]<33) && (strlen(string)>0) )
+ 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 */
/* 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);
*/
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;
}
safestrncpy(username, trythisname, USERNAME_SIZE);
striplt(username);
- if (strlen(username) == 0) {
+ if (IsEmptyStr(username)) {
return login_not_found;
}
*/
snprintf(CC->cs_inet_email, sizeof CC->cs_inet_email, "%s@%s",
CC->user.fullname, config.c_fqdn);
- for (i=0; i<strlen(CC->cs_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] = '_';
}
/*
* 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);
}
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;
}
return;
}
strproc(new_pw);
- if (strlen(new_pw) == 0) {
+ if (IsEmptyStr(new_pw)) {
cprintf("%d Password unchanged.\n", CIT_OK);
return;
}
strproc(username);
strproc(password);
- if (strlen(username) == 0) {
+ if (IsEmptyStr(username)) {
cprintf("%d You must supply a user name.\n", ERROR + USERNAME_REQUIRED);
return;
}
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) {
remove_token(strbuf, i, ';');
}
}
- if (strlen(strbuf) > 0) {
+ if (!IsEmptyStr(strbuf)) {
if (strbuf[strlen(strbuf)-1] == ';') {
strbuf[strlen(strbuf)-1] = 0;
}
* To make it easier to parse, we convert CRLF to LF, and unfold any
* multi-line fields into single lines.
*/
- for (i=0; i<strlen(mycopy); ++i) {
+ for (i=0; !IsEmptyStr(&mycopy[i]); ++i) {
if (!strncmp(&mycopy[i], "\r\n", 2)) {
strcpy(&mycopy[i], &mycopy[i+1]);
}
if (v == NULL) return v;
ptr = mycopy;
- while (strlen(ptr)>0) {
+ while (!IsEmptyStr(ptr)) {
colonpos = (-1);
nlpos = (-1);
colonpos = pattern2(ptr, ":");
}
- while ( (*ptr != '\n') && (strlen(ptr)>0) ) {
+ while ( (*ptr != '\n') && (!IsEmptyStr(ptr)) ) {
++ptr;
}
if (*ptr == '\n') ++ptr;
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; j<strlen(v->prop[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;
}
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<strlen(hold); ++i) {
- size_t tmp = strlen(buf);
-
- if (hold[i]=='<')
+ tmp = 0;
+ len = strlen(hold);
+ for (i=0; i<len; ++i) {
+ if (hold[i]=='<') {
snprintf(&buf[tmp], n - tmp, "<");
- else if (hold[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 ++;
+ }
}
}
}
- while (strlen(listing) > 0) {
+ while (!IsEmptyStr(listing)) {
extract_token(buf, listing, 0, '\n', sizeof buf);
remove_token(listing, 0, '\n');