From: markus schnalke Date: Thu, 9 Feb 2012 20:22:35 +0000 (+0100) Subject: Replaced open_form() with new_fs() for the last time and dropped the function. X-Git-Tag: mmh-thesis-end~328 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=84c6039eb7226c0ba0a8f708205e33d10950d2ae;p=mmh Replaced open_form() with new_fs() for the last time and dropped the function. --- diff --git a/h/utils.h b/h/utils.h index 18d778e..7ee6046 100644 --- a/h/utils.h +++ b/h/utils.h @@ -16,4 +16,3 @@ struct msgs_array { }; void app_msgarg(struct msgs_array *, char *); -int open_form(char **, char *); diff --git a/sbr/utils.c b/sbr/utils.c index 641a75d..5c5b0f5 100644 --- a/sbr/utils.c +++ b/sbr/utils.c @@ -216,19 +216,3 @@ app_msgarg(struct msgs_array *msgs, char *cp) (msgs->max+=MAXMSGS)*sizeof(*msgs->msgs)); msgs->msgs[msgs->size++] = cp; } - -/* Open a form or components file */ -int -open_form(char **form, char *def) -{ - int in; - if (*form) { - if ((in = open(etcpath(*form), O_RDONLY)) == NOTOK) - adios(*form, "unable to open form file"); - } else { - if ((in = open(etcpath(def), O_RDONLY)) == NOTOK) - adios(def, "unable to open default components file"); - *form = def; - } - return in; -} diff --git a/uip/dist.c b/uip/dist.c index 52e480e..39d6525 100644 --- a/uip/dist.c +++ b/uip/dist.c @@ -45,6 +45,7 @@ main(int argc, char **argv) char *form = NULL, *msg = NULL, buf[BUFSIZ], drft[BUFSIZ]; char **argp, **arguments; struct msgs *mp = NULL; + char *nfs; #ifdef LOCALE setlocale(LC_ALL, ""); @@ -134,15 +135,14 @@ main(int argc, char **argv) if (file && (msg || folder)) adios(NULL, "can't mix files and folders/msgs"); - in = open_form(&form, distcomps); - strncpy(drft, m_draft(seq_beyond), sizeof(drft)); - if ((out = creat(drft, m_gmprot())) == NOTOK) adios(drft, "unable to create"); - cpydata(in, out, form, drft); - close(in); + nfs = new_fs(form, NULL, distcomps, NULL); + if (write(out, nfs, strlen(nfs)) != strlen(nfs)) { + adios(drft, "error writing"); + } close(out); if (file) {