* Holy war on strlen: use IsEmptyStr where apropriate.
[citadel.git] / citadel / client_passwords.c
index 5e8dc10de1cf56c9700d5027009fcb13ed946e04..2087f1b7a722e661b111b6a43a4573026b333adf 100644 (file)
@@ -47,22 +47,22 @@ void get_stored_password(
        FILE *fp;
        char buf[SIZ];
        char buf64[SIZ];
-       char hostbuf[SIZ], portbuf[SIZ], ubuf[SIZ], pbuf[SIZ];
+       char hostbuf[256], portbuf[256], ubuf[256], pbuf[256];
 
        strcpy(username, "");
        strcpy(password, "");
 
        determine_pwfilename(pwfile, sizeof pwfile);
-       if (strlen(pwfile)==0) return;
+       if (IsEmptyStr(pwfile)) return;
 
        fp = fopen(pwfile, "r");
        if (fp == NULL) return;
        while (fgets(buf64, sizeof buf64, fp) != NULL) {
                CtdlDecodeBase64(buf, buf64, sizeof(buf64));
-               extract(hostbuf, buf, 0);
-               extract(portbuf, buf, 1);
-               extract(ubuf, buf, 2);
-               extract(pbuf, buf, 3);
+               extract_token(hostbuf, buf, 0, '|', sizeof hostbuf);
+               extract_token(portbuf, buf, 1, '|', sizeof portbuf);
+               extract_token(ubuf, buf, 2, '|', sizeof ubuf);
+               extract_token(pbuf, buf, 3, '|', sizeof pbuf);
 
                if (!strcasecmp(hostbuf, host)) {
                        if (!strcasecmp(portbuf, port)) {
@@ -88,10 +88,10 @@ void set_stored_password(
        FILE *fp, *oldfp;
        char buf[SIZ];
        char buf64[SIZ];
-       char hostbuf[SIZ], portbuf[SIZ], ubuf[SIZ], pbuf[SIZ];
+       char hostbuf[256], portbuf[256], ubuf[256], pbuf[256];
 
        determine_pwfilename(pwfile, sizeof pwfile);
-       if (strlen(pwfile)==0) return;
+       if (IsEmptyStr(pwfile)) return;
 
        oldfp = fopen(pwfile, "r");
        if (oldfp == NULL) oldfp = fopen("/dev/null", "r");
@@ -100,10 +100,10 @@ void set_stored_password(
        if (fp == NULL) fp = fopen("/dev/null", "w");
        while (fgets(buf64, sizeof buf64, oldfp) != NULL) {
                CtdlDecodeBase64(buf, buf64, sizeof(buf64));
-               extract(hostbuf, buf, 0);
-               extract(portbuf, buf, 1);
-               extract(ubuf, buf, 2);
-               extract(pbuf, buf, 3);
+               extract_token(hostbuf, buf, 0, '|', sizeof hostbuf);
+               extract_token(portbuf, buf, 1, '|', sizeof portbuf);
+               extract_token(ubuf, buf, 2, '|', sizeof ubuf);
+               extract_token(pbuf, buf, 3, '|', sizeof pbuf);
 
                if ( (strcasecmp(hostbuf, host)) 
                   || (strcasecmp(portbuf, port)) ) {
@@ -113,7 +113,7 @@ void set_stored_password(
                        fprintf(fp, "%s\n", buf64);
                }
        }
-       if (strlen(username) > 0) {
+       if (!IsEmptyStr(username)) {
                snprintf(buf, sizeof buf, "%s|%s|%s|%s|",
                        host, port, username, password);
                CtdlEncodeBase64(buf64, buf, strlen(buf));