Replaced open_form() with new_fs() for the last time and dropped the function.
authormarkus schnalke <meillo@marmaro.de>
Thu, 9 Feb 2012 20:22:35 +0000 (21:22 +0100)
committermarkus schnalke <meillo@marmaro.de>
Thu, 9 Feb 2012 20:22:35 +0000 (21:22 +0100)
h/utils.h
sbr/utils.c
uip/dist.c

index 18d778e..7ee6046 100644 (file)
--- 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 *);
index 641a75d..5c5b0f5 100644 (file)
@@ -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;
-}
index 52e480e..39d6525 100644 (file)
@@ -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) {