* Moved to the new string tokenizer API
authorArt Cancro <ajc@citadel.org>
Fri, 8 Apr 2005 19:36:56 +0000 (19:36 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 8 Apr 2005 19:36:56 +0000 (19:36 +0000)
29 files changed:
webcit/ChangeLog
webcit/auth.c
webcit/calendar.c
webcit/context_loop.c
webcit/cookie_conversion.c
webcit/event.c
webcit/floors.c
webcit/groupdav_delete.c
webcit/groupdav_get.c
webcit/groupdav_main.c
webcit/groupdav_propfind.c
webcit/groupdav_put.c
webcit/iconbar.c
webcit/inetconf.c
webcit/listsub.c
webcit/messages.c
webcit/netconf.c
webcit/paging.c
webcit/preferences.c
webcit/roomops.c
webcit/setup.c
webcit/summary.c
webcit/tools.c
webcit/useredit.c
webcit/userlist.c
webcit/vcard_edit.c
webcit/webcit.c
webcit/webcit.h
webcit/who.c

index 0bf77bbe6e66fcee183d72977fd16a99996a7440..f603ca4d18d449d308dc95b8e0bb5ba43bf1e366 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 610.1  2005/04/08 19:36:56  ajc
+* Moved to the new string tokenizer API
+
 Revision 610.0  2005/04/04 17:50:04  ajc
 * THIS IS 6.10 (unfinished first time install wizard has been disabled)
 
@@ -2502,3 +2505,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index a48e2277190519f8a0ed549312c3faf6567e9096..3fb489847cf21239dd70b7214f47e9022be51ddd 100644 (file)
@@ -77,7 +77,7 @@ void become_logged_in(char *user, char *pass, char *serv_response)
        char buf[SIZ];
 
        WC->logged_in = 1;
-       extract(WC->wc_username, &serv_response[4], 0);
+       extract_token(WC->wc_username, &serv_response[4], 0, '|', sizeof WC->wc_username);
        strcpy(WC->wc_password, pass);
        WC->axlevel = extract_int(&serv_response[4], 1);
        if (WC->axlevel >= 6) {
@@ -92,7 +92,7 @@ void become_logged_in(char *user, char *pass, char *serv_response)
                WC->new_mail = extract_int(&buf[4], 0);
                WC->need_regi = extract_int(&buf[4], 1);
                WC->need_vali = extract_int(&buf[4], 2);
-               extract(WC->cs_inet_email, &buf[4], 3);
+               extract_token(WC->cs_inet_email, &buf[4], 3, '|', sizeof WC->cs_inet_email);
        }
 }
 
@@ -154,10 +154,10 @@ void do_login(void)
 void do_welcome(void)
 {
        char buf[SIZ];
+#ifdef XXX_NOT_FINISHED_YET_XXX
        FILE *fp;
        int i;
 
-#ifdef XXX_NOT_FINISHED_YET_XXX
        /*
         * See if we have to run the first-time setup wizard
         */
@@ -193,7 +193,7 @@ void do_welcome(void)
        /*
         * Go to the user's preferred start page
         */
-       get_preference("startpage", buf);
+       get_preference("startpage", buf, sizeof buf);
        if (strlen(buf)==0) {
                strcpy(buf, "/dotskip&room=_BASEROOM_");
                set_preference("startpage", buf);
index bb8afc103d34683e854ec7224d81ba74890915e6..10296ae798d82827a84877b4d80f15c81bc34113 100644 (file)
@@ -232,7 +232,7 @@ void cal_process_object(icalcomponent *cal,
                serv_gets(buf);
                if (buf[0] == '1') {
                        while (serv_gets(buf), strcmp(buf, "000")) {
-                               extract(conflict_name, buf, 3);
+                               extract_token(conflict_name, buf, 3, '|', sizeof conflict_name);
                                is_update = extract_int(buf, 4);
                                wprintf("<TR><TD><B><I>%s</I></B></TD>"
                                        "<TD>"
@@ -780,10 +780,10 @@ void display_using_handler(long msgnum,
 
        while (serv_gets(buf), strcmp(buf, "000")) {
                if (!strncasecmp(buf, "part=", 5)) {
-                       extract(mime_filename, &buf[5], 1);
-                       extract(mime_partnum, &buf[5], 2);
-                       extract(mime_disposition, &buf[5], 3);
-                       extract(mime_content_type, &buf[5], 4);
+                       extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
+                       extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
+                       extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
+                       extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
                        mime_length = extract_int(&buf[5], 5);
 
                        if (!strcasecmp(mime_content_type, "text/calendar")) {
@@ -913,7 +913,7 @@ void do_freebusy(char *req) {
        char buf[SIZ];
        char *fb;
 
-       extract_token(who, req, 1, ' ');
+       extract_token(who, req, 1, ' ', sizeof who);
        if (!strncasecmp(who, "/freebusy/", 10)) {
                strcpy(who, &who[10]);
        }
index fdd97a819a10c60c240c82b0b4ebf07e598e9700..9fd9ba8fe4f9b003457879b5ff7bb21ef72eb33a 100644 (file)
@@ -298,7 +298,7 @@ void context_loop(int sock)
                 */
                if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
                        cookie_to_stuff(&buf[15], &desired_session,
-                               NULL, NULL, NULL);
+                               NULL, 0, NULL, 0, NULL, 0);
                        got_cookie = 1;
                }
 
@@ -307,8 +307,8 @@ void context_loop(int sock)
                 */
                if (!strncasecmp(buf, "Authorization: Basic ", 21)) {
                        CtdlDecodeBase64(httpauth_string, &buf[21], strlen(&buf[21]));
-                       extract_token(httpauth_user, httpauth_string, 0, ':');
-                       extract_token(httpauth_pass, httpauth_string, 1, ':');
+                       extract_token(httpauth_user, httpauth_string, 0, ':', sizeof httpauth_user);
+                       extract_token(httpauth_pass, httpauth_string, 1, ':', sizeof httpauth_pass);
                }
 
                /*
index 644dbfc32a3b84259d9c71f7818a689b072346ac..27c4830d214cc2d5b24ac70d3920abd32db3f003 100644 (file)
@@ -64,7 +64,10 @@ int xtoi(char *in, size_t len)
 /*
  * Extract all that fun stuff out of the cookie.
  */
-void cookie_to_stuff(char *cookie, int *session, char *user, char *pass, char *room)
+void cookie_to_stuff(char *cookie, int *session,
+               char *user, size_t user_len,
+               char *pass, size_t pass_len,
+               char *room, size_t room_len)
 {
        char buf[SIZ];
        int i, len;
@@ -79,9 +82,9 @@ void cookie_to_stuff(char *cookie, int *session, char *user, char *pass, char *r
        if (session != NULL)
                *session = extract_int(buf, 0);
        if (user != NULL)
-               extract(user, buf, 1);
+               extract_token(user, buf, 1, '|', user_len);
        if (pass != NULL)
-               extract(pass, buf, 2);
+               extract_token(pass, buf, 2, '|', pass_len);
        if (room != NULL)
-               extract(room, buf, 3);
+               extract_token(room, buf, 3, '|', room_len);
 }
index eff197c51956186252b4b7c685e778151970d12b..5634326efd64c866d17a7f960e74aca8aa7b573f 100644 (file)
@@ -614,7 +614,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum) {
 
                /* Now iterate! */
                for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
-                       extract_token(buf, form_attendees, i, '\n');
+                       extract_token(buf, form_attendees, i, '\n', sizeof buf);
                        striplt(buf);
                        if (strlen(buf) > 0) {
                                lprintf(9, "Attendee: <%s>\n", buf);
@@ -647,7 +647,7 @@ STARTOVER:  lprintf(9, "Remove unlisted attendees\n");
                                striplt(attendee_string);
                                foundit = 0;
                                for (i=0; i<num_tokens(form_attendees, '\n'); ++i) {
-                                       extract_token(buf, form_attendees, i, '\n');
+                                       extract_token(buf, form_attendees, i, '\n', sizeof buf);
                                        striplt(buf);
                                        if (!strcasecmp(buf, attendee_string)) ++foundit;
                                }
index a0b4edf1061cd5a6776576671e9a8e430bbf73e6..a9d4ddfadc0c329717bce4167bfb5bb97f10f31d 100644 (file)
@@ -77,7 +77,7 @@ void display_floorconfig(char *prepend_html)
 
        while (serv_gets(buf), strcmp(buf, "000")) {
                floornum = extract_int(buf, 0);
-               extract(floorname, buf, 1);
+               extract_token(floorname, buf, 1, '|', sizeof floorname);
                refcount = extract_int(buf, 2);
 
                wprintf("<TR><TD><TABLE border=0><TR><TD>%d", floornum);
index 16991b53740823f1be1100d5eabc1c80ba79aeb9..eebe1a0ce0f44fdc84515ce1aba82f5f2fb2c1e0 100644 (file)
@@ -42,7 +42,7 @@ void groupdav_delete(char *dav_pathname, char *dav_ifmatch) {
 
        /* Now extract the message euid */
        n = num_tokens(dav_pathname, '/');
-       extract_token(dav_uid, dav_pathname, n-1, '/');
+       extract_token(dav_uid, dav_pathname, n-1, '/', sizeof dav_uid);
        remove_token(dav_pathname, n-1, '/');
 
        /* What's left is the room name.  Remove trailing slashes. */
index dafcc7653857d09f71fbd4c19c4354884239d2b9..87286632ae35a2466218d486dbfb48372b03ce4c 100644 (file)
@@ -44,7 +44,7 @@ void groupdav_get(char *dav_pathname) {
 
        /* Now extract the message euid */
        n = num_tokens(dav_pathname, '/');
-       extract_token(dav_uid, dav_pathname, n-1, '/');
+       extract_token(dav_uid, dav_pathname, n-1, '/', sizeof dav_uid);
        remove_token(dav_pathname, n-1, '/');
 
        /* What's left is the room name.  Remove trailing slashes. */
index a25bdc72e9c8da7c775b156dffe3864ab5c53bb4..21ef55bd87762f9e8ac5eb8fe60ece6d1014d4ea 100644 (file)
@@ -150,8 +150,8 @@ void groupdav_main(struct httprequest *req,
                return;
        }
 
-       extract_token(dav_method, req->line, 0, ' ');
-       extract_token(dav_pathname, req->line, 1, ' ');
+       extract_token(dav_method, req->line, 0, ' ', sizeof dav_method);
+       extract_token(dav_pathname, req->line, 1, ' ', sizeof dav_pathname);
        unescape_input(dav_pathname);
 
        /*
index b3f2d3b816885c038486ed6fe74c12e301ab3b40..2780a5909cb9f4b6c5c1c00736ca671aa7953290 100644 (file)
@@ -98,7 +98,7 @@ void groupdav_folder_list(void) {
        serv_gets(buf);
        if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
 
-               extract(roomname, buf, 0);
+               extract_token(roomname, buf, 0, '|', sizeof roomname);
                view = extract_int(buf, 6);
 
                /*
index c6ced17b6429995e0d8cacbbdb5599afbc444e2c..d634a9aff6b50072da143b84c24bb6ec0bdd189c 100644 (file)
@@ -46,7 +46,7 @@ void groupdav_put(char *dav_pathname, char *dav_ifmatch,
 
        /* Now extract the message euid */
        n = num_tokens(dav_pathname, '/');
-       extract_token(dav_uid, dav_pathname, n-1, '/');
+       extract_token(dav_uid, dav_pathname, n-1, '/', sizeof dav_uid);
        remove_token(dav_pathname, n-1, '/');
 
        /* What's left is the room name.  Remove trailing slashes. */
index 3733703899ef6ea887c3d8ab5db6b9f56f605a3a..248f2b6806da7937a149f790a7ebc7d617a58f4a 100644 (file)
@@ -59,11 +59,11 @@ void do_iconbar(void) {
        /*
         */
 
-       get_preference("iconbar", iconbar);
+       get_preference("iconbar", iconbar, sizeof iconbar);
        for (i=0; i<num_tokens(iconbar, ','); ++i) {
-               extract_token(buf, iconbar, i, ',');
-               extract_token(key, buf, 0, '=');
-               extract_token(value, buf, 1, '=');
+               extract_token(buf, iconbar, i, ',', sizeof buf);
+               extract_token(key, buf, 0, '=', sizeof key);
+               extract_token(value, buf, 1, '=', sizeof value);
 
                if (!strcasecmp(key, "ib_displayas")) ib_displayas = atoi(value);
                if (!strcasecmp(key, "ib_logo")) ib_logo = atoi(value);
@@ -338,11 +338,11 @@ void display_customize_iconbar(void) {
        /*
         */
 
-       get_preference("iconbar", iconbar);
+       get_preference("iconbar", iconbar, sizeof iconbar);
        for (i=0; i<num_tokens(iconbar, ','); ++i) {
-               extract_token(buf, iconbar, i, ',');
-               extract_token(key, buf, 0, '=');
-               extract_token(value, buf, 1, '=');
+               extract_token(buf, iconbar, i, ',', sizeof buf);
+               extract_token(key, buf, 0, '=', sizeof key);
+               extract_token(value, buf, 1, '=', sizeof value);
 
                if (!strcasecmp(key, "ib_displayas")) ib_displayas = atoi(value);
                if (!strcasecmp(key, "ib_logo")) ib_logo = atoi(value);
index cbdf3260077c8704e1ceeff4b3ee3dd94d2eb1d6..64d76bd77fac8eb72d13702118fac6d9ea95287e 100644 (file)
@@ -84,8 +84,8 @@ void display_inetconf(void)
        serv_gets(buf);
        if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
 
-               extract(ename, buf, 0);
-               extract(etype, buf, 1);
+               extract_token(ename, buf, 0, '|', sizeof ename);
+               extract_token(etype, buf, 1, '|', sizeof etype);
                which = (-1);
                for (i=0; i<ic_max; ++i) {
                        if (!strcasecmp(etype, ic_keyword[i])) {
@@ -128,7 +128,7 @@ void display_inetconf(void)
                if (strlen(ic_spec[which]) > 0) {
                        for (i=0; i<num_tokens(ic_spec[which], '\n'); ++i) {
                                wprintf("<TR><TD ALIGN=LEFT>");
-                               extract_token(buf, ic_spec[which], i, '\n');
+                               extract_token(buf, ic_spec[which], i, '\n', sizeof buf);
                                escputs(buf);
                                wprintf("</TD><TD ALIGN=RIGHT>"
                                        "<A HREF=\"/save_inetconf?oper=delete&ename=");
@@ -174,8 +174,8 @@ void save_inetconf(void) {
        serv_printf("CONF GETSYS|application/x-citadel-internet-config");
        serv_gets(buf);
        if (buf[0] == '1') while (serv_gets(buf), strcmp(buf, "000")) {
-               extract(ename, buf, 0);
-               extract(etype, buf, 1);
+               extract_token(ename, buf, 0, '|', sizeof ename);
+               extract_token(etype, buf, 1, '|', sizeof etype);
                if (strlen(buf) == 0) {
                        /* skip blank lines */
                }
index 919408fab476aedf5af54e74e3bfa12ad26106ce..1dc1abb5c3add7508d281041214b58ce7e15042f 100644 (file)
@@ -179,7 +179,7 @@ FORM:               wprintf("<FORM METHOD=\"GET\" ACTION=\"/listsub\">\n"
                serv_gets(buf);
                if (buf[0] == '1') {
                        while (serv_gets(buf), strcmp(buf, "000")) {
-                               extract(sroom, buf, 0);
+                               extract_token(sroom, buf, 0, '|', sizeof sroom);
                                self = extract_int(buf, 4) & QR2_SELFLIST ;
                                if (self) {
                                        wprintf("<OPTION VALUE=\"");
index 59e9d7eedc00123860a4349c48f09721b9c643f9..fddc4894851cfa85e8f62f467cf5b297a8086be2 100644 (file)
@@ -204,10 +204,10 @@ void display_parsed_vcard(struct vCard *v, int full) {
                if (v->numprops) for (i=0; i<(v->numprops); ++i) {
 
                        thisname = strdup(v->prop[i].name);
-                       extract_token(firsttoken, thisname, 0, ';');
+                       extract_token(firsttoken, thisname, 0, ';', sizeof firsttoken);
        
                        for (j=0; j<num_tokens(thisname, ';'); ++j) {
-                               extract_token(buf, thisname, j, ';');
+                               extract_token(buf, thisname, j, ';', sizeof buf);
                                if (!strcasecmp(buf, "encoding=quoted-printable")) {
                                        is_qp = 1;
                                        remove_token(thisname, j, ';');
@@ -274,7 +274,7 @@ void display_parsed_vcard(struct vCard *v, int full) {
                                if (strlen(phone) > 0) strcat(phone, "<br />");
                                strcat(phone, thisvalue);
                                for (j=0; j<num_tokens(thisname, ';'); ++j) {
-                                       extract_token(buf, thisname, j, ';');
+                                       extract_token(buf, thisname, j, ';', sizeof buf);
                                        if (!strcasecmp(buf, "tel"))
                                                strcat(phone, "");
                                        else if (!strcasecmp(buf, "work"))
@@ -294,7 +294,7 @@ void display_parsed_vcard(struct vCard *v, int full) {
                                if (pass == 2) {
                                        wprintf("<TR><TD>Address:</TD><TD>");
                                        for (j=0; j<num_tokens(thisvalue, ';'); ++j) {
-                                               extract_token(buf, thisvalue, j, ';');
+                                               extract_token(buf, thisvalue, j, ';', sizeof buf);
                                                if (strlen(buf) > 0) {
                                                        escputs(buf);
                                                        if (j<3) wprintf("<br />");
@@ -505,10 +505,10 @@ void read_message(long msgnum) {
                }
 
                if (!strncasecmp(buf, "part=", 5)) {
-                       extract(mime_filename, &buf[5], 1);
-                       extract(mime_partnum, &buf[5], 2);
-                       extract(mime_disposition, &buf[5], 3);
-                       extract(mime_content_type, &buf[5], 4);
+                       extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
+                       extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
+                       extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
+                       extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
                        mime_length = extract_int(&buf[5], 5);
 
                        if (!strcasecmp(mime_disposition, "attachment")) {
@@ -821,10 +821,10 @@ void display_addressbook(long msgnum, char alpha) {
 
        while (serv_gets(buf), strcmp(buf, "000")) {
                if (!strncasecmp(buf, "part=", 5)) {
-                       extract(mime_filename, &buf[5], 1);
-                       extract(mime_partnum, &buf[5], 2);
-                       extract(mime_disposition, &buf[5], 3);
-                       extract(mime_content_type, &buf[5], 4);
+                       extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
+                       extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
+                       extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
+                       extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
                        mime_length = extract_int(&buf[5], 5);
 
                        if (!strcasecmp(mime_content_type, "text/x-vcard")) {
@@ -874,7 +874,7 @@ void lastfirst_firstlast(char *namebuf) {
        i = num_tokens(namebuf, ' ');
        if (i < 2) return;
 
-       extract_token(lastname, namebuf, i-1, ' ');
+       extract_token(lastname, namebuf, i-1, ' ', sizeof lastname);
        remove_token(namebuf, i-1, ' ');
        strcpy(firstname, namebuf);
        sprintf(namebuf, "%s; %s", lastname, firstname);
@@ -913,10 +913,10 @@ void fetch_ab_name(long msgnum, char *namebuf) {
 
        while (serv_gets(buf), strcmp(buf, "000")) {
                if (!strncasecmp(buf, "part=", 5)) {
-                       extract(mime_filename, &buf[5], 1);
-                       extract(mime_partnum, &buf[5], 2);
-                       extract(mime_disposition, &buf[5], 3);
-                       extract(mime_content_type, &buf[5], 4);
+                       extract_token(mime_filename, &buf[5], 1, '|', sizeof mime_filename);
+                       extract_token(mime_partnum, &buf[5], 2, '|', sizeof mime_partnum);
+                       extract_token(mime_disposition, &buf[5], 3, '|', sizeof mime_disposition);
+                       extract_token(mime_content_type, &buf[5], 4, '|', sizeof mime_content_type);
                        mime_length = extract_int(&buf[5], 5);
 
                        if (!strcasecmp(mime_content_type, "text/x-vcard")) {
@@ -1787,7 +1787,7 @@ void confirm_move_msg(void)
        serv_gets(buf);
        if (buf[0] == '1') {
                while (serv_gets(buf), strcmp(buf, "000")) {
-                       extract(targ, buf, 0);
+                       extract_token(targ, buf, 0, '|', sizeof targ);
                        wprintf("<OPTION>");
                        escputs(targ);
                        wprintf("\n");
index 0c16ebc5954efbd207d75e86f9b41ac144409a8d..6886446ec90da2211fdffc70bedb9a5308a64e85 100644 (file)
@@ -42,7 +42,7 @@ void edit_node(void) {
                        serv_gets(buf);
                        if (buf[0] == '1') {
                                while (serv_gets(buf), strcmp(buf, "000")) {
-                                       extract(cnode, buf, 0);
+                                       extract_token(cnode, buf, 0, '|', sizeof cnode);
                                        if (strcasecmp(node, cnode)) {
                                                fprintf(fp, "%s\n", buf);
                                        }
@@ -125,10 +125,10 @@ void display_edit_node(void)
        serv_gets(buf);
        if (buf[0] == '1') {
                while (serv_gets(buf), strcmp(buf, "000")) {
-                       extract(cnode, buf, 0);
-                       extract(csecret, buf, 1);
-                       extract(chost, buf, 2);
-                       extract(cport, buf, 3);
+                       extract_token(cnode, buf, 0, '|', sizeof cnode);
+                       extract_token(csecret, buf, 1, '|', sizeof csecret);
+                       extract_token(chost, buf, 2, '|', sizeof chost);
+                       extract_token(cport, buf, 3, '|', sizeof cport);
 
                        if (!strcasecmp(node, cnode)) {
                                wprintf("<FORM METHOD=\"POST\" ACTION=\"/edit_node\">\n");
@@ -185,7 +185,7 @@ void display_netconf(void)
        if (buf[0] == '1') {
                wprintf("<CENTER><TABLE border=0>\n");
                while (serv_gets(buf), strcmp(buf, "000")) {
-                       extract(node, buf, 0);
+                       extract_token(node, buf, 0, '|', sizeof node);
                        wprintf("<TR><TD><FONT SIZE=+1>");
                        escputs(node);
                        wprintf("</FONT></TD>");
@@ -240,7 +240,7 @@ void delete_node(void)
                serv_gets(buf);
                if (buf[0] == '1') {
                        while (serv_gets(buf), strcmp(buf, "000")) {
-                               extract(cnode, buf, 0);
+                               extract_token(cnode, buf, 0, '|', sizeof cnode);
                                if (strcasecmp(node, cnode)) {
                                        fprintf(fp, "%s\n", buf);
                                }
index c892b7a64ed9926286d76b34962692e584450297..25ccbf0fbb4af65e35383d4b9241df9757166262 100644 (file)
@@ -169,7 +169,7 @@ void page_popup(void)
 
        while (serv_puts("GEXP"), serv_gets(buf), buf[0]=='1') {
 
-               extract(pagefrom, &buf[4], 3);
+               extract_token(pagefrom, &buf[4], 3, '|', sizeof pagefrom);
 
                wprintf("<table border=1 bgcolor=\"#880000\"><tr><td>");
                wprintf("<span class=\"titlebar\">Instant message from ");
@@ -341,9 +341,9 @@ void chat_recv(void) {
                );
 
                for (i=0; i<num_tokens(output_data, '\n'); ++i) {
-                       extract_token(buf, output_data, i, '\n');
-                       extract_token(cl_user, buf, 0, '|');
-                       extract_token(cl_text, buf, 1, '|');
+                       extract_token(buf, output_data, i, '\n', sizeof buf);
+                       extract_token(cl_user, buf, 0, '|', sizeof cl_user);
+                       extract_token(cl_text, buf, 1, '|', sizeof cl_text);
 
                        if (strcasecmp(cl_text, "NOOP")) {
 
index 86c8cde9e605b4934df4941c934357c7f08b3ed1..36ec5c2408cd1e46c99eb00d2cba70628bd24fe6 100644 (file)
@@ -132,7 +132,7 @@ void save_preferences(void) {
        serv_gets(buf);
 }
 
-void get_preference(char *key, char *value) {
+void get_preference(char *key, char *value, size_t value_len) {
        int num_prefs;
        int i;
        char buf[SIZ];
@@ -142,10 +142,10 @@ void get_preference(char *key, char *value) {
 
        num_prefs = num_tokens(WC->preferences, '\n');
        for (i=0; i<num_prefs; ++i) {
-               extract_token(buf, WC->preferences, i, '\n');
-               extract_token(thiskey, buf, 0, '|');
+               extract_token(buf, WC->preferences, i, '\n', sizeof buf);
+               extract_token(thiskey, buf, 0, '|', sizeof thiskey);
                if (!strcasecmp(thiskey, key)) {
-                       extract_token(value, buf, 1, '|');
+                       extract_token(value, buf, 1, '|', value_len);
                }
        }
 }
@@ -159,9 +159,9 @@ void set_preference(char *key, char *value) {
 
        num_prefs = num_tokens(WC->preferences, '\n');
        for (i=0; i<num_prefs; ++i) {
-               extract_token(buf, WC->preferences, i, '\n');
+               extract_token(buf, WC->preferences, i, '\n', sizeof buf);
                if (num_tokens(buf, '|') == 2) {
-                       extract_token(thiskey, buf, 0, '|');
+                       extract_token(thiskey, buf, 0, '|', sizeof thiskey);
                        if (strcasecmp(thiskey, key)) {
                                if (newprefs == NULL) newprefs = strdup("");
                                newprefs = realloc(newprefs,
index 3d40fb3ec30e77429dcd7c1973d5ad8dd6cedbcf..d54ca16199accb15f7b3a7c0a70c4d5ae14046e8 100644 (file)
@@ -63,7 +63,7 @@ void load_floorlist(void)
                return;
        }
        while (serv_gets(buf), strcmp(buf, "000")) {
-               extract(floorlist[extract_int(buf, 0)], buf, 1);
+               extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
        }
 }
 
@@ -180,7 +180,7 @@ void listrms(char *variety)
        while (serv_gets(buf), strcmp(buf, "000")) {
                ++num_rooms;
                rp = malloc(sizeof(struct roomlisting));
-               extract(rp->rlname, buf, 0);
+               extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
                rp->rlflags = extract_int(buf, 1);
                rp->rlfloor = extract_int(buf, 2);
                rp->rlorder = extract_int(buf, 3);
@@ -546,7 +546,7 @@ void gotoroom(char *gname)
        if (buf[0] != '2') {
                return;
        }
-       extract(WC->wc_roomname, &buf[4], 0);
+       extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
        WC->room_flags = extract_int(&buf[4], 4);
        /* highest_msg_read = extract_int(&buf[4],6);
           maxmsgnum = extract_int(&buf[4],5);
@@ -630,7 +630,7 @@ void gotonext(void)
                        while (serv_gets(buf), strcmp(buf, "000")) {
                                mptr = (struct march *) malloc(sizeof(struct march));
                                mptr->next = NULL;
-                               extract(mptr->march_name, buf, 0);
+                               extract_token(mptr->march_name, buf, 0, '|', sizeof mptr->march_name);
                                mptr->march_floor = extract_int(buf, 2);
                                mptr->march_order = extract_int(buf, 3);
                                if (WC->march == NULL) {
@@ -747,9 +747,9 @@ int self_service(int newval) {
        serv_gets(buf);
        if (buf[0] != '2') return(0);
 
-       extract(name, &buf[4], 0);
-       extract(password, &buf[4], 1);
-       extract(dirname, &buf[4], 2);
+       extract_token(name, &buf[4], 0, '|', sizeof name);
+       extract_token(password, &buf[4], 1, '|', sizeof password);
+       extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
        flags = extract_int(&buf[4], 3);
        floor = extract_int(&buf[4], 4);
        order = extract_int(&buf[4], 5);
@@ -826,9 +826,9 @@ void display_editroom(void)
                display_main_menu();
                return;
        }
-       extract(er_name, &buf[4], 0);
-       extract(er_password, &buf[4], 1);
-       extract(er_dirname, &buf[4], 2);
+       extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
+       extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
+       extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
        er_flags = extract_int(&buf[4], 3);
        er_floor = extract_int(&buf[4], 4);
 
@@ -1082,7 +1082,7 @@ void display_editroom(void)
                if (buf[0] != '2') {
                        wprintf("<EM>%s</EM>\n", &buf[4]);
                } else {
-                       extract(er_roomaide, &buf[4], 0);
+                       extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
                        wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
                }
        
@@ -1106,7 +1106,7 @@ void display_editroom(void)
                serv_puts("CONF getsys|application/x-citadel-ignet-config");
                serv_gets(buf);
                if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
-                       extract(node, buf, 0);
+                       extract_token(node, buf, 0, '|', sizeof node);
                        not_shared_with = realloc(not_shared_with,
                                        strlen(not_shared_with) + 32);
                        strcat(not_shared_with, node);
@@ -1116,9 +1116,9 @@ void display_editroom(void)
                serv_puts("GNET");
                serv_gets(buf);
                if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
-                       extract(cmd, buf, 0);
-                       extract(node, buf, 1);
-                       extract(remote_room, buf, 2);
+                       extract_token(cmd, buf, 0, '|', sizeof cmd);
+                       extract_token(node, buf, 1, '|', sizeof node);
+                       extract_token(remote_room, buf, 2, '|', sizeof remote_room);
                        if (!strcasecmp(cmd, "ignet_push_share")) {
                                shared_with = realloc(shared_with,
                                                strlen(shared_with) + 32);
@@ -1132,10 +1132,10 @@ void display_editroom(void)
                }
 
                for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
-                       extract_token(buf, shared_with, i, '\n');
-                       extract_token(node, buf, 0, '|');
+                       extract_token(buf, shared_with, i, '\n', sizeof buf);
+                       extract_token(node, buf, 0, '|', sizeof node);
                        for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
-                               extract_token(cmd, not_shared_with, j, '\n');
+                               extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
                                if (!strcasecmp(node, cmd)) {
                                        remove_token(not_shared_with, j, '\n');
                                }
@@ -1157,9 +1157,9 @@ void display_editroom(void)
                );
 
                for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
-                       extract_token(buf, shared_with, i, '\n');
-                       extract_token(node, buf, 0, '|');
-                       extract_token(remote_room, buf, 1, '|');
+                       extract_token(buf, shared_with, i, '\n', sizeof buf);
+                       extract_token(node, buf, 0, '|', sizeof node);
+                       extract_token(remote_room, buf, 1, '|', sizeof remote_room);
                        if (strlen(node) > 0) {
                                wprintf("<FORM METHOD=\"POST\" "
                                        "ACTION=\"/netedit\">"
@@ -1201,7 +1201,7 @@ void display_editroom(void)
                );
 
                for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
-                       extract_token(node, not_shared_with, i, '\n');
+                       extract_token(node, not_shared_with, i, '\n', sizeof node);
                        if (strlen(node) > 0) {
                                wprintf("<FORM METHOD=\"POST\" "
                                        "ACTION=\"/netedit\">"
@@ -1259,9 +1259,9 @@ void display_editroom(void)
                serv_puts("GNET");
                serv_gets(buf);
                if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
-                       extract(cmd, buf, 0);
+                       extract_token(cmd, buf, 0, '|', sizeof cmd);
                        if (!strcasecmp(cmd, "listrecp")) {
-                               extract(recp, buf, 1);
+                               extract_token(recp, buf, 1, '|', sizeof recp);
                        
                                escputs(recp);
                                wprintf(" <A HREF=\"/netedit&cmd=remove&line="
@@ -1288,9 +1288,9 @@ void display_editroom(void)
                serv_puts("GNET");
                serv_gets(buf);
                if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
-                       extract(cmd, buf, 0);
+                       extract_token(cmd, buf, 0, '|', sizeof cmd);
                        if (!strcasecmp(cmd, "digestrecp")) {
-                               extract(recp, buf, 1);
+                               extract_token(recp, buf, 1, '|', sizeof recp);
                        
                                escputs(recp);
                                wprintf(" <A HREF=\"/netedit&cmd=remove&line="
@@ -1462,9 +1462,9 @@ void editroom(void)
                display_editroom();
                return;
        }
-       extract(er_name, &buf[4], 0);
-       extract(er_password, &buf[4], 1);
-       extract(er_dirname, &buf[4], 2);
+       extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
+       extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
+       extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
        er_flags = extract_int(&buf[4], 3);
 
        strcpy(er_roomaide, bstr("er_roomaide"));
@@ -1474,7 +1474,7 @@ void editroom(void)
                if (buf[0] != '2') {
                        strcpy(er_roomaide, "");
                } else {
-                       extract(er_roomaide, &buf[4], 0);
+                       extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
                }
        }
        strcpy(buf, bstr("er_name"));
@@ -1607,7 +1607,7 @@ void do_invt_kick(void) {
                escputs(&buf[4]);
                return;
         }
-        extract(room, &buf[4], 0);
+        extract_token(room, &buf[4], 0, '|', sizeof room);
 
         strcpy(username, bstr("username"));
 
@@ -1658,7 +1658,7 @@ void display_whok(void)
                escputs(&buf[4]);
                return;
         }
-        extract(room, &buf[4], 0);
+        extract_token(room, &buf[4], 0, '|', sizeof room);
 
         
        wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
@@ -1673,7 +1673,7 @@ void display_whok(void)
         serv_gets(buf);
         if (buf[0] == '1') {
                 while (serv_gets(buf), strcmp(buf, "000")) {
-                        extract(username, buf, 0);
+                        extract_token(username, buf, 0, '|', sizeof username);
                         wprintf("<OPTION>");
                         escputs(username);
                         wprintf("\n");
@@ -1845,9 +1845,9 @@ void er_set_default_view(int newview) {
        serv_gets(buf);
        if (buf[0] != '2') return;
 
-       extract(rm_name, &buf[4], 0);
-       extract(rm_pass, &buf[4], 1);
-       extract(rm_dir, &buf[4], 2);
+       extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
+       extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
+       extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
        rm_bits1 = extract_int(&buf[4], 3);
        rm_floor = extract_int(&buf[4], 4);
        rm_listorder = extract_int(&buf[4], 5);
@@ -2106,10 +2106,10 @@ void netedit(void) {
 
        /* This loop works for add *or* remove.  Spiffy, eh? */
        while (serv_gets(buf), strcmp(buf, "000")) {
-               extract(cmpa0, buf, 0);
-               extract(cmpa1, buf, 1);
-               extract(cmpb0, line, 0);
-               extract(cmpb1, line, 1);
+               extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
+               extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
+               extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
+               extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
                if ( (strcasecmp(cmpa0, cmpb0)) 
                   || (strcasecmp(cmpa1, cmpb1)) ) {
                        fprintf(fp, "%s\n", buf);
@@ -2261,7 +2261,7 @@ void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
                else {
                        wprintf("<SPAN CLASS=\"roomlist_old\">");
                }
-               extract(buf, fold[i].name, levels-1);
+               extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
                escputs(buf);
                wprintf("</SPAN>");
 
@@ -2339,7 +2339,7 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
                if (levels == 1) {
 
                        /* Begin inner box */
-                       extract(buf, fold[i].name, levels-1);
+                       extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
                        stresc(boxtitle, buf, 1, 0);
                        svprintf("BOXTITLE", WCS_STRING, boxtitle);
                        do_template("beginbox");
@@ -2365,7 +2365,7 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
                        else {
                                wprintf("<SPAN CLASS=\"roomlist_old\">");
                        }
-                       extract(buf, fold[i].name, levels-1);
+                       extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
                        escputs(buf);
                        wprintf("</SPAN>");
                        if (fold[i].selectable) {
@@ -2422,7 +2422,7 @@ void list_all_rooms_by_floor(char *viewpref) {
                                alloc_folders * sizeof(struct folder));
                }
                memset(&fold[max_folders], 0, sizeof(struct folder));
-               extract(fold[max_folders].name, buf, 1);
+               extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
                ++max_folders;
                ++num_floors;
        }
@@ -2437,7 +2437,7 @@ void list_all_rooms_by_floor(char *viewpref) {
                                alloc_folders * sizeof(struct folder));
                }
                memset(&fold[max_folders], 0, sizeof(struct folder));
-               extract(fold[max_folders].room, buf, 0);
+               extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
                ra_flags = extract_int(buf, 5);
                flags = extract_int(buf, 1);
                fold[max_folders].floor = extract_int(buf, 2);
@@ -2515,7 +2515,7 @@ void knrooms() {
                }
        }
 
-       get_preference("roomlistview", listviewpref);
+       get_preference("roomlistview", listviewpref, sizeof listviewpref);
 
        if ( (strcasecmp(listviewpref, "folders"))
           && (strcasecmp(listviewpref, "table")) ) {
index 8b6cb3828849923e9be686b9dc182f120ed6a734..a43aecda906094047616bcb1327fdf1f52897401 100644 (file)
@@ -62,10 +62,10 @@ void set_init_entry(char *which_entry, char *new_state) {
        while(fgets(buf, sizeof buf, fp) != NULL) {
 
                if (num_tokens(buf, ':') == 4) {
-                       extract_token(entry, buf, 0, ':');
-                       extract_token(levels, buf, 1, ':');
-                       extract_token(state, buf, 2, ':');
-                       extract_token(prog, buf, 3, ':'); /* includes 0x0a LF */
+                       extract_token(entry, buf, 0, ':', sizeof entry);
+                       extract_token(levels, buf, 1, ':', sizeof levels);
+                       extract_token(state, buf, 2, ':', sizeof state);
+                       extract_token(prog, buf, 3, ':', sizeof prog); /* includes 0x0a LF */
 
                        if (!strcmp(entry, which_entry)) {
                                strcpy(state, new_state);
@@ -120,8 +120,8 @@ void shutdown_service(void) {
        } else {
                while (fgets(buf, sizeof buf, infp) != NULL) {
                        buf[strlen(buf) - 1] = 0;
-                       extract_token(entry, buf, 0, ':');      
-                       extract_token(prog, buf, 3, ':');
+                       extract_token(entry, buf, 0, ':', sizeof entry);
+                       extract_token(prog, buf, 3, ':', sizeof prog);
                        if (!strncasecmp(prog, looking_for,
                           strlen(looking_for))) {
                                ++have_entry;
@@ -213,7 +213,7 @@ int yesno(char *question)
                newtCenteredWindow(76, 10, "Question");
                form = newtForm(NULL, NULL, 0);
                for (i=0; i<num_tokens(question, '\n'); ++i) {
-                       extract_token(buf, question, i, '\n');
+                       extract_token(buf, question, i, '\n', sizeof buf);
                        newtFormAddComponent(form, newtLabel(1, 1+i, buf));
                }
                yesbutton = newtButton(10, 5, "Yes");
@@ -288,7 +288,7 @@ void set_value(char *prompt, char str[])
                newtCenteredWindow(76, 10, "WebCit setup");
                form = newtForm(NULL, NULL, 0);
                for (i=0; i<num_tokens(prompt, '\n'); ++i) {
-                       extract_token(buf, prompt, i, '\n');
+                       extract_token(buf, prompt, i, '\n', sizeof buf);
                        newtFormAddComponent(form, newtLabel(1, 1+i, buf));
                }
                newtFormAddComponent(form, newtEntry(1, 8, str, 74, &result,
@@ -334,7 +334,7 @@ void important_message(char *title, char *msgtext)
                newtCenteredWindow(76, 10, title);
                form = newtForm(NULL, NULL, 0);
                for (i=0; i<num_tokens(msgtext, '\n'); ++i) {
-                       extract_token(buf, msgtext, i, '\n');
+                       extract_token(buf, msgtext, i, '\n', sizeof buf);
                        newtFormAddComponent(form, newtLabel(1, 1+i, buf));
                }
                newtFormAddComponent(form, newtButton(35, 5, "OK"));
index c9073c7da784008e9eb29d703229bb96800ab7d4..ff735031e0c07f23b3244e09bf21f3c6d4844306 100644 (file)
@@ -85,12 +85,12 @@ void new_messages_section(void) {
 
        wprintf("<TABLE BORDER=0 WIDTH=100%%>\n");
        for (i=0; i<number_of_rooms_to_check; ++i) {
-               extract(room, rooms_to_check, i);
+               extract_token(room, rooms_to_check, i, '|', sizeof room);
 
                serv_printf("GOTO %s", room);
                serv_gets(buf);
                if (buf[0] == '2') {
-                       extract(room, &buf[4], 0);
+                       extract_token(room, &buf[4], 0, '|', sizeof room);
                        wprintf("<TR><TD><A HREF=\"/dotgoto?room=");
                        urlescputs(room);
                        wprintf("\">");
@@ -119,7 +119,7 @@ void wholist_section(void) {
        serv_puts("RWHO");
        serv_gets(buf);
        if (buf[0] == '1') while(serv_gets(buf), strcmp(buf, "000")) {
-               extract(user, buf, 1);
+               extract_token(user, buf, 1, '|', sizeof user);
                escputs(user);
                wprintf("<br />\n");
        }
index 83c4d45e0499c7961cbfadf7f419b2a274c8211c..f001ffb7e4cfa8e5adf5856009bfbf69aef79adb 100644 (file)
@@ -73,30 +73,36 @@ int num_tokens(char *source, char tok)
 }
 
 /*
- * extract_token()  -  a smarter string tokenizer
+ * extract_token() - a string tokenizer
  */
-void extract_token(char *dest, char *source, int parmnum, char separator)
+void extract_token(char *dest, const char *source, int parmnum, char separator, int maxlen)
 {
-       int i;
-       int len;
-       int curr_parm;
+       char *d;                /* dest */
+       const char *s;          /* source */
+       int count = 0;
+       int len = 0;
 
        strcpy(dest, "");
-       len = 0;
-       curr_parm = 0;
 
-       if (strlen(source) == 0) {
-               return;
+       /* Locate desired parameter */
+       s = source;
+       while (count < parmnum) {
+               /* End of string, bail! */
+               if (!*s) {
+                       s = NULL;
+                       break;
+               }
+               if (*s == separator) {
+                       count++;
+               }
+               s++;
        }
+       if (!s) return;         /* Parameter not found */
 
-       for (i = 0; i < strlen(source); ++i) {
-               if (source[i] == separator) {
-                       ++curr_parm;
-               } else if (curr_parm == parmnum) {
-                       dest[len + 1] = 0;
-                       dest[len++] = source[i];
-               }
+       for (d = dest; *s && *s != separator && ++len<maxlen; s++, d++) {
+               *d = *s;
        }
+       *d = 0;
 }
 
 
@@ -146,23 +152,23 @@ void remove_token(char *source, int parmnum, char separator)
 /*
  * extract_int()  -  extract an int parm w/o supplying a buffer
  */
-int extract_int(char *source, int parmnum)
+int extract_int(const char *source, int parmnum)
 {
-       char buf[SIZ];
-
-       extract_token(buf, source, parmnum, '|');
-       return (atoi(buf));
+       char buf[32];
+       
+       extract_token(buf, source, parmnum, '|', sizeof buf);
+       return(atoi(buf));
 }
 
 /*
  * extract_long()  -  extract an long parm w/o supplying a buffer
  */
-long extract_long(char *source, long int parmnum)
+long extract_long(const char *source, int parmnum)
 {
-       char buf[SIZ];
-
-       extract_token(buf, source, parmnum, '|');
-       return (atol(buf));
+       char buf[32];
+       
+       extract_token(buf, source, parmnum, '|', sizeof buf);
+       return(atol(buf));
 }
 
 
@@ -170,15 +176,6 @@ long extract_long(char *source, long int parmnum)
 
 
 
-
-
-
-
-
-
-
-
-
 /*
  * check for the presence of a character within a string (returns count)
  */
@@ -326,8 +323,7 @@ void striplt(char *buf)
  * Determine whether the specified message number is contained within the
  * specified set.
  */
-int is_msg_in_mset(char *mset, long msgnum)
-{
+int is_msg_in_mset(char *mset, long msgnum) {
        int num_sets;
        int s;
        char setstr[SIZ], lostr[SIZ], histr[SIZ];       /* was 1024 */
@@ -337,30 +333,30 @@ int is_msg_in_mset(char *mset, long msgnum)
         * Now set it for all specified messages.
         */
        num_sets = num_tokens(mset, ',');
-       for (s = 0; s < num_sets; ++s) {
-               extract_token(setstr, mset, s, ',');
+       for (s=0; s<num_sets; ++s) {
+               extract_token(setstr, mset, s, ',', sizeof setstr);
 
-               extract_token(lostr, setstr, 0, ':');
+               extract_token(lostr, setstr, 0, ':', sizeof lostr);
                if (num_tokens(setstr, ':') >= 2) {
-                       extract_token(histr, setstr, 1, ':');
+                       extract_token(histr, setstr, 1, ':', sizeof histr);
                        if (!strcmp(histr, "*")) {
-                               snprintf(histr, sizeof histr, "%ld",
-                                        LONG_MAX);
+                               snprintf(histr, sizeof histr, "%ld", LONG_MAX);
                        }
-               } else {
+               } 
+               else {
                        strcpy(histr, lostr);
                }
                lo = atol(lostr);
                hi = atol(histr);
 
-               if ((msgnum >= lo) && (msgnum <= hi))
-                       return (1);
+               if ((msgnum >= lo) && (msgnum <= hi)) return(1);
        }
 
-       return (0);
+       return(0);
 }
 
 
+
 /*
  * Strip a boundarized substring out of a string (for example, remove
  * parentheses and anything inside them).
index 60ee1881c48a21f06f4da6bf702d34815e834d24..835105bf37b00de501ec2533dc65ca1aa587eab7 100644 (file)
@@ -81,7 +81,7 @@ void select_user_to_edit(char *message, char *preselect)
         serv_gets(buf);
         if (buf[0] == '1') {
                 while (serv_gets(buf), strcmp(buf, "000")) {
-                        extract(username, buf, 0);
+                        extract_token(username, buf, 0, '|', sizeof username);
                         wprintf("<OPTION");
                        if (preselect != NULL)
                           if (!strcasecmp(username, preselect))
@@ -143,8 +143,8 @@ TRYAGAIN:
                if (buf[0]=='1') {
                        while(serv_gets(buf), strcmp(buf, "000")) {
                                if (!strncasecmp(buf, "part=", 5)) {
-                                       extract(partnum, &buf[5], 2);
-                                       extract(content_type, &buf[5], 4);
+                                       extract_token(partnum, &buf[5], 2, '|', sizeof partnum);
+                                       extract_token(content_type, &buf[5], 4, '|', sizeof content_type);
                                        if (!strcasecmp(content_type,
                                           "text/x-vcard")) {
                                                vcard_msgnum = stuff->msgnum;
@@ -262,8 +262,8 @@ void display_edituser(char *supplied_username, int is_new) {
                return;
        }
 
-       extract(username, &buf[4], 0);
-       extract(password, &buf[4], 1);
+       extract_token(username, &buf[4], 0, '|', sizeof username);
+       extract_token(password, &buf[4], 1, '|', sizeof password);
        flags = extract_int(&buf[4], 2);
        timescalled = extract_int(&buf[4], 3);
        msgsposted = extract_int(&buf[4], 4);
index ad828db6de242f8ad5e15a7a3a5c1ad8245cde1b..69a4c2e88b940dc5cc604773b8ecad1f781622d3 100644 (file)
@@ -77,7 +77,7 @@ void userlist(void)
        wprintf("<TH>Last Login</TH><TH>Total Logins</TH><TH>Total Posts</TH></TR>\n");
 
        while (serv_gets(buf), strcmp(buf, "000")) {
-               extract(fl, buf, 0);
+               extract_token(fl, buf, 0, '|', sizeof fl);
                has_bio = 0;
                for (bptr = bio; bptr != NULL; bptr = bptr->next) {
                        if (!strcasecmp(fl, bptr->name))
index 23c8df4a817dd173edcc03ac4b5d7ca6e04bbfc2..fbc271174bed7a1f93c9ea00e82ce958d36c8871 100644 (file)
@@ -127,11 +127,11 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to) {
                        value = vcard_get_prop(v, "", 0, i++, 0);
        
                        if (!strcasecmp(key, "n")) {
-                               extract_token(lastname, value, 0, ';');
-                               extract_token(firstname, value, 1, ';');
-                               extract_token(middlename, value, 2, ';');
-                               extract_token(prefix, value, 3, ';');
-                               extract_token(suffix, value, 4, ';');
+                               extract_token(lastname, value, 0, ';', sizeof lastname);
+                               extract_token(firstname, value, 1, ';', sizeof firstname);
+                               extract_token(middlename, value, 2, ';', sizeof middlename);
+                               extract_token(prefix, value, 3, ';', sizeof prefix);
+                               extract_token(suffix, value, 4, ';', sizeof suffix);
                        }
 
                        else if (!strcasecmp(key, "title")) {
@@ -143,21 +143,21 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to) {
                        }
        
                        else if (!strcasecmp(key, "adr")) {
-                               extract_token(pobox, value, 0, ';');
-                               extract_token(extadr, value, 1, ';');
-                               extract_token(street, value, 2, ';');
-                               extract_token(city, value, 3, ';');
-                               extract_token(state, value, 4, ';');
-                               extract_token(zipcode, value, 5, ';');
-                               extract_token(country, value, 6, ';');
+                               extract_token(pobox, value, 0, ';', sizeof pobox);
+                               extract_token(extadr, value, 1, ';', sizeof extadr);
+                               extract_token(street, value, 2, ';', sizeof street);
+                               extract_token(city, value, 3, ';', sizeof city);
+                               extract_token(state, value, 4, ';', sizeof state);
+                               extract_token(zipcode, value, 5, ';', sizeof zipcode);
+                               extract_token(country, value, 6, ';', sizeof country);
                        }
        
                        else if (!strcasecmp(key, "tel;home")) {
-                               extract_token(hometel, value, 0, ';');
+                               extract_token(hometel, value, 0, ';', sizeof hometel);
                        }
        
                        else if (!strcasecmp(key, "tel;work")) {
-                               extract_token(worktel, value, 0, ';');
+                               extract_token(worktel, value, 0, ';', sizeof worktel);
                        }
        
                        else if (!strcasecmp(key, "email;internet")) {
@@ -372,7 +372,7 @@ void submit_vcard(void) {
 
        serv_printf("email;internet:%s\n", bstr("primary_inetemail"));  
        for (i=0; i<num_tokens(bstr("other_inetemail"), '\n'); ++i) {
-               extract_token(buf, bstr("other_inetemail"), i, '\n');
+               extract_token(buf, bstr("other_inetemail"), i, '\n', sizeof buf);
                if (strlen(buf) > 0) {
                        serv_printf("email;internet:%s", buf);
                }
index be1c6a68fd1b097d6ec60aec80908a8159c147c6..b615dbc5a81bf43d1575fde006f3c8583fbbb854 100644 (file)
@@ -653,7 +653,7 @@ void output_mimepart()
        if (buf[0] == '2') {
                bytes = extract_long(&buf[4], 0);
                content = malloc(bytes + 2);
-               extract(content_type, &buf[4], 3);
+               extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
                output_headers(0, 0, 0, 0, 0, 0, 0);
                read_server_binary(content, bytes);
                serv_puts("CLOS");
@@ -684,7 +684,7 @@ char *load_mimepart(long msgnum, char *partnum)
        serv_gets(buf);
        if (buf[0] == '2') {
                bytes = extract_long(&buf[4], 0);
-               extract(content_type, &buf[4], 3);
+               extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
 
                content = malloc(bytes + 2);
                read_server_binary(content, bytes);
@@ -904,7 +904,7 @@ void session_loop(struct httprequest *req)
 
        strcpy(cmd, hptr->line);
        hptr = hptr->next;
-       extract_token(method, cmd, 0, ' ');
+       extract_token(method, cmd, 0, ' ', sizeof method);
        extract_action(action, cmd);
 
        while (hptr != NULL) {
@@ -914,12 +914,14 @@ void session_loop(struct httprequest *req)
                if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
                        safestrncpy(cookie, &buf[15], sizeof cookie);
                        cookie_to_stuff(cookie, NULL,
-                                     c_username, c_password, c_roomname);
+                                       c_username, sizeof c_username,
+                                       c_password, sizeof c_password,
+                                       c_roomname, sizeof c_roomname);
                }
                else if (!strncasecmp(buf, "Authorization: Basic ", 21)) {
                        CtdlDecodeBase64(c_httpauth_string, &buf[21], strlen(&buf[21]));
-                       extract_token(c_httpauth_user, c_httpauth_string, 0, ':');
-                       extract_token(c_httpauth_pass, c_httpauth_string, 1, ':');
+                       extract_token(c_httpauth_user, c_httpauth_string, 0, ':', sizeof c_httpauth_user);
+                       extract_token(c_httpauth_pass, c_httpauth_string, 1, ':', sizeof c_httpauth_pass);
                }
                else if (!strncasecmp(buf, "Content-length: ", 16)) {
                        ContentLength = atoi(&buf[16]);
index ec39ab477eaf8d0f4b0e6e7d5ae4cb4acb40af31..e9747c083943ac47b55b0e6b1a94741915a18de1 100644 (file)
@@ -236,7 +236,6 @@ struct wcsession {
        int gzip_ok;                    /* Nonzero if Accept-encoding: gzip */
 };
 
-#define extract(dest,source,parmnum)   extract_token(dest,source,parmnum,'|')
 #define num_parms(source)              num_tokens(source, '|')
 
 /* Per-session data */
@@ -262,7 +261,9 @@ void do_setup_wizard(void);
 void stuff_to_cookie(char *cookie, int session,
                        char *user, char *pass, char *room);
 void cookie_to_stuff(char *cookie, int *session,
-                       char *user, char *pass, char *room);
+                char *user, size_t user_len,
+                char *pass, size_t pass_len,
+                char *room, size_t room_len);
 void locate_host(char *, int);
 void become_logged_in(char *, char *, char *);
 void do_login(void);
@@ -304,8 +305,8 @@ void url(char *buf);
 void escputs1(char *strbuf, int nbsp, int nolinebreaks);
 void msgesc(char *target, char *strbuf);
 void msgescputs(char *strbuf);
-long extract_long(char *source, long int parmnum);
-int extract_int(char *source, int parmnum);
+int extract_int(const char *source, int parmnum);
+long extract_long(const char *source, int parmnum);
 void stripout(char *str, char leftboundary, char rightboundary);
 void dump_vars(void);
 void embed_main_menu(void);
@@ -388,7 +389,7 @@ void do_template(void *templatename);
 int lingering_close(int fd);
 char *memreadline(char *start, char *buf, int maxlen);
 int num_tokens (char *source, char tok);
-void extract_token(char *dest, char *source, int parmnum, char separator);
+void extract_token(char *dest, const char *source, int parmnum, char separator, int maxlen);
 void remove_token(char *source, int parmnum, char separator);
 char *load_mimepart(long msgnum, char *partnum);
 int pattern2(char *search, char *patn);
@@ -407,7 +408,7 @@ void folders(void);
 void do_stuff_to_msgs(void);
 void load_preferences(void);
 void save_preferences(void);
-void get_preference(char *key, char *value);
+void get_preference(char *key, char *value, size_t value_len);
 void set_preference(char *key, char *value);
 void knrooms(void);
 int is_msg_in_mset(char *mset, long msgnum);
index 18d1f0844ae063c0b5cf5fe108d35780d6948c6d..c3bb03f868d59888bc5057be0143ce7d04da3372 100644 (file)
@@ -84,11 +84,11 @@ void whobbs(void)
        if (buf[0] == '1') {
                while (serv_gets(buf), strcmp(buf, "000")) {
                        sess = extract_int(buf, 0);
-                       extract(user, buf, 1);
-                       extract(room, buf, 2);
-                       extract(host, buf, 3);
-                       extract(realroom, buf, 9);
-                       extract(realhost, buf, 10);
+                       extract_token(user, buf, 1, '|', sizeof user);
+                       extract_token(room, buf, 2, '|', sizeof room);
+                       extract_token(host, buf, 3, '|', sizeof host);
+                       extract_token(realroom, buf, 9, '|', sizeof realroom);
+                       extract_token(realhost, buf, 10, '|', sizeof realhost);
                        last_activity = extract_long(buf, 5);
 
                        bg = 1 - bg;