]> diplodocus.org Git - nmh/blobdiff - uip/mhbuildsbr.c
Added support for "-" to indicate stdout to output_message().
[nmh] / uip / mhbuildsbr.c
index 653c5b3f380d926a6a07a313cf9789da91a29c95..5954521f507320a0668bd82f7b921537da6cd9a5 100644 (file)
@@ -134,6 +134,7 @@ build_mime (char *infile, int directives)
     struct part **pp;
     CT ct;
     FILE *in;
+    m_getfld_state_t gstate = 0;
 
     directive_init(directives);
 
@@ -161,11 +162,12 @@ build_mime (char *infile, int directives)
      * draft into the linked list of header fields for
      * the new MIME message.
      */
-    for (compnum = 1, state = FLD;;) {
-       switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+    m_getfld_track_filepos (&gstate, in);
+    for (compnum = 1;;) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (&gstate, name, buf, &bufsz, in)) {
        case FLD:
        case FLDPLUS:
-       case FLDEOF:
            compnum++;
 
            /* abort if draft has Mime-Version header field */
@@ -178,8 +180,10 @@ build_mime (char *infile, int directives)
 
            /* ignore any Content-Type fields in the header */
            if (!mh_strcasecmp (name, TYPE_FIELD)) {
-               while (state == FLDPLUS)
-                   state = m_getfld (state, name, buf, sizeof(buf), in);
+               while (state == FLDPLUS) {
+                   bufsz = sizeof buf;
+                   state = m_getfld (&gstate, name, buf, &bufsz, in);
+               }
                goto finish_field;
            }
 
@@ -189,7 +193,8 @@ build_mime (char *infile, int directives)
 
            /* if necessary, get rest of field */
            while (state == FLDPLUS) {
-               state = m_getfld (state, name, buf, sizeof(buf), in);
+               bufsz = sizeof buf;
+               state = m_getfld (&gstate, name, buf, &bufsz, in);
                vp = add (buf, vp);     /* add to previous value */
            }
 
@@ -198,16 +203,13 @@ build_mime (char *infile, int directives)
 
 finish_field:
            /* if this wasn't the last header field, then continue */
-           if (state != FLDEOF)
-               continue;
-           /* else fall... */
+           continue;
 
        case FILEEOF:
            adios (NULL, "draft has empty body -- no directives!");
            /* NOTREACHED */
 
        case BODY:
-       case BODYEOF:
            fseek (in, (long) (-strlen (buf)), SEEK_CUR);
            break;
 
@@ -220,6 +222,7 @@ finish_field:
        }
        break;
     }
+    m_getfld_state_destroy (&gstate);
 
     /*
      * Now add the MIME-Version header field
@@ -1093,7 +1096,7 @@ raw:
            if ((out = fopen (ce->ce_file, "w")) == NULL)
                adios (ce->ce_file, "unable to open for writing");
 
-           for (i = 0; (child_id = vfork()) == NOTOK && i > 5; i++)
+           for (i = 0; (child_id = fork()) == NOTOK && i > 5; i++)
                sleep (5);
            switch (child_id) {
            case NOTOK: