Replace getcpy() and strdup() with mh_xstrdup()
[mmh] / uip / mhparse.c
index f04a348..71c1e8e 100644 (file)
@@ -166,7 +166,7 @@ parse_mime(char *file)
                        advise("mhparse", "unable to create temporary file");
                        return NULL;
                }
-               file = getcpy(tfile);
+               file = mh_xstrdup(tfile);
                chmod(file, 0600);
 
                while (fgets(buffer, sizeof(buffer), stdin))
@@ -241,7 +241,7 @@ get_content(FILE *in, char *file, int toplevel)
        ct = mh_xcalloc(1, sizeof(*ct));
 
        ct->c_fp = in;
-       ct->c_file = getcpy(file);
+       ct->c_file = mh_xstrdup(file);
        ct->c_begin = ftell(ct->c_fp) + 1;
 
        /*
@@ -255,8 +255,8 @@ get_content(FILE *in, char *file, int toplevel)
                        compnum++;
 
                        /* get copies of the buffers */
-                       np = getcpy(name);
-                       vp = getcpy(buf);
+                       np = mh_xstrdup(name);
+                       vp = mh_xstrdup(buf);
 
                        /* if necessary, get rest of field */
                        while (state == FLDPLUS) {
@@ -311,7 +311,7 @@ get_content(FILE *in, char *file, int toplevel)
                                advise(NULL, "message %s has multiple %s: fields", ct->c_file, VRSN_FIELD);
                                goto next_header;
                        }
-                       ct->c_vrsn = getcpy(hp->value);
+                       ct->c_vrsn = mh_xstrdup(hp->value);
 
                        /* Now, cleanup this field */
                        cp = ct->c_vrsn;
@@ -383,7 +383,7 @@ get_content(FILE *in, char *file, int toplevel)
                        }
 
                        /* get copy of this field */
-                       ct->c_celine = cp = getcpy(hp->value);
+                       ct->c_celine = cp = mh_xstrdup(hp->value);
 
                        while (isspace(*cp))
                                cp++;
@@ -530,7 +530,7 @@ incl_name_value(unsigned char *buf, char *name, char *value) {
                        ** Insert at first semicolon, if any.
                        ** If none, append to end.
                        */
-                       prefix = getcpy(buf);
+                       prefix = mh_xstrdup(buf);
                        if ((cp = strchr(prefix, ';'))) {
                                suffix = concat(cp, NULL);
                                *cp = '\0';
@@ -603,7 +603,7 @@ get_ctinfo(unsigned char *cp, CT ct, int magic)
        i = strlen(invo_name) + 2;
 
        /* store copy of Content-Type line */
-       cp = ct->c_ctline = getcpy(cp);
+       cp = ct->c_ctline = mh_xstrdup(cp);
 
        while (isspace(*cp))  /* trim leading spaces */
                cp++;
@@ -627,7 +627,7 @@ get_ctinfo(unsigned char *cp, CT ct, int magic)
        for (dp = cp; istoken(*dp); dp++)
                continue;
        c = *dp, *dp = '\0';
-       ci->ci_type = getcpy(cp);  /* store content type */
+       ci->ci_type = mh_xstrdup(cp);  /* store content type */
        *dp = c, cp = dp;
 
        if (!*ci->ci_type) {
@@ -649,7 +649,7 @@ get_ctinfo(unsigned char *cp, CT ct, int magic)
 
        if (*cp != '/') {
                if (!magic)
-                       ci->ci_subtype = getcpy("");
+                       ci->ci_subtype = mh_xstrdup("");
                goto magic_skip;
        }
 
@@ -663,7 +663,7 @@ get_ctinfo(unsigned char *cp, CT ct, int magic)
        for (dp = cp; istoken(*dp); dp++)
                continue;
        c = *dp, *dp = '\0';
-       ci->ci_subtype = getcpy(cp);  /* store the content subtype */
+       ci->ci_subtype = mh_xstrdup(cp);  /* store the content subtype */
        *dp = c, cp = dp;
 
        if (!*ci->ci_subtype) {
@@ -720,7 +720,7 @@ magic_skip:
                        return NOTOK;
                }
 
-               vp = (*ap = getcpy(cp)) + (up - cp);
+               vp = (*ap = mh_xstrdup(cp)) + (up - cp);
                *vp = '\0';
                for (dp++; isspace(*dp);)
                        dp++;
@@ -857,7 +857,7 @@ bad_quote:
        */
        if (*cp) {
                if (magic) {
-                       ci->ci_magic = getcpy(cp);
+                       ci->ci_magic = mh_xstrdup(cp);
 
                        /*
                        ** If there is a Content-Disposition header and
@@ -926,7 +926,7 @@ invalid:
                        ci->ci_comment = concat(dp, " ", buffer, NULL);
                        mh_free0(&dp);
                } else {
-                       ci->ci_comment = getcpy(buffer);
+                       ci->ci_comment = mh_xstrdup(buffer);
                }
        }
 
@@ -986,7 +986,7 @@ InitText(CT ct)
        /* check if content specified a character set */
        if (*ap) {
                /* store its name */
-               ct->c_charset = getcpy(norm_charmap(*ep));
+               ct->c_charset = mh_xstrdup(norm_charmap(*ep));
                /* match character set or set to CHARSET_UNKNOWN */
                for (kv = Charset; kv->kv_key; kv++) {
                        if (!mh_strcasecmp(*ep, kv->kv_key)) {
@@ -1173,7 +1173,7 @@ last_part:
                        p = part->mp_part;
 
                        sprintf(pp, "%d", partnum);
-                       p->c_partno = getcpy(partnam);
+                       p->c_partno = mh_xstrdup(partnam);
 
                        /* initialize the content of the subparts */
                        if (p->c_ctinitfnx && (*p->c_ctinitfnx) (p) == NOTOK) {
@@ -1278,7 +1278,7 @@ InitMessage(CT ct)
                */
                for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
                        if (!mh_strcasecmp(*ap, "id")) {
-                               p->pm_partid = getcpy(*ep);
+                               p->pm_partid = mh_xstrdup(*ep);
                                continue;
                        }
                        if (!mh_strcasecmp(*ap, "number")) {
@@ -1511,10 +1511,10 @@ openBase64(CT ct, char **file)
        }
 
        if (*file == NULL) {
-               ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
+               ce->ce_file = mh_xstrdup(m_mktemp(tmp, NULL, NULL));
                ce->ce_unlink = 1;
        } else {
-               ce->ce_file = getcpy(*file);
+               ce->ce_file = mh_xstrdup(*file);
                ce->ce_unlink = 0;
        }
 
@@ -1534,7 +1534,7 @@ openBase64(CT ct, char **file)
                        ** Temporary file already exists, so we rename to
                        ** version with extension.
                        */
-                       char *file_org = strdup(ce->ce_file);
+                       char *file_org = mh_xstrdup(ce->ce_file);
                        ce->ce_file = add(cp, ce->ce_file);
                        if (rename(file_org, ce->ce_file)) {
                                adios(EX_IOERR, ce->ce_file, "unable to rename %s to ",
@@ -1722,10 +1722,10 @@ openQuoted(CT ct, char **file)
        }
 
        if (*file == NULL) {
-               ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
+               ce->ce_file = mh_xstrdup(m_mktemp(tmp, NULL, NULL));
                ce->ce_unlink = 1;
        } else {
-               ce->ce_file = getcpy(*file);
+               ce->ce_file = mh_xstrdup(*file);
                ce->ce_unlink = 0;
        }
 
@@ -1745,7 +1745,7 @@ openQuoted(CT ct, char **file)
                        ** Temporary file already exists, so we rename to
                        ** version with extension.
                        */
-                       char *file_org = strdup(ce->ce_file);
+                       char *file_org = mh_xstrdup(ce->ce_file);
                        ce->ce_file = add(cp, ce->ce_file);
                        if (rename(file_org, ce->ce_file)) {
                                adios(EX_IOERR, ce->ce_file, "unable to rename %s to ",
@@ -1939,10 +1939,10 @@ open7Bit(CT ct, char **file)
        }
 
        if (*file == NULL) {
-               ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
+               ce->ce_file = mh_xstrdup(m_mktemp(tmp, NULL, NULL));
                ce->ce_unlink = 1;
        } else {
-               ce->ce_file = getcpy(*file);
+               ce->ce_file = mh_xstrdup(*file);
                ce->ce_unlink = 0;
        }
 
@@ -1962,7 +1962,7 @@ open7Bit(CT ct, char **file)
                        ** Temporary file already exists, so we rename to
                        ** version with extension.
                        */
-                       char *file_org = strdup(ce->ce_file);
+                       char *file_org = mh_xstrdup(ce->ce_file);
                        ce->ce_file = add(cp, ce->ce_file);
                        if (rename(file_org, ce->ce_file)) {
                                adios(EX_IOERR, ce->ce_file, "unable to rename %s to ",