From 9f145319b92b196662aa51cb2e3d7c392629965e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Fri, 4 Apr 2008 10:44:32 +0000 Subject: [PATCH] * we have now several bstrs: * bstr: simply gives the string * xbstr: gives string and its length * lbstr: gives the long value of the item * ibstr: gives the int value of the item * havebstr: whether this bstr and if it wasn't set empty * yesbstr: returns true if the value equals "yes" there also is a CAPITAL version of each, for dynamicaly calculated keys. * replaced all atol(bstr()), strcmp(bstr(), "yes") IsEmptyStr(bstr()) by the above. --- webcit/auth.c | 14 ++--- webcit/calendar.c | 18 +++--- webcit/calendar_view.c | 10 ++-- webcit/downloads.c | 5 +- webcit/event.c | 40 +++++++------- webcit/floors.c | 4 +- webcit/graphics.c | 2 +- webcit/iconbar.c | 4 +- webcit/mainmenu.c | 2 +- webcit/messages.c | 95 ++++++++++++++++++------------- webcit/netconf.c | 2 +- webcit/paging.c | 10 ++-- webcit/preferences.c | 2 +- webcit/roomops.c | 74 ++++++++++++------------- webcit/sieve.c | 6 +- webcit/siteconfig.c | 34 ++++++------ webcit/sysmsgs.c | 2 +- webcit/useredit.c | 16 +++--- webcit/vcard_edit.c | 6 +- webcit/webcit.c | 123 +++++++++++++++++++++++++++++++++++------ webcit/webcit.h | 26 ++++++++- webcit/who.c | 8 +-- 22 files changed, 318 insertions(+), 185 deletions(-) diff --git a/webcit/auth.c b/webcit/auth.c index 5e1bda48a..b26196919 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -142,16 +142,16 @@ void do_login(void) { char buf[SIZ]; - if (!IsEmptyStr(bstr("language"))) { + if (havebstr("language")) { set_selected_language(bstr("language")); go_selected_language(); } - if (!IsEmptyStr(bstr("exit_action"))) { + if (havebstr("exit_action")) { do_logout(); return; } - if (!IsEmptyStr(bstr("login_action"))) { + if (havebstr("login_action")) { serv_printf("USER %s", bstr("name")); serv_getln(buf, sizeof buf); if (buf[0] == '3') { @@ -169,8 +169,8 @@ void do_login(void) return; } } - if (!IsEmptyStr(bstr("newuser_action"))) { - if (IsEmptyStr(bstr("pass"))) { + if (havebstr("newuser_action")) { + if (!havebstr("pass")) { display_login(_("Blank passwords are not allowed.")); return; } @@ -349,7 +349,7 @@ void validate(void) /** If the user just submitted a validation, process it... */ safestrncpy(buf, bstr("user"), sizeof buf); if (!IsEmptyStr(buf)) { - if (!IsEmptyStr(bstr("axlevel"))) { + if (havebstr("axlevel")) { serv_printf("VALI %s|%s", buf, bstr("axlevel")); serv_getln(buf, sizeof buf); if (buf[0] != '2') { @@ -521,7 +521,7 @@ void changepw(void) char buf[SIZ]; char newpass1[32], newpass2[32]; - if (IsEmptyStr(bstr("change_action"))) { + if (!havebstr("change_action")) { safestrncpy(WC->ImportantMessage, _("Cancelled. Password was not changed."), sizeof WC->ImportantMessage); diff --git a/webcit/calendar.c b/webcit/calendar.c index bb1166d8b..7e81620e4 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -579,7 +579,7 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from created_new_vtodo = 1; } - if (!IsEmptyStr(bstr("save_button"))) { + if (havebstr("save_button")) { /** Replace values in the component with ones from the form */ @@ -588,7 +588,7 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from icalcomponent_remove_property(vtodo, prop); icalproperty_free(prop); } - if (!IsEmptyStr(bstr("summary"))) { + if (havebstr("summary")) { icalcomponent_add_property(vtodo, icalproperty_new_summary(bstr("summary"))); @@ -683,12 +683,12 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from /** * If the user clicked 'Delete' then explicitly delete the message. */ - if (!IsEmptyStr(bstr("delete_button"))) { + if (havebstr("delete_button")) { delete_existing = 1; } if ( (delete_existing) && (msgnum > 0L) ) { - serv_printf("DELE %ld", atol(bstr("msgnum"))); + serv_printf("DELE %ld", lbstr("msgnum")); serv_getln(buf, sizeof buf); } @@ -812,11 +812,11 @@ void display_edit_task(void) { long msgnum = 0L; /** Force change the room if we have to */ - if (!IsEmptyStr(bstr("taskrm"))) { + if (havebstr("taskrm")) { gotoroom(bstr("taskrm")); } - msgnum = atol(bstr("msgnum")); + msgnum = lbstr("msgnum"); if (msgnum > 0L) { /** existing task */ display_using_handler(msgnum, 0, @@ -835,7 +835,7 @@ void display_edit_task(void) { void save_task(void) { long msgnum = 0L; - msgnum = atol(bstr("msgnum")); + msgnum = lbstr("msgnum"); if (msgnum > 0L) { display_using_handler(msgnum, 0, ICAL_VTODO_COMPONENT, @@ -852,7 +852,7 @@ void save_task(void) { void display_edit_event(void) { long msgnum = 0L; - msgnum = atol(bstr("msgnum")); + msgnum = lbstr("msgnum"); if (msgnum > 0L) { /* existing event */ display_using_handler(msgnum, 0, @@ -871,7 +871,7 @@ void display_edit_event(void) { void save_event(void) { long msgnum = 0L; - msgnum = atol(bstr("msgnum")); + msgnum = lbstr("msgnum"); if (msgnum > 0L) { display_using_handler(msgnum, 0, diff --git a/webcit/calendar_view.c b/webcit/calendar_view.c index 2f8421dff..78325f835 100644 --- a/webcit/calendar_view.c +++ b/webcit/calendar_view.c @@ -157,7 +157,7 @@ void ajax_mini_calendar(void) { urlformat[i+1] = 0; } - embeddable_mini_calendar( atoi(bstr("year")), atoi(bstr("month")), urlformat ); + embeddable_mini_calendar( ibstr("year"), ibstr("month"), urlformat ); } @@ -1346,12 +1346,12 @@ void do_calendar_view(void) { day = tm.tm_mday; /** Now see if a date was specified */ - if (!IsEmptyStr(bstr("year"))) year = atoi(bstr("year")); - if (!IsEmptyStr(bstr("month"))) month = atoi(bstr("month")); - if (!IsEmptyStr(bstr("day"))) day = atoi(bstr("day")); + if (havebstr("year")) year = ibstr("year"); + if (havebstr("month")) month = ibstr("month"); + if (havebstr("day")) day = ibstr("day"); /** How would you like that cooked? */ - if (!IsEmptyStr(bstr("calview"))) { + if (havebstr("calview")) { strcpy(calview, bstr("calview")); } else { diff --git a/webcit/downloads.c b/webcit/downloads.c index 2ed8e247c..a208e51b7 100644 --- a/webcit/downloads.c +++ b/webcit/downloads.c @@ -99,7 +99,7 @@ void display_pictureview(void) int n = 0; - if (atol(bstr("frame")) == 1) { + if (lbstr("frame") == 1) { output_headers(1, 1, 2, 0, 0, 0); wprintf("
\n"); @@ -158,8 +158,9 @@ void display_mime_icon(void) { char FileBuf[SIZ]; const char *FileName; + size_t tlen; - FileName = GetIconFilename(bstr("type"), strlen(bstr("type"))); + FileName = GetIconFilename(xbstr("type", &tlen), tlen); if (FileName == NULL) snprintf (FileBuf, SIZ, "%s%s", static_dirs[0], "/diskette_24x.gif"); diff --git a/webcit/event.c b/webcit/event.c index c9deb38b6..d1a6e6e36 100644 --- a/webcit/event.c +++ b/webcit/event.c @@ -174,14 +174,14 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, } else { localtime_r(&now, &tm_now); - 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")); + if (havebstr("year")) { + tm_now.tm_year = ibstr("year") - 1900; + tm_now.tm_mon = ibstr("month") - 1; + tm_now.tm_mday = ibstr("day"); } - if (!IsEmptyStr(bstr("hour"))) { - tm_now.tm_hour = atoi(bstr("hour")); - tm_now.tm_min = atoi(bstr("minute")); + if (havebstr("hour")) { + tm_now.tm_hour = ibstr("hour"); + tm_now.tm_min = ibstr("minute"); tm_now.tm_sec = 0; } else { @@ -192,7 +192,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, t_start = icaltime_from_timet_with_zone( mktime(&tm_now), - ((!strcasecmp(bstr("alldayevent"), "yes")) ? 1 : 0), + ((yesbstr("alldayevent")) ? 1 : 0), icaltimezone_get_utc_timezone() ); t_start.is_utc = 1; @@ -464,8 +464,8 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr created_new_vevent = 1; } - if ( (!IsEmptyStr(bstr("save_button"))) - || (!IsEmptyStr(bstr("check_button"))) ) { + if ( (havebstr("save_button")) + || (havebstr("check_button")) ) { /** Replace values in the component with ones from the form */ @@ -475,7 +475,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr icalproperty_free(prop); } - if (!IsEmptyStr(bstr("summary"))) { + if (havebstr("summary")) { icalcomponent_add_property(vevent, icalproperty_new_summary(bstr("summary"))); @@ -489,7 +489,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr icalcomponent_remove_property(vevent, prop); icalproperty_free(prop); } - if (!IsEmptyStr(bstr("location"))) { + if (havebstr("location")) { icalcomponent_add_property(vevent, icalproperty_new_location(bstr("location"))); } @@ -498,7 +498,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr icalcomponent_remove_property(vevent, prop); icalproperty_free(prop); } - if (!IsEmptyStr(bstr("description"))) { + if (havebstr("description")) { icalcomponent_add_property(vevent, icalproperty_new_description(bstr("description"))); } @@ -509,7 +509,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr icalproperty_free(prop); } - if (!strcmp(bstr("alldayevent"), "yes")) { + if (yesbstr("alldayevent")) { all_day_event = 1; } else { @@ -559,7 +559,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr } /** See if transparency is indicated */ - if (!IsEmptyStr(bstr("transp"))) { + if (havebstr("transp")) { if (!strcasecmp(bstr("transp"), "opaque")) { formtransp = ICAL_TRANSP_OPAQUE; } @@ -690,7 +690,7 @@ STARTOVER: for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE icalcomponent_set_method(encaps, ICAL_METHOD_PUBLISH); /** If the user clicked 'Save' then save it to the server. */ - if ( (encaps != NULL) && (!IsEmptyStr(bstr("save_button"))) ) { + if ( (encaps != NULL) && (havebstr("save_button")) ) { serv_puts("ENT0 1|||4|||1|"); serv_getln(buf, sizeof buf); if (buf[0] == '8') { @@ -711,7 +711,7 @@ STARTOVER: for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE } /** Or, check attendee availability if the user asked for that. */ - if ( (encaps != NULL) && (!IsEmptyStr(bstr("check_button"))) ) { + if ( (encaps != NULL) && (havebstr("check_button")) ) { /** Call this function, which does the real work */ check_attendee_availability(encaps); @@ -727,8 +727,8 @@ STARTOVER: for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE /** * If the user clicked 'Delete' then delete it. */ - if ( (!IsEmptyStr(bstr("delete_button"))) && (msgnum > 0L) ) { - serv_printf("DELE %ld", atol(bstr("msgnum"))); + if ( (havebstr("delete_button")) && (msgnum > 0L) ) { + serv_printf("DELE %ld", lbstr("msgnum")); serv_getln(buf, sizeof buf); } @@ -737,7 +737,7 @@ STARTOVER: for (attendee = icalcomponent_get_first_property(vevent, ICAL_ATTENDE } /** If this was a save or delete, go back to the calendar view. */ - if (IsEmptyStr(bstr("check_button"))) { + if (!havebstr("check_button")) { readloop("readfwd"); } } diff --git a/webcit/floors.c b/webcit/floors.c index fb268ff48..f662ab408 100644 --- a/webcit/floors.c +++ b/webcit/floors.c @@ -139,7 +139,7 @@ void delete_floor(void) { char buf[SIZ]; char message[SIZ]; - floornum = atoi(bstr("floornum")); + floornum = ibstr("floornum"); serv_printf("KFLR %d|1", floornum); serv_getln(buf, sizeof buf); @@ -185,7 +185,7 @@ void rename_floor(void) { char message[SIZ]; char floorname[SIZ]; - floornum = atoi(bstr("floornum")); + floornum = ibstr("floornum"); strcpy(floorname, bstr("floorname")); serv_printf("EFLR %d|%s", floornum, floorname); diff --git a/webcit/graphics.c b/webcit/graphics.c index 3c16baf41..e9c0d8c34 100644 --- a/webcit/graphics.c +++ b/webcit/graphics.c @@ -66,7 +66,7 @@ void do_graphics_upload(char *filename) int thisblock; bytes_remaining = WC->upload_length; - if (!IsEmptyStr(bstr("cancel_button"))) { + if (havebstr("cancel_button")) { strcpy(WC->ImportantMessage, _("Graphics upload has been cancelled.")); display_main_menu(); diff --git a/webcit/iconbar.c b/webcit/iconbar.c index eceb4c864..25c1b9e2e 100644 --- a/webcit/iconbar.c +++ b/webcit/iconbar.c @@ -764,12 +764,12 @@ void commit_iconbar(void) { "ib_citadel" }; - if (IsEmptyStr(bstr("ok_button"))) { + if (!havebstr("ok_button")) { display_main_menu(); return; } - sprintf(iconbar, "ib_displayas=%d", atoi(bstr("ib_displayas"))); + sprintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas")); for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) { char *Val; diff --git a/webcit/mainmenu.c b/webcit/mainmenu.c index 8673df5d8..a869e8b3b 100644 --- a/webcit/mainmenu.c +++ b/webcit/mainmenu.c @@ -254,7 +254,7 @@ void do_generic(void) char *junk; size_t len; - if (IsEmptyStr(bstr("sc_button"))) { + if (!havebstr("sc_button")) { display_main_menu(); return; } diff --git a/webcit/messages.c b/webcit/messages.c index f9e0ae767..a36bd38b4 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -2320,9 +2320,9 @@ void readloop(char *oper) return; } - startmsg = atol(bstr("startmsg")); - maxmsgs = atoi(bstr("maxmsgs")); - is_summary = atoi(bstr("is_summary")); + startmsg = lbstr("startmsg"); + maxmsgs = ibstr("maxmsgs"); + is_summary = ibstr("is_summary"); if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS; snprintf(sortpref_name, sizeof sortpref_name, "sort %s", WCC->wc_roomname); @@ -2408,7 +2408,7 @@ void readloop(char *oper) } } - is_singlecard = atoi(bstr("is_singlecard")); + is_singlecard = ibstr("is_singlecard"); if (WCC->wc_default_view == VIEW_CALENDAR) { /**< calendar */ is_calendar = 1; @@ -3017,7 +3017,7 @@ void post_message(void) struct wcsession *WCC = WC; char *ptr = NULL; - if (!IsEmptyStr(bstr("force_room"))) { + if (havebstr("force_room")) { gotoroom(bstr("force_room")); } @@ -3078,13 +3078,13 @@ void post_message(void) return; } - if (!IsEmptyStr(bstr("cancel_button"))) { + if (havebstr("cancel_button")) { sprintf(WCC->ImportantMessage, _("Cancelled. Message was not posted.")); - } else if (!IsEmptyStr(bstr("attach_button"))) { + } else if (havebstr("attach_button")) { display_enter(); return; - } else if (atol(bstr("postseq")) == dont_post) { + } else if (lbstr("postseq") == dont_post) { sprintf(WCC->ImportantMessage, _("Automatically cancelled because you have already " "saved this message.")); @@ -3155,16 +3155,16 @@ void post_message(void) if (encoded_subject) free(encoded_subject); if (buf[0] == '4') { post_mime_to_server(); - if ( (!IsEmptyStr(bstr("recp"))) - || (!IsEmptyStr(bstr("cc" ))) - || (!IsEmptyStr(bstr("bcc" ))) + if ( (havebstr("recp")) + || (havebstr("cc" )) + || (havebstr("bcc" )) ) { sprintf(WCC->ImportantMessage, _("Message has been sent.\n")); } else { sprintf(WC->ImportantMessage, _("Message has been posted.\n")); } - dont_post = atol(bstr("postseq")); + dont_post = lbstr("postseq"); } else { lprintf(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, buf); sprintf(WC->ImportantMessage, "%s", &buf[4]); @@ -3179,13 +3179,13 @@ void post_message(void) * We may have been supplied with instructions regarding the location * to which we must return after posting. If found, go there. */ - if (!IsEmptyStr(bstr("return_to"))) { + if (havebstr("return_to")) { http_redirect(bstr("return_to")); } /** * If we were editing a page in a wiki room, go to that page now. */ - else if (!IsEmptyStr(bstr("wikipage"))) { + else if (havebstr("wikipage")) { snprintf(buf, sizeof buf, "wiki?page=%s", bstr("wikipage")); http_redirect(buf); } @@ -3216,16 +3216,18 @@ void display_enter(void) int i; int is_anonymous = 0; long existing_page = (-1L); + size_t dplen; now = time(NULL); - if (!IsEmptyStr(bstr("force_room"))) { + if (havebstr("force_room")) { gotoroom(bstr("force_room")); } - display_name = bstr("display_name"); + display_name = xbstr("display_name", &dplen); if (!strcmp(display_name, "__ANONYMOUS__")) { display_name = ""; + dplen = 0; is_anonymous = 1; } @@ -3287,18 +3289,40 @@ void display_enter(void) /* Now check our actual recipients if there are any */ if (recipient_required) { - sprintf(buf, "ENT0 0|%s|%d|0||%s||%s|%s|%s", - bstr("recp"), + const char *Recp = ""; + const char *Cc = ""; + const char *Bcc = ""; + const char *Wikipage = ""; + char *CmdBuf = NULL;; + size_t len = 0; + size_t nLen; + const char CMD[] = "ENT0 0|%s|%d|0||%s||%s|%s|%s"; + + len = sizeof(CMD) + dplen; + Recp = xbstr("recp", &nLen); + len += nLen; + Cc = xbstr("cc", &nLen); + len += nLen; + Bcc = xbstr("bcc", &nLen); + len += nLen; + Wikipage = xbstr("wikipage", &nLen); + len += nLen; + + + CmdBuf = (char*) malloc (len + 1); + + snprintf(CmdBuf, len, CMD, + Recp, is_anonymous, display_name, - bstr("cc"), bstr("bcc"), bstr("wikipage")); + Cc, Bcc, Wikipage); serv_puts(buf); serv_getln(buf, sizeof buf); if (!strncmp(buf, "570", 3)) { /** 570 means we have an invalid recipient listed */ - if (!IsEmptyStr(bstr("recp")) && - !IsEmptyStr(bstr("cc" )) && - !IsEmptyStr(bstr("bcc" ))) { + if (havebstr("recp") && + havebstr("cc" ) && + havebstr("bcc" )) { recipient_bad = 1; } } @@ -3418,8 +3442,7 @@ void display_enter(void) wprintf(_("To:")); wprintf("" "" "" " 0L) { + if (lbstr("fwdquote") > 0L) { wprintf("
"); wprintf(_("--- forwarded message ---")); wprintf("

"); - pullquote_message(atol(bstr("fwdquote")), 1, 1); + pullquote_message(lbstr("fwdquote"), 1, 1); } /** If we're replying quoted, insert the quote here... */ - else if (atol(bstr("replyquote")) > 0L) { + else if (lbstr("replyquote") > 0L) { wprintf("
" "
"); - pullquote_message(atol(bstr("replyquote")), 0, 1); + pullquote_message(lbstr("replyquote"), 0, 1); wprintf("

"); } @@ -3528,7 +3549,7 @@ void display_enter(void) } /** Insert our signature if appropriate... */ - if ( (WC->is_mailbox) && (strcmp(bstr("sig_inserted"), "yes")) ) { + if ( (WC->is_mailbox) && yesbstr("sig_inserted") ) { get_preference("use_sig", buf, sizeof buf); if (!strcasecmp(buf, "yes")) { int len; @@ -3617,7 +3638,7 @@ void delete_msg(void) long msgid; char buf[SIZ]; - msgid = atol(bstr("msgid")); + msgid = lbstr("msgid"); if (WC->wc_is_trash) { /** Delete from Trash is a real delete */ serv_printf("DELE %ld", msgid); @@ -3641,9 +3662,9 @@ void move_msg(void) long msgid; char buf[SIZ]; - msgid = atol(bstr("msgid")); + msgid = lbstr("msgid"); - if (!IsEmptyStr(bstr("move_button"))) { + if (havebstr("move_button")) { sprintf(buf, "MOVE %ld|%s", msgid, bstr("target_room")); serv_puts(buf); serv_getln(buf, sizeof buf); @@ -3668,7 +3689,7 @@ void confirm_move_msg(void) char buf[SIZ]; char targ[SIZ]; - msgid = atol(bstr("msgid")); + msgid = lbstr("msgid"); output_headers(1, 1, 2, 0, 0, 0); diff --git a/webcit/netconf.c b/webcit/netconf.c index 1dde529ba..ee7c5a91f 100644 --- a/webcit/netconf.c +++ b/webcit/netconf.c @@ -18,7 +18,7 @@ void edit_node(void) { char cnode[SIZ]; FILE *fp; - if (!IsEmptyStr(bstr("ok_button"))) { + if (havebstr("ok_button")) { strcpy(node, bstr("node") ); fp = tmpfile(); if (fp != NULL) { diff --git a/webcit/paging.c b/webcit/paging.c index 96247ae3f..dc3643603 100644 --- a/webcit/paging.c +++ b/webcit/paging.c @@ -68,7 +68,7 @@ void page_user(void) safestrncpy(recp, bstr("recp"), sizeof recp); - if (IsEmptyStr(bstr("send_button"))) { + if (!havebstr("send_button")) { safestrncpy(WC->ImportantMessage, _("Message was not sent."), sizeof WC->ImportantMessage @@ -431,22 +431,22 @@ void chat_send(void) { "" ); - if (bstr("send_this") != NULL) { + if (havebstr("send_this")) { strcpy(send_this, bstr("send_this")); } else { strcpy(send_this, ""); } - if (!IsEmptyStr(bstr("help_button"))) { + if (havebstr("help_button")) { strcpy(send_this, "/help"); } - if (!IsEmptyStr(bstr("list_button"))) { + if (havebstr("list_button")) { strcpy(send_this, "/who"); } - if (!IsEmptyStr(bstr("exit_button"))) { + if (havebstr("exit_button")) { strcpy(send_this, "/quit"); } diff --git a/webcit/preferences.c b/webcit/preferences.c index c8ec33116..eaf6f7f42 100644 --- a/webcit/preferences.c +++ b/webcit/preferences.c @@ -438,7 +438,7 @@ void set_preferences(void) time_format_cache = &(WC->time_format_cache); - if (IsEmptyStr(bstr("change_button"))) { + if (!havebstr("change_button")) { safestrncpy(WC->ImportantMessage, _("Cancelled. No settings were changed."), sizeof WC->ImportantMessage); diff --git a/webcit/roomops.c b/webcit/roomops.c index 4b7b5df54..d2bc437ea 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -644,9 +644,9 @@ void embed_room_banner(char *got, int navbar_style) { case VIEW_CALENDAR: case VIEW_CALBRIEF: wprintf("
  • " "" @@ -2031,21 +2031,21 @@ void toggle_self_service(void) { get_roomflags (&RoomFlags); - if (!strcasecmp(bstr("QR2_SelfList"), "yes")) + if (yesbstr("QR2_SelfList")) RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST; else RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST; - if (!strcasecmp(bstr("QR2_SMTP_PUBLIC"), "yes")) + if (yesbstr("QR2_SMTP_PUBLIC")) RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC; else RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC; - if (!strcasecmp(bstr("QR2_Moderated"), "yes")) + if (yesbstr("QR2_Moderated")) RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED; else RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED; - if (!strcasecmp(bstr("QR2_SubsOnly"), "yes")) + if (yesbstr("QR2_SubsOnly")) RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC; else RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC; @@ -2075,7 +2075,7 @@ void editroom(void) int bump; - if (IsEmptyStr(bstr("ok_button"))) { + if (!havebstr("ok_button")) { strcpy(WC->ImportantMessage, _("Cancelled. Changes were not saved.")); display_editroom(); @@ -2141,62 +2141,62 @@ void editroom(void) er_flags &= ~QR_MAILBOX; } - if (!strcmp(bstr("prefonly"), "yes")) { + if (yesbstr("prefonly")) { er_flags |= QR_PREFONLY; } else { er_flags &= ~QR_PREFONLY; } - if (!strcmp(bstr("readonly"), "yes")) { + if (yesbstr("readonly")) { er_flags |= QR_READONLY; } else { er_flags &= ~QR_READONLY; } - if (!strcmp(bstr("collabdel"), "yes")) { + if (yesbstr("collabdel")) { er_flags2 |= QR2_COLLABDEL; } else { er_flags2 &= ~QR2_COLLABDEL; } - if (!strcmp(bstr("permanent"), "yes")) { + if (yesbstr("permanent")) { er_flags |= QR_PERMANENT; } else { er_flags &= ~QR_PERMANENT; } - if (!strcmp(bstr("subjectreq"), "yes")) { + if (yesbstr("subjectreq")) { er_flags2 |= QR2_SUBJECTREQ; } else { er_flags2 &= ~QR2_SUBJECTREQ; } - if (!strcmp(bstr("network"), "yes")) { + if (yesbstr("network")) { er_flags |= QR_NETWORK; } else { er_flags &= ~QR_NETWORK; } - if (!strcmp(bstr("directory"), "yes")) { + if (yesbstr("directory")) { er_flags |= QR_DIRECTORY; } else { er_flags &= ~QR_DIRECTORY; } - if (!strcmp(bstr("ulallowed"), "yes")) { + if (yesbstr("ulallowed")) { er_flags |= QR_UPLOAD; } else { er_flags &= ~QR_UPLOAD; } - if (!strcmp(bstr("dlallowed"), "yes")) { + if (yesbstr("dlallowed")) { er_flags |= QR_DOWNLOAD; } else { er_flags &= ~QR_DOWNLOAD; } - if (!strcmp(bstr("visdir"), "yes")) { + if (yesbstr("visdir")) { er_flags |= QR_VISDIR; } else { er_flags &= ~QR_VISDIR; @@ -2214,7 +2214,7 @@ void editroom(void) if (!strcmp(bstr("bump"), "yes")) bump = 1; - er_floor = atoi(bstr("er_floor")); + er_floor = ibstr("er_floor"); sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u", er_name, er_password, er_dirname, er_flags, bump, er_floor, @@ -2262,7 +2262,7 @@ void do_invt_kick(void) { strcpy(username, bstr("username")); - if (!IsEmptyStr(bstr("kick_button"))) { + if (havebstr("kick_button")) { sprintf(buf, "KICK %s", username); serv_puts(buf); serv_getln(buf, sizeof buf); @@ -2276,7 +2276,7 @@ void do_invt_kick(void) { } } - if (!IsEmptyStr(bstr("invite_button"))) { + if (havebstr("invite_button")) { sprintf(buf, "INVT %s", username); serv_puts(buf); serv_getln(buf, sizeof buf); @@ -2568,7 +2568,7 @@ void entroom(void) int er_num_type; int er_view; - if (IsEmptyStr(bstr("ok_button"))) { + if (!havebstr("ok_button")) { strcpy(WC->ImportantMessage, _("Cancelled. No new room was created.")); display_main_menu(); @@ -2577,8 +2577,8 @@ void entroom(void) strcpy(er_name, bstr("er_name")); strcpy(er_type, bstr("type")); strcpy(er_password, bstr("er_password")); - er_floor = atoi(bstr("er_floor")); - er_view = atoi(bstr("er_view")); + er_floor = ibstr("er_floor"); + er_view = ibstr("er_view"); er_num_type = 0; if (!strcmp(er_type, "hidden")) @@ -2666,7 +2666,7 @@ void goto_private(void) char hold_rm[SIZ]; char buf[SIZ]; - if (IsEmptyStr(bstr("ok_button"))) { + if (!havebstr("ok_button")) { display_main_menu(); return; } @@ -2736,7 +2736,7 @@ void zap(void) */ strcpy(final_destination, WC->wc_roomname); - if (!IsEmptyStr(bstr("ok_button"))) { + if (havebstr("ok_button")) { serv_printf("GOTO %s", WC->wc_roomname); serv_getln(buf, sizeof buf); if (buf[0] == '2') { @@ -2786,8 +2786,8 @@ void netedit(void) { char cmpb0[SIZ]; char cmpb1[SIZ]; int i, num_addrs; - - if (!IsEmptyStr(bstr("line_pop3host"))) { + // TODO: do line dynamic! + if (havebstr("line_pop3host")) { strcpy(line, bstr("prefix")); strcat(line, bstr("line_pop3host")); strcat(line, "|"); @@ -2795,12 +2795,12 @@ void netedit(void) { strcat(line, "|"); strcat(line, bstr("line_pop3pass")); strcat(line, "|"); - strcat(line, atoi(bstr("line_pop3keep")) ? "1" : "0" ); + strcat(line, ibstr("line_pop3keep") ? "1" : "0" ); strcat(line, "|"); - sprintf(&line[strlen(line)],"%ld", atol(bstr("line_pop3int"))); + sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int")); strcat(line, bstr("suffix")); } - else if (!IsEmptyStr(bstr("line"))) { + else if (havebstr("line")) { strcpy(line, bstr("prefix")); strcat(line, bstr("line")); strcat(line, bstr("suffix")); @@ -2851,7 +2851,7 @@ void netedit(void) { serv_puts(buf); } - if (!IsEmptyStr(bstr("add_button"))) { + if (havebstr("add_button")) { num_addrs = num_tokens(bstr("line"), ','); if (num_addrs < 2) { /* just adding one node or address */ @@ -2941,7 +2941,7 @@ void do_change_view(int newview) { void change_view(void) { int view; - view = atol(bstr("view")); + view = lbstr("view"); do_change_view(view); } @@ -3529,7 +3529,7 @@ void knrooms(void) /** Determine whether the user is trying to change views */ if (bstr("view") != NULL) { - if (!IsEmptyStr(bstr("view"))) { + if (havebstr("view")) { set_preference("roomlistview", bstr("view"), 1); } } @@ -3597,20 +3597,20 @@ void knrooms(void) void set_room_policy(void) { char buf[SIZ]; - if (IsEmptyStr(bstr("ok_button"))) { + if (!havebstr("ok_button")) { strcpy(WC->ImportantMessage, _("Cancelled. Changes were not saved.")); display_editroom(); return; } - serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue"))); + serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue")); serv_getln(buf, sizeof buf); strcpy(WC->ImportantMessage, &buf[4]); if (WC->axlevel >= 6) { strcat(WC->ImportantMessage, "
    \n"); - serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue"))); + serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), bstr("floorvalue")); serv_getln(buf, sizeof buf); strcat(WC->ImportantMessage, &buf[4]); } diff --git a/webcit/sieve.c b/webcit/sieve.c index 2187d8296..849af01e0 100644 --- a/webcit/sieve.c +++ b/webcit/sieve.c @@ -513,7 +513,7 @@ void parse_fields_from_rule_editor(void) { safestrncpy(sizecomp, BSTR(fname), sizeof sizecomp); sprintf(fname, "sizeval%d", i); - sizeval = atoi(BSTR(fname)); + sizeval = IBSTR(fname); sprintf(fname, "action%d", i); safestrncpy(action, BSTR(fname), sizeof action); @@ -563,7 +563,7 @@ void save_sieve(void) { char this_name[64]; char buf[256]; - if (IsEmptyStr(bstr("save_button"))) { + if (!havebstr("save_button")) { strcpy(WC->ImportantMessage, _("Cancelled. Changes were not saved.")); display_main_menu(); @@ -584,7 +584,7 @@ void save_sieve(void) { } } - bigaction = atoi(bstr("bigaction")); + bigaction = ibstr("bigaction"); if (bigaction == 0) { serv_puts("MSIV setactive||"); diff --git a/webcit/siteconfig.c b/webcit/siteconfig.c index 0ab15744a..d15d8506c 100644 --- a/webcit/siteconfig.c +++ b/webcit/siteconfig.c @@ -769,14 +769,14 @@ void siteconfig(void) serv_printf("%s", bstr("c_fqdn")); serv_printf("%s", bstr("c_humannode")); serv_printf("%s", bstr("c_phonenum")); - serv_printf("%s", ((!strcasecmp(bstr("c_creataide"), "yes") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_creataide") ? "1" : "0"))); serv_printf("%s", bstr("c_sleeping")); serv_printf("%s", bstr("c_initax")); - serv_printf("%s", ((!strcasecmp(bstr("c_regiscall"), "yes") ? "1" : "0"))); - serv_printf("%s", ((!strcasecmp(bstr("c_twitdetect"), "yes") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_regiscall") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_twitdetect") ? "1" : "0"))); serv_printf("%s", bstr("c_twitroom")); serv_printf("%s", bstr("c_moreprompt")); - serv_printf("%s", ((!strcasecmp(bstr("c_restrict"), "yes") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_restrict") ? "1" : "0"))); serv_printf("%s", bstr("c_bbs_city")); serv_printf("%s", bstr("c_sysadm")); serv_printf("%s", bstr("c_maxsessions")); @@ -790,11 +790,11 @@ void siteconfig(void) serv_printf("%s", bstr("c_max_workers")); serv_printf("%s", bstr("c_pop3_port")); serv_printf("%s", bstr("c_smtp_port")); - serv_printf("%s", ((!strcasecmp(bstr("c_rfc822_strict_from"), "yes") ? "0" : "1"))); /* note: reverse bool */ - serv_printf("%s", ((!strcasecmp(bstr("c_aide_zap"), "yes") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_rfc822_strict_from") ? "0" : "1"))); /* note: reverse bool */ + serv_printf("%s", ((yesbstr("c_aide_zap") ? "1" : "0"))); serv_printf("%s", bstr("c_imap_port")); serv_printf("%s", bstr("c_net_freq")); - serv_printf("%s", ((!strcasecmp(bstr("c_disable_newu"), "yes") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_disable_newu") ? "1" : "0"))); serv_printf("1"); /* placeholder - this field is not in use */ serv_printf("%s", bstr("c_purge_hour")); serv_printf("%s", bstr("c_ldap_host")); @@ -807,12 +807,12 @@ void siteconfig(void) serv_printf("%s", bstr("c_imaps_port")); serv_printf("%s", bstr("c_pop3s_port")); serv_printf("%s", bstr("c_smtps_port")); - serv_printf("%s", ((!strcasecmp(bstr("c_enable_fulltext"), "yes") ? "1" : "0"))); - serv_printf("%s", ((!strcasecmp(bstr("c_auto_cull"), "yes") ? "1" : "0"))); - serv_printf("%s", ((!strcasecmp(bstr("c_instant_expunge"), "yes") ? "1" : "0"))); - serv_printf("%s", ((!strcasecmp(bstr("c_allow_spoofing"), "yes") ? "1" : "0"))); - serv_printf("%s", ((!strcasecmp(bstr("c_journal_email"), "yes") ? "1" : "0"))); - serv_printf("%s", ((!strcasecmp(bstr("c_journal_pubmsgs"), "yes") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_enable_fulltext") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_auto_cull") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_instant_expunge") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_allow_spoofing") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_journal_email") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_journal_pubmsgs") ? "1" : "0"))); serv_printf("%s", bstr("c_journal_dest")); serv_printf("%s", bstr("c_default_cal_zone")); serv_printf("%s", bstr("c_pftcpdict_port")); @@ -822,20 +822,20 @@ void siteconfig(void) serv_printf("%s", bstr("c_funambol_port")); serv_printf("%s", bstr("c_funambol_source")); serv_printf("%s", bstr("c_funambol_auth")); - serv_printf("%s", ((!strcasecmp(bstr("c_rbl_at_greeting"), "yes") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_rbl_at_greeting") ? "1" : "0"))); serv_printf("%s", bstr("c_master_user")); serv_printf("%s", bstr("c_master_pass")); serv_printf("%s", bstr("c_pager_program")); - serv_printf("%s", ((!strcasecmp(bstr("c_imap_keep_from"), "yes") ? "1" : "0"))); + serv_printf("%s", ((yesbstr("c_imap_keep_from") ? "1" : "0"))); serv_printf("%s", bstr("c_xmpp_c2s_port")); serv_printf("%s", bstr("c_xmpp_s2s_port")); serv_printf("%s", bstr("c_pop3_fetch")); serv_printf("%s", bstr("c_pop3_fastest")); serv_printf("000"); - serv_printf("SPEX site|%d|%d", atoi(bstr("sitepolicy")), atoi(bstr("sitevalue"))); + serv_printf("SPEX site|%d|%d", ibstr("sitepolicy"), ibstr("sitevalue")); serv_getln(buf, sizeof buf); - serv_printf("SPEX mailboxes|%d|%d", atoi(bstr("mboxpolicy")), atoi(bstr("mboxvalue"))); + serv_printf("SPEX mailboxes|%d|%d", ibstr("mboxpolicy"), ibstr("mboxvalue")); serv_getln(buf, sizeof buf); strcpy(serv_info.serv_default_cal_zone, bstr("c_default_cal_zone")); diff --git a/webcit/sysmsgs.c b/webcit/sysmsgs.c index 3c139232a..1dac62755 100644 --- a/webcit/sysmsgs.c +++ b/webcit/sysmsgs.c @@ -72,7 +72,7 @@ void save_edit(char *description, char *enter_cmd, int regoto) { char buf[SIZ]; - if (IsEmptyStr(bstr("save_button"))) { + if (!havebstr("save_button")) { sprintf(WC->ImportantMessage, _("Cancelled. %s was not saved."), description); diff --git a/webcit/useredit.c b/webcit/useredit.c index e6625ace2..1d37da65d 100644 --- a/webcit/useredit.c +++ b/webcit/useredit.c @@ -267,12 +267,12 @@ void display_edituser(char *supplied_username, int is_new) { lastcall = extract_long(&buf[4], 7); purgedays = extract_long(&buf[4], 8); - if (!IsEmptyStr(bstr("edit_abe_button"))) { + if (havebstr("edit_abe_button")) { display_edit_address_book_entry(username, usernum); return; } - if (!IsEmptyStr(bstr("delete_button"))) { + if (havebstr("delete_button")) { delete_user(username); return; } @@ -407,24 +407,24 @@ void edituser(void) { unsigned int flags = 0; char *username; - is_new = atoi(bstr("is_new")); + is_new = ibstr("is_new"); safestrncpy(message, "", sizeof message); username = bstr("username"); - if (IsEmptyStr(bstr("ok_button"))) { + if (!havebstr("ok_button")) { safestrncpy(message, _("Changes were not saved."), sizeof message); } else { - flags = atoi(bstr("flags")); - if (!strcasecmp(bstr("inetmail"), "yes")) { + flags = ibstr("flags"); + if (yesbstr("inetmail")) { flags |= US_INTERNET; } else { flags &= ~US_INTERNET ; } - if (bstr("newname") != NULL) if (strcasecmp(bstr("username"), bstr("newname"))) { + if ((havebstr("newname")) && (strcasecmp(bstr("username"), bstr("newname")))) { serv_printf("RENU %s|%s", bstr("username"), bstr("newname")); serv_getln(buf, sizeof buf); if (buf[0] != '2') { @@ -461,7 +461,7 @@ void edituser(void) { * the vCard edit screen. */ if (is_new) { - display_edit_address_book_entry(username, atol(bstr("usernum")) ); + display_edit_address_book_entry(username, lbstr("usernum") ); } else { select_user_to_edit(message, username); diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c index b527217f1..401738754 100644 --- a/webcit/vcard_edit.c +++ b/webcit/vcard_edit.c @@ -372,7 +372,7 @@ void edit_vcard(void) { long msgnum; char *partnum; - msgnum = atol(bstr("msgnum")); + msgnum = lbstr("msgnum"); partnum = bstr("partnum"); do_edit_vcard(msgnum, partnum, "", NULL); } @@ -388,12 +388,12 @@ void submit_vcard(void) { char buf[SIZ]; int i; - if (IsEmptyStr(bstr("ok_button"))) { + if (!havebstr("ok_button")) { readloop("readnew"); return; } - if (!IsEmptyStr(bstr("force_room"))) { + if (havebstr("force_room")) { gotoroom(bstr("force_room")); } diff --git a/webcit/webcit.c b/webcit/webcit.c index 40ccb261e..dd6955d68 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -82,7 +82,7 @@ void addurls(char *url) { char *aptr, *bptr, *eptr; char *up; - char buf[SIZ]; + char buf[SIZ] = ""; int len, n, keylen; urlcontent *u; struct wcsession *WCC = WC; @@ -165,15 +165,20 @@ void dump_vars(void) * \brief Return the value of a variable supplied to the current web page (from the url or a form) * \param key The name of the variable we want */ -const char *BSTR(char *key) + +const char *XBstr(char *key, size_t keylen, size_t *len) { void *U; - if ((WC->urlstrings != NULL) && - GetHash(WC->urlstrings, key, strlen (key), &U)) + if ((WC->urlstrings != NULL) && + GetHash(WC->urlstrings, key, keylen, &U)) { + *len = ((urlcontent *)U)->url_data_size; return ((urlcontent *)U)->url_data; - else + } + else { + *len = 0; return (""); + } } const char *XBSTR(char *key, size_t *len) @@ -191,6 +196,18 @@ const char *XBSTR(char *key, size_t *len) } } + +const char *BSTR(char *key) +{ + void *U; + + if ((WC->urlstrings != NULL) && + GetHash(WC->urlstrings, key, strlen (key), &U)) + return ((urlcontent *)U)->url_data; + else + return (""); +} + const char *Bstr(char *key, size_t keylen) { void *U; @@ -202,19 +219,93 @@ const char *Bstr(char *key, size_t keylen) return (""); } -const char *XBstr(char *key, size_t keylen, size_t *len) +long LBstr(char *key, size_t keylen) { void *U; if ((WC->urlstrings != NULL) && - GetHash(WC->urlstrings, key, keylen, &U)) { - *len = ((urlcontent *)U)->url_data_size; - return ((urlcontent *)U)->url_data; - } - else { - *len = 0; - return (""); - } + GetHash(WC->urlstrings, key, keylen, &U)) + return atol(((urlcontent *)U)->url_data); + else + return (0); +} + +long LBSTR(char *key) +{ + void *U; + + if ((WC->urlstrings != NULL) && + GetHash(WC->urlstrings, key, strlen(key), &U)) + return atol(((urlcontent *)U)->url_data); + else + return (0); +} + +int IBstr(char *key, size_t keylen) +{ + void *U; + + if ((WC->urlstrings != NULL) && + GetHash(WC->urlstrings, key, keylen, &U)) + return atoi(((urlcontent *)U)->url_data); + else + return (0); +} + +int IBSTR(char *key) +{ + void *U; + + if ((WC->urlstrings != NULL) && + GetHash(WC->urlstrings, key, strlen(key), &U)) + return atoi(((urlcontent *)U)->url_data); + else + return (0); +} + +int HaveBstr(char *key, size_t keylen) +{ + void *U; + + if ((WC->urlstrings != NULL) && + GetHash(WC->urlstrings, key, keylen, &U)) + return ((urlcontent *)U)->url_data_size != 0; + else + return (0); +} + +int HAVEBSTR(char *key) +{ + void *U; + + if ((WC->urlstrings != NULL) && + GetHash(WC->urlstrings, key, strlen(key), &U)) + return ((urlcontent *)U)->url_data_size != 0; + else + return (0); +} + + +int YesBstr(char *key, size_t keylen) +{ + void *U; + + if ((WC->urlstrings != NULL) && + GetHash(WC->urlstrings, key, keylen, &U)) + return strcmp( ((urlcontent *)U)->url_data, "yes") == 0; + else + return (0); +} + +int YESBSTR(char *key) +{ + void *U; + + if ((WC->urlstrings != NULL) && + GetHash(WC->urlstrings, key, strlen(key), &U)) + return strcmp( ((urlcontent *)U)->url_data, "yes") == 0; + else + return (0); } /** @@ -787,7 +878,7 @@ void output_static(char *what) http_transmit_thing(bigbuffer, (size_t)bytes, content_type, 1); free(bigbuffer); } - if (!strcasecmp(bstr("force_close_session"), "yes")) { + if (yesbstr("force_close_session")) { end_webcit_session(); } } @@ -1415,7 +1506,7 @@ void session_loop(struct httprequest *req) if (strlen(bstr("nonce")) > 0) { lprintf(9, "Comparing supplied nonce %s to session nonce %ld\n", bstr("nonce"), WC->nonce); - if (atoi(bstr("nonce")) != WC->nonce) { + if (ibstr("nonce") != WC->nonce) { lprintf(9, "Ignoring request with mismatched nonce.\n"); wprintf("HTTP/1.1 404 Security check failed\r\n"); wprintf("Content-Type: text/plain\r\n"); diff --git a/webcit/webcit.h b/webcit/webcit.h index 68e64fa2f..c9215c9ab 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -502,13 +502,33 @@ void fmout(char *align); void pullquote_fmout(void); void wDumpContent(int); void serv_printf(const char *format,...); -const char *Bstr(char *key, size_t keylen); -const char *XBstr(char *key, size_t keylen, size_t *len); + /* TODO: get rid of the non-const-typecast */ #define bstr(a) (char*) Bstr(a, sizeof(a) - 1) -#define xbstr(a, b) (char*) XBstr(a, sizeof(a) - 1, b) const char *BSTR(char *key); +const char *Bstr(char *key, size_t keylen); + +#define xbstr(a, b) (char*) XBstr(a, sizeof(a) - 1, b) +const char *XBstr(char *key, size_t keylen, size_t *len); const char *XBSTR(char *key, size_t *len); + +#define lbstr(a) LBstr(a, sizeof(a) - 1) +long LBstr(char *key, size_t keylen); +long LBSTR(char *key); + +#define ibstr(a) IBstr(a, sizeof(a) - 1) +int IBstr(char *key, size_t keylen); +int IBSTR(char *key); + +#define havebstr(a) HaveBstr(a, sizeof(a) - 1) +int HaveBstr(char *key, size_t keylen); +int HAVEBSTR(char *key); + +#define yesbstr(a) YesBstr(a, sizeof(a) - 1) +int YesBstr(char *key, size_t keylen); +int YESBSTR(char *key); + + void urlescputs(char *); void jsesc(char *, size_t, char *); void jsescputs(char *); diff --git a/webcit/who.c b/webcit/who.c index c88d3a90d..42be15838 100644 --- a/webcit/who.c +++ b/webcit/who.c @@ -318,19 +318,19 @@ void edit_me(void) { char buf[SIZ]; - if (!IsEmptyStr(bstr("change_room_name_button"))) { + if (havebstr("change_room_name_button")) { serv_printf("RCHG %s", bstr("fake_roomname")); serv_getln(buf, sizeof buf); http_redirect("who"); - } else if (!IsEmptyStr(bstr("change_host_name_button"))) { + } else if (havebstr("change_host_name_button")) { serv_printf("HCHG %s", bstr("fake_hostname")); serv_getln(buf, sizeof buf); http_redirect("who"); - } else if (!IsEmptyStr(bstr("change_user_name_button"))) { + } else if (havebstr("change_user_name_button")) { serv_printf("UCHG %s", bstr("fake_username")); serv_getln(buf, sizeof buf); http_redirect("who"); - } else if (!IsEmptyStr(bstr("cancel_button"))) { + } else if (havebstr("cancel_button")) { http_redirect("who"); } else { output_headers(1, 1, 0, 0, 0, 0); -- 2.30.2