Completely reworked the path convertion functions
[mmh] / uip / mhbuildsbr.c
index 23163f7..873b0e3 100644 (file)
@@ -171,8 +171,8 @@ build_mime(char *infile)
                        }
 
                        /* get copies of the buffers */
-                       np = add(name, NULL);
-                       vp = add(buf, NULL);
+                       np = getcpy(name);
+                       vp = getcpy(buf);
 
                        /* if necessary, get rest of field */
                        while (state == FLDPLUS) {
@@ -214,7 +214,7 @@ finish_field:
        ** Now add the MIME-Version header field
        ** to the list of header fields.
        */
-       np = add(VRSN_FIELD, NULL);
+       np = getcpy(VRSN_FIELD);
        vp = concat(" ", VRSN_VALUE, "\n", NULL);
        add_header(ct, np, vp);
 
@@ -227,7 +227,7 @@ finish_field:
                done(1);
        ct->c_type = CT_MULTIPART;
        ct->c_subtype = MULTI_MIXED;
-       ct->c_file = add(infile, NULL);
+       ct->c_file = getcpy(infile);
 
        if ((m = (struct multipart *) calloc(1, sizeof(*m))) == NULL)
                adios(NULL, "out of memory");
@@ -424,7 +424,7 @@ user_content(FILE *in, char *file, char *buf, CT *ctp)
                        adios("mhbuildsbr", "unable to create temporary file");
 
                /* use a temp file to collect the plain text lines */
-               ce->ce_file = add(cp, NULL);
+               ce->ce_file = getcpy(cp);
                ce->ce_unlink = 1;
 
                if (buf[0] == '#' && buf[1] == '<') {
@@ -652,7 +652,7 @@ use_forw:
                                        continue;
                                if (!*cp)
                                        adios(NULL, "empty pipe command for #%s directive", ci->ci_type);
-                               cp = add(cp, NULL);
+                               cp = getcpy(cp);
                                free(ci->ci_magic);
                                ci->ci_magic = cp;
                        } else {
@@ -682,7 +682,7 @@ use_forw:
                                done(1);
                        }
                }
-               ci->ci_magic = add(cp, NULL);
+               ci->ci_magic = getcpy(cp);
                return OK;
        }
 
@@ -715,13 +715,13 @@ use_forw:
                                if (folder)
                                        adios(NULL, "only one folder per #forw directive");
                                else
-                                       folder = pluspath(cp);
+                                       folder = getcpy(expandfol(cp));
                        }
                }
 
                /* else, use the current folder */
                if (!folder)
-                       folder = add(getfolder(1), NULL);
+                       folder = getcpy(getcurfol());
 
                if (!(mp = folder_read(folder)))
                        adios(NULL, "unable to read folder %s", folder);
@@ -773,7 +773,7 @@ use_forw:
                                        snprintf(buffer, sizeof(buffer),
                                                        "%s/%d", mp->foldpath,
                                                        msgnum);
-                                       pe->ce_file = add(buffer, NULL);
+                                       pe->ce_file = getcpy(buffer);
                                        if (listsw && stat(pe->ce_file, &st)
                                                        != NOTOK)
                                                p->c_end = (long) st.st_size;
@@ -795,7 +795,7 @@ use_forw:
                        msgnum = mp->lowsel;
                        snprintf(buffer, sizeof(buffer), "%s/%d",
                                        mp->foldpath, msgnum);
-                       ce->ce_file = add(buffer, NULL);
+                       ce->ce_file = getcpy(buffer);
                        if (listsw && stat(ce->ce_file, &st) != NOTOK)
                                ct->c_end = (long) st.st_size;
                }
@@ -966,7 +966,7 @@ compose_content(CT ct)
                        CT p = part->mp_part;
 
                        sprintf(pp, "%d", partnum);
-                       p->c_partno = add(partnam, NULL);
+                       p->c_partno = getcpy(partnam);
                        if (compose_content(p) == NOTOK)
                                return NOTOK;
                }
@@ -1032,7 +1032,7 @@ compose_content(CT ct)
                        if (tfile == NULL) {
                                adios("mhbuildsbr", "unable to create temporary file");
                        }
-                       ce->ce_file = add(tfile, NULL);
+                       ce->ce_file = getcpy(tfile);
                        ce->ce_unlink = 1;
 
                        xstdout = 0;
@@ -1369,7 +1369,7 @@ scan_content(CT ct)
                                                NULL);
                        } else {
                                t->tx_charset = CHARSET_USASCII;
-                               *ap = add("charset=us-ascii", NULL);
+                               *ap = getcpy("charset=us-ascii");
                        }
 
                        cp = strchr(*ap++, '=');
@@ -1438,7 +1438,7 @@ build_headers(CT ct)
                ep = ci->ci_values;
                snprintf(buffer, sizeof(buffer), "boundary=%s%d",
                                prefix, level++);
-               cp = strchr(*ap++ = add(buffer, NULL), '=');
+               cp = strchr(*ap++ = getcpy(buffer), '=');
                *ap = NULL;
                *cp++ = '\0';
                *ep = cp;
@@ -1457,7 +1457,7 @@ build_headers(CT ct)
        /*
        ** output the content type and subtype
        */
-       np = add(TYPE_FIELD, NULL);
+       np = getcpy(TYPE_FIELD);
        vp = concat(" ", ci->ci_type, "/", ci->ci_subtype, NULL);
 
        /* keep track of length of line */
@@ -1514,7 +1514,7 @@ build_headers(CT ct)
        ** output the Content-ID, unless disabled by -nocontentid
        */
        if (contentidsw && ct->c_id) {
-               np = add(ID_FIELD, NULL);
+               np = getcpy(ID_FIELD);
                vp = concat(" ", ct->c_id, NULL);
                add_header(ct, np, vp);
        }
@@ -1523,7 +1523,7 @@ build_headers(CT ct)
        ** output the Content-Description
        */
        if (ct->c_descr) {
-               np = add(DESCR_FIELD, NULL);
+               np = getcpy(DESCR_FIELD);
                vp = concat(" ", ct->c_descr, NULL);
                add_header(ct, np, vp);
        }
@@ -1532,7 +1532,7 @@ build_headers(CT ct)
        ** output the Content-Disposition
        */
        if (ct->c_dispo) {
-               np = add(DISPO_FIELD, NULL);
+               np = getcpy(DISPO_FIELD);
                vp = concat(" ", ct->c_dispo, NULL);
                add_header(ct, np, vp);
        }
@@ -1550,7 +1550,7 @@ skip_headers:
        ** output the Content-MD5
        */
        if (checksw) {
-               np = add(MD5_FIELD, NULL);
+               np = getcpy(MD5_FIELD);
                vp = calculate_digest(ct, (ct->c_encoding == CE_QUOTED) ?
                                1 : 0);
                add_header(ct, np, vp);
@@ -1563,7 +1563,7 @@ skip_headers:
        case CE_7BIT:
                /* Nothing to output */
 #if 0
-               np = add(ENCODING_FIELD, NULL);
+               np = getcpy(ENCODING_FIELD);
                vp = concat(" ", "7bit", "\n", NULL);
                add_header(ct, np, vp);
 #endif
@@ -1573,7 +1573,7 @@ skip_headers:
                if (ct->c_type == CT_MESSAGE)
                        adios(NULL, "internal error, invalid encoding");
 
-               np = add(ENCODING_FIELD, NULL);
+               np = getcpy(ENCODING_FIELD);
                vp = concat(" ", "8bit", "\n", NULL);
                add_header(ct, np, vp);
                break;
@@ -1582,7 +1582,7 @@ skip_headers:
                if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART)
                        adios(NULL, "internal error, invalid encoding");
 
-               np = add(ENCODING_FIELD, NULL);
+               np = getcpy(ENCODING_FIELD);
                vp = concat(" ", "quoted-printable", "\n", NULL);
                add_header(ct, np, vp);
                break;
@@ -1591,7 +1591,7 @@ skip_headers:
                if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART)
                        adios(NULL, "internal error, invalid encoding");
 
-               np = add(ENCODING_FIELD, NULL);
+               np = getcpy(ENCODING_FIELD);
                vp = concat(" ", "base64", "\n", NULL);
                add_header(ct, np, vp);
                break;
@@ -1600,7 +1600,7 @@ skip_headers:
                if (ct->c_type == CT_MESSAGE)
                        adios(NULL, "internal error, invalid encoding");
 
-               np = add(ENCODING_FIELD, NULL);
+               np = getcpy(ENCODING_FIELD);
                vp = concat(" ", "binary", "\n", NULL);
                add_header(ct, np, vp);
                break;