]> diplodocus.org Git - nmh/blobdiff - uip/mhparse.c
Renamed getmymbox mh-format escape function to getmyaddr, and
[nmh] / uip / mhparse.c
index 14701398ebc4f787fd4e63b8ae89811aa8c6cca5..69bb542e7c56cca2088ef18bc3addf9eeb6db77a 100644 (file)
@@ -283,7 +283,7 @@ get_content (FILE *in, char *file, int toplevel)
     m_getfld_state_t gstate = 0;
 
     /* allocate the content structure */
-    if (!(ct = (CT) calloc (1, sizeof(*ct))))
+    if (!(ct = (CT) mh_xcalloc (1, sizeof(*ct))))
        adios (NULL, "out of memory");
 
     ct->c_fp = in;
@@ -1018,7 +1018,7 @@ InitText (CT ct)
     ct->c_subtype = kv->kv_value;
 
     /* allocate text character set structure */
-    if ((t = (struct text *) calloc (1, sizeof(*t))) == NULL)
+    if ((t = (struct text *) mh_xcalloc (1, sizeof(*t))) == NULL)
        adios (NULL, "out of memory");
     ct->c_ctparams = (void *) t;
 
@@ -1126,7 +1126,7 @@ InitMultiPart (CT ct)
     }
 
     /* allocate primary structure for multipart info */
-    if ((m = (struct multipart *) calloc (1, sizeof(*m))) == NULL)
+    if ((m = (struct multipart *) mh_xcalloc (1, sizeof(*m))) == NULL)
        adios (NULL, "out of memory");
     ct->c_ctparams = (void *) m;
 
@@ -1171,7 +1171,7 @@ InitMultiPart (CT ct)
            if (strcmp (bufp + 2, m->mp_start))
                continue;
 next_part:
-           if ((part = (struct part *) calloc (1, sizeof(*part))) == NULL)
+           if ((part = (struct part *) mh_xcalloc (1, sizeof(*part))) == NULL)
                adios (NULL, "out of memory");
            *next = part;
            next = &part->mp_next;
@@ -1354,7 +1354,7 @@ InitMessage (CT ct)
                PM pm;
                struct partial *p;
 
-               if ((p = (struct partial *) calloc (1, sizeof(*p))) == NULL)
+               if ((p = (struct partial *) mh_xcalloc (1, sizeof(*p))) == NULL)
                    adios (NULL, "out of memory");
                ct->c_ctparams = (void *) p;
 
@@ -1403,7 +1403,7 @@ invalid_param:
                CT p;
                FILE *fp;
 
-               if ((e = (struct exbody *) calloc (1, sizeof(*e))) == NULL)
+               if ((e = (struct exbody *) mh_xcalloc (1, sizeof(*e))) == NULL)
                    adios (NULL, "out of memory");
                ct->c_ctparams = (void *) e;
 
@@ -2274,7 +2274,9 @@ open7Bit (CT ct, char **file)
                cc = len;
            len -= cc;
 
-           fwrite (buffer, sizeof(*buffer), cc, ce->ce_fp);
+           if ((int) fwrite (buffer, sizeof(*buffer), cc, ce->ce_fp) < cc) {
+               advise ("open7Bit", "fwrite");
+           }
            if (ferror (ce->ce_fp)) {
                content_error (ce->ce_file, ct, "error writing to");
                goto clean_up;
@@ -2341,6 +2343,7 @@ openExternal (CT ct, CT cb, CE ce, char **file, int *fd)
        }
     }
 
+    *fd = fileno (ce->ce_fp);
     return OK;
 
 ready_already:
@@ -2408,7 +2411,9 @@ openFile (CT ct, char **file)
 
            while ((cc = fread (buffer, sizeof(*buffer), sizeof(buffer), gp))
                       > 0)
-               fwrite (buffer, sizeof(*buffer), cc, fp);
+               if ((int) fwrite (buffer, sizeof(*buffer), cc, fp) < cc) {
+                   advise ("openFile", "fwrite");
+               }
            fflush (fp);
 
            if (ferror (gp)) {
@@ -2617,7 +2622,9 @@ openFTP (CT ct, char **file)
 
                while ((cc= fread (buffer, sizeof(*buffer), sizeof(buffer), gp))
                           > 0)
-                   fwrite (buffer, sizeof(*buffer), cc, fp);
+                   if ((int) fwrite (buffer, sizeof(*buffer), cc, fp) < cc) {
+                       advise ("openFTP", "fwrite");
+                   }
                fflush (fp);
 
                if (ferror (gp)) {
@@ -2877,7 +2884,9 @@ openURL (CT ct, char **file)
 
                while ((cc = fread(buffer, sizeof(*buffer),
                                   sizeof(buffer), gp)) > 0)
-                   fwrite(buffer, sizeof(*buffer), cc, fp);
+                   if ((int) fwrite(buffer, sizeof(*buffer), cc, fp) < cc) {
+                       advise ("openURL", "fwrite");
+                   }
 
                fflush(fp);