* we have now several bstrs:
authorWilfried Göesgens <willi@citadel.org>
Fri, 4 Apr 2008 10:44:32 +0000 (10:44 +0000)
committerWilfried Göesgens <willi@citadel.org>
Fri, 4 Apr 2008 10:44:32 +0000 (10:44 +0000)
  * 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.

22 files changed:
webcit/auth.c
webcit/calendar.c
webcit/calendar_view.c
webcit/downloads.c
webcit/event.c
webcit/floors.c
webcit/graphics.c
webcit/iconbar.c
webcit/mainmenu.c
webcit/messages.c
webcit/netconf.c
webcit/paging.c
webcit/preferences.c
webcit/roomops.c
webcit/sieve.c
webcit/siteconfig.c
webcit/sysmsgs.c
webcit/useredit.c
webcit/vcard_edit.c
webcit/webcit.c
webcit/webcit.h
webcit/who.c

index 5e1bda48a82b1712b6f21552619ef7c58e4cf35e..b2619691917252d1fd706b75aed4934f5fcacf2c 100644 (file)
@@ -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);
index bb1166d8babbed331965383e3fbc42dfe8a63526..7e81620e428b8bd8ee72773bac99b4110aede83d 100644 (file)
@@ -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,
index 2f8421dff52417dcbc8d3f21bb80dc5272791a54..78325f835832789f462a724429edc39da2917f08 100644 (file)
@@ -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 {
index 2ed8e247c51da2d559fd3cf6578d087a41ef461f..a208e51b7dc317fb4248c7dbe94bcab4ca32344e 100644 (file)
@@ -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("<div id=\"banner\">\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");
index c9deb38b69ebb1da80173188df78c99ed40967f4..d1a6e6e366744f7f32aed6401baaad1a5ec934d5 100644 (file)
@@ -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");
        }
 }
index fb268ff4830d461d3d9b286781f8e4534d447eec..f662ab408a3b16963ec96d5611d91333366c8477 100644 (file)
@@ -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);
index 3c16baf414e218dd2c91fa16de6880e26ced0bcd..e9c0d8c3410067c6a24f7753128278372b383579 100644 (file)
@@ -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();
index eceb4c86426ad13166ef87a09d9fab9423564bf8..25c1b9e2e431dd314cedb47f94f40939de99062f 100644 (file)
@@ -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;
index 8673df5d8c76ba78e4aee7d87f884cbe139e387e..a869e8b3bdaa116ca92ac00fdb6d732afed101f4 100644 (file)
@@ -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;
        }
index f9e0ae7677adc31fd9eb68095baf191f774f681c..a36bd38b4902497c97ed8f48f7ac5e2f9a4ad933 100644 (file)
@@ -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("</label></th>"
                        "<td><input autocomplete=\"off\" type=\"text\" name=\"recp\" id=\"recp_id\" value=\"");
-               ccraw = bstr("recp");
-               len = strlen(ccraw);
+               ccraw = xbstr("recp", &len);
                copy = (char*) malloc(len * 2 + 1);
                memcpy(copy, ccraw, len + 1); 
                utf8ify_rfc822_string(copy);
@@ -3446,8 +3469,7 @@ void display_enter(void)
                wprintf(_("CC:"));
                wprintf("</label></th>"
                        "<td><input autocomplete=\"off\" type=\"text\" name=\"cc\" id=\"cc_id\" value=\"");
-               ccraw = bstr("cc");
-               len = strlen(ccraw);
+               ccraw = xbstr("cc", &len);
                copy = (char*) malloc(len * 2 + 1);
                memcpy(copy, ccraw, len + 1); 
                utf8ify_rfc822_string(copy);
@@ -3461,8 +3483,7 @@ void display_enter(void)
                wprintf(_("BCC:"));
                wprintf("</label></th>"
                        "<td><input autocomplete=\"off\" type=\"text\" name=\"bcc\" id=\"bcc_id\" value=\"");
-               ccraw = bstr("bcc");
-               len = strlen(ccraw);
+               ccraw = xbstr("bcc", &len);
                copy = (char*) malloc(len * 2 + 1);
                memcpy(copy, ccraw, len + 1); 
                utf8ify_rfc822_string(copy);
@@ -3502,18 +3523,18 @@ void display_enter(void)
        msgescputs(bstr("msgtext"));
 
        /* If we're forwarding a message, insert it here... */
-       if (atol(bstr("fwdquote")) > 0L) {
+       if (lbstr("fwdquote") > 0L) {
                wprintf("<br><div align=center><i>");
                wprintf(_("--- forwarded message ---"));
                wprintf("</i></div><br>");
-               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("<br>"
                        "<blockquote>");
-               pullquote_message(atol(bstr("replyquote")), 0, 1);
+               pullquote_message(lbstr("replyquote"), 0, 1);
                wprintf("</blockquote><br>");
        }
 
@@ -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);
index 1dde529ba8bcc0e4959741412be7be7fd8761ccc..ee7c5a91fd7f4bf4e30dbe568453873f71c99fa8 100644 (file)
@@ -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) {
index 96247ae3fe48a44babe2f3451d90c52ef6f3c36d..dc364360335910faf8e6480a264dc58b37a613df 100644 (file)
@@ -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) {
                "<BODY onLoad=\"document.chatsendform.send_this.focus();\" >"
        );
 
-       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");
        }
 
index c8ec33116afa8f0cb1714486a114912d8c81f8cf..eaf6f7f4249ca4985a1ef9d698fb9d58d2de3184 100644 (file)
@@ -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);
index 4b7b5df54503b3601bf1b8906e316b98c581ca96..d2bc437ea8ef25ae615faeb60915237e3b098a40 100644 (file)
@@ -644,9 +644,9 @@ void embed_room_banner(char *got, int navbar_style) {
                                case VIEW_CALENDAR:
                                case VIEW_CALBRIEF:
                                        wprintf("<li class=\"addevent\"><a href=\"display_enter");
-                                       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"));
+                                       if (havebstr("year" )) wprintf("?year=%s", bstr("year"));
+                                       if (havebstr("month")) wprintf("?month=%s", bstr("month"));
+                                       if (havebstr("day"  )) wprintf("?day=%s", bstr("day"));
                                        wprintf("\">"
                                                "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
                                                "border=\"0\"><span class=\"navbar_link\">"
@@ -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, "<br />\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]);
        }
index 2187d8296c2d4f3c3ddd91f8a821995a43397ceb..849af01e08747c3487675ff9b22f1964994bee9d 100644 (file)
@@ -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||");
index 0ab15744aadd314508b24dbd2094fd59e784909e..d15d8506ced306f7bc7214ae325a658f3ccaead2 100644 (file)
@@ -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"));
index 3c139232ae41542dd94e79bc5cfff0823e283e1d..1dac62755e8a85c683e800a0538834c5f12f9f84 100644 (file)
@@ -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);
index e6625ace28365d2f9e22aee06526947c5adaf89f..1d37da65d8cf601389a3f7e6351e685fd2ed0c9c 100644 (file)
@@ -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);
index b527217f17a99e31f907cb44d1df99ab1ed3f6d9..4017387547f15b96636510dc150c80ce5c51f916 100644 (file)
@@ -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"));
        }
 
index 40ccb261e5e915ab36f8c5e2d2ac383acd24f632..dd6955d68ee834eb9a0119a41a19e13918f962a6 100644 (file)
@@ -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");
index 68e64fa2f90325727db8dff7996748542f4d6411..c9215c9abb6eb24420c38621c0b9cd681c74b240 100644 (file)
@@ -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 *);
index c88d3a90de9d97de737b88731394a06aea28451a..42be1583890aedd68d09c3de6343c2752c0adfb4 100644 (file)
@@ -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);