this harmonise the code.
Also fix some bugs, if return value of strdup is not checked.
* Write different function to read configuration files, instead
of using m_getfld.c
* convert calls from sprintf/vsprintf to snprintf/vsnprintf
-* convert calls from getcpy to strdup
* modularize access to context/profile list.
* add command printm to print messages
* finish changing to macros for msgstats and msgflags
int getanswer(char *);
char **getarguments(char *, int, char **, int);
char *get_charset();
-char *getcpy(char *);
char *getcurfol(void);
char *getdeffol(void);
int lkclose(int, char*);
char *add(char *, char *);
void create_folder(char *, int, void (*)(int));
int num_digits(int);
+char *mh_xstrdup(char *);
struct msgs_array {
int max, size;
error.c execprog.c ext_hook.c folder_addmsg.c folder_delmsgs.c \
folder_free.c folder_read.c \
folder_realloc.c gans.c getans.c getanswer.c \
- getarguments.c getcpy.c \
+ getarguments.c \
fmt_addr.c fmt_compile.c fmt_new.c fmt_rfc2047.c \
fmt_scan.c lock_file.c m_atoi.c \
m_convert.c m_draft.c m_getfld.c m_gmprot.c \
}
mp->m_next = NULL;
- mp->m_text = getcpy(str);
+ mp->m_text = mh_xstrdup(str);
if (pers)
- mp->m_pers = getcpy(pers);
+ mp->m_pers = mh_xstrdup(pers);
if (mbox == NULL) {
mp->m_type = BADHOST;
mp->m_nohost = 1;
mp->m_ingrp = ingrp;
- mp->m_gname = getcpy(grp);
+ mp->m_gname = mh_xstrdup(grp);
if (note)
- mp->m_note = getcpy(note);
+ mp->m_note = mh_xstrdup(note);
return mp;
}
if (host) {
- mp->m_mbox = getcpy(mbox);
- mp->m_host = getcpy(host);
+ mp->m_mbox = mh_xstrdup(mbox);
+ mp->m_host = mh_xstrdup(host);
} else {
mp->m_nohost = 1;
- mp->m_mbox = getcpy(mbox);
+ mp->m_mbox = mh_xstrdup(mbox);
if (route == NULL && dftype == LOCALHOST) {
mp->m_host = NULL;
mp->m_type = dftype;
} else {
- mp->m_host = route ? NULL : getcpy(dfhost);
+ mp->m_host = route ? NULL : mh_xstrdup(dfhost);
mp->m_type = route ? NETHOST : dftype;
}
goto got_host;
got_host: ;
if (route)
- mp->m_path = getcpy(route);
+ mp->m_path = mh_xstrdup(route);
mp->m_ingrp = ingrp;
if (grp)
- mp->m_gname = getcpy(grp);
+ mp->m_gname = mh_xstrdup(grp);
if (note)
- mp->m_note = getcpy(note);
+ mp->m_note = mh_xstrdup(note);
return mp;
}
*/
#include <h/mh.h> /* mh internals */
-#include <h/utils.h> /* mh_free0() */
+#include <h/utils.h>
#include <errno.h> /* system call errors */
#include <pwd.h> /* structure for getpwuid() results */
#include <unistd.h>
** set mmhpath
*/
if ((cp = getenv("MMH")) && *cp) {
- mmhpath = getcpy(expanddir(cp)); /* rel to cwd */
+ mmhpath = mh_xstrdup(expanddir(cp)); /* rel to cwd */
if (stat(mmhpath, &st) != -1 && (st.st_mode & S_IFDIR) == 0) {
adios(EX_CONFIG, NULL, "`%s' specified by your MMH environment variable is not a directory", cp);
}
*/
if ((cp = getenv("MMHP")) && *cp) {
if (*cp == '/') {
- defpath = getcpy(cp);
+ defpath = mh_xstrdup(cp);
} else {
defpath = concat(mmhpath, "/", cp, NULL);
}
}
if (*cp == '/') {
- ctxpath = getcpy(cp);
+ ctxpath = mh_xstrdup(cp);
} else {
ctxpath = concat(mmhpath, "/", cp, NULL);
}
m_defs = mh_xcalloc(1, sizeof(*np));
np = m_defs;
- np->n_name = getcpy(key);
- np->n_field = getcpy(value);
+ np->n_name = mh_xstrdup(key);
+ np->n_field = mh_xstrdup(value);
np->n_context = 1;
np->n_next = NULL;
ctxflags |= CTXMOD;
admonish(NULL, "bug: context_replace(key=\"%s\",value=\"%s\")", key, value);
if (np->n_field)
mh_free0(&(np->n_field));
- np->n_field = getcpy(value);
+ np->n_field = mh_xstrdup(value);
ctxflags |= CTXMOD;
}
return;
np->n_next = mh_xcalloc(1, sizeof(*np));
np = np->n_next;
- np->n_name = getcpy(key);
- np->n_field = getcpy(value);
+ np->n_name = mh_xstrdup(key);
+ np->n_field = mh_xstrdup(value);
np->n_context = 1;
np->n_next = NULL;
ctxflags |= CTXMOD;
}
if (strcmp(name, ".") == 0) {
- prefix = getcpy("");
+ prefix = mh_xstrdup("");
} else {
prefix = concat(name, "/", (void *)NULL);
}
** returns a pointer to the concatenated address string.
**
** We try to not do a lot of malloc/copy/free's (which is why we
-** don't call "getcpy") but still place no upper limit on the
+** don't call "mh_xstrdup") but still place no upper limit on the
** length of the result string.
**
** This routine is placed in a separate library so it can be
if (format_string)
mh_free0(&format_string);
- format_string = getcpy(fstring);
+ format_string = mh_xstrdup(fstring);
usr_fstring = fstring;
/* init the component hash table. */
if (form) {
if (*form == '=') {
- formats = getcpy(form+1);
+ formats = mh_xstrdup(form+1);
} else {
if ((fp = fopen(etcpath(form), "r")) == NULL) {
adios(EX_IOERR, form, "unable to open format file");
}
} else if (def_form) {
if (*def_form == '=') {
- formats = getcpy(def_form+1);
+ formats = mh_xstrdup(def_form+1);
} else {
if ((fp = fopen(etcpath(def_form), "r")) == NULL) {
adios(EX_IOERR, def_form, "unable to open format file");
struct dirent *dp;
DIR *dd;
- name = getcpy(toabsdir(name));
+ name = mh_xstrdup(toabsdir(name));
if (!(dd = opendir(name))) {
mh_free0(&name);
return NULL;
** Check if profile/context specifies any arguments
*/
if (check_context && (cp = context_find(invo_name))) {
- cp = getcpy(cp); /* make copy */
+ cp = mh_xstrdup(cp); /* make copy */
ap = brkstring(cp, " ", "\n"); /* split string */
/* Count number of arguments split */
+++ /dev/null
-/*
-** getcpy.c -- copy a string in managed memory
-**
-** THIS IS OBSOLETE. NEED TO REPLACE ALL OCCURENCES
-** OF GETCPY WITH STRDUP. BUT THIS WILL REQUIRE
-** CHANGING PARTS OF THE CODE TO DEAL WITH NULL VALUES.
-**
-** This code is Copyright (c) 2002, by the authors of nmh. See the
-** COPYRIGHT file in the root directory of the nmh distribution for
-** complete copyright information.
-*/
-
-#include <h/mh.h>
-#include <h/utils.h>
-
-
-char *
-getcpy(char *str)
-{
- char *cp;
- size_t len;
-
- if (str) {
- len = strlen(str) + 1;
- cp = mh_xcalloc(len, sizeof(char));
- memcpy(cp, str, len);
- } else {
- cp = mh_xcalloc(1, sizeof(char));
- *cp = '\0';
- }
- return cp;
-}
static char buffer[BUFSIZ];
char *folder;
- folder = getcpy(toabsdir(draftfolder));
+ folder = mh_xstrdup(toabsdir(draftfolder));
create_folder(folder, 0, exit);
if (!(mp = folder_read(folder))) {
adios(EX_IOERR, NULL, "unable to read folder %s", folder);
np = mh_xcalloc(1, sizeof(*np));
*npp = np;
*(npp = &np->n_next) = NULL;
- np->n_name = getcpy(name);
+ np->n_name = mh_xstrdup(name);
if (state == FLDPLUS) {
- cp = getcpy(field);
+ cp = mh_xstrdup(field);
while (state == FLDPLUS) {
state = m_getfld(state, name, field,
sizeof(field), ib);
** Initialize the list of sequence names. Go ahead and
** add the cur sequence to the list of sequences.
*/
- mp->msgattrs[0] = getcpy(seq_cur);
+ mp->msgattrs[0] = mh_xstrdup(seq_cur);
mp->msgattrs[1] = NULL;
make_all_public(mp); /* initially, make all public */
case FLD:
case FLDPLUS:
if (state == FLDPLUS) {
- cp = getcpy(field);
+ cp = mh_xstrdup(field);
while (state == FLDPLUS) {
state = m_getfld(state, name, field,
sizeof(field), fp);
cp = add(field, cp);
}
- seq_init(mp, getcpy(name), trimcpy(cp));
+ seq_init(mp, mh_xstrdup(name), trimcpy(cp));
mh_free0(&cp);
} else {
- seq_init(mp, getcpy(name), trimcpy(field));
+ seq_init(mp, mh_xstrdup(name), trimcpy(field));
}
continue;
(j = strlen(np->n_name) - plen) > alen &&
*(np->n_name + j) == '-' &&
strcmp(mp->foldpath, np->n_name + j + 1)==0) {
- cp = getcpy(np->n_name + alen);
+ cp = mh_xstrdup(np->n_name + alen);
*(cp + j - alen) = '\0';
- if ((i = seq_init(mp, cp, getcpy(np->n_field))) != -1)
+ if ((i = seq_init(mp, cp, mh_xstrdup(np->n_field))) != -1)
make_seq_private(mp, i);
}
}
** and split them.
*/
if ((cp = context_find(psequence))) {
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
if (!(ap = brkstring(dp, " ", "\n")) || !*ap) {
mh_free0(&dp);
return;
*/
#include <h/mh.h>
-#include <h/utils.h> /* mh_free0() */
+#include <h/utils.h>
/*
** We scan through the folder and act upon all messages
** and split them.
*/
if ((cp = context_find(usequence))) {
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
} else {
/* not set in profile, thus use the default */
- dp = getcpy(seq_unseen);
+ dp = mh_xstrdup(seq_unseen);
}
if (!(ap = brkstring(dp, " ", "\n")) || !*ap) {
/* contains no sequence name, i.e. we're finished */
*/
#include <h/mh.h>
+#include <h/utils.h>
#include <ctype.h>
}
/* now return a copy */
- return getcpy(cp);
+ return mh_xstrdup(cp);
}
/*
** add -- If "s1" is NULL, this routine just creates a
** -- copy of "s2" into newly malloc'ed memory.
-** -- (use getcpy() instead in this case)
+** -- (use mh_xstrdup() instead in this case)
** --
** -- If "s1" is not NULL, then copy the concatenation
** -- of "s1" and "s2" (note the order) into newly
}
msgs->msgs[msgs->size++] = cp;
}
+
+/*
+** mh_xstrdup() is a wrapper of strdup() to replace getcpy(). It returns
+** a copy of its argument if this is nonnull; otherwise, it returns a
+** string of length 0.
+*/
+char *
+mh_xstrdup(char * s)
+{
+ char * tmp;
+ tmp = strdup(s ? s : "");
+ if (!tmp) {
+ adios(EX_OSERR, "strdup", "can't copy string");
+ }
+ return tmp;
+}
if (deffiles && (cp = context_find("Aliasfile"))) {
char *dp = NULL;
- for (ap = brkstring(dp=getcpy(cp), " ", "\n");
+ for (ap = brkstring(dp=mh_xstrdup(cp), " ", "\n");
ap && *ap; ap++) {
if ((i = alias(etcpath(*ap))) != AK_OK) {
adios(EX_DATAERR, NULL, "aliasing error in %s: %s",
if (!mh_strcasecmp(mp->m_host, np->m_host)
&& !mh_strcasecmp(mp->m_mbox, np->m_mbox)) {
vp = vp ? add(ak->ak_name, add(",", vp))
- : getcpy(ak->ak_name);
+ : mh_xstrdup(ak->ak_name);
mnfree(np);
while (getname(""))
continue;
for (ad = ak->ak_addr; ad; ad = ad->ad_next) {
pp = ad->ad_local ? akval(ak->ak_next, ad->ad_text)
- : getcpy(ad->ad_text);
+ : mh_xstrdup(ad->ad_text);
if (cp) {
dp = cp;
if (aleq(s, ak->ak_name))
return akresult(ak);
- return getcpy(s);
+ return mh_xstrdup(s);
}
return;
ad = mh_xcalloc(1, sizeof(*ad));
- ad->ad_text = getcpy(pp);
+ ad->ad_text = mh_xstrdup(pp);
ad->ad_local = strchr(pp, '@') == NULL;
ad->ad_next = NULL;
if (ak->ak_addr)
p = mh_xcalloc(1, sizeof(*p));
- p->ak_name = getcpy(id);
+ p->ak_name = mh_xstrdup(id);
p->ak_visible = 0;
p->ak_addr = NULL;
p->ak_next = NULL;
p = mh_xcalloc(1, sizeof(*p));
- p->h_name = getcpy(pw->pw_name);
+ p->h_name = mh_xstrdup(pw->pw_name);
p->h_uid = pw->pw_uid;
p->h_gid = pw->pw_gid;
- p->h_home = getcpy(pw->pw_dir);
- p->h_shell = getcpy(pw->pw_shell);
+ p->h_home = mh_xstrdup(pw->pw_dir);
+ p->h_shell = mh_xstrdup(pw->pw_shell);
p->h_ngrps = 0;
p->h_next = NULL;
/* append to end */
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else if (*cp == '/' || *cp == '.') {
if (file)
adios(EX_USAGE, NULL, "only one file at a time!");
while ((cp = getname(arg))) {
p = mh_xcalloc(1, sizeof(*p));
if ((mp = getm(cp, NULL, 0, norm, error)) == NULL) {
- p->pq_text = getcpy(cp);
- p->pq_error = getcpy(error);
+ p->pq_text = mh_xstrdup(cp);
+ p->pq_error = mh_xstrdup(error);
status++;
} else {
- p->pq_text = getcpy(mp->m_text);
+ p->pq_text = mh_xstrdup(mp->m_text);
mnfree(mp);
}
q = (q->pq_next = p);
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else {
msgs[msgp++] = cp;
}
if (folder) {
adios(EX_USAGE, NULL, "only one folder at a time!");
} else {
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
}
} else {
if (msg) {
}
}
- cwd = getcpy(pwd());
+ cwd = mh_xstrdup(pwd());
if (form && (folder || msg)) {
adios(EX_USAGE, NULL, "can't mix forms and folders/msgs");
if (mp->numsel > 1) {
adios(EX_USAGE, NULL, "only one message at a time!");
}
- if ((in = open(form = getcpy(m_name(mp->lowsel)),
+ if ((in = open(form = mh_xstrdup(m_name(mp->lowsel)),
O_RDONLY)) == NOTOK) {
adios(EX_IOERR, form, "unable to open message");
}
if (folder) {
adios(EX_USAGE, NULL, "only one folder at a time!");
} else {
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
}
} else {
if (msg) {
}
}
- cwd = getcpy(pwd());
+ cwd = mh_xstrdup(pwd());
strncpy(drft, m_draft(seq_beyond), sizeof(drft));
if ((out = creat(drft, m_gmprot())) == NOTOK) {
adios(EX_USAGE, NULL, "only one message at a time!");
}
- msgnam = getcpy(m_name(mp->lowsel));
+ msgnam = mh_xstrdup(m_name(mp->lowsel));
if ((in = open(msgnam, O_RDONLY)) == NOTOK) {
adios(EX_IOERR, msgnam, "unable to open message");
}
foldersToDo = mh_xrealloc(foldersToDo, maxfolders * sizeof(*foldersToDo));
}
if (*cp == '+' || *cp == '@') {
- foldersToDo[numfolders++] = getcpy(expandfol(cp));
+ foldersToDo[numfolders++] = mh_xstrdup(expandfol(cp));
} else
foldersToDo[numfolders++] = cp;
}
} else {
cp = seq_unseen; /* use default */
}
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
ap = brkstring(dp, " ", "\n");
for (; ap && *ap; ap++) {
if (numsequences >= NUMATTRS) {
/* Oops, error occurred. Record it and continue. */
AllocFolders(&folders, &nFoldersAlloced, nFolders + 1);
f = &folders[nFolders++];
- f->name = getcpy(name);
+ f->name = mh_xstrdup(name);
f->error = 1;
f->priority = AssignPriority(f->name);
return 0;
/* save general folder information */
AllocFolders(&folders, &nFoldersAlloced, nFolders + 1);
f = &folders[nFolders++];
- f->name = getcpy(name);
+ f->name = mh_xstrdup(name);
f->nMsgs = mp->nummsg;
f->error = 0;
f->priority = AssignPriority(f->name);
if (argfolder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- argfolder = getcpy(expandfol(cp));
+ argfolder = mh_xstrdup(expandfol(cp));
} else {
if (msg)
adios(EX_USAGE, NULL, "only one (current) message at a time!");
/* If no folder is given, the current folder and */
/* the top of the folder stack are swapped. */
if ((cp = context_find(stack))) {
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
ap = brkstring(dp, " ", "\n");
- argfolder = getcpy(*ap++);
+ argfolder = mh_xstrdup(*ap++);
} else {
adios(EX_USAGE, NULL, "no other folder");
}
- for (cp = getcpy(getcurfol()); *ap; ap++)
+ for (cp = mh_xstrdup(getcurfol()); *ap; ap++)
cp = add(*ap, add(" ", cp));
mh_free0(&dp);
context_replace(stack, cp); /* update folder stack */
/* update folder stack */
context_replace(stack, (cp = context_find (stack)) ?
concat(getcurfol(), " ", cp, NULL) :
- getcpy(getcurfol()));
+ mh_xstrdup(getcurfol()));
}
}
if (argfolder)
adios(EX_USAGE, NULL, "sorry, no folders allowed with -pop");
if ((cp = context_find(stack))) {
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
ap = brkstring(dp, " ", "\n");
- argfolder = getcpy(*ap++);
+ argfolder = mh_xstrdup(*ap++);
} else {
adios(EX_DATAERR, NULL, "folder stack empty");
}
if (*ap) {
/* if there's anything left in the stack */
- cp = getcpy(*ap++);
+ cp = mh_xstrdup(*ap++);
for (; *ap; ap++)
cp = add(*ap, add(" ", cp));
context_replace(stack, cp); /* update folder stack */
if (listsw) {
printf("%s", argfolder ? argfolder : getcurfol());
if ((cp = context_find(stack))) {
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
for (ap = brkstring(dp, " ", "\n"); *ap; ap++)
printf(" %s", *ap);
mh_free0(&dp);
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else {
msgs[msgp++] = cp;
}
}
- cwd = getcpy(pwd());
+ cwd = mh_xstrdup(pwd());
strncpy(drft, buildsw ? toabsdir("draft") : m_draft(seq_beyond),
sizeof(drft));
/*
if (digest) {
snprintf(buf, sizeof(buf), IFORMAT, digest);
snprintf(value, sizeof(value), "%d", issue);
- context_replace(buf, getcpy(value));
+ context_replace(buf, mh_xstrdup(value));
snprintf(buf, sizeof(buf), VFORMAT, digest);
snprintf(value, sizeof(value), "%d", volume);
- context_replace(buf, getcpy(value));
+ context_replace(buf, mh_xstrdup(value));
}
context_replace(curfolder, folder); /* update current folder */
cptr->c_text = digest;
FINDCOMP(cptr, "date");
if (cptr)
- cptr->c_text = getcpy(dtimenow());
+ cptr->c_text = mh_xstrdup(dtimenow());
dat[0] = issue;
dat[1] = volume;
case AUDSW:
if (!(cp = *argp++) || *cp == '-')
adios(EX_USAGE, NULL, "missing argument to %s", argp[-2]);
- audfile = getcpy(expanddir(cp));
+ audfile = mh_xstrdup(expanddir(cp));
continue;
case NAUDSW:
audfile = NULL;
if (!(cp = *argp++) || *cp == '-')
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- from = getcpy(expanddir(cp));
+ from = mh_xstrdup(expanddir(cp));
/*
** If the truncate file is in default state,
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else {
adios(EX_USAGE, NULL, "usage: %s [+folder] [switches]",
invo_name);
if (folder) {
adios(EX_USAGE, NULL, "only one folder at a time!");
} else {
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
}
} else {
app_msgarg(&msgs, cp);
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = getcpy(toabsdir(invo_name));
+ tmp = mh_xstrdup(toabsdir(invo_name));
/* Check if we have a file to process */
if (!compfile)
}
/* 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) {
** Now add the MIME-Version header field
** to the list of header fields.
*/
- np = getcpy(VRSN_FIELD);
+ np = mh_xstrdup(VRSN_FIELD);
vp = concat(" ", VRSN_VALUE, "\n", NULL);
add_header(ct, np, vp);
}
ct->c_type = CT_MULTIPART;
ct->c_subtype = MULTI_MIXED;
- ct->c_file = getcpy(infile);
+ ct->c_file = mh_xstrdup(infile);
m = mh_xcalloc(1, sizeof(*m));
ct->c_ctparams = (void *) m;
adios(EX_CANTCREAT, "mhbuild", "unable to create temporary file");
/* use a temp file to collect the plain text lines */
- ce->ce_file = getcpy(cp);
+ ce->ce_file = mh_xstrdup(cp);
ce->ce_unlink = 1;
if (buf[0] == '#' && buf[1] == '<') {
continue;
if (!*cp)
adios(EX_DATAERR, NULL, "empty pipe command for #%s directive", ci->ci_type);
- cp = getcpy(cp);
+ cp = mh_xstrdup(cp);
mh_free0(&(ci->ci_magic));
ci->ci_magic = cp;
} else {
exit(EX_CONFIG);
}
}
- ci->ci_magic = getcpy(cp);
+ ci->ci_magic = mh_xstrdup(cp);
return OK;
}
if (folder)
adios(EX_USAGE, NULL, "only one folder per #forw directive");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
}
}
/* else, use the current folder */
if (!folder)
- folder = getcpy(getcurfol());
+ folder = mh_xstrdup(getcurfol());
if (!(mp = folder_read(folder)))
adios(EX_IOERR, NULL, "unable to read folder %s", folder);
snprintf(buffer, sizeof(buffer),
"%s/%d", mp->foldpath,
msgnum);
- pe->ce_file = getcpy(buffer);
+ pe->ce_file = mh_xstrdup(buffer);
part = mh_xcalloc(1, sizeof(*part));
*pp = part;
msgnum = mp->lowsel;
snprintf(buffer, sizeof(buffer), "%s/%d",
mp->foldpath, msgnum);
- ce->ce_file = getcpy(buffer);
+ ce->ce_file = mh_xstrdup(buffer);
}
folder_free(mp); /* free folder/message structure */
snprintf(msgid, sizeof(msgid), "<%d.%ld.%%d@%s>\n",
(int) getpid(), (long) clock, LocalName());
partno = 0;
- msgfmt = getcpy(msgid);
+ msgfmt = mh_xstrdup(msgid);
}
snprintf(msgid, sizeof(msgid), msgfmt, top ? 0 : ++partno);
- ct->c_id = getcpy(msgid);
+ ct->c_id = mh_xstrdup(msgid);
}
CT p = part->mp_part;
sprintf(pp, "%d", partnum);
- p->c_partno = getcpy(partnam);
+ p->c_partno = mh_xstrdup(partnam);
if (compose_content(p) == NOTOK)
return NOTOK;
}
if (tfile == NULL) {
adios(EX_CANTCREAT, "mhbuild", "unable to create temporary file");
}
- ce->ce_file = getcpy(tfile);
+ ce->ce_file = mh_xstrdup(tfile);
ce->ce_unlink = 1;
xstdout = 0;
NULL);
} else {
t->tx_charset = CHARSET_USASCII;
- *ap = getcpy("charset=us-ascii");
+ *ap = mh_xstrdup("charset=us-ascii");
}
cp = strchr(*ap++, '=');
ep = ci->ci_values;
snprintf(buffer, sizeof(buffer), "boundary=%s%d",
prefix, level++);
- cp = strchr(*ap++ = getcpy(buffer), '=');
+ cp = strchr(*ap++ = mh_xstrdup(buffer), '=');
*ap = NULL;
*cp++ = '\0';
*ep = cp;
/*
** output the content type and subtype
*/
- np = getcpy(TYPE_FIELD);
+ np = mh_xstrdup(TYPE_FIELD);
vp = concat(" ", ci->ci_type, "/", ci->ci_subtype, NULL);
/* keep track of length of line */
** output the Content-ID
*/
if (ct->c_id) {
- np = getcpy(ID_FIELD);
+ np = mh_xstrdup(ID_FIELD);
vp = concat(" ", ct->c_id, NULL);
add_header(ct, np, vp);
}
** output the Content-Description
*/
if (ct->c_descr) {
- np = getcpy(DESCR_FIELD);
+ np = mh_xstrdup(DESCR_FIELD);
vp = concat(" ", ct->c_descr, NULL);
if (encode_rfc2047(DESCR_FIELD, &vp, NULL)) {
adios(EX_DATAERR, NULL, "Unable to encode %s header", DESCR_FIELD);
** output the Content-Disposition
*/
if (ct->c_dispo) {
- np = getcpy(DISPO_FIELD);
+ np = mh_xstrdup(DISPO_FIELD);
vp = concat(" ", ct->c_dispo, NULL);
add_header(ct, np, vp);
}
if (ct->c_type == CT_MESSAGE)
adios(EX_DATAERR, NULL, "internal error, invalid encoding");
- np = getcpy(ENCODING_FIELD);
+ np = mh_xstrdup(ENCODING_FIELD);
vp = concat(" ", "8bit", "\n", NULL);
add_header(ct, np, vp);
break;
if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART)
adios(EX_DATAERR, NULL, "internal error, invalid encoding");
- np = getcpy(ENCODING_FIELD);
+ np = mh_xstrdup(ENCODING_FIELD);
vp = concat(" ", "quoted-printable", "\n", NULL);
add_header(ct, np, vp);
break;
if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART)
adios(EX_DATAERR, NULL, "internal error, invalid encoding");
- np = getcpy(ENCODING_FIELD);
+ np = mh_xstrdup(ENCODING_FIELD);
vp = concat(" ", "base64", "\n", NULL);
add_header(ct, np, vp);
break;
if (ct->c_type == CT_MESSAGE)
adios(EX_DATAERR, NULL, "internal error, invalid encoding");
- np = getcpy(ENCODING_FIELD);
+ np = mh_xstrdup(ENCODING_FIELD);
vp = concat(" ", "binary", "\n", NULL);
add_header(ct, np, vp);
break;
int n = 0;
/* split the fields */
- tmparray = brkstring(getcpy(++parptr), ",",
+ tmparray = brkstring(mh_xstrdup(++parptr), ",",
NULL);
/*
** copy pointers to split fields
if (!c1->c_fstr && global.c_fstr) {
if ((c1->c_flags & DATEFMT) &&
(global.c_flags & DATEFMT)) {
- c1->c_fstr = getcpy(global.c_fstr);
+ c1->c_fstr = mh_xstrdup(global.c_fstr);
} else if ((c1->c_flags & ADDRFMT) &&
(global.c_flags & ADDRFMT)) {
- c1->c_fstr = getcpy(global.c_fstr);
+ c1->c_fstr = mh_xstrdup(global.c_fstr);
}
}
continue;
cp = concat("=", cp, NULL);
fmtstr = new_fs(cp, NULL);
mh_free0(&cp);
- c1->c_fstr = getcpy(fmtstr);
+ c1->c_fstr = mh_xstrdup(fmtstr);
c1->c_flags |= FORMAT;
return 0;
}
char *fmtstr;
fmtstr = new_fs("=%(decode{text})", NULL);
- c1->c_fstr = getcpy(fmtstr);
+ c1->c_fstr = mh_xstrdup(fmtstr);
c1->c_flags |= FORMAT;
return 0;
}
}
c = *parptr;
*parptr = 0;
- *s = getcpy(cp);
+ *s = mh_xstrdup(cp);
if ((*parptr = c) == '"')
parptr++;
return 0;
fmt_scan(c1->c_fmt, buffer, sizeof(buffer) - 1, dat);
/* Don't need to append a newline, dctime() already did */
- c2->c_text = getcpy(buffer);
+ c2->c_text = mh_xstrdup(buffer);
mh_free0(&ap);
return;
p = mh_xcalloc(1, sizeof(*p));
if ((mp = getm(cp, NULL, 0, AD_NAME, error)) == NULL) {
- p->pq_text = getcpy(cp);
- p->pq_error = getcpy(error);
+ p->pq_text = mh_xstrdup(cp);
+ p->pq_error = mh_xstrdup(error);
} else {
- p->pq_text = getcpy(mp->m_text);
+ p->pq_text = mh_xstrdup(mp->m_text);
mnfree(mp);
}
q = (q->pq_next = p);
c1 = mh_xcalloc(1, sizeof(*c1));
c1->c_flags = flags & ~INIT;
- if ((c1->c_name = name ? getcpy(name) : NULL))
+ if ((c1->c_name = name ? mh_xstrdup(name) : NULL))
c1->c_flags |= mcomp_flags(c1->c_name);
- c1->c_text = text ? getcpy(text) : NULL;
+ c1->c_text = text ? mh_xstrdup(text) : NULL;
if (flags & INIT) {
if (global.c_ovtxt)
- c1->c_ovtxt = getcpy(global.c_ovtxt);
+ c1->c_ovtxt = mh_xstrdup(global.c_ovtxt);
c1->c_offset = global.c_offset;
c1->c_ovoff = global. c_ovoff;
c1->c_width = 0;
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- file = *cp == '-' ? cp : getcpy(expanddir(cp));
+ file = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
continue;
case VERBSW:
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = getcpy(toabsdir(invo_name));
+ tmp = mh_xstrdup(toabsdir(invo_name));
if (file && msgs.size)
adios(EX_USAGE, NULL, "cannot specify msg and file at same time!");
/* print Content-Description */
if (ct->c_descr) {
char *dp;
-
- dp = trimcpy(cp = getcpy(ct->c_descr));
+ dp = trimcpy(cp = mh_xstrdup(ct->c_descr));
mh_free0(&cp);
printf(LSTFMT2d1, dp);
mh_free0(&dp);
}
if (iscc)
cclist = cclist ? add(cp, add(", ", cclist)) :
- getcpy(cp);
+ mh_xstrdup(cp);
else
tolist = tolist ? add(cp, add(", ", tolist)) :
- getcpy(cp);
+ mh_xstrdup(cp);
}
if (tolist == NULL)
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))
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;
/*
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) {
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;
}
/* get copy of this field */
- ct->c_celine = cp = getcpy(hp->value);
+ ct->c_celine = cp = mh_xstrdup(hp->value);
while (isspace(*cp))
cp++;
** 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';
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++;
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) {
if (*cp != '/') {
if (!magic)
- ci->ci_subtype = getcpy("");
+ ci->ci_subtype = mh_xstrdup("");
goto magic_skip;
}
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) {
return NOTOK;
}
- vp = (*ap = getcpy(cp)) + (up - cp);
+ vp = (*ap = mh_xstrdup(cp)) + (up - cp);
*vp = '\0';
for (dp++; isspace(*dp);)
dp++;
*/
if (*cp) {
if (magic) {
- ci->ci_magic = getcpy(cp);
+ ci->ci_magic = mh_xstrdup(cp);
/*
** If there is a Content-Disposition header and
ci->ci_comment = concat(dp, " ", buffer, NULL);
mh_free0(&dp);
} else {
- ci->ci_comment = getcpy(buffer);
+ ci->ci_comment = mh_xstrdup(buffer);
}
}
/* 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)) {
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) {
*/
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")) {
}
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;
}
** 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 ",
}
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;
}
** 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 ",
}
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;
}
** 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 ",
if (folder) {
adios(EX_USAGE, NULL, "only one folder at a time!");
} else {
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
}
} else {
app_msgarg(&msgs, cp);
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- file = *cp == '-' ? cp : getcpy(expanddir(cp));
+ file = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
continue;
case FORMSW:
argp[-2]);
if (formsw)
mh_free0(&formsw);
- formsw = getcpy(etcpath(cp));
+ formsw = mh_xstrdup(etcpath(cp));
continue;
case VERBSW:
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else if (mode != SHOW) {
adios(EX_USAGE, NULL, "Either call show as `%s' or give message arguments", invo_name);
} else {
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = getcpy(toabsdir(invo_name));
+ tmp = mh_xstrdup(toabsdir(invo_name));
if (file && msgs.size)
adios(EX_USAGE, NULL, "cannot specify msg and file at same time!");
** for showing headers of MIME messages.
*/
if (!formsw)
- formsw = getcpy(etcpath("mhl.headers"));
+ formsw = mh_xstrdup(etcpath("mhl.headers"));
/*
** If form is "mhl.null", suppress display of header.
} else {
snprintf(buffer, sizeof(buffer), "%%lcat");
}
- ct->c_showproc = getcpy(buffer);
+ ct->c_showproc = mh_xstrdup(buffer);
return show_content_aux(ct, alternate, ct->c_showproc, NULL);
}
return NOTOK;
/* I'm not sure if this is necessary? */
- p->c_storage = getcpy(file);
+ p->c_storage = mh_xstrdup(file);
if (p->c_showproc && strcmp(p->c_showproc, "true")==0)
return (alternate ? DONE : OK);
/* default method for message/rfc822 */
if (ct->c_subtype == MESSAGE_RFC822) {
- cp = (ct->c_showproc = getcpy("%lshow -file %F"));
+ cp = (ct->c_showproc = mh_xstrdup("%lshow -file %F"));
return show_content_aux(ct, alternate, cp, NULL);
}
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- file = *cp == '-' ? cp : getcpy(expanddir(cp));
+ file = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
continue;
case DEBUGSW:
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
/*
** Cache the current directory before we do any chdirs()'s.
*/
- cwd = getcpy(pwd());
+ cwd = mh_xstrdup(pwd());
/*
** Check for storage directory. If specified,
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = getcpy(toabsdir(invo_name));
+ tmp = mh_xstrdup(toabsdir(invo_name));
if (file && msgs.size)
adios(EX_USAGE, NULL, "cannot specify msg and file at same time!");
** store any contents.
*/
if ((cp = context_find(nmhstorage)) && *cp)
- dir = getcpy(cp);
+ dir = mh_xstrdup(cp);
else
- dir = getcpy(cwd);
+ dir = mh_xstrdup(cwd);
for (ctp = cts; *ctp; ctp++) {
ct = *ctp;
if (*cp && *cp!='.' && *cp!='|' && *cp!='!' &&
!strchr(cp, '%')) {
/* filename looks good: use it */
- ct->c_storeproc = getcpy(cp);
+ ct->c_storeproc = mh_xstrdup(cp);
}
break;
}
*/
if (p) {
appending = 1;
- ct->c_storage = getcpy(p->c_storage);
+ ct->c_storage = mh_xstrdup(p->c_storage);
/* record the folder name */
if (p->c_folder) {
- ct->c_folder = getcpy(p->c_folder);
+ ct->c_folder = mh_xstrdup(p->c_folder);
}
goto got_filename;
}
/* Store content in temporary file for now */
tmpfilenam = m_mktemp(invo_name, NULL, NULL);
- ct->c_storage = getcpy(tmpfilenam);
+ ct->c_storage = mh_xstrdup(tmpfilenam);
/* Get the folder name */
if (cp[1])
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
else
folder = getcurfol();
create_folder(toabsdir(folder), 0, exit);
/* Record the folder name */
- ct->c_folder = getcpy(folder);
+ ct->c_folder = mh_xstrdup(folder);
if (cp[1])
mh_free0(&folder);
return show_content_aux(ct, 0, buffer + 1, dir);
/* record the filename */
- ct->c_storage = getcpy(buffer);
+ ct->c_storage = mh_xstrdup(buffer);
got_filename:
/* flush the output stream */
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- file = *cp == '-' ? cp : getcpy(expanddir(cp));
+ file = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
continue;
case OUTFILESW:
if (!(cp = *argp++) || (*cp == '-' && cp[1]))
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- outfile = *cp == '-' ? cp : getcpy(expanddir(cp));
+ outfile = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
continue;
case VERBSW:
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if ((cp = context_find(nmhstorage)) && *cp)
tmp = concat(cp, "/", invo_name, NULL);
else
- tmp = getcpy(toabsdir(invo_name));
+ tmp = mh_xstrdup(toabsdir(invo_name));
if (file && msgs.size)
adios(EX_USAGE, NULL, "cannot specify msg and file at same time!");
int j, k;
char *cp, **ap;
- field = getcpy(field);
+ field = mh_xstrdup(field);
/* copied from seq_read.c:seq_init */
for (ap = brkstring(field, " ", "\n"); *ap; ap++) {
case FLD:
case FLDPLUS:
if (state == FLDPLUS) {
- cp = getcpy(field);
+ cp = mh_xstrdup(field);
while (state == FLDPLUS) {
state = m_getfld(state, name, field,
sizeof(field), fp);
while (vfgets(fp, &line) == OK) {
len = strlen(line) - 1;
line[len] = '\0';
- check_folder(getcpy(line), len, &b);
+ check_folder(mh_xstrdup(line), len, &b);
}
fclose(fp);
}
} else {
unseen = seq_unseen; /* use default */
}
- dp = getcpy(unseen);
+ dp = mh_xstrdup(unseen);
for (ap = brkstring(dp, " ", "\n"); *ap; ap++) {
sequences[i++] = *ap;
}
if (*cp == '+' || *cp == '@') {
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
padvise(NULL, "pattern error in %s %s", argp[-2], cp);
return NULL;
}
- n->n_patbuf = getcpy(dp);
+ n->n_patbuf = mh_xstrdup(dp);
return n;
case PROTHR:
if (bp != NULL) {
mh_free0(&bp);
}
- bp = getcpy(buf);
+ bp = mh_xstrdup(buf);
while (state == FLDPLUS) {
state = m_getfld(state, name, buf,
sizeof buf, fp);
continue;
}
}
- addrs = addrs ? add(cp, add(", ", addrs)) : getcpy(cp);
+ addrs = addrs ? add(cp, add(", ", addrs)) : mh_xstrdup(cp);
}
if (!addrs) {
*/
#include <h/mh.h>
+#include <h/utils.h>
#include <fcntl.h>
#include <h/signals.h>
#include <errno.h>
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else {
adios(EX_USAGE, NULL, "usage: %s [+folder] [switches]",
invo_name);
if (!(cp = *argp++) || *cp == '-')
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
continue;
case FILESW:
if (filep > NFOLDERS)
if (!(cp = *argp++) || *cp == '-')
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- files[filep++] = getcpy(expanddir(cp));
+ files[filep++] = mh_xstrdup(expanddir(cp));
continue;
}
}
if (foldp > NFOLDERS)
adios(EX_USAGE, NULL, "only %d folders allowed!",
NFOLDERS);
- folders[foldp++].f_name = getcpy(expandfol(cp));
+ folders[foldp++].f_name = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
*/
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (is_selected(mp, msgnum)) {
- cp = getcpy(m_name(msgnum));
+ cp = mh_xstrdup(m_name(msgnum));
if (m_file(cp, folders, foldp, !linkf))
exit(EX_IOERR);
mh_free0(&cp);
/* read user profile/context */
context_read();
- filter = getcpy(etcpath(mhlreply));
+ filter = mh_xstrdup(etcpath(mhlreply));
arguments = getarguments(invo_name, argc, argv, 1);
argp = arguments;
if (!(cp = *argp++) || *cp == '-')
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- file = getcpy(expanddir(cp));
+ file = mh_xstrdup(expanddir(cp));
continue;
case FORMSW:
if (!(form = *argp++) || *form == '-')
if (!(cp = *argp++) || *cp == '-')
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
- filter = getcpy(etcpath(cp));
+ filter = mh_xstrdup(etcpath(cp));
continue;
case NFILTSW:
filter = NULL;
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else {
if (msg)
adios(EX_USAGE, NULL, "only one message at a time!");
if (ccme == -1)
ccme = groupreply;
- cwd = getcpy(pwd());
+ cwd = mh_xstrdup(pwd());
if (file && (msg || folder))
adios(EX_USAGE, NULL, "can't mix files and folders/msgs");
context_save(); /* save the context file */
}
- msg = file ? file : getcpy(m_name(mp->lowsel));
+ msg = file ? file : mh_xstrdup(m_name(mp->lowsel));
if ((in = fopen(msg, "r")) == NULL)
adios(EX_IOERR, msg, "unable to open");
if ((cp = getenv("USER"))) {
FINDCOMP(cptr, "user");
if (cptr)
- cptr->c_text = getcpy(cp);
+ cptr->c_text = mh_xstrdup(cp);
}
if (!ccme)
ismymbox(NULL);
}
if (sp != cptr->c_text) {
cp = cptr->c_text;
- cptr->c_text = getcpy(sp);
+ cptr->c_text = mh_xstrdup(sp);
mh_free0(&cp);
}
}
** returns a pointer to the concatenated address string.
**
** We try to not do a lot of malloc/copy/free's (which is why we
-** don't call "getcpy") but still place no upper limit on the
+** don't call "mh_xstrdup") but still place no upper limit on the
** length of the result string.
**
** This routine is an override for the equally named one in sbr/fmt_addr.c.
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else {
adios(EX_USAGE, NULL, "usage: %s [+folder] [switches]",
invo_name);
struct node *np, *pp;
alen = strlen("atr-");
- plen = strlen(cp = getcpy(toabsdir(folder))) + 1;
+ plen = strlen(cp = mh_xstrdup(toabsdir(folder))) + 1;
/*
** Search context list for keys that look like
if (folder) {
adios(EX_USAGE, NULL, "only one folder at a time!");
} else {
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
}
} else {
app_msgarg(&msgs, cp);
adios(EX_USAGE, NULL, "missing argument to %s",
argp[-2]);
if (strcmp(file = cp, "-")!=0)
- file = getcpy(expanddir(cp));
+ file = mh_xstrdup(expanddir(cp));
continue;
}
}
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
if (*cp) {
char **ap, *dp;
- dp = getcpy(cp);
+ dp = mh_xstrdup(cp);
ap = brkstring(dp, " ", "\n");
for (i = 0; ap && *ap; i++, ap++) {
seqnum[i] = seq_getnum(mp, *ap);
for (nmsgs = 0, msgnum = mp->lowsel;
msgnum <= mp->hghsel; msgnum++) {
if (is_selected(mp, msgnum)) {
- files[nfiles++] = getcpy(m_name(msgnum));
+ files[nfiles++] = mh_xstrdup(m_name(msgnum));
unset_exists(mp, msgnum);
}
}
adios(EX_IOERR, altmsg, "unable to open for reading");
}
fstat(in, &st2);
- distfile = getcpy(m_mktemp2(NULL, invo_name, NULL, NULL));
+ distfile = mh_xstrdup(m_mktemp2(NULL, invo_name, NULL, NULL));
if ((out = creat(distfile, (int)st2.st_mode & 0777))==NOTOK) {
adios(EX_IOERR, distfile, "unable to open for writing");
}
/* add special entries to lookup table */
if ((p = lookup(hdrs, "source"))) {
- p->p_value = getcpy(sender);
+ p->p_value = mh_xstrdup(sender);
}
if ((p = lookup(hdrs, "addr"))) {
- p->p_value = getcpy(addr);
+ p->p_value = mh_xstrdup(addr);
}
/*
in)) {
case FLD:
case FLDPLUS:
- lp = getcpy(field);
+ lp = mh_xstrdup(field);
while (state == FLDPLUS) {
state = m_getfld(state, name, field,
sizeof(field), in);
}
}
if (!p->p_name && i < NVEC) {
- p->p_name = getcpy(name);
+ p->p_name = mh_xstrdup(name);
p->p_value = lp;
p->p_flags = P_NIL;
p++, i++;
if (!(q = lookup(hdrs, "reply-to")) || !q->p_value) {
q = lookup(hdrs, "from");
}
- p->p_value = getcpy(q ? q->p_value : "");
+ p->p_value = mh_xstrdup(q ? q->p_value : "");
p->p_flags &= ~P_CHK;
if (debug) {
debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
return;
}
if ((p = lookup(vars, "sender"))) {
- p->p_value = getcpy(sender);
+ p->p_value = mh_xstrdup(sender);
}
if ((p = lookup(vars, "address"))) {
- p->p_value = getcpy(addr);
+ p->p_value = mh_xstrdup(addr);
}
if ((p = lookup(vars, "size"))) {
snprintf(buffer, sizeof(buffer), "%d",
fstat(fd, &st) != -1 ? (int) st.st_size : 0);
- p->p_value = getcpy(buffer);
+ p->p_value = mh_xstrdup(buffer);
}
if ((p = lookup(vars, "info"))) {
- p->p_value = getcpy(info);
+ p->p_value = mh_xstrdup(info);
}
if (debug) {
for (p = vars; p->p_name; p++) {
unsigned char buffer[BUFSIZ];
if (!envelope) {
- *sender = getcpy("");
+ *sender = mh_xstrdup("");
return;
}
} else {
break;
}
- *sender = getcpy(buffer);
+ *sender = mh_xstrdup(buffer);
}
** get copy of envelope information
** ("From " line)
*/
- envelope = getcpy(buffer);
+ envelope = mh_xstrdup(buffer);
/* Put the delivery date in message */
fputs(ddate, ffp);
*sp = ' ';
}
}
- return getcpy(bp);
+ return mh_xstrdup(bp);
}
/*
if (folder)
adios(EX_USAGE, NULL, "only one folder at a time!");
else
- folder = getcpy(expandfol(cp));
+ folder = mh_xstrdup(expandfol(cp));
} else
app_msgarg(&msgs, cp);
}
verbose++;
out = stdout;
} else {
- tmpfil = getcpy(m_mktemp2("/tmp/", invo_name, NULL, &out));
+ tmpfil = mh_xstrdup(m_mktemp2("/tmp/", invo_name, NULL, &out));
}
/* check for "Aliasfile:" profile entry */
char *dp, **ap;
aliasflg = 1;
- for (ap=brkstring(dp=getcpy(cp), " ", "\n"); ap && *ap;
+ for (ap=brkstring(dp=mh_xstrdup(cp), " ", "\n"); ap && *ap;
ap++) {
if ((state = alias(etcpath(*ap))) != AK_OK) {
adios(EX_IOERR, NULL, "aliasing error in file %s: %s",
case FLD:
case FLDPLUS:
compnum++;
- cp = getcpy(buf);
+ cp = mh_xstrdup(buf);
while (state == FLDPLUS) {
state = m_getfld(state, name, buf,
sizeof(buf), in);
}
while (recipients != NULL) {
- cp = getcpy(recipients->m_mbox);
+ cp = mh_xstrdup(recipients->m_mbox);
if (recipients->m_host) {
cp = add("@", cp);
cp = add(recipients->m_host, cp);
}
if (hdr->flags & HSUB) {
- subject = getcpy(str);
+ subject = mh_xstrdup(str);
}
if (!(hdr->flags & HADR)) {
}
if (mp->m_ingrp) {
if (mp->m_gname != NULL) {
- cp = getcpy(mp->m_gname);
+ cp = mh_xstrdup(mp->m_gname);
cp = add(";", cp);
linepos = putone(cp, linepos, namelen);
mh_free0(&cp);
FILE *out = NULL;
for (mp=bccs; mp; mp=mp->m_next) {
- bccdraft = getcpy(m_mktemp2("/tmp/", invo_name, NULL, &out));
+ bccdraft = mh_xstrdup(m_mktemp2("/tmp/", invo_name, NULL, &out));
fprintf(out, "To: %s\n", mp->m_text);
if (from) {
fprintf(out, "From: %s\n", from->m_text);
}
if ((!drft && !(drft = getenv("mhdraft"))) || !*drft)
- drft = getcpy(m_draft(seq_cur));
+ drft = mh_xstrdup(m_draft(seq_cur));
if ((cp = getenv("mhuse")) && *cp)
use = atoi(cp);
}
/* remember which editor we used */
- edsave = getcpy(*ed);
+ edsave = mh_xstrdup(*ed);
*ed = NULL;
case FLDPLUS:
compnum++;
- cp = getcpy(buf);
+ cp = mh_xstrdup(buf);
while (state == FLDPLUS) {
state = m_getfld(state, name, buf,
sizeof(buf), in);