* moved strlens out of loops everywhere possible anyhow.
* evaded about half of our strlen()'s; more to come.
37 files changed:
output_headers(1, 1, 2, 0, 0, 0);
wprintf("<div id=\"login_screen\">\n");
output_headers(1, 1, 2, 0, 0, 0);
wprintf("<div id=\"login_screen\">\n");
- if (mesg != NULL) if (strlen(mesg) > 0) {
+ if (mesg != NULL) if (!IsEmptyStr(mesg)) {
stresc(buf, mesg, 0, 0);
svprintf("mesg", WCS_STRING, "%s", buf);
}
stresc(buf, mesg, 0, 0);
svprintf("mesg", WCS_STRING, "%s", buf);
}
- if (strlen(bstr("language")) > 0) {
+ if (!IsEmptyStr(bstr("language"))) {
set_selected_language(bstr("language"));
go_selected_language();
}
set_selected_language(bstr("language"));
go_selected_language();
}
- if (strlen(bstr("exit_action")) > 0) {
+ if (!IsEmptyStr(bstr("exit_action"))) {
- if (strlen(bstr("login_action")) > 0) {
+ if (!IsEmptyStr(bstr("login_action"))) {
serv_printf("USER %s", bstr("name"));
serv_getln(buf, sizeof buf);
if (buf[0] == '3') {
serv_printf("USER %s", bstr("name"));
serv_getln(buf, sizeof buf);
if (buf[0] == '3') {
- if (strlen(bstr("newuser_action")) > 0) {
- if (strlen(bstr("pass")) == 0) {
+ if (!IsEmptyStr(bstr("newuser_action"))) {
+ if (IsEmptyStr(bstr("pass"))) {
display_login(_("Blank passwords are not allowed."));
return;
}
display_login(_("Blank passwords are not allowed."));
return;
}
*/
if (WC->is_aide) {
if (!setup_wizard) {
*/
if (WC->is_aide) {
if (!setup_wizard) {
sprintf(wizard_filename, "setupwiz.%s.%s",
ctdlhost, ctdlport);
sprintf(wizard_filename, "setupwiz.%s.%s",
ctdlhost, ctdlport);
- for (i=0; i<strlen(wizard_filename); ++i) {
+ len = strlen(wizard_filename);
+ for (i=0; i<len; ++i) {
if ( (wizard_filename[i]==' ')
|| (wizard_filename[i] == '/')
) {
if ( (wizard_filename[i]==' ')
|| (wizard_filename[i] == '/')
) {
* Go to the user's preferred start page
*/
get_preference("startpage", buf, sizeof buf);
* Go to the user's preferred start page
*/
get_preference("startpage", buf, sizeof buf);
safestrncpy(buf, "dotskip&room=_BASEROOM_", sizeof buf);
set_preference("startpage", buf, 1);
}
safestrncpy(buf, "dotskip&room=_BASEROOM_", sizeof buf);
set_preference("startpage", buf, 1);
}
/** If the user just submitted a validation, process it... */
safestrncpy(buf, bstr("user"), sizeof buf);
/** If the user just submitted a validation, process it... */
safestrncpy(buf, bstr("user"), sizeof buf);
- if (strlen(buf) > 0) {
- if (strlen(bstr("axlevel")) > 0) {
+ if (!IsEmptyStr(buf)) {
+ if (!IsEmptyStr(bstr("axlevel"))) {
serv_printf("VALI %s|%s", buf, bstr("axlevel"));
serv_getln(buf, sizeof buf);
if (buf[0] != '2') {
serv_printf("VALI %s|%s", buf, bstr("axlevel"));
serv_getln(buf, sizeof buf);
if (buf[0] != '2') {
"</div>\n<div id=\"content\">\n"
);
"</div>\n<div id=\"content\">\n"
);
- if (strlen(WC->ImportantMessage) > 0) {
+ if (!IsEmptyStr(WC->ImportantMessage)) {
do_template("beginbox_nt");
wprintf("<SPAN CLASS=\"errormsg\">"
"%s</SPAN><br />\n", WC->ImportantMessage);
do_template("beginbox_nt");
wprintf("<SPAN CLASS=\"errormsg\">"
"%s</SPAN><br />\n", WC->ImportantMessage);
char buf[SIZ];
char newpass1[32], newpass2[32];
char buf[SIZ];
char newpass1[32], newpass2[32];
- if (strlen(bstr("change_action")) == 0) {
+ if (IsEmptyStr(bstr("change_action"))) {
safestrncpy(WC->ImportantMessage,
_("Cancelled. Password was not changed."),
sizeof WC->ImportantMessage);
safestrncpy(WC->ImportantMessage,
_("Cancelled. Password was not changed."),
sizeof WC->ImportantMessage);
- if (strlen(newpass1) == 0) {
+ if (IsEmptyStr(newpass1)) {
safestrncpy(WC->ImportantMessage,
_("Blank passwords are not allowed."),
sizeof WC->ImportantMessage);
safestrncpy(WC->ImportantMessage,
_("Blank passwords are not allowed."),
sizeof WC->ImportantMessage);
- if (strlen(bstr("save_button")) > 0) {
+ if (!IsEmptyStr(bstr("save_button"))) {
/** Replace values in the component with ones from the form */
/** Replace values in the component with ones from the form */
/**
* If the user clicked 'Delete' then explicitly delete the message.
*/
/**
* If the user clicked 'Delete' then explicitly delete the message.
*/
- if (strlen(bstr("delete_button")) > 0) {
+ if (!IsEmptyStr(bstr("delete_button"))) {
- if (strlen(relevant_partnum) > 0) {
+ if (!IsEmptyStr(relevant_partnum)) {
relevant_source = load_mimepart(msgnum, relevant_partnum);
if (relevant_source != NULL) {
relevant_source = load_mimepart(msgnum, relevant_partnum);
if (relevant_source != NULL) {
long msgnum = 0L;
/** Force change the room if we have to */
long msgnum = 0L;
/** Force change the room if we have to */
- if (strlen(bstr("taskrm")) > 0) {
+ if (!IsEmptyStr(bstr("taskrm"))) {
gotoroom(bstr("taskrm"));
}
gotoroom(bstr("taskrm"));
}
char who[SIZ];
char buf[SIZ];
char *fb;
char who[SIZ];
char buf[SIZ];
char *fb;
extract_token(who, req, 1, ' ', sizeof who);
if (!strncasecmp(who, "/freebusy/", 10)) {
extract_token(who, req, 1, ' ', sizeof who);
if (!strncasecmp(who, "/freebusy/", 10)) {
- if ( (!strcasecmp(&who[strlen(who)-4], ".vcf"))
- || (!strcasecmp(&who[strlen(who)-4], ".ifb"))
- || (!strcasecmp(&who[strlen(who)-4], ".vfb")) ) {
- who[strlen(who)-4] = 0;
+ len = strlen(who);
+ if ( (!strcasecmp(&who[len-4], ".vcf"))
+ || (!strcasecmp(&who[len-4], ".ifb"))
+ || (!strcasecmp(&who[len-4], ".vfb")) ) {
+ who[len-4] = 0;
}
lprintf(9, "freebusy requested for <%s>\n", who);
}
lprintf(9, "freebusy requested for <%s>\n", who);
get_preference("calhourformat", calhourformat, sizeof calhourformat);
get_preference("daystart", daystart_str, sizeof daystart_str);
get_preference("calhourformat", calhourformat, sizeof calhourformat);
get_preference("daystart", daystart_str, sizeof daystart_str);
- if (strlen(daystart_str) > 0) daystart = atoi(daystart_str);
+ if (!IsEmptyStr(daystart_str)) daystart = atoi(daystart_str);
get_preference("dayend", dayend_str, sizeof dayend_str);
get_preference("dayend", dayend_str, sizeof dayend_str);
- if (strlen(dayend_str) > 0) dayend = atoi(dayend_str);
+ if (!IsEmptyStr(dayend_str)) dayend = atoi(dayend_str);
/** Figure out the dates for "yesterday" and "tomorrow" links */
/** Figure out the dates for "yesterday" and "tomorrow" links */
day = tm.tm_mday;
/** Now see if a date was specified */
day = tm.tm_mday;
/** Now see if a date was specified */
- if (strlen(bstr("year")) > 0) year = atoi(bstr("year"));
- if (strlen(bstr("month")) > 0) month = atoi(bstr("month"));
- if (strlen(bstr("day")) > 0) day = atoi(bstr("day"));
+ if (!IsEmptyStr(bstr("year"))) year = atoi(bstr("year"));
+ if (!IsEmptyStr(bstr("month"))) month = atoi(bstr("month"));
+ if (!IsEmptyStr(bstr("day"))) day = atoi(bstr("day"));
/** How would you like that cooked? */
/** How would you like that cooked? */
- if (strlen(bstr("calview")) > 0) {
+ if (!IsEmptyStr(bstr("calview"))) {
strcpy(calview, bstr("calview"));
}
else {
strcpy(calview, bstr("calview"));
}
else {
* \param sock a socket?
* \param buf some bunch of chars?
* \param hold hold what?
* \param sock a socket?
* \param buf some bunch of chars?
* \param hold hold what?
+ * TODO: get this comment right
*/
int req_gets(int sock, char *buf, char *hold)
{
*/
int req_gets(int sock, char *buf, char *hold)
{
- if (strlen(hold) == 0) {
+ if (IsEmptyStr(hold)) {
strcpy(buf, "");
a = client_getln(sock, buf, SIZ);
if (a<1) return(-1);
strcpy(buf, "");
a = client_getln(sock, buf, SIZ);
if (a<1) return(-1);
strcpy(hold, "");
if (!strncasecmp(buf, "Cookie: ", 8)) {
strcpy(hold, "");
if (!strncasecmp(buf, "Cookie: ", 8)) {
- for (a = 0; a < strlen(buf); ++a)
+ int len;
+ len = strlen(buf);
+ for (a = 0; a < len; ++a)
+ // we don't refresh len, because of we
+ // only exit from here.
sprintf(hold, "Cookie: %s", &buf[a + 1]);
buf[a] = 0;
sprintf(hold, "Cookie: %s", &buf[a + 1]);
buf[a] = 0;
- while (isspace(hold[8]))
- strcpy(&hold[8], &hold[9]);
+ b = 8;
+ while (isspace(hold[b]))
+ b++;
+
+ memmove(&hold[8], &hold[b], len - b + 1);
* \param fd the fd to close??????
* lingering_close() a`la Apache. see
* http://www.apache.org/docs/misc/fin_wait_2.html for rationale
* \param fd the fd to close??????
* lingering_close() a`la Apache. see
* http://www.apache.org/docs/misc/fin_wait_2.html for rationale
+ * TODO: get this comment precise.
*/
int lingering_close(int fd)
*/
int lingering_close(int fd)
safestrncpy(hptr->line, buf, sizeof hptr->line);
safestrncpy(hptr->line, buf, sizeof hptr->line);
- } while (strlen(buf) > 0);
+ } while (!IsEmptyStr(buf));
/**
* If the request is prefixed by "/webcit" then chop that off. This
/**
* If the request is prefixed by "/webcit" then chop that off. This
for (sptr = SessionList; sptr != NULL; sptr = sptr->next) {
/** If HTTP-AUTH, look for a session with matching credentials */
for (sptr = SessionList; sptr != NULL; sptr = sptr->next) {
/** If HTTP-AUTH, look for a session with matching credentials */
- if ( (strlen(httpauth_user) > 0)
+ if ( (!IsEmptyStr(httpauth_user))
&&(!strcasecmp(sptr->httpauth_user, httpauth_user))
&&(!strcasecmp(sptr->httpauth_pass, httpauth_pass)) ) {
TheSession = sptr;
&&(!strcasecmp(sptr->httpauth_user, httpauth_user))
&&(!strcasecmp(sptr->httpauth_pass, httpauth_pass)) ) {
TheSession = sptr;
sprintf(buf, "%d|%s|%s|%s|", session, user, pass, room);
strcpy(cookie, "");
sprintf(buf, "%d|%s|%s|%s|", session, user, pass, room);
strcpy(cookie, "");
- for (i=0; i<strlen(buf); ++i) {
+ len = strlen(buf);
+ for (i=0; i<len; ++i) {
sprintf(&cookie[i*2], "%02X", buf[i]);
}
}
sprintf(&cookie[i*2], "%02X", buf[i]);
}
}
}
else {
localtime_r(&now, &tm_now);
}
else {
localtime_r(&now, &tm_now);
- if (strlen(bstr("year")) > 0) {
+ if (!IsEmptyStr(bstr("year"))) {
tm_now.tm_year = atoi(bstr("year")) - 1900;
tm_now.tm_mon = atoi(bstr("month")) - 1;
tm_now.tm_mday = atoi(bstr("day"));
}
tm_now.tm_year = atoi(bstr("year")) - 1900;
tm_now.tm_mon = atoi(bstr("month")) - 1;
tm_now.tm_mday = atoi(bstr("day"));
}
- if (strlen(bstr("hour")) > 0) {
+ if (!IsEmptyStr(bstr("hour"))) {
tm_now.tm_hour = atoi(bstr("hour"));
tm_now.tm_min = atoi(bstr("minute"));
tm_now.tm_sec = 0;
tm_now.tm_hour = atoi(bstr("hour"));
tm_now.tm_min = atoi(bstr("minute"));
tm_now.tm_sec = 0;
created_new_vevent = 1;
}
created_new_vevent = 1;
}
- if ( (strlen(bstr("save_button")) > 0)
- || (strlen(bstr("check_button")) > 0) ) {
+ if ( (!IsEmptyStr(bstr("save_button")))
+ || (!IsEmptyStr(bstr("check_button"))) ) {
/** Replace values in the component with ones from the form */
/** Replace values in the component with ones from the form */
icalproperty_free(prop);
}
icalproperty_free(prop);
}
- if (strlen(bstr("summary")) > 0) {
+ if (!IsEmptyStr(bstr("summary"))) {
icalcomponent_add_property(vevent,
icalproperty_new_summary(bstr("summary")));
icalcomponent_add_property(vevent,
icalproperty_new_summary(bstr("summary")));
icalcomponent_remove_property(vevent, prop);
icalproperty_free(prop);
}
icalcomponent_remove_property(vevent, prop);
icalproperty_free(prop);
}
- if (strlen(bstr("location")) > 0) {
+ if (!IsEmptyStr(bstr("location"))) {
icalcomponent_add_property(vevent,
icalproperty_new_location(bstr("location")));
}
icalcomponent_add_property(vevent,
icalproperty_new_location(bstr("location")));
}
icalcomponent_remove_property(vevent, prop);
icalproperty_free(prop);
}
icalcomponent_remove_property(vevent, prop);
icalproperty_free(prop);
}
- if (strlen(bstr("description")) > 0) {
+ if (!IsEmptyStr(bstr("description"))) {
icalcomponent_add_property(vevent,
icalproperty_new_description(bstr("description")));
}
icalcomponent_add_property(vevent,
icalproperty_new_description(bstr("description")));
}
}
/** See if transparency is indicated */
}
/** See if transparency is indicated */
- if (strlen(bstr("transp")) > 0) {
+ if (!IsEmptyStr(bstr("transp"))) {
if (!strcasecmp(bstr("transp"), "opaque")) {
formtransp = ICAL_TRANSP_OPAQUE;
}
if (!strcasecmp(bstr("transp"), "opaque")) {
formtransp = ICAL_TRANSP_OPAQUE;
}
strcpy(buf, bstr("organizer"));
if ( (icalcomponent_get_first_property(vevent,
ICAL_ORGANIZER_PROPERTY) == NULL)
strcpy(buf, bstr("organizer"));
if ( (icalcomponent_get_first_property(vevent,
ICAL_ORGANIZER_PROPERTY) == NULL)
- && (strlen(buf) > 0) ) {
+ && (!IsEmptyStr(buf)) ) {
/** set new organizer */
sprintf(organizer_string, "MAILTO:%s", buf);
/** set new organizer */
sprintf(organizer_string, "MAILTO:%s", buf);
for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
extract_token(buf, form_attendees, i, '\n', sizeof buf);
striplt(buf);
for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
extract_token(buf, form_attendees, i, '\n', sizeof buf);
striplt(buf);
+ if (!IsEmptyStr(buf)) {
lprintf(9, "Attendee: <%s>\n", buf);
sprintf(attendee_string, "MAILTO:%s", buf);
foundit = 0;
lprintf(9, "Attendee: <%s>\n", buf);
sprintf(attendee_string, "MAILTO:%s", buf);
foundit = 0;
/** If the user clicked 'Save' then save it to the server. */
lprintf(9, "Serializing it for saving\n");
/** If the user clicked 'Save' then save it to the server. */
lprintf(9, "Serializing it for saving\n");
- if ( (encaps != NULL) && (strlen(bstr("save_button")) > 0) ) {
+ if ( (encaps != NULL) && (!IsEmptyStr(bstr("save_button"))) ) {
serv_puts("ENT0 1|||4|||1|");
serv_getln(buf, sizeof buf);
if (buf[0] == '8') {
serv_puts("ENT0 1|||4|||1|");
serv_getln(buf, sizeof buf);
if (buf[0] == '8') {
}
/** Or, check attendee availability if the user asked for that. */
}
/** Or, check attendee availability if the user asked for that. */
- if ( (encaps != NULL) && (strlen(bstr("check_button")) > 0) ) {
+ if ( (encaps != NULL) && (!IsEmptyStr(bstr("check_button"))) ) {
/** Call this function, which does the real work */
check_attendee_availability(encaps);
/** Call this function, which does the real work */
check_attendee_availability(encaps);
* If the user clicked 'Delete' then delete it.
*/
lprintf(9, "Checking to see if we have to delete an old event\n");
* If the user clicked 'Delete' then delete it.
*/
lprintf(9, "Checking to see if we have to delete an old event\n");
- if ( (strlen(bstr("delete_button")) > 0) && (msgnum > 0L) ) {
+ if ( (!IsEmptyStr(bstr("delete_button"))) && (msgnum > 0L) ) {
serv_printf("DELE %ld", atol(bstr("msgnum")));
serv_getln(buf, sizeof buf);
}
serv_printf("DELE %ld", atol(bstr("msgnum")));
serv_getln(buf, sizeof buf);
}
}
/** If this was a save or delete, go back to the calendar view. */
}
/** If this was a save or delete, go back to the calendar view. */
- if (strlen(bstr("check_button")) == 0) {
+ if (IsEmptyStr(bstr("check_button"))) {
int pos = 0;
int thisblock;
int pos = 0;
int thisblock;
- if (strlen(bstr("cancel_button")) > 0) {
+ if (!IsEmptyStr(bstr("cancel_button"))) {
strcpy(WC->ImportantMessage,
_("Graphics upload has been cancelled."));
display_main_menu();
strcpy(WC->ImportantMessage,
_("Graphics upload has been cancelled."));
display_main_menu();
long dav_msgnum = (-1);
char buf[SIZ];
int n = 0;
long dav_msgnum = (-1);
char buf[SIZ];
int n = 0;
/* First, break off the "/groupdav/" prefix */
remove_token(dav_pathname, 0, '/');
/* First, break off the "/groupdav/" prefix */
remove_token(dav_pathname, 0, '/');
remove_token(dav_pathname, n-1, '/');
/* What's left is the room name. Remove trailing slashes. */
remove_token(dav_pathname, n-1, '/');
/* What's left is the room name. Remove trailing slashes. */
- if (dav_pathname[strlen(dav_pathname)-1] == '/') {
- dav_pathname[strlen(dav_pathname)-1] = 0;
+ len = strlen(dav_pathname);
+ if (dav_pathname[len-1] == '/') {
+ dav_pathname[len-1] = 0;
}
strcpy(dav_roomname, dav_pathname);
}
strcpy(dav_roomname, dav_pathname);
* It's there ... check the ETag and make sure it matches
* the message number.
*/
* It's there ... check the ETag and make sure it matches
* the message number.
*/
- if (strlen(dav_ifmatch) > 0) {
+ if (!IsEmptyStr(dav_ifmatch)) {
if (atol(dav_ifmatch) != dav_msgnum) {
wprintf("HTTP/1.1 412 Precondition Failed\r\n");
groupdav_common_headers();
if (atol(dav_ifmatch) != dav_msgnum) {
wprintf("HTTP/1.1 412 Precondition Failed\r\n");
groupdav_common_headers();
int hit = 0;
/* We only want the first one that we found */
int hit = 0;
/* We only want the first one that we found */
- if (strlen(epdata->found_section) > 0) return;
+ if (!IsEmptyStr(epdata->found_section)) return;
/* Check for a content type match */
if (strlen(epdata->desired_content_type_1) > 0) {
/* Check for a content type match */
if (strlen(epdata->desired_content_type_1) > 0) {
- if (strlen(epdata->desired_content_type_2) > 0) {
+ if (!IsEmptyStr(epdata->desired_content_type_2)) {
if (!strcasecmp(epdata->desired_content_type_2, cbtype)) {
hit = 1;
}
if (!strcasecmp(epdata->desired_content_type_2, cbtype)) {
hit = 1;
}
/* Is this the one? If so, output it. */
if (hit) {
safestrncpy(epdata->found_section, partnum, sizeof epdata->found_section);
/* Is this the one? If so, output it. */
if (hit) {
safestrncpy(epdata->found_section, partnum, sizeof epdata->found_section);
- if (strlen(cbcharset) > 0) {
+ if (!IsEmptyStr(cbcharset)) {
safestrncpy(epdata->charset, cbcharset, sizeof epdata->charset);
}
wprintf("Content-type: %s; charset=%s\r\n", cbtype, epdata->charset);
safestrncpy(epdata->charset, cbcharset, sizeof epdata->charset);
}
wprintf("Content-type: %s; charset=%s\r\n", cbtype, epdata->charset);
/* If epdata.found_section is empty, we haven't output anything yet, so output the whole thing */
/* If epdata.found_section is empty, we haven't output anything yet, so output the whole thing */
- if (strlen(epdata.found_section) == 0) {
+ if (IsEmptyStr(epdata.found_section)) {
ptr = msgtext;
endptr = &msgtext[msglen];
ptr = msgtext;
endptr = &msgtext[msglen];
* string conversion function
*/
void euid_escapize(char *target, char *source) {
* string conversion function
*/
void euid_escapize(char *target, char *source) {
int target_length = 0;
strcpy(target, "");
int target_length = 0;
strcpy(target, "");
- for (i=0; i<strlen(source); ++i) {
+ len = strlen(source);
+ for (i=0; i<len; ++i) {
if ( (isalnum(source[i])) || (source[i]=='-') || (source[i]=='_') ) {
target[target_length] = source[i];
target[++target_length] = 0;
if ( (isalnum(source[i])) || (source[i]=='-') || (source[i]=='_') ) {
target[target_length] = source[i];
target[++target_length] = 0;
* string conversion function
*/
void euid_unescapize(char *target, char *source) {
* string conversion function
*/
void euid_unescapize(char *target, char *source) {
char hex[3];
int target_length = 0;
strcpy(target, "");
char hex[3];
int target_length = 0;
strcpy(target, "");
- for (a = 0; a < strlen(source); ++a) {
+ len = strlen(source);
+ for (a = 0; a < len; ++a) {
if (source[a] == '=') {
hex[0] = source[a + 1];
hex[1] = source[a + 2];
if (source[a] == '=') {
hex[0] = source[a + 1];
hex[1] = source[a + 2];
char dav_ifmatch[256];
int dav_depth;
char *ds;
char dav_ifmatch[256];
int dav_depth;
char *ds;
strcpy(dav_method, "");
strcpy(dav_pathname, "");
strcpy(dav_method, "");
strcpy(dav_pathname, "");
for (rptr=req; rptr!=NULL; rptr=rptr->next) {
if (!strncasecmp(rptr->line, "Host: ", 6)) {
for (rptr=req; rptr!=NULL; rptr=rptr->next) {
if (!strncasecmp(rptr->line, "Host: ", 6)) {
- if (strlen(WC->http_host) == 0) {
+ if (IsEmptyStr(WC->http_host)) {
safestrncpy(WC->http_host, &rptr->line[6],
sizeof WC->http_host);
}
safestrncpy(WC->http_host, &rptr->line[6],
sizeof WC->http_host);
}
* If there's an If-Match: header, strip out the quotes if present, and
* then if all that's left is an asterisk, make it go away entirely.
*/
* If there's an If-Match: header, strip out the quotes if present, and
* then if all that's left is an asterisk, make it go away entirely.
*/
- if (strlen(dav_ifmatch) > 0) {
- striplt(dav_ifmatch);
+ len = strlen(dav_ifmatch);
+ if (len > 0) {
+ stripltlen(dav_ifmatch, &len);
if (dav_ifmatch[0] == '\"') {
if (dav_ifmatch[0] == '\"') {
- strcpy(dav_ifmatch, &dav_ifmatch[1]);
- for (i=0; i<strlen(dav_ifmatch); ++i) {
+ memmove (dav_ifmatch, &dav_ifmatch[1], len);
+ len --;
+ for (i=0; i<len; ++i) {
if (dav_ifmatch[i] == '\"') {
dav_ifmatch[i] = 0;
if (dav_ifmatch[i] == '\"') {
dav_ifmatch[i] = 0;
* Output our host prefix for globally absolute URL's.
*/
void groupdav_identify_host(void) {
* Output our host prefix for globally absolute URL's.
*/
void groupdav_identify_host(void) {
- if (strlen(WC->http_host) > 0) {
+ if (!IsEmptyStr(WC->http_host)) {
wprintf("%s://%s",
(is_https ? "https" : "http"),
WC->http_host);
wprintf("%s://%s",
(is_https ? "https" : "http"),
WC->http_host);
/*
* If the room name is blank, the client is doing a top-level OPTIONS.
*/
/*
* If the room name is blank, the client is doing a top-level OPTIONS.
*/
- if (strlen(dav_roomname) == 0) {
+ if (IsEmptyStr(dav_roomname)) {
wprintf("HTTP/1.1 200 OK\r\n");
groupdav_common_headers();
wprintf("Date: %s\r\n", datestring);
wprintf("HTTP/1.1 200 OK\r\n");
groupdav_common_headers();
wprintf("Date: %s\r\n", datestring);
/* If dav_uid is non-empty, client is requesting an OPTIONS on
* a specific item in the room.
*/
/* If dav_uid is non-empty, client is requesting an OPTIONS on
* a specific item in the room.
*/
- if (strlen(dav_uid) > 0) {
+ if (!IsEmptyStr(dav_uid)) {
dav_msgnum = locate_message_by_uid(dav_uid);
if (dav_msgnum < 0) {
dav_msgnum = locate_message_by_uid(dav_uid);
if (dav_msgnum < 0) {
* If the room name is blank, the client is requesting a
* folder list.
*/
* If the room name is blank, the client is requesting a
* folder list.
*/
- if (strlen(dav_roomname) == 0) {
+ if (IsEmptyStr(dav_roomname)) {
groupdav_collection_list(dav_pathname, dav_depth);
return;
}
groupdav_collection_list(dav_pathname, dav_depth);
return;
}
* a specific item in the room. This is not valid GroupDAV, but
* it is valid WebDAV.
*/
* a specific item in the room. This is not valid GroupDAV, but
* it is valid WebDAV.
*/
- if (strlen(dav_uid) > 0) {
+ if (!IsEmptyStr(dav_uid)) {
dav_msgnum = locate_message_by_uid(dav_uid);
if (dav_msgnum < 0) {
dav_msgnum = locate_message_by_uid(dav_uid);
if (dav_msgnum < 0) {
+ if (!IsEmptyStr(uid)) {
wprintf("<response>");
wprintf("<href>");
groupdav_identify_host();
wprintf("<response>");
wprintf("<href>");
groupdav_identify_host();
* client is expecting. If not, the server probably contains a newer
* version, so we fail...
*/
* client is expecting. If not, the server probably contains a newer
* version, so we fail...
*/
- if (strlen(dav_ifmatch) > 0) {
+ if (!IsEmptyStr(dav_ifmatch)) {
lprintf(9, "dav_ifmatch: %s\n", dav_ifmatch);
old_msgnum = locate_message_by_uid(dav_uid);
lprintf(9, "old_msgnum: %ld\n", old_msgnum);
lprintf(9, "dav_ifmatch: %s\n", dav_ifmatch);
old_msgnum = locate_message_by_uid(dav_uid);
lprintf(9, "old_msgnum: %ld\n", old_msgnum);
- if (strlen(bstr("ok_button")) == 0) {
+ if (IsEmptyStr(bstr("ok_button"))) {
display_main_menu();
return;
}
display_main_menu();
return;
}
sprintf(iconbar, "ib_displayas=%d", atoi(bstr("ib_displayas")));
for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
sprintf(iconbar, "ib_displayas=%d", atoi(bstr("ib_displayas")));
for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
- sprintf(&iconbar[strlen(iconbar)], ",%s=", boxen[i]);
if (!strcasecmp(bstr(boxen[i]), "yes")) {
if (!strcasecmp(bstr(boxen[i]), "yes")) {
- sprintf(&iconbar[strlen(iconbar)], "1");
- sprintf(&iconbar[strlen(iconbar)], "0");
+ sprintf(&iconbar[strlen(iconbar)], ",%s=%s", boxen[i], Val);
}
set_preference("iconbar", iconbar, 1);
}
set_preference("iconbar", iconbar, 1);
if (which >= 0) {
ic_spec[which] = realloc(ic_spec[which], strlen(ic_spec[which]) + strlen(ename) + 2);
if (which >= 0) {
ic_spec[which] = realloc(ic_spec[which], strlen(ic_spec[which]) + strlen(ename) + 2);
- if (strlen(ic_spec[which]) > 0) strcat(ic_spec[which], "\n");
+ if (!IsEmptyStr(ic_spec[which])) strcat(ic_spec[which], "\n");
strcat(ic_spec[which], ename);
}
else {
ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2);
strcat(ic_spec[which], ename);
}
else {
ic_misc = realloc(ic_misc, strlen(ic_misc) + strlen(buf) + 2);
- if (strlen(ic_misc) > 0) strcat(ic_misc, "\n");
+ if (!IsEmptyStr(ic_misc)) strcat(ic_misc, "\n");
escputs(ic_desc[which]);
wprintf("</span><br />");
wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>\n");
escputs(ic_desc[which]);
wprintf("</span><br />");
wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>\n");
- if (strlen(ic_spec[which]) > 0) {
+ if (!IsEmptyStr(ic_spec[which])) {
for (i=0; i<num_tokens(ic_spec[which], '\n'); ++i) {
wprintf("<TR><TD ALIGN=LEFT>");
extract_token(buf, ic_spec[which], i, '\n', sizeof buf);
for (i=0; i<num_tokens(ic_spec[which], '\n'); ++i) {
wprintf("<TR><TD ALIGN=LEFT>");
extract_token(buf, ic_spec[which], i, '\n', sizeof buf);
if (buf[0] == '1') while (serv_getln(buf, SIZ), strcmp(buf, "000")) {
extract_token(ename, buf, 0, '|', SIZ);
extract_token(etype, buf, 1, '|', SIZ);
if (buf[0] == '1') while (serv_getln(buf, SIZ), strcmp(buf, "000")) {
extract_token(ename, buf, 0, '|', SIZ);
extract_token(etype, buf, 1, '|', SIZ);
- if (strlen(buf) == 0) {
/** skip blank lines */
}
else if ((!strcasecmp(ename, bstr("ename")))
/** skip blank lines */
}
else if ((!strcasecmp(ename, bstr("ename")))
sprintf(WC->ImportantMessage, _("%s has been deleted."), ename);
}
else {
sprintf(WC->ImportantMessage, _("%s has been deleted."), ename);
}
else {
- if (strlen(newconfig) > 0) strcat(newconfig, "\n");
+ if (!IsEmptyStr(newconfig)) strcat(newconfig, "\n");
strcat(newconfig, buf);
}
}
strcat(newconfig, buf);
}
}
wprintf(_("(come back here later)"));
wprintf("</span></li>\n");
wprintf(_("(come back here later)"));
wprintf("</span></li>\n");
- if ((strlen(WC->ugname) > 0) && (strcasecmp(WC->ugname, WC->wc_roomname))) {
+ if ((!IsEmptyStr(WC->ugname)) && (strcasecmp(WC->ugname, WC->wc_roomname))) {
wprintf("<li><a href=\"ungoto\">");
wprintf(_("Ungoto"));
wprintf("</a><span>");
wprintf("<li><a href=\"ungoto\">");
wprintf(_("Ungoto"));
wprintf("</a><span>");
- if (strlen(bstr("sc_button")) == 0) {
+ if (IsEmptyStr(bstr("sc_button"))) {
display_main_menu();
return;
}
display_main_menu();
return;
}
char *isav; /**< Saved pointer to input buffer */
char *osav; /**< Saved pointer to output buffer */
int passes = 0;
char *isav; /**< Saved pointer to input buffer */
char *osav; /**< Saved pointer to output buffer */
int passes = 0;
int illegal_non_rfc2047_encoding = 0;
/** Sometimes, badly formed messages contain strings which were simply
int illegal_non_rfc2047_encoding = 0;
/** Sometimes, badly formed messages contain strings which were simply
* handle it anyway by converting from a user-specified default
* charset to UTF-8 if we see any nonprintable characters.
*/
* handle it anyway by converting from a user-specified default
* charset to UTF-8 if we see any nonprintable characters.
*/
- for (i=0; i<strlen(buf); ++i) {
+ len = strlen(buf);
+ for (i=0; i<len; ++i) {
if ((buf[i] < 32) || (buf[i] > 126)) {
illegal_non_rfc2047_encoding = 1;
if ((buf[i] < 32) || (buf[i] > 126)) {
illegal_non_rfc2047_encoding = 1;
+ i = len; ///< take a shortcut, it won't be more than one.
}
}
if (illegal_non_rfc2047_encoding) {
}
}
if (illegal_non_rfc2047_encoding) {
void rfc2047encode(char *target, int maxlen, char *source)
{
int need_to_encode = 0;
void rfc2047encode(char *target, int maxlen, char *source)
{
int need_to_encode = 0;
unsigned char ch;
if (target == NULL) return;
unsigned char ch;
if (target == NULL) return;
-
- for (i=0; i<strlen(source); ++i) {
+ len = strlen(source);
+ for (i=0; i<len; ++i) {
if ((source[i] < 32) || (source[i] > 126)) {
need_to_encode = 1;
if ((source[i] < 32) || (source[i] > 126)) {
need_to_encode = 1;
+ i = len; ///< shortcut. won't become more than 1
}
strcpy(target, "=?UTF-8?Q?");
}
strcpy(target, "=?UTF-8?Q?");
- for (i=0; i<strlen(source); ++i) {
+ for (i=0; i<len; ++i) {
ch = (unsigned char) source[i];
if ((ch < 32) || (ch > 126) || (ch == 61)) {
sprintf(&target[strlen(target)], "=%02X", ch);
ch = (unsigned char) source[i];
if ((ch < 32) || (ch > 126) || (ch == 61)) {
sprintf(&target[strlen(target)], "=%02X", ch);
int start, end;
char urlbuf[SIZ];
char outbuf[1024];
start = (-1);
int start, end;
char urlbuf[SIZ];
char outbuf[1024];
start = (-1);
+ len = end = strlen(buf);
- for (pos = 0; pos < strlen(buf); ++pos) {
+ for (pos = 0; pos < len; ++pos) {
if (!strncasecmp(&buf[pos], "http://", 7))
start = pos;
if (!strncasecmp(&buf[pos], "ftp://", 6))
if (!strncasecmp(&buf[pos], "http://", 7))
start = pos;
if (!strncasecmp(&buf[pos], "ftp://", 6))
- for (pos = strlen(buf); pos > start; --pos) {
+ for (pos = len; pos > start; --pos) {
if ( (!isprint(buf[pos]))
|| (isspace(buf[pos]))
|| (buf[pos] == '{')
if ( (!isprint(buf[pos]))
|| (isspace(buf[pos]))
|| (buf[pos] == '{')
void vcard_n_prettyize(char *name)
{
char *original_name;
void vcard_n_prettyize(char *name)
{
char *original_name;
original_name = strdup(name);
original_name = strdup(name);
+ len = strlen(original_name);
- if (strlen(original_name) > 0) {
- if (original_name[strlen(original_name)-1] == ' ') {
- original_name[strlen(original_name)-1] = 0;
+ if (len > 0) {
+ if (original_name[len-1] == ' ') {
+ original_name[--len] = 0;
- if (original_name[strlen(original_name)-1] == ';') {
- original_name[strlen(original_name)-1] = 0;
+ if (original_name[len-1] == ';') {
+ original_name[--len] = 0;
- for (i=0; i<strlen(original_name); ++i) {
+ j=0;
+ for (i=0; i<len; ++i) {
if (original_name[i] == ';') {
if (original_name[i] == ';') {
+ name[j++] = ',';
+ name[j++] = ' ';
- name[strlen(name)+1] = 0;
- name[strlen(name)] = original_name[i];
+ name[j++] = original_name[i];
for (pass=1; pass<=2; ++pass) {
if (v->numprops) for (i=0; i<(v->numprops); ++i) {
for (pass=1; pass<=2; ++pass) {
if (v->numprops) for (i=0; i<(v->numprops); ++i) {
thisname = strdup(v->prop[i].name);
extract_token(firsttoken, thisname, 0, ';', sizeof firsttoken);
thisname = strdup(v->prop[i].name);
extract_token(firsttoken, thisname, 0, ';', sizeof firsttoken);
remove_token(thisname, j, ';');
}
}
remove_token(thisname, j, ';');
}
}
+
+ len = strlen(v->prop[i].value);
- thisvalue = malloc(strlen(v->prop[i].value) + 50);
+ // %ff can become 6 bytes in utf8
+ thisvalue = malloc(len * 2 + 3);
j = CtdlDecodeQuotedPrintable(
thisvalue, v->prop[i].value,
j = CtdlDecodeQuotedPrintable(
thisvalue, v->prop[i].value,
- strlen(v->prop[i].value) );
thisvalue[j] = 0;
}
else if (is_b64) {
thisvalue[j] = 0;
}
else if (is_b64) {
- thisvalue = malloc(strlen(v->prop[i].value) + 50);
+ // ff will become one byte..
+ thisvalue = malloc(len + 50);
CtdlDecodeBase64(
thisvalue, v->prop[i].value,
strlen(v->prop[i].value) );
CtdlDecodeBase64(
thisvalue, v->prop[i].value,
strlen(v->prop[i].value) );
/** N is name, but only if there's no FN already there */
if (!strcasecmp(firsttoken, "n")) {
/** N is name, but only if there's no FN already there */
if (!strcasecmp(firsttoken, "n")) {
- if (strlen(fullname) == 0) {
+ if (IsEmptyStr(fullname)) {
strcpy(fullname, thisvalue);
vcard_n_prettyize(fullname);
}
strcpy(fullname, thisvalue);
vcard_n_prettyize(fullname);
}
}
else if (!strcasecmp(firsttoken, "email")) {
}
else if (!strcasecmp(firsttoken, "email")) {
- if (strlen(mailto) > 0) strcat(mailto, "<br />");
+ if (!IsEmptyStr(mailto)) strcat(mailto, "<br />");
strcat(mailto,
"<a href=\"display_enter"
"?force_room=_MAIL_?recp=");
strcat(mailto,
"<a href=\"display_enter"
"?force_room=_MAIL_?recp=");
strcat(mailto, "</A>");
}
else if (!strcasecmp(firsttoken, "tel")) {
strcat(mailto, "</A>");
}
else if (!strcasecmp(firsttoken, "tel")) {
- if (strlen(phone) > 0) strcat(phone, "<br />");
+ if (!IsEmptyStr(phone)) strcat(phone, "<br />");
strcat(phone, thisvalue);
for (j=0; j<num_tokens(thisname, ';'); ++j) {
extract_token(buf, thisname, j, ';', sizeof buf);
strcat(phone, thisvalue);
for (j=0; j<num_tokens(thisname, ';'); ++j) {
extract_token(buf, thisname, j, ';', sizeof buf);
wprintf("</TD><TD>");
for (j=0; j<num_tokens(thisvalue, ';'); ++j) {
extract_token(buf, thisvalue, j, ';', sizeof buf);
wprintf("</TD><TD>");
for (j=0; j<num_tokens(thisvalue, ';'); ++j) {
extract_token(buf, thisvalue, j, ';', sizeof buf);
+ if (!IsEmptyStr(buf)) {
escputs(buf);
if (j<3) wprintf("<br />");
else wprintf(" ");
escputs(buf);
if (j<3) wprintf("<br />");
else wprintf(" ");
"<FONT SIZE=+1><B>");
escputs(fullname);
wprintf("</B></FONT>");
"<FONT SIZE=+1><B>");
escputs(fullname);
wprintf("</B></FONT>");
- if (strlen(title) > 0) {
+ if (!IsEmptyStr(title)) {
wprintf("<div align=right>");
escputs(title);
wprintf("</div>");
}
wprintf("<div align=right>");
escputs(title);
wprintf("</div>");
}
+ if (!IsEmptyStr(org)) {
wprintf("<div align=right>");
escputs(org);
wprintf("</div>");
}
wprintf("</TD></TR>\n");
wprintf("<div align=right>");
escputs(org);
wprintf("</div>");
}
wprintf("</TD></TR>\n");
- if (strlen(phone) > 0) {
+ if (!IsEmptyStr(phone)) {
wprintf("<tr><td>");
wprintf(_("Telephone:"));
wprintf("</td><td>%s</td></tr>\n", phone);
}
wprintf("<tr><td>");
wprintf(_("Telephone:"));
wprintf("</td><td>%s</td></tr>\n", phone);
}
- if (strlen(mailto) > 0) {
+ if (!IsEmptyStr(mailto)) {
wprintf("<tr><td>");
wprintf(_("E-mail:"));
wprintf("</td><td>%s</td></tr>\n", mailto);
wprintf("<tr><td>");
wprintf(_("E-mail:"));
wprintf("</td><td>%s</td></tr>\n", mailto);
}
wprintf("?recp=");
urlescputs(reply_to);
}
wprintf("?recp=");
urlescputs(reply_to);
- if (strlen(m_subject) > 0) {
+ if (!IsEmptyStr(m_subject)) {
wprintf("?subject=");
if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
urlescputs(m_subject);
wprintf("?subject=");
if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
urlescputs(m_subject);
wprintf("?replyquote=%ld", msgnum);
wprintf("?recp=");
urlescputs(reply_to);
wprintf("?replyquote=%ld", msgnum);
wprintf("?recp=");
urlescputs(reply_to);
- if (strlen(m_subject) > 0) {
+ if (!IsEmptyStr(m_subject)) {
wprintf("?subject=");
if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
urlescputs(m_subject);
wprintf("?subject=");
if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
urlescputs(m_subject);
urlescputs(reply_to);
wprintf("?cc=");
urlescputs(reply_all);
urlescputs(reply_to);
wprintf("?cc=");
urlescputs(reply_all);
- if (strlen(m_subject) > 0) {
+ if (!IsEmptyStr(m_subject)) {
wprintf("?subject=");
if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
urlescputs(m_subject);
wprintf("?subject=");
if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
urlescputs(m_subject);
safestrncpy(m_subject, &buf[5], sizeof m_subject);
}
if (!strncasecmp(buf, "cccc=", 5)) {
safestrncpy(m_subject, &buf[5], sizeof m_subject);
}
if (!strncasecmp(buf, "cccc=", 5)) {
safestrncpy(m_cc, &buf[5], sizeof m_cc);
safestrncpy(m_cc, &buf[5], sizeof m_cc);
- if (strlen(reply_all) > 0) {
+ if (!IsEmptyStr(reply_all)) {
strcat(reply_all, ", ");
}
strcat(reply_all, ", ");
}
- safestrncpy(&reply_all[strlen(reply_all)], &buf[5],
- (sizeof reply_all - strlen(reply_all)) );
+ len = strlen(reply_all);
+ safestrncpy(&reply_all[len], &buf[5],
+ (sizeof reply_all - len) );
}
if ((!strncasecmp(buf, "hnod=", 5))
&& (strcasecmp(&buf[5], serv_info.serv_humannode))) {
}
if ((!strncasecmp(buf, "hnod=", 5))
&& (strcasecmp(&buf[5], serv_info.serv_humannode))) {
}
if ((!strncasecmp(buf, "room=", 5))
&& (strcasecmp(&buf[5], WC->wc_roomname))
}
if ((!strncasecmp(buf, "room=", 5))
&& (strcasecmp(&buf[5], WC->wc_roomname))
- && (strlen(&buf[5])>0) ) {
+ && (!IsEmptyStr(&buf[5])) ) {
wprintf(_("in "));
wprintf("%s> ", &buf[5]);
}
wprintf(_("in "));
wprintf("%s> ", &buf[5]);
}
if ( ((WC->room_flags & QR_NETWORK)
|| ((strcasecmp(&buf[5], serv_info.serv_nodename)
&& (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
if ( ((WC->room_flags & QR_NETWORK)
|| ((strcasecmp(&buf[5], serv_info.serv_nodename)
&& (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
) {
wprintf("@%s ", &buf[5]);
}
}
if (!strncasecmp(buf, "rcpt=", 5)) {
) {
wprintf("@%s ", &buf[5]);
}
}
if (!strncasecmp(buf, "rcpt=", 5)) {
- if (strlen(reply_all) > 0) {
+ if (!IsEmptyStr(reply_all)) {
strcat(reply_all, ", ");
}
strcat(reply_all, ", ");
}
- safestrncpy(&reply_all[strlen(reply_all)], &buf[5],
- (sizeof reply_all - strlen(reply_all)) );
+ len = strlen(reply_all);
+ safestrncpy(&reply_all[len], &buf[5],
+ (sizeof reply_all - len) );
#ifdef HAVE_ICONV
utf8ify_rfc822_string(&buf[5]);
#endif
#ifdef HAVE_ICONV
utf8ify_rfc822_string(&buf[5]);
#endif
striplt(mime_name);
striplt(mime_filename);
striplt(mime_name);
striplt(mime_filename);
- if ( (strlen(mime_filename) == 0) && (strlen(mime_name) > 0) ) {
+ if ( (IsEmptyStr(mime_filename)) && (!IsEmptyStr(mime_name)) ) {
strcpy(mime_filename, mime_name);
}
if (!strcasecmp(mime_content_type, "message/rfc822")) {
strcpy(mime_filename, mime_name);
}
if (!strcasecmp(mime_content_type, "message/rfc822")) {
- if (strlen(mime_submessages) > 0) {
+ if (!IsEmptyStr(mime_submessages)) {
strcat(mime_submessages, "|");
}
strcat(mime_submessages, mime_partnum);
strcat(mime_submessages, "|");
}
strcat(mime_submessages, mime_partnum);
else if ( ( (!strcasecmp(mime_disposition, "attachment"))
|| (!strcasecmp(mime_disposition, "inline"))
|| (!strcasecmp(mime_disposition, ""))
else if ( ( (!strcasecmp(mime_disposition, "attachment"))
|| (!strcasecmp(mime_disposition, "inline"))
|| (!strcasecmp(mime_disposition, ""))
- ) && (strlen(mime_content_type) > 0)
+ ) && (!IsEmptyStr(mime_content_type))
) {
++num_attach_links;
attach_links = realloc(attach_links,
) {
++num_attach_links;
attach_links = realloc(attach_links,
}
/** Generate a reply-to address */
}
/** Generate a reply-to address */
- if (strlen(rfca) > 0) {
- if (strlen(from) > 0) {
+ if (!IsEmptyStr(rfca)) {
+ if (!IsEmptyStr(from)) {
snprintf(reply_to, sizeof(reply_to), "%s <%s>", from, rfca);
}
else {
snprintf(reply_to, sizeof(reply_to), "%s <%s>", from, rfca);
}
else {
- if ( (strlen(node) > 0)
+ if ((!IsEmptyStr(node))
&& (strcasecmp(node, serv_info.serv_nodename))
&& (strcasecmp(node, serv_info.serv_humannode)) ) {
snprintf(reply_to, sizeof(reply_to), "%s @ %s",
&& (strcasecmp(node, serv_info.serv_nodename))
&& (strcasecmp(node, serv_info.serv_humannode)) ) {
snprintf(reply_to, sizeof(reply_to), "%s @ %s",
utf8ify_rfc822_string(m_cc);
utf8ify_rfc822_string(m_subject);
#endif
utf8ify_rfc822_string(m_cc);
utf8ify_rfc822_string(m_subject);
#endif
- if (strlen(m_cc) > 0) {
+ if (!IsEmptyStr(m_cc)) {
wprintf("<div class=\"message_subject\">");
wprintf(_("CC:"));
wprintf(" ");
escputs(m_cc);
wprintf("</div>");
}
wprintf("<div class=\"message_subject\">");
wprintf(_("CC:"));
wprintf(" ");
escputs(m_cc);
wprintf("</div>");
}
- if (strlen(m_subject) > 0) {
+ if (!IsEmptyStr(m_subject)) {
wprintf("<div class=\"message_subject\">");
wprintf(_("Subject:"));
wprintf(" ");
wprintf("<div class=\"message_subject\">");
wprintf(_("Subject:"));
wprintf(" ");
/** Begin body */
wprintf("<div class=\"message_content\">");
/** Begin body */
wprintf("<div class=\"message_content\">");
* Learn the content type
*/
strcpy(mime_content_type, "text/plain");
* Learn the content type
*/
strcpy(mime_content_type, "text/plain");
- while (serv_getln(buf, sizeof buf), (strlen(buf) > 0)) {
+ while (serv_getln(buf, sizeof buf), (!IsEmptyStr(buf))) {
if (!strcmp(buf, "000")) {
wprintf("<i>");
wprintf(_("unexpected end of message"));
if (!strcmp(buf, "000")) {
wprintf("<i>");
wprintf(_("unexpected end of message"));
striplt(msg4_partnum);
}
if (!strncasecmp(buf, "Content-type:", 13)) {
striplt(msg4_partnum);
}
if (!strncasecmp(buf, "Content-type:", 13)) {
safestrncpy(mime_content_type, &buf[13], sizeof(mime_content_type));
striplt(mime_content_type);
safestrncpy(mime_content_type, &buf[13], sizeof(mime_content_type));
striplt(mime_content_type);
- for (i=0; i<strlen(mime_content_type); ++i) {
+ len = strlen(mime_content_type);
+ for (i=0; i<len; ++i) {
if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
safestrncpy(mime_charset, &mime_content_type[i+8],
sizeof mime_charset);
}
}
if (!strncasecmp(&mime_content_type[i], "charset=", 8)) {
safestrncpy(mime_charset, &mime_content_type[i+8],
sizeof mime_charset);
}
}
- for (i=0; i<strlen(mime_content_type); ++i) {
+ for (i=0; i<len; ++i) {
if (mime_content_type[i] == ';') {
mime_content_type[i] = 0;
if (mime_content_type[i] == ';') {
mime_content_type[i] = 0;
- for (i=0; i<strlen(mime_charset); ++i) {
+ len = strlen(mime_charset);
+ for (i=0; i<len; ++i) {
if (mime_charset[i] == ';') {
mime_charset[i] = 0;
if (mime_charset[i] == ';') {
mime_charset[i] = 0;
else if ( (!strcasecmp(mime_content_type, "text/plain"))
|| (!strcasecmp(mime_content_type, "text")) ) {
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
else if ( (!strcasecmp(mime_content_type, "text/plain"))
|| (!strcasecmp(mime_content_type, "text")) ) {
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0;
- if (buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = 0;
+ int len;
+ len = strlen(buf);
+ if (buf[len-1] == '\n') buf[--len] = 0;
+ if (buf[len-1] == '\r') buf[--len] = 0;
#ifdef HAVE_ICONV
if (ic != (iconv_t)(-1) ) {
#ifdef HAVE_ICONV
if (ic != (iconv_t)(-1) ) {
- while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
- buf[strlen(buf) - 1] = 0;
+ len = strlen(buf);
+ while ((!IsEmptyStr(buf)) && (isspace(buf[len-1])))
+ buf[--len] = 0;
if ((bq == 0) &&
((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) )) {
wprintf("<blockquote>");
if ((bq == 0) &&
((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) )) {
wprintf("<blockquote>");
}
/** If there are attached submessages, display them now... */
}
/** If there are attached submessages, display them now... */
- if ( (strlen(mime_submessages) > 0) && (!section[0]) ) {
+ if ( (!IsEmptyStr(mime_submessages)) && (!section[0]) ) {
for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
extract_token(buf, mime_submessages, i, '|', sizeof buf);
/** use printable_view to suppress buttons */
for (i=0; i<num_tokens(mime_submessages, '|'); ++i) {
extract_token(buf, mime_submessages, i, '|', sizeof buf);
/** use printable_view to suppress buttons */
}
/** Handler for vCard parts */
}
/** Handler for vCard parts */
- if (strlen(vcard_partnum) > 0) {
+ if (!IsEmptyStr(vcard_partnum)) {
part_source = load_mimepart(msgnum, vcard_partnum);
if (part_source != NULL) {
part_source = load_mimepart(msgnum, vcard_partnum);
if (part_source != NULL) {
}
/** Handler for calendar parts */
}
/** Handler for calendar parts */
- if (strlen(cal_partnum) > 0) {
+ if (!IsEmptyStr(cal_partnum)) {
part_source = load_mimepart(msgnum, cal_partnum);
if (part_source != NULL) {
cal_process_attachment(part_source,
part_source = load_mimepart(msgnum, cal_partnum);
if (part_source != NULL) {
cal_process_attachment(part_source,
}
if ((!strncasecmp(buf, "room=", 5))
&& (strcasecmp(&buf[5], WC->wc_roomname))
}
if ((!strncasecmp(buf, "room=", 5))
&& (strcasecmp(&buf[5], WC->wc_roomname))
- && (strlen(&buf[5])>0) ) {
+ && (!IsEmptyStr(&buf[5])) ) {
wprintf(_("in "));
wprintf("%s> ", &buf[5]);
}
wprintf(_("in "));
wprintf("%s> ", &buf[5]);
}
if ( ((WC->room_flags & QR_NETWORK)
|| ((strcasecmp(&buf[5], serv_info.serv_nodename)
&& (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
if ( ((WC->room_flags & QR_NETWORK)
|| ((strcasecmp(&buf[5], serv_info.serv_nodename)
&& (strcasecmp(&buf[5], serv_info.serv_fqdn)))))
) {
wprintf("@%s ", &buf[5]);
}
) {
wprintf("@%s ", &buf[5]);
}
#ifdef HAVE_ICONV
utf8ify_rfc822_string(m_subject);
#endif
#ifdef HAVE_ICONV
utf8ify_rfc822_string(m_subject);
#endif
- if (strlen(m_subject) > 0) {
+ if (!IsEmptyStr(m_subject)) {
wprintf(_("Subject:"));
wprintf(" ");
msgescputs(m_subject);
wprintf(_("Subject:"));
wprintf(" ");
msgescputs(m_subject);
* Learn the content type
*/
strcpy(mime_content_type, "text/plain");
* Learn the content type
*/
strcpy(mime_content_type, "text/plain");
- while (serv_getln(buf, sizeof buf), (strlen(buf) > 0)) {
+ while (serv_getln(buf, sizeof buf), (!IsEmptyStr(buf))) {
if (!strcmp(buf, "000")) {
wprintf("%s (4)", _("unexpected end of message"));
goto ENDBODY;
}
if (!strncasecmp(buf, "Content-type: ", 14)) {
if (!strcmp(buf, "000")) {
wprintf("%s (4)", _("unexpected end of message"));
goto ENDBODY;
}
if (!strncasecmp(buf, "Content-type: ", 14)) {
safestrncpy(mime_content_type, &buf[14],
sizeof(mime_content_type));
for (i=0; i<strlen(mime_content_type); ++i) {
safestrncpy(mime_content_type, &buf[14],
sizeof(mime_content_type));
for (i=0; i<strlen(mime_content_type); ++i) {
sizeof mime_charset);
}
}
sizeof mime_charset);
}
}
- for (i=0; i<strlen(mime_content_type); ++i) {
+ len = strlen(mime_content_type);
+ for (i=0; i<len; ++i) {
if (mime_content_type[i] == ';') {
mime_content_type[i] = 0;
if (mime_content_type[i] == ';') {
mime_content_type[i] = 0;
- for (i=0; i<strlen(mime_charset); ++i) {
+ len = strlen(mime_charset);
+ for (i=0; i<len; ++i) {
if (mime_charset[i] == ';') {
mime_charset[i] = 0;
if (mime_charset[i] == ';') {
mime_charset[i] = 0;
/* Boring old 80-column fixed format text gets handled this way... */
else if (!strcasecmp(mime_content_type, "text/plain")) {
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
/* Boring old 80-column fixed format text gets handled this way... */
else if (!strcasecmp(mime_content_type, "text/plain")) {
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0;
- if (buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = 0;
+ int len;
+ len = strlen(buf);
+ if (buf[len-1] == '\n') buf[--len] = 0;
+ if (buf[len-1] == '\r') buf[--len] = 0;
#ifdef HAVE_ICONV
if (ic != (iconv_t)(-1) ) {
ibuf = buf;
#ifdef HAVE_ICONV
if (ic != (iconv_t)(-1) ) {
ibuf = buf;
- ibuflen = strlen(ibuf);
obuflen = SIZ;
obuf = (char *) malloc(obuflen);
osav = obuf;
obuflen = SIZ;
obuf = (char *) malloc(obuflen);
osav = obuf;
- while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
- buf[strlen(buf) - 1] = 0;
+ len = strlen(buf);
+ while ((!IsEmptyStr(buf)) && (isspace(buf[len - 1])))
+ buf[--len] = 0;
if ((bq == 0) &&
((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) )) {
wprintf("<blockquote>");
if ((bq == 0) &&
((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) )) {
wprintf("<blockquote>");
- if (strlen(vcard_partnum) > 0) {
+ if (!IsEmptyStr(vcard_partnum)) {
vcard_source = load_mimepart(msgnum, vcard_partnum);
if (vcard_source != NULL) {
vcard_source = load_mimepart(msgnum, vcard_partnum);
if (vcard_source != NULL) {
int mime_length;
char vcard_partnum[SIZ];
char *vcard_source = NULL;
int mime_length;
char vcard_partnum[SIZ];
char *vcard_source = NULL;
struct message_summary summ;
if (namebuf == NULL) return;
struct message_summary summ;
if (namebuf == NULL) return;
- if (strlen(vcard_partnum) > 0) {
+ if (!IsEmptyStr(vcard_partnum)) {
vcard_source = load_mimepart(msgnum, vcard_partnum);
if (vcard_source != NULL) {
vcard_source = load_mimepart(msgnum, vcard_partnum);
if (vcard_source != NULL) {
lastfirst_firstlast(namebuf);
striplt(namebuf);
lastfirst_firstlast(namebuf);
striplt(namebuf);
- for (i=0; i<strlen(namebuf); ++i) {
+ len = strlen(namebuf);
+ for (i=0; i<len; ++i) {
if (namebuf[i] != ';') return;
}
strcpy(namebuf, _("(no name)"));
if (namebuf[i] != ';') return;
}
strcpy(namebuf, _("(no name)"));
WC->summ[nummsgs-1].msgnum = WC->msgarr[nummsgs-1];
safestrncpy(WC->summ[nummsgs-1].subj,
_("(no subject)"), sizeof WC->summ[nummsgs-1].subj);
WC->summ[nummsgs-1].msgnum = WC->msgarr[nummsgs-1];
safestrncpy(WC->summ[nummsgs-1].subj,
_("(no subject)"), sizeof WC->summ[nummsgs-1].subj);
- if (strlen(fullname) > 0) {
+ if (!IsEmptyStr(fullname)) {
safestrncpy(WC->summ[nummsgs-1].from,
fullname, sizeof WC->summ[nummsgs-1].from);
}
safestrncpy(WC->summ[nummsgs-1].from,
fullname, sizeof WC->summ[nummsgs-1].from);
}
- if (strlen(subject) > 0) {
+ if (!IsEmptyStr(subject)) {
safestrncpy(WC->summ[nummsgs-1].subj, subject,
sizeof WC->summ[nummsgs-1].subj);
}
safestrncpy(WC->summ[nummsgs-1].subj, subject,
sizeof WC->summ[nummsgs-1].subj);
}
strcpy(&WC->summ[nummsgs-1].subj[72], "...");
}
strcpy(&WC->summ[nummsgs-1].subj[72], "...");
}
- if (strlen(nodename) > 0) {
+ if (!IsEmptyStr(nodename)) {
if ( ((WC->room_flags & QR_NETWORK)
|| ((strcasecmp(nodename, serv_info.serv_nodename)
&& (strcasecmp(nodename, serv_info.serv_fqdn)))))
if ( ((WC->room_flags & QR_NETWORK)
|| ((strcasecmp(nodename, serv_info.serv_nodename)
&& (strcasecmp(nodename, serv_info.serv_fqdn)))))
get_preference(sortpref_name, sortpref_value, sizeof sortpref_value);
sortby = bstr("sortby");
get_preference(sortpref_name, sortpref_value, sizeof sortpref_value);
sortby = bstr("sortby");
- if ( (strlen(sortby) > 0) && (strcasecmp(sortby, sortpref_value)) ) {
+ if ( (!IsEmptyStr(sortby)) && (strcasecmp(sortby, sortpref_value)) ) {
set_preference(sortpref_name, sortby, 1);
}
set_preference(sortpref_name, sortby, 1);
}
- if (strlen(sortby) == 0) sortby = sortpref_value;
+ if (IsEmptyStr(sortby)) sortby = sortpref_value;
- if (strlen(sortby) == 0) sortby = "rdate";
+ if (IsEmptyStr(sortby)) sortby = "rdate";
/** message board sort */
if (!strcasecmp(sortby, "reverse")) {
/** message board sort */
if (!strcasecmp(sortby, "reverse")) {
- if (strlen(bstr("cancel_button")) > 0) {
+ if (!IsEmptyStr(bstr("cancel_button"))) {
sprintf(WC->ImportantMessage,
_("Cancelled. Message was not posted."));
sprintf(WC->ImportantMessage,
_("Cancelled. Message was not posted."));
- } else if (strlen(bstr("attach_button")) > 0) {
+ } else if (!IsEmptyStr(bstr("attach_button"))) {
display_enter();
return;
} else if (atol(bstr("postseq")) == dont_post) {
display_enter();
return;
} else if (atol(bstr("postseq")) == dont_post) {
serv_getln(buf, sizeof buf);
if (buf[0] == '4') {
post_mime_to_server();
serv_getln(buf, sizeof buf);
if (buf[0] == '4') {
post_mime_to_server();
- if ( (strlen(bstr("recp")) > 0)
- || (strlen(bstr("cc")) > 0)
- || (strlen(bstr("bcc")) > 0)
+ if ( (!IsEmptyStr(bstr("recp")))
+ || (!IsEmptyStr(bstr("cc" )))
+ || (!IsEmptyStr(bstr("bcc" )))
) {
sprintf(WC->ImportantMessage, _("Message has been sent.\n"));
}
) {
sprintf(WC->ImportantMessage, _("Message has been sent.\n"));
}
* We may have been supplied with instructions regarding the location
* to which we must return after posting. If found, go there.
*/
* We may have been supplied with instructions regarding the location
* to which we must return after posting. If found, go there.
*/
- if (strlen(bstr("return_to")) > 0) {
+ if (!IsEmptyStr(bstr("return_to"))) {
http_redirect(bstr("return_to"));
}
/**
* If we were editing a page in a wiki room, go to that page now.
*/
http_redirect(bstr("return_to"));
}
/**
* If we were editing a page in a wiki room, go to that page now.
*/
- else if (strlen(bstr("wikipage")) > 0) {
+ else if (!IsEmptyStr(bstr("wikipage"))) {
snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage"));
http_redirect(buf);
}
snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage"));
http_redirect(buf);
}
- if (strlen(bstr("force_room")) > 0) {
+ if (!IsEmptyStr(bstr("force_room"))) {
gotoroom(bstr("force_room"));
}
gotoroom(bstr("force_room"));
}
serv_getln(buf, sizeof buf);
if (!strncmp(buf, "570", 3)) { /** 570 means we have an invalid recipient listed */
serv_getln(buf, sizeof buf);
if (!strncmp(buf, "570", 3)) { /** 570 means we have an invalid recipient listed */
- if (strlen(bstr("recp")) + strlen(bstr("cc")) + strlen(bstr("bcc")) > 0) {
+ if (!IsEmptyStr(bstr("recp")) &&
+ !IsEmptyStr(bstr("cc" )) &&
+ !IsEmptyStr(bstr("bcc" ))) {
if ( (WC->is_mailbox) && (strcmp(bstr("sig_inserted"), "yes")) ) {
get_preference("use_sig", buf, sizeof buf);
if (!strcasecmp(buf, "yes")) {
if ( (WC->is_mailbox) && (strcmp(bstr("sig_inserted"), "yes")) ) {
get_preference("use_sig", buf, sizeof buf);
if (!strcasecmp(buf, "yes")) {
get_preference("signature", ebuf, sizeof ebuf);
euid_unescapize(buf, ebuf);
wprintf("<br>--<br>");
get_preference("signature", ebuf, sizeof ebuf);
euid_unescapize(buf, ebuf);
wprintf("<br>--<br>");
- for (i=0; i<strlen(buf); ++i) {
+ len = strlen(buf);
+ for (i=0; i<len; ++i) {
if (buf[i] == '\n') {
wprintf("<br>");
}
if (buf[i] == '\n') {
wprintf("<br>");
}
msgid = atol(bstr("msgid"));
msgid = atol(bstr("msgid"));
- if (strlen(bstr("move_button")) > 0) {
+ if (!IsEmptyStr(bstr("move_button"))) {
sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
serv_puts(buf);
serv_getln(buf, sizeof buf);
sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room"));
serv_puts(buf);
serv_getln(buf, sizeof buf);
*/
char *fixed_partnum(char *supplied_partnum) {
if (supplied_partnum == NULL) return "1";
*/
char *fixed_partnum(char *supplied_partnum) {
if (supplied_partnum == NULL) return "1";
- if (strlen(supplied_partnum)==0) return "1";
+ if (IsEmptyStr(supplied_partnum)) return "1";
return supplied_partnum;
}
return supplied_partnum;
}
strcpy(encoding, "");
/* If this part is not encoded, send as-is */
strcpy(encoding, "");
/* If this part is not encoded, send as-is */
- if ( (strlen(encoding) == 0) || (dont_decode)) {
+ if ( (IsEmptyStr(encoding)) || (dont_decode)) {
if (CallBack != NULL) {
CallBack(name, filename, fixed_partnum(partnum),
disposition, part_start,
if (CallBack != NULL) {
CallBack(name, filename, fixed_partnum(partnum),
disposition, part_start,
/* Learn interesting things from the headers */
strcpy(header, "");
do {
/* Learn interesting things from the headers */
strcpy(header, "");
do {
ptr = memreadline(ptr, buf, SIZ);
if (ptr >= content_end) {
goto end_parser;
}
ptr = memreadline(ptr, buf, SIZ);
if (ptr >= content_end) {
goto end_parser;
}
- for (i = 0; i < strlen(buf); ++i) {
+ len = strlen (buf);
+ for (i = 0; i < len; ++i) {
if (isspace(buf[i])) {
buf[i] = ' ';
}
if (isspace(buf[i])) {
buf[i] = ' ';
}
strcpy(encoding, &header[26]);
striplt(encoding);
}
strcpy(encoding, &header[26]);
striplt(encoding);
}
- if (strlen(boundary) == 0)
+ if (IsEmptyStr(boundary))
extract_key(boundary, header, "boundary");
strcpy(header, "");
}
if ((strlen(header) + strlen(buf) + 2) < SIZ) {
strcat(header, buf);
}
extract_key(boundary, header, "boundary");
strcpy(header, "");
}
if ((strlen(header) + strlen(buf) + 2) < SIZ) {
strcat(header, buf);
}
- } while ((strlen(buf) > 0) && (*ptr != 0));
+ } while ((!IsEmptyStr(buf)) && (*ptr != 0));
if (strchr(disposition, ';'))
*(strchr(disposition, ';')) = '\0';
if (strchr(disposition, ';'))
*(strchr(disposition, ';')) = '\0';
*(strchr(content_type, ';')) = '\0';
striplt(content_type);
*(strchr(content_type, ';')) = '\0';
striplt(content_type);
- if (strlen(boundary) > 0) {
+ if (!IsEmptyStr(boundary)) {
is_multipart = 1;
} else {
is_multipart = 0;
is_multipart = 1;
} else {
is_multipart = 0;
--part_end; /* omit the trailing CR */
}
--part_end; /* omit the trailing CR */
}
- if (strlen(partnum) > 0) {
+ if (!IsEmptyStr(partnum)) {
snprintf(nested_partnum,
sizeof nested_partnum,
"%s.%d", partnum,
snprintf(nested_partnum,
sizeof nested_partnum,
"%s.%d", partnum,
0, encoding, userdata);
}
if (CallBack != NULL) {
0, encoding, userdata);
}
if (CallBack != NULL) {
- if (strlen(partnum) > 0) {
+ if (!IsEmptyStr(partnum)) {
snprintf(nested_partnum,
sizeof nested_partnum,
"%s.%d", partnum,
snprintf(nested_partnum,
sizeof nested_partnum,
"%s.%d", partnum,
char cnode[SIZ];
FILE *fp;
char cnode[SIZ];
FILE *fp;
- if (strlen(bstr("ok_button")) > 0) {
+ if (!IsEmptyStr(bstr("ok_button"))) {
strcpy(node, bstr("node") );
fp = tmpfile();
if (fp != NULL) {
strcpy(node, bstr("node") );
fp = tmpfile();
if (fp != NULL) {
strcpy(node, bstr("node"));
strcpy(node, bstr("node"));
- if (strlen(bstr("add_button")) > 0) {
+ if (!IsEmptyStr(bstr("add_button"))) {
sprintf(buf, "NSET addnode|%s", node);
serv_puts(buf);
serv_getln(buf, sizeof buf);
sprintf(buf, "NSET addnode|%s", node);
serv_puts(buf);
serv_getln(buf, sizeof buf);
char display_notetext[SIZ];
char eid[128];
int in_text = 0;
char display_notetext[SIZ];
char eid[128];
int in_text = 0;
wprintf("<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\">\n");
wprintf("<IMG ALIGN=MIDDLE src=\"static/storenotes_48x.gif\">\n");
}
/** Now sanitize the buffer */
}
/** Now sanitize the buffer */
- for (i=0; i<strlen(notetext); ++i) {
+ len = strlen(notetext);
+ for (i=0; i<len; ++i) {
if (isspace(notetext[i])) notetext[i] = ' ';
}
/** Make it HTML-happy and print it. */
stresc(display_notetext, notetext, 0, 0);
if (isspace(notetext[i])) notetext[i] = ' ';
}
/** Make it HTML-happy and print it. */
stresc(display_notetext, notetext, 0, 0);
+ if (!IsEmptyStr(eid)) {
wprintf("<span id=\"note%s\">%s</span><br />\n", eid, display_notetext);
}
else {
wprintf("<span id=\"note%s\">%s</span><br />\n", eid, display_notetext);
}
else {
}
/** Offer in-place editing. */
}
/** Offer in-place editing. */
+ if (!IsEmptyStr(eid)) {
wprintf("<script type=\"text/javascript\">"
"new Ajax.InPlaceEditor('note%s', 'updatenote?nonce=%ld?eid=%s', {rows:5,cols:72});"
"</script>\n",
wprintf("<script type=\"text/javascript\">"
"new Ajax.InPlaceEditor('note%s', 'updatenote?nonce=%ld?eid=%s', {rows:5,cols:72});"
"</script>\n",
char display_notetext[SIZ];
long msgnum;
int in_text = 0;
char display_notetext[SIZ];
long msgnum;
int in_text = 0;
serv_printf("ENT0 1||0|0||||||%s", bstr("eid"));
serv_getln(buf, sizeof buf);
serv_printf("ENT0 1||0|0||||||%s", bstr("eid"));
serv_getln(buf, sizeof buf);
}
}
/** Now sanitize the buffer */
}
}
/** Now sanitize the buffer */
- for (i=0; i<strlen(notetext); ++i) {
+ len = strlen(notetext);
+ for (i=0; i<len; ++i) {
if (isspace(notetext[i])) notetext[i] = ' ';
}
if (isspace(notetext[i])) notetext[i] = ' ';
}
safestrncpy(recp, bstr("recp"), sizeof recp);
safestrncpy(recp, bstr("recp"), sizeof recp);
- if (strlen(bstr("send_button")) == 0) {
+ if (IsEmptyStr(bstr("send_button"))) {
safestrncpy(WC->ImportantMessage,
_("Message was not sent."),
sizeof WC->ImportantMessage
safestrncpy(WC->ImportantMessage,
_("Message was not sent."),
sizeof WC->ImportantMessage
wprintf("<img src=\"static/blank.gif\" onLoad=\"parent.window.close();\">\n");
}
wprintf("<img src=\"static/blank.gif\" onLoad=\"parent.window.close();\">\n");
}
- if (strlen(output_data) > 0) {
-
- if (output_data[strlen(output_data)-1] == '\n') {
- output_data[strlen(output_data)-1] = 0;
+ if (!IsEmptyStr(output_data)) {
+ int len;
+ len = strlen(output_data);
+ if (output_data[len-1] == '\n') {
+ output_data[len-1] = 0;
}
/** Output our fun to the other frame. */
}
/** Output our fun to the other frame. */
- if (strlen(bstr("help_button")) > 0) {
+ if (!IsEmptyStr(bstr("help_button"))) {
strcpy(send_this, "/help");
}
strcpy(send_this, "/help");
}
- if (strlen(bstr("list_button")) > 0) {
+ if (!IsEmptyStr(bstr("list_button"))) {
strcpy(send_this, "/who");
}
strcpy(send_this, "/who");
}
- if (strlen(bstr("exit_button")) > 0) {
+ if (!IsEmptyStr(bstr("exit_button"))) {
strcpy(send_this, "/quit");
}
strcpy(send_this, "/quit");
}
WC->serv_sock = WC->chat_sock;
WC->chat_sock = i;
WC->serv_sock = WC->chat_sock;
WC->chat_sock = i;
- while (strlen(send_this) > 0) {
+ while (!IsEmptyStr(send_this)) {
if (strlen(send_this) < 67) {
serv_puts(send_this);
strcpy(send_this, "");
if (strlen(send_this) < 67) {
serv_puts(send_this);
strcpy(send_this, "");
- if (strlen(bstr("change_button")) == 0) {
+ if (IsEmptyStr(bstr("change_button"))) {
safestrncpy(WC->ImportantMessage,
_("Cancelled. No settings were changed."),
sizeof WC->ImportantMessage);
safestrncpy(WC->ImportantMessage,
_("Cancelled. No settings were changed."),
sizeof WC->ImportantMessage);
case VIEW_CALENDAR:
case VIEW_CALBRIEF:
wprintf("<li class=\"addevent\"><a href=\"display_enter");
case VIEW_CALENDAR:
case VIEW_CALBRIEF:
wprintf("<li class=\"addevent\"><a href=\"display_enter");
- if (strlen(bstr("year")) > 0) wprintf("?year=%s", bstr("year"));
- if (strlen(bstr("month")) > 0) wprintf("?month=%s", bstr("month"));
- if (strlen(bstr("day")) > 0) wprintf("?day=%s", bstr("day"));
+ if (!IsEmptyStr(bstr("year" ))) wprintf("?year=%s", bstr("year"));
+ if (!IsEmptyStr(bstr("month"))) wprintf("?month=%s", bstr("month"));
+ if (!IsEmptyStr(bstr("day" ))) wprintf("?day=%s", bstr("day"));
wprintf("\">"
"<img align=\"middle\" src=\"static/addevent_24x.gif\" "
"border=\"0\"><span class=\"navbar_link\">"
wprintf("\">"
"<img align=\"middle\" src=\"static/addevent_24x.gif\" "
"border=\"0\"><span class=\"navbar_link\">"
int floorvalue = 0;
tab = bstr("tab");
int floorvalue = 0;
tab = bstr("tab");
- if (strlen(tab) == 0) tab = "admin";
+ if (IsEmptyStr(tab)) tab = "admin";
load_floorlist();
serv_puts("GETR");
load_floorlist();
serv_puts("GETR");
wprintf(_("Resides on floor: "));
wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
for (i = 0; i < 128; ++i)
wprintf(_("Resides on floor: "));
wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
for (i = 0; i < 128; ++i)
- if (strlen(floorlist[i]) > 0) {
+ if (!IsEmptyStr(floorlist[i])) {
wprintf("<OPTION ");
if (i == er_floor)
wprintf("SELECTED ");
wprintf("<OPTION ");
if (i == er_floor)
wprintf("SELECTED ");
shared_with = realloc(shared_with,
strlen(shared_with) + 32);
strcat(shared_with, node);
shared_with = realloc(shared_with,
strlen(shared_with) + 32);
strcat(shared_with, node);
- if (strlen(remote_room) > 0) {
+ if (!IsEmptyStr(remote_room)) {
strcat(shared_with, "|");
strcat(shared_with, remote_room);
}
strcat(shared_with, "|");
strcat(shared_with, remote_room);
}
extract_token(buf, shared_with, i, '\n', sizeof buf);
extract_token(node, buf, 0, '|', sizeof node);
extract_token(remote_room, buf, 1, '|', sizeof remote_room);
extract_token(buf, shared_with, i, '\n', sizeof buf);
extract_token(node, buf, 0, '|', sizeof node);
extract_token(remote_room, buf, 1, '|', sizeof remote_room);
- if (strlen(node) > 0) {
+ if (!IsEmptyStr(node)) {
wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
wprintf("<TR><TD>%s</TD>\n", node);
wprintf("<TD>");
wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
wprintf("<TR><TD>%s</TD>\n", node);
wprintf("<TD>");
- if (strlen(remote_room) > 0) {
+ if (!IsEmptyStr(remote_room)) {
escputs(remote_room);
}
wprintf("</TD>");
escputs(remote_room);
}
wprintf("</TD>");
wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
"VALUE=\"ignet_push_share|");
urlescputs(node);
wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
"VALUE=\"ignet_push_share|");
urlescputs(node);
- if (strlen(remote_room) > 0) {
+ if (!IsEmptyStr(remote_room)) {
wprintf("|");
urlescputs(remote_room);
}
wprintf("|");
urlescputs(remote_room);
}
for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
extract_token(node, not_shared_with, i, '\n', sizeof node);
for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
extract_token(node, not_shared_with, i, '\n', sizeof node);
- if (strlen(node) > 0) {
+ if (!IsEmptyStr(node)) {
wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
wprintf("<TR><TD>");
wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
wprintf("<TR><TD>");
- if (strlen(bstr("ok_button")) == 0) {
+ if (IsEmptyStr(bstr("ok_button"))) {
strcpy(WC->ImportantMessage,
_("Cancelled. Changes were not saved."));
display_editroom();
strcpy(WC->ImportantMessage,
_("Cancelled. Changes were not saved."));
display_editroom();
er_flags2 = extract_int(&buf[4], 7);
strcpy(er_roomaide, bstr("er_roomaide"));
er_flags2 = extract_int(&buf[4], 7);
strcpy(er_roomaide, bstr("er_roomaide"));
- if (strlen(er_roomaide) == 0) {
+ if (IsEmptyStr(er_roomaide)) {
serv_puts("GETA");
serv_getln(buf, sizeof buf);
if (buf[0] != '2') {
serv_puts("GETA");
serv_getln(buf, sizeof buf);
if (buf[0] != '2') {
}
strcpy(buf, bstr("er_name"));
buf[128] = 0;
}
strcpy(buf, bstr("er_name"));
buf[128] = 0;
+ if (!IsEmptyStr(buf)) {
strcpy(er_name, buf);
}
strcpy(buf, bstr("er_password"));
buf[10] = 0;
strcpy(er_name, buf);
}
strcpy(buf, bstr("er_password"));
buf[10] = 0;
strcpy(er_password, buf);
strcpy(buf, bstr("er_dirname"));
buf[15] = 0;
strcpy(er_password, buf);
strcpy(buf, bstr("er_dirname"));
buf[15] = 0;
strcpy(er_dirname, buf);
strcpy(buf, bstr("type"));
strcpy(er_dirname, buf);
strcpy(buf, bstr("type"));
- if (strlen(er_roomaide) > 0) {
+ if (!IsEmptyStr(er_roomaide)) {
sprintf(buf, "SETA %s", er_roomaide);
serv_puts(buf);
serv_getln(buf, sizeof buf);
sprintf(buf, "SETA %s", er_roomaide);
serv_puts(buf);
serv_getln(buf, sizeof buf);
strcpy(username, bstr("username"));
strcpy(username, bstr("username"));
- if (strlen(bstr("kick_button")) > 0) {
+ if (!IsEmptyStr(bstr("kick_button"))) {
sprintf(buf, "KICK %s", username);
serv_puts(buf);
serv_getln(buf, sizeof buf);
sprintf(buf, "KICK %s", username);
serv_puts(buf);
serv_getln(buf, sizeof buf);
- if (strlen(bstr("invite_button")) > 0) {
+ if (!IsEmptyStr(bstr("invite_button"))) {
sprintf(buf, "INVT %s", username);
serv_puts(buf);
serv_getln(buf, sizeof buf);
sprintf(buf, "INVT %s", username);
serv_puts(buf);
serv_getln(buf, sizeof buf);
load_floorlist();
wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
for (i = 0; i < 128; ++i)
load_floorlist();
wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
for (i = 0; i < 128; ++i)
- if (strlen(floorlist[i]) > 0) {
+ if (!IsEmptyStr(floorlist[i])) {
wprintf("<OPTION ");
wprintf("VALUE=\"%d\">", i);
escputs(floorlist[i]);
wprintf("<OPTION ");
wprintf("VALUE=\"%d\">", i);
escputs(floorlist[i]);
int er_num_type;
int er_view;
int er_num_type;
int er_view;
- if (strlen(bstr("ok_button")) == 0) {
+ if (IsEmptyStr(bstr("ok_button"))) {
strcpy(WC->ImportantMessage,
_("Cancelled. No new room was created."));
display_main_menu();
strcpy(WC->ImportantMessage,
_("Cancelled. No new room was created."));
display_main_menu();
char hold_rm[SIZ];
char buf[SIZ];
char hold_rm[SIZ];
char buf[SIZ];
- if (strlen(bstr("ok_button")) == 0) {
+ if (IsEmptyStr(bstr("ok_button"))) {
display_main_menu();
return;
}
display_main_menu();
return;
}
*/
strcpy(final_destination, WC->wc_roomname);
*/
strcpy(final_destination, WC->wc_roomname);
- if (strlen(bstr("ok_button")) > 0) {
+ if (!IsEmptyStr(bstr("ok_button"))) {
serv_printf("GOTO %s", WC->wc_roomname);
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
serv_printf("GOTO %s", WC->wc_roomname);
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
char cmpb1[SIZ];
int i, num_addrs;
char cmpb1[SIZ];
int i, num_addrs;
- if (strlen(bstr("line"))==0) {
+ if (IsEmptyStr(bstr("line"))) {
display_editroom();
return;
}
display_editroom();
return;
}
- if (strlen(bstr("add_button")) > 0) {
+ if (!IsEmptyStr(bstr("add_button"))) {
num_addrs = num_tokens(bstr("line"), ',');
if (num_addrs < 2) {
/* just adding one node or address */
num_addrs = num_tokens(bstr("line"), ',');
if (num_addrs < 2) {
/* just adding one node or address */
*/
void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
{
*/
void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
{
/**
* For mailboxes, just do it straight...
/**
* For mailboxes, just do it straight...
/**
* Replace "\" characters with "|" for pseudo-folder-delimiting
*/
/**
* Replace "\" characters with "|" for pseudo-folder-delimiting
*/
- for (i=0; i<strlen(folder); ++i) {
+ len = strlen (folder);
+ for (i=0; i<len; ++i) {
if (folder[i] == '\\') folder[i] = '|';
}
}
if (folder[i] == '\\') folder[i] = '|';
}
}
has_subfolders = 0;
if ((i+1) < max_folders) {
has_subfolders = 0;
if ((i+1) < max_folders) {
- if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
- && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
+ int len;
+ len = strlen(fold[i].name);
+ if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
+ && (fold[i+1].name[len] == '|') ) {
'|', sizeof floor_name);
if ( (strcasecmp(floor_name, old_floor_name))
'|', sizeof floor_name);
if ( (strcasecmp(floor_name, old_floor_name))
- && (strlen(old_floor_name) > 0) ) {
+ && (!IsEmptyStr(old_floor_name)) ) {
/* End inner box */
do_template("endbox");
/* End inner box */
do_template("endbox");
'|', sizeof floor_name);
if ( (strcasecmp(floor_name, old_floor_name))
'|', sizeof floor_name);
if ( (strcasecmp(floor_name, old_floor_name))
- && (strlen(old_floor_name) > 0) ) {
+ && (!IsEmptyStr(old_floor_name)) ) {
/** End inner box */
wprintf("<br>\n");
wprintf("</div>\n"); /** floordiv */
/** End inner box */
wprintf("<br>\n");
wprintf("</div>\n"); /** floordiv */
}
wprintf("num_drop_targets = %d;\n", num_drop_targets);
}
wprintf("num_drop_targets = %d;\n", num_drop_targets);
- if (strlen(WC->floordiv_expanded) > 1) {
+ if ((WC->floordiv_expanded[0] != '\0')&&
+ (WC->floordiv_expanded[1] != '\0')){
wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
}
wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
}
/** Determine whether the user is trying to change views */
if (bstr("view") != NULL) {
/** Determine whether the user is trying to change views */
if (bstr("view") != NULL) {
- if (strlen(bstr("view")) > 0) {
+ if (!IsEmptyStr(bstr("view"))) {
set_preference("roomlistview", bstr("view"), 1);
}
}
set_preference("roomlistview", bstr("view"), 1);
}
}
void set_room_policy(void) {
char buf[SIZ];
void set_room_policy(void) {
char buf[SIZ];
- if (strlen(bstr("ok_button")) == 0) {
+ if (IsEmptyStr(bstr("ok_button"))) {
strcpy(WC->ImportantMessage,
_("Cancelled. Changes were not saved."));
display_editroom();
strcpy(WC->ImportantMessage,
_("Cancelled. Changes were not saved."));
display_editroom();
}
wprintf(" %s", from);
wprintf(" in %s", room);
}
wprintf(" %s", from);
wprintf(" in %s", room);
- if (strcmp(hnod, serv_info.serv_humannode) && strlen(hnod) > 0) {
+ if (strcmp(hnod, serv_info.serv_humannode) && !IsEmptyStr(hnod)) {
wprintf(" on %s", hnod);
}
wprintf("</title>\n");
wprintf(" on %s", hnod);
}
wprintf("</title>\n");
wprintf(" <guid isPermaLink=\"false\">%s</guid>\n", msgn);
/** Now the hard part, the message itself */
strcpy(content_type, "text/plain");
wprintf(" <guid isPermaLink=\"false\">%s</guid>\n", msgn);
/** Now the hard part, the message itself */
strcpy(content_type, "text/plain");
- while (serv_getln(buf, sizeof buf), strlen(buf) > 0) {
+ while (serv_getln(buf, sizeof buf), !IsEmptyStr(buf)) {
if (!strcmp(buf, "000")) {
goto ENDBODY;
}
if (!strncasecmp(buf, "Content-type: ", 14)) {
if (!strcmp(buf, "000")) {
goto ENDBODY;
}
if (!strncasecmp(buf, "Content-type: ", 14)) {
safestrncpy(content_type, &buf[14], sizeof content_type);
safestrncpy(content_type, &buf[14], sizeof content_type);
- for (b = 0; b < strlen(content_type); ++b) {
+ len = strlen (content_type);
+ for (b = 0; b < len; ++b) {
if (!strncasecmp(&content_type[b], "charset=", 8)) {
safestrncpy(charset, &content_type[b + 8], sizeof charset);
}
}
if (!strncasecmp(&content_type[b], "charset=", 8)) {
safestrncpy(charset, &content_type[b + 8], sizeof charset);
}
}
- for (b = 0; b < strlen(content_type); ++b) {
+ for (b = 0; b < len; ++b) {
if (content_type[b] == ';') {
content_type[b] = 0;
if (content_type[b] == ';') {
content_type[b] = 0;
else if (!strcasecmp(content_type, "text/plain")) {
wprintf(" <description><![CDATA[");
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
else if (!strcasecmp(content_type, "text/plain")) {
wprintf(" <description><![CDATA[");
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- if (buf[strlen(buf)-1] == '\n') buf[strlen(buf)-1] = 0;
- if (buf[strlen(buf)-1] == '\r') buf[strlen(buf)-1] = 0;
+ int len;
+ len = strlen(buf);
+ if (buf[len-1] == '\n') buf[--len] = 0;
+ if (buf[len-1] == '\r') buf[--len] = 0;
#ifdef HAVE_ICONV
if (ic != (iconv_t)(-1) ) {
ibuf = buf;
#ifdef HAVE_ICONV
if (ic != (iconv_t)(-1) ) {
ibuf = buf;
- ibuflen = strlen(ibuf);
obuflen = SIZ;
obuf = (char *) malloc(obuflen);
osav = obuf;
obuflen = SIZ;
obuf = (char *) malloc(obuflen);
osav = obuf;
-
- while ((strlen(buf) > 0) && (isspace(buf[strlen(buf) - 1])))
- buf[strlen(buf) - 1] = 0;
+ len = strlen (buf);
+ while ((!IsEmptyStr(buf)) && (isspace(buf[len - 1])))
+ buf[--len] = 0;
if ((bq == 0) &&
((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
wprintf("<blockquote>");
if ((bq == 0) &&
((!strncmp(buf, ">", 1)) || (!strncmp(buf, " >", 2)) || (!strncmp(buf, " :-)", 4)))) {
wprintf("<blockquote>");
void text_to_server(char *ptr)
{
char buf[256];
void text_to_server(char *ptr)
{
char buf[256];
while (ptr[pos] != 0) {
ch = ptr[pos++];
if (ch == 10) {
while (ptr[pos] != 0) {
ch = ptr[pos++];
if (ch == 10) {
- while ( (isspace(buf[strlen(buf) - 1]))
- && (strlen(buf) > 1) )
- buf[strlen(buf) - 1] = 0;
+ len = strlen(buf);
+ while ( (isspace(buf[len - 1]))
+ && (buf[0] != '\0')
+ && (buf[1] != '\0') )
+ buf[--len] = 0;
serv_puts(buf);
buf[0] = 0;
if (ptr[pos] != 0) strcat(buf, " ");
serv_puts(buf);
buf[0] = 0;
if (ptr[pos] != 0) strcat(buf, " ");
* \brief Helper function for output_sieve_rule() to output strings with quotes escaped
*/
void osr_sanitize(char *str) {
* \brief Helper function for output_sieve_rule() to output strings with quotes escaped
*/
void osr_sanitize(char *str) {
- for (i=0; i<strlen(str); ++i) {
+ len = strlen(str);
+ for (i=0; i<len; ++i) {
if (str[i]=='\"') {
str[i] = '\'' ;
}
if (str[i]=='\"') {
str[i] = '\'' ;
}
char this_name[64];
char buf[256];
char this_name[64];
char buf[256];
- if (strlen(bstr("save_button")) == 0) {
+ if (IsEmptyStr(bstr("save_button"))) {
strcpy(WC->ImportantMessage,
_("Cancelled. Changes were not saved."));
display_main_menu();
strcpy(WC->ImportantMessage,
_("Cancelled. Changes were not saved."));
display_main_menu();
*/
/**
* \defgroup SMTPqueue Display the outbound SMTP queue
*/
/**
* \defgroup SMTPqueue Display the outbound SMTP queue
char thisrecp[256];
char thisdsn[256];
long msgid = 0;
char thisrecp[256];
char thisdsn[256];
long msgid = 0;
strcpy(sender, "");
strcpy(recipients, "");
strcpy(sender, "");
strcpy(recipients, "");
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- if (strlen(buf) > 0) {
- if (buf[strlen(buf)-1] == 13) {
- buf[strlen(buf)-1] = 0;
+ if (!IsEmptyStr(buf)) {
+ len = strlen(buf);
+ if (buf[len - 1] == 13) {
+ buf[len - 1] = 0;
- if ( (strlen(buf) == 0) && (in_body == 0) ) {
+ if ( (IsEmptyStr(buf) == 0) && (in_body == 0) ) {
if (strlen(recipients) + strlen(thisrecp) + strlen(thisdsn) + 100
< sizeof recipients) {
if (strlen(recipients) + strlen(thisrecp) + strlen(thisdsn) + 100
< sizeof recipients) {
- if (strlen(recipients) > 0) {
+ if (!IsEmptyStr(recipients)) {
strcat(recipients, "<br />");
}
stresc(&recipients[strlen(recipients)], thisrecp, 1, 1);
strcat(recipients, "<br />");
}
stresc(&recipients[strlen(recipients)], thisrecp, 1, 1);
- if (strlen(bstr("save_button")) == 0) {
+ if (IsEmptyStr(bstr("save_button"))) {
sprintf(WC->ImportantMessage,
_("Cancelled. %s was not saved."),
description);
sprintf(WC->ImportantMessage,
_("Cancelled. %s was not saved."),
description);
{
int a = 0;
int count = 1;
{
int a = 0;
int count = 1;
if (source == NULL)
return (0);
if (source == NULL)
return (0);
- for (a = 0; a < strlen(source); ++a) {
+ len = strlen(source);
+ for (a = 0; a < len; ++a) {
if (source[a] == tok)
++count;
}
if (source[a] == tok)
++count;
}
*/
int haschar(char *st,char ch)
{
*/
int haschar(char *st,char ch)
{
- for (a = 0; a < strlen(st); ++a)
+ len = strlen(st);
+ for (a = 0; a < len; ++a)
if (st[a] == ch)
++b;
return (b);
if (st[a] == ch)
++b;
return (b);
- if ((len < (maxlen - 1)) && (ch != 13) && (ch != 10)) {
- buf[strlen(buf) + 1] = 0;
- buf[strlen(buf)] = ch;
- ++len;
+ if ((len + 1 < (maxlen)) && (ch != 13) && (ch != 10)) {
+ buf[len++] = ch;
+ buf[len] = 0;
}
if ((ch == 10) || (ch == 0)) {
return ptr;
}
if ((ch == 10) || (ch == 0)) {
return ptr;
int pattern2(char *search, char *patn)
{
int a;
int pattern2(char *search, char *patn)
{
int a;
- for (a = 0; a < strlen(search); ++a) {
- if (!strncasecmp(&search[a], patn, strlen(patn)))
+ int len, plen;
+ len = strlen (search);
+ plen = strlen (patn);
+ for (a = 0; a < len; ++a) {
+ if (!strncasecmp(&search[a], patn, plen))
return (a);
}
return (-1);
}
return (a);
}
return (-1);
}
+/**
+ * \brief Strip leading and trailing spaces from a string; with premeasured and adjusted length.
+ * \param buf the string to modify
+ * \param len length of the string.
+ */
+void stripltlen(char *buf, int *len)
+{
+ int delta = 0;
+ if (*len == 0) return;
+ while ((*len > delta) && (isspace(buf[delta]))){
+ delta ++;
+ }
+ memmove (buf, &buf[delta], *len - delta + 1);
+ (*len) -=delta;
+
+ if (*len == 0) return;
+ while (isspace(buf[(*len) - 1])){
+ buf[--(*len)] = '\0';
+ }
+}
+
/**
* \brief Strip leading and trailing spaces from a string
* \param buf the string to modify
*/
void striplt(char *buf)
{
/**
* \brief Strip leading and trailing spaces from a string
* \param buf the string to modify
*/
void striplt(char *buf)
{
- if (len == 0) return;
- while ((len > 0) && (isspace(buf[0]))){
- memmove (buf, &buf[1], len);
- len --;
- }
- if (len == 0) return;
- while (isspace(buf[len - 1])){
- buf[len - 1] = 0;
- len --;
- }
int a;
int lb = (-1);
int rb = (-1);
int a;
int lb = (-1);
int rb = (-1);
do {
lb = (-1);
rb = (-1);
do {
lb = (-1);
rb = (-1);
- for (a = 0; a < strlen(str); ++a) {
+ for (a = 0; a < len; ++a) {
if (str[a] == leftboundary)
lb = a;
if (str[a] == rightboundary)
if (str[a] == leftboundary)
lb = a;
if (str[a] == rightboundary)
}
if ((lb > 0) && (rb > lb)) {
}
if ((lb > 0) && (rb > lb)) {
- strcpy(&str[lb - 1], &str[rb + 1]);
+ memmove(&str[lb - 1], &str[rb + 1], len - rb);
+ len -= (rb - lb + 2);
}
} while ((lb > 0) && (rb > lb));
}
} while ((lb > 0) && (rb > lb));
lastcall = extract_long(&buf[4], 7);
purgedays = extract_long(&buf[4], 8);
lastcall = extract_long(&buf[4], 7);
purgedays = extract_long(&buf[4], 8);
- if (strlen(bstr("edit_abe_button")) > 0) {
+ if (!IsEmptyStr(bstr("edit_abe_button"))) {
display_edit_address_book_entry(username, usernum);
return;
}
display_edit_address_book_entry(username, usernum);
return;
}
- if (strlen(bstr("delete_button")) > 0) {
+ if (!IsEmptyStr(bstr("delete_button"))) {
delete_user(username);
return;
}
delete_user(username);
return;
}
is_new = atoi(bstr("is_new"));
is_new = atoi(bstr("is_new"));
- if (strlen(bstr("ok_button")) == 0) {
+ if (IsEmptyStr(bstr("ok_button"))) {
safestrncpy(message, _("Changes were not saved."), sizeof message);
}
else {
safestrncpy(message, _("Changes were not saved."), sizeof message);
}
else {
remove_token(strbuf, i, ';');
}
}
remove_token(strbuf, i, ';');
}
}
- if (strlen(strbuf) > 0) {
- if (strbuf[strlen(strbuf)-1] == ';') {
- strbuf[strlen(strbuf)-1] = 0;
+ if (!IsEmptyStr(strbuf)) {
+ int len;
+ len = strlen(strbuf);
+ if (strbuf[len-1] == ';') {
+ strbuf[len-1] = 0;
int is_partial, int instance, int get_propname) {
int i;
int found_instance = 0;
int is_partial, int instance, int get_propname) {
int i;
int found_instance = 0;
+ len = strlen(propname);
if (v->numprops) for (i=0; i<(v->numprops); ++i) {
if ( (!strcasecmp(v->prop[i].name, propname))
|| (propname[0] == 0)
|| ( (!strncasecmp(v->prop[i].name,
if (v->numprops) for (i=0; i<(v->numprops); ++i) {
if ( (!strcasecmp(v->prop[i].name, propname))
|| (propname[0] == 0)
|| ( (!strncasecmp(v->prop[i].name,
- propname, strlen(propname)))
- && (v->prop[i].name[strlen(propname)] == ';')
+ propname, len))
+ && (v->prop[i].name[len] == ';')
&& (is_partial) ) ) {
if (instance == found_instance++) {
if (get_propname) {
&& (is_partial) ) ) {
if (instance == found_instance++) {
if (get_propname) {
- if (strlen(bstr("ok_button")) == 0) {
+ if (IsEmptyStr(bstr("ok_button"))) {
readloop("readnew");
return;
}
readloop("readnew");
return;
}
for (i=0; i<num_tokens(bstr("other_inetemail"), '\n'); ++i) {
extract_token(buf, bstr("other_inetemail"), i, '\n', sizeof buf);
for (i=0; i<num_tokens(bstr("other_inetemail"), '\n'); ++i) {
extract_token(buf, bstr("other_inetemail"), i, '\n', sizeof buf);
+ if (!IsEmptyStr(buf)) {
vcard_add_prop(v, "email;internet", buf);
}
}
vcard_add_prop(v, "email;internet", buf);
}
}
{
char *up, *ptr;
char buf[SIZ];
{
char *up, *ptr;
char buf[SIZ];
struct urlcontent *u;
up = url;
struct urlcontent *u;
up = url;
- while (strlen(up) > 0) {
+ while (!IsEmptyStr(up)) {
/** locate the = sign */
safestrncpy(buf, up, sizeof buf);
/** locate the = sign */
safestrncpy(buf, up, sizeof buf);
/** locate "&" and "?" delimiters */
ptr = up;
/** locate "&" and "?" delimiters */
ptr = up;
- b = strlen(up);
- for (a = 0; a < strlen(up); ++a) {
+ len = b = strlen(up);
+ for (a = 0; a < len; ++a) {
if ( (ptr[0] == '&') || (ptr[0] == '?') ) {
b = a;
break;
}
++ptr;
}
if ( (ptr[0] == '&') || (ptr[0] == '?') ) {
b = a;
break;
}
++ptr;
}
- ptr = up;
- for (a = 0; a < b; ++a)
- ++ptr;
- strcpy(ptr, "");
+ ptr = up + b;
+ *ptr = '\0';
- u->url_data = malloc(strlen(up) + 2);
- safestrncpy(u->url_data, up, strlen(up) + 1);
+ len = b;
+ u->url_data = malloc(len + 2);
+ safestrncpy(u->url_data, up, b + 1);
u->url_data[b] = 0;
unescape_input(u->url_data);
up = ptr;
u->url_data[b] = 0;
unescape_input(u->url_data);
up = ptr;
*/
void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
{
*/
void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
{
- for (a = 0; a < strlen(strbuf); ++a) {
+ len = strlen(strbuf);
+ for (a = 0; a < len; ++a) {
if (strbuf[a] == '<')
strcat(target, "<");
else if (strbuf[a] == '>')
if (strbuf[a] == '<')
strcat(target, "<");
else if (strbuf[a] == '>')
*/
void urlesc(char *outbuf, char *strbuf)
{
*/
void urlesc(char *outbuf, char *strbuf)
{
+ int a, b, c, len, eclen, olen;
char *ec = " #&;`'|*?-~<>^()[]{}/$\"\\";
strcpy(outbuf, "");
char *ec = " #&;`'|*?-~<>^()[]{}/$\"\\";
strcpy(outbuf, "");
-
- for (a = 0; a < strlen(strbuf); ++a) {
+ len = strlen(strbuf);
+ eclen = strlen(ec);
+ olen = 0;
+ for (a = 0; a < len; ++a) {
- for (b = 0; b < strlen(ec); ++b) {
+ for (b = 0; b < eclen; ++b) {
if (strbuf[a] == ec[b])
c = 1;
}
if (strbuf[a] == ec[b])
c = 1;
}
- b = strlen(outbuf);
- if (c == 1)
- sprintf(&outbuf[b], "%%%02x", strbuf[a]);
- else
- sprintf(&outbuf[b], "%c", strbuf[a]);
+ if (c == 1) {
+ sprintf(&outbuf[olen], "%%%02x", strbuf[a]);
+ olen += 3;
+ }
+ else
+ outbuf[olen ++] = strbuf[a];
*/
void jsesc(char *target, char *strbuf)
{
*/
void jsesc(char *target, char *strbuf)
{
- int a;
- strcpy(target, "");
- for (a = 0; a < strlen(strbuf); ++a) {
+ target[0]='\0';
+ len = strlen (strbuf);
+ for (a = 0; a < len; ++a) {
if (strbuf[a] == '<')
strcat(target, "[");
else if (strbuf[a] == '>')
if (strbuf[a] == '<')
strcat(target, "[");
else if (strbuf[a] == '>')
*/
void msgesc(char *target, char *strbuf)
{
*/
void msgesc(char *target, char *strbuf)
{
- int a;
- strcpy(target, "");
- for (a = 0; a < strlen(strbuf); ++a) {
+ *target='\0';
+ len = strlen(strbuf);
+ for (a = 0; a < len; ++a) {
if (strbuf[a] == '\n')
strcat(target, " ");
else if (strbuf[a] == '\r')
if (strbuf[a] == '\n')
strcat(target, " ");
else if (strbuf[a] == '\r')
/** check for ImportantMessages (these display in a div overlaying the main screen) */
/** check for ImportantMessages (these display in a div overlaying the main screen) */
- if (strlen(WC->ImportantMessage) > 0) {
+ if (!IsEmptyStr(WC->ImportantMessage)) {
wprintf("<div id=\"important_message\">\n");
wprintf("<span class=\"imsg\">"
"%s</span><br />\n", WC->ImportantMessage);
wprintf("<div id=\"important_message\">\n");
wprintf("<span class=\"imsg\">"
"%s</span><br />\n", WC->ImportantMessage);
off_t bytes;
char *bigbuffer;
char content_type[128];
off_t bytes;
char *bigbuffer;
char content_type[128];
fp = fopen(what, "rb");
if (fp == NULL) {
fp = fopen(what, "rb");
if (fp == NULL) {
wprintf("\r\n");
wprintf("Cannot open %s: %s\n", what, strerror(errno));
} else {
wprintf("\r\n");
wprintf("Cannot open %s: %s\n", what, strerror(errno));
} else {
- if (!strncasecmp(&what[strlen(what) - 4], ".gif", 4))
+ len = strlen (what);
+ if (!strncasecmp(&what[len - 4], ".gif", 4))
safestrncpy(content_type, "image/gif", sizeof content_type);
safestrncpy(content_type, "image/gif", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 4], ".txt", 4))
+ else if (!strncasecmp(&what[len - 4], ".txt", 4))
safestrncpy(content_type, "text/plain", sizeof content_type);
safestrncpy(content_type, "text/plain", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 4], ".css", 4))
+ else if (!strncasecmp(&what[len - 4], ".css", 4))
safestrncpy(content_type, "text/css", sizeof content_type);
safestrncpy(content_type, "text/css", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 4], ".jpg", 4))
+ else if (!strncasecmp(&what[len - 4], ".jpg", 4))
safestrncpy(content_type, "image/jpeg", sizeof content_type);
safestrncpy(content_type, "image/jpeg", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 4], ".png", 4))
+ else if (!strncasecmp(&what[len - 4], ".png", 4))
safestrncpy(content_type, "image/png", sizeof content_type);
safestrncpy(content_type, "image/png", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 4], ".ico", 4))
+ else if (!strncasecmp(&what[len - 4], ".ico", 4))
safestrncpy(content_type, "image/x-icon", sizeof content_type);
safestrncpy(content_type, "image/x-icon", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 5], ".html", 5))
+ else if (!strncasecmp(&what[len - 5], ".html", 5))
safestrncpy(content_type, "text/html", sizeof content_type);
safestrncpy(content_type, "text/html", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 4], ".htm", 4))
+ else if (!strncasecmp(&what[len - 4], ".htm", 4))
safestrncpy(content_type, "text/html", sizeof content_type);
safestrncpy(content_type, "text/html", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 4], ".wml", 4))
+ else if (!strncasecmp(&what[len - 4], ".wml", 4))
safestrncpy(content_type, "text/vnd.wap.wml", sizeof content_type);
safestrncpy(content_type, "text/vnd.wap.wml", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 5], ".wmls", 5))
+ else if (!strncasecmp(&what[len - 5], ".wmls", 5))
safestrncpy(content_type, "text/vnd.wap.wmlscript", sizeof content_type);
safestrncpy(content_type, "text/vnd.wap.wmlscript", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 5], ".wmlc", 5))
+ else if (!strncasecmp(&what[len - 5], ".wmlc", 5))
safestrncpy(content_type, "application/vnd.wap.wmlc", sizeof content_type);
safestrncpy(content_type, "application/vnd.wap.wmlc", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 6], ".wmlsc", 6))
+ else if (!strncasecmp(&what[len - 6], ".wmlsc", 6))
safestrncpy(content_type, "application/vnd.wap.wmlscriptc", sizeof content_type);
safestrncpy(content_type, "application/vnd.wap.wmlscriptc", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 5], ".wbmp", 5))
+ else if (!strncasecmp(&what[len - 5], ".wbmp", 5))
safestrncpy(content_type, "image/vnd.wap.wbmp", sizeof content_type);
safestrncpy(content_type, "image/vnd.wap.wbmp", sizeof content_type);
- else if (!strncasecmp(&what[strlen(what) - 3], ".js", 3))
+ else if (!strncasecmp(&what[len - 3], ".js", 3))
safestrncpy(content_type, "text/javascript", sizeof content_type);
else
safestrncpy(content_type, "application/octet-stream", sizeof content_type);
safestrncpy(content_type, "text/javascript", sizeof content_type);
else
safestrncpy(content_type, "application/octet-stream", sizeof content_type);
lprintf(9, "upload_handler() name=%s, type=%s, len=%d\n", name, cbtype, length);
/* Form fields */
lprintf(9, "upload_handler() name=%s, type=%s, len=%d\n", name, cbtype, length);
/* Form fields */
- if ( (length > 0) && (strlen(cbtype) == 0) ) {
+ if ( (length > 0) && (IsEmptyStr(cbtype)) ) {
u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
u->next = WC->urlstrings;
WC->urlstrings = u;
u = (struct urlcontent *) malloc(sizeof(struct urlcontent));
u->next = WC->urlstrings;
WC->urlstrings = u;
- if ( (length > 0) && (strlen(cbtype) > 0) ) {
+ if ( (length > 0) && (!IsEmptyStr(cbtype)) ) {
WC->upload = malloc(length);
if (WC->upload != NULL) {
WC->upload_length = length;
WC->upload = malloc(length);
if (WC->upload != NULL) {
WC->upload_length = length;
int body_start = 0;
int is_static = 0;
int n_static = 0;
int body_start = 0;
int is_static = 0;
int n_static = 0;
/**
* We stuff these with the values coming from the client cookies,
* so we can use them to reconnect a timed out session if we have to.
/**
* We stuff these with the values coming from the client cookies,
* so we can use them to reconnect a timed out session if we have to.
}
}
else if (!strncasecmp(buf, "Host: ", 6)) {
}
}
else if (!strncasecmp(buf, "Host: ", 6)) {
- if (strlen(WC->http_host) == 0) {
+ if (IsEmptyStr(WC->http_host)) {
safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
}
}
safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
}
}
remove_token(WC->this_page, 0, ' ');
/** If there are variables in the URL, we must grab them now */
remove_token(WC->this_page, 0, ' ');
/** If there are variables in the URL, we must grab them now */
- for (a = 0; a < strlen(cmd); ++a) {
+ len = strlen(cmd);
+ for (a = 0; a < len; ++a) {
if ((cmd[a] == '?') || (cmd[a] == '&')) {
if ((cmd[a] == '?') || (cmd[a] == '&')) {
- for (b = a; b < strlen(cmd); ++b)
- if (isspace(cmd[b]))
+ for (b = a; b < len; ++b) {
+ if (isspace(cmd[b])){
addurls(&cmd[a + 1]);
cmd[a] = 0;
addurls(&cmd[a + 1]);
cmd[a] = 0;
* supplied by the browser, try using them to log in.
*/
if ((!WC->logged_in)
* supplied by the browser, try using them to log in.
*/
if ((!WC->logged_in)
- && (strlen(c_username) > 0)
- && (strlen(c_password) > 0)) {
+ && (!IsEmptyStr(c_username))
+ && (!IsEmptyStr(c_password))) {
serv_printf("USER %s", c_username);
serv_getln(buf, sizeof buf);
if (buf[0] == '3') {
serv_printf("USER %s", c_username);
serv_getln(buf, sizeof buf);
if (buf[0] == '3') {
* If we don't have a current room, but a cookie specifying the
* current room is supplied, make an effort to go there.
*/
* If we don't have a current room, but a cookie specifying the
* current room is supplied, make an effort to go there.
*/
- if ((strlen(WC->wc_roomname) == 0) && (strlen(c_roomname) > 0)) {
+ if ((IsEmptyStr(WC->wc_roomname)) && (!IsEmptyStr(c_roomname))) {
serv_printf("GOTO %s", c_roomname);
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
serv_printf("GOTO %s", c_roomname);
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
#define _(string) (string)
#endif
#define _(string) (string)
#endif
+#define IsEmptyStr(a) ((a)[0] == '\0')
/*
* Uncomment to dump an HTTP trace to stderr
#define HTTP_TRACING 1
/*
* Uncomment to dump an HTTP trace to stderr
#define HTTP_TRACING 1
void edit_vcard(void);
void submit_vcard(void);
void striplt(char *);
void edit_vcard(void);
void submit_vcard(void);
void striplt(char *);
+void stripltlen(char *, int *);
void select_user_to_edit(char *message, char *preselect);
void delete_user(char *);
void display_edituser(char *who, int is_new);
void select_user_to_edit(char *message, char *preselect);
void delete_user(char *);
void display_edituser(char *who, int is_new);
* Strip any trailing non-printable characters.
*/
buf[i] = 0;
* Strip any trailing non-printable characters.
*/
buf[i] = 0;
- while ((strlen(buf) > 0) && (!isprint(buf[strlen(buf) - 1]))) {
- buf[strlen(buf) - 1] = 0;
+ while ((i > 0) && (!isprint(buf[i - 1]))) {
+ buf[--i] = 0;
* exits if it doesn't succeed.
*/
* exits if it doesn't succeed.
*/
- if (strlen(uds_listen_path) > 0) {
+ if (!IsEmptyStr(uds_listen_path)) {
lprintf(2, "Attempting to create listener socket at %s...\n", uds_listen_path);
msock = ig_uds_server(uds_listen_path, LISTEN_QUEUE_LENGTH);
}
lprintf(2, "Attempting to create listener socket at %s...\n", uds_listen_path);
msock = ig_uds_server(uds_listen_path, LISTEN_QUEUE_LENGTH);
}
/** room */
wprintf("</td>\n\t<td>");
escputs(room);
/** room */
wprintf("</td>\n\t<td>");
escputs(room);
- if (strlen(realroom) > 0) {
+ if (!IsEmptyStr(realroom) ) {
wprintf("<br /><i>");
escputs(realroom);
wprintf("</i>");
wprintf("<br /><i>");
escputs(realroom);
wprintf("</i>");
/** hostname */
escputs(host);
/** hostname */
escputs(host);
- if (strlen(realhost) > 0) {
+ if (!IsEmptyStr(realhost)) {
wprintf("<br /><i>");
escputs(realhost);
wprintf("</i>");
wprintf("<br /><i>");
escputs(realhost);
wprintf("</i>");
- if (strlen(bstr("change_room_name_button")) > 0) {
+ if (!IsEmptyStr(bstr("change_room_name_button"))) {
serv_printf("RCHG %s", bstr("fake_roomname"));
serv_getln(buf, sizeof buf);
http_redirect("who");
serv_printf("RCHG %s", bstr("fake_roomname"));
serv_getln(buf, sizeof buf);
http_redirect("who");
- } else if (strlen(bstr("change_host_name_button")) > 0) {
+ } else if (!IsEmptyStr(bstr("change_host_name_button"))) {
serv_printf("HCHG %s", bstr("fake_hostname"));
serv_getln(buf, sizeof buf);
http_redirect("who");
serv_printf("HCHG %s", bstr("fake_hostname"));
serv_getln(buf, sizeof buf);
http_redirect("who");
- } else if (strlen(bstr("change_user_name_button")) > 0) {
+ } else if (!IsEmptyStr(bstr("change_user_name_button"))) {
serv_printf("UCHG %s", bstr("fake_username"));
serv_getln(buf, sizeof buf);
http_redirect("who");
serv_printf("UCHG %s", bstr("fake_username"));
serv_getln(buf, sizeof buf);
http_redirect("who");
- } else if (strlen(bstr("cancel_button")) > 0) {
+ } else if (!IsEmptyStr(bstr("cancel_button"))) {
http_redirect("who");
} else {
output_headers(1, 1, 0, 0, 0, 0);
http_redirect("who");
} else {
output_headers(1, 1, 0, 0, 0, 0);
safestrncpy(pagename, bstr("page"), sizeof pagename);
str_wiki_index(pagename);
safestrncpy(pagename, bstr("page"), sizeof pagename);
str_wiki_index(pagename);
- if (strlen(roomname) > 0) {
+ if (!IsEmptyStr(roomname)) {
/* If we're not in the correct room, try going there. */
if (strcasecmp(roomname, WC->wc_roomname)) {
/* If we're not in the correct room, try going there. */
if (strcasecmp(roomname, WC->wc_roomname)) {
- if (strlen(pagename) == 0) {
+ if (IsEmptyStr(pagename)) {
strcpy(pagename, "home");
}
strcpy(pagename, "home");
}