Rocco Rutte:
[apps/madmutt.git] / sendlib.c
index cade3dc..226715b 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
 
 extern char RFC822Specials[];
 
-static struct sysexits {
-  int v;
-  const char *str;
-} sysexits_h[] = {
-#ifdef EX_USAGE
-  {
-  0xff & EX_USAGE, "Bad usage."},
-#endif
-#ifdef EX_DATAERR
-  {
-  0xff & EX_DATAERR, "Data format error."},
-#endif
-#ifdef EX_NOINPUT
-  {
-  0xff & EX_NOINPUT, "Cannot open input."},
-#endif
-#ifdef EX_NOUSER
-  {
-  0xff & EX_NOUSER, "User unknown."},
-#endif
-#ifdef EX_NOHOST
-  {
-  0xff & EX_NOHOST, "Host unknown."},
-#endif
-#ifdef EX_UNAVAILABLE
-  {
-  0xff & EX_UNAVAILABLE, "Service unavailable."},
-#endif
-#ifdef EX_SOFTWARE
-  {
-  0xff & EX_SOFTWARE, "Internal error."},
-#endif
-#ifdef EX_OSERR
-  {
-  0xff & EX_OSERR, "Operating system error."},
-#endif
-#ifdef EX_OSFILE
-  {
-  0xff & EX_OSFILE, "System file missing."},
-#endif
-#ifdef EX_CANTCREAT
-  {
-  0xff & EX_CANTCREAT, "Can't create output."},
-#endif
-#ifdef EX_IOERR
-  {
-  0xff & EX_IOERR, "I/O error."},
-#endif
-#ifdef EX_TEMPFAIL
-  {
-  0xff & EX_TEMPFAIL, "Deferred."},
-#endif
-#ifdef EX_PROTOCOL
-  {
-  0xff & EX_PROTOCOL, "Remote protocol error."},
-#endif
-#ifdef EX_NOPERM
-  {
-  0xff & EX_NOPERM, "Insufficient permission."},
-#endif
-#ifdef EX_CONFIG
-  {
-  0xff & EX_NOPERM, "Local configuration error."},
-#endif
-  {
-  S_ERR, "Exec error."}, {
-  -1, NULL}
-};
-
-
-
 #define DISPOSITION(X) X==DISPATTACH?"attachment":"inline"
 
 const char MimeSpecials[] = "@.,;:<>[]\\\"()?/= \t";
@@ -362,7 +291,7 @@ int mutt_write_mime_header (BODY * a, FILE * f)
   fprintf (f, "Content-Type: %s/%s", TYPE (a), a->subtype);
 
   if (a->parameter) {
-    len = 25 + safe_strlen (a->subtype);        /* approximate len. of content-type */
+    len = 25 + mutt_strlen (a->subtype);        /* approximate len. of content-type */
 
     for (p = a->parameter; p; p = p->next) {
       char *tmp;
@@ -388,7 +317,7 @@ int mutt_write_mime_header (BODY * a, FILE * f)
 
       FREE (&tmp);
 
-      tmplen = safe_strlen (buffer) + safe_strlen (p->attribute) + 1;
+      tmplen = mutt_strlen (buffer) + mutt_strlen (p->attribute) + 1;
 
       if (len + tmplen + 2 > 76) {
         fputs ("\n\t", f);
@@ -479,7 +408,7 @@ int mutt_write_mime_body (BODY * a, FILE * f)
   /* This is pretty gross, but it's the best solution for now... */
   if ((WithCrypto & APPLICATION_PGP)
       && a->type == TYPEAPPLICATION
-      && safe_strcmp (a->subtype, "pgp-encrypted") == 0) {
+      && mutt_strcmp (a->subtype, "pgp-encrypted") == 0) {
     fputs ("Version: 1\n", f);
     return 0;
   }
@@ -958,7 +887,7 @@ int mutt_lookup_mime_type (BODY * att, const char *path)
   type = TYPEOTHER;
   cur_sze = 0;
 
-  szf = safe_strlen (path);
+  szf = mutt_strlen (path);
 
   for (count = 0; count < 3; count++) {
     /*
@@ -998,7 +927,7 @@ int mutt_lookup_mime_type (BODY * att, const char *path)
 
         /* cycle through the file extensions */
         while ((p = strtok (p, " \t\n"))) {
-          sze = safe_strlen (p);
+          sze = mutt_strlen (p);
           if ((sze > cur_sze) && (szf >= sze) &&
               (safe_strcasecmp (path + szf - sze, p) == 0
                || ascii_strcasecmp (path + szf - sze, p) == 0) && (szf == sze
@@ -1465,7 +1394,7 @@ void mutt_write_address_list (ADDRESS * adr, FILE * fp, int linelen,
     adr->next = NULL;
     buf[0] = 0;
     rfc822_write_address (buf, sizeof (buf), adr, display);
-    len = safe_strlen (buf);
+    len = mutt_strlen (buf);
     if (count && linelen + len > 74) {
       fputs ("\n\t", fp);
       linelen = len + 8;        /* tab is usually about 8 spaces... */
@@ -1683,7 +1612,7 @@ int mutt_write_rfc822_header (FILE * fp, ENVELOPE * env, BODY * attach,
       }
     }
     /* Add a vanity header */
-    fprintf (fp, "User-Agent: mutt-ng %s (%s)\n", MUTT_VERSION, os);
+    fprintf (fp, "User-Agent: mutt-ng/%s (%s)\n", MUTT_VERSION, os);
   }
 
   return (ferror (fp) == 0 ? 0 : -1);
@@ -1709,7 +1638,7 @@ static void encode_headers (LIST * h)
 
     rfc2047_encode_string (&tmp);
     safe_realloc (&h->data,
-                  safe_strlen (h->data) + 2 + safe_strlen (tmp) + 1);
+                  mutt_strlen (h->data) + 2 + mutt_strlen (tmp) + 1);
 
     sprintf (h->data + i, ": %s", NONULL (tmp));        /* __SPRINTF_CHECKED__ */
 
@@ -1783,11 +1712,11 @@ static void mutt_gen_localpart (char *buf, unsigned int len, char *fmt)
         break;
       case 'O':
         snprintf (tmp, sizeof (tmp), "%lo", (unsigned long) now);
-        safe_strncat (buf, len, tmp, safe_strlen (tmp));
+        safe_strncat (buf, len, tmp, mutt_strlen (tmp));
         break;
       case 'p':
         snprintf (tmp, sizeof (tmp), "%u", (unsigned int) getpid ());
-        safe_strncat (buf, len, tmp, safe_strlen (tmp));
+        safe_strncat (buf, len, tmp, mutt_strlen (tmp));
         break;
       case 'P':
         snprintf (tmp, sizeof (tmp), "%c", MsgIdPfx);
@@ -1796,11 +1725,11 @@ static void mutt_gen_localpart (char *buf, unsigned int len, char *fmt)
         break;
       case 'r':
         snprintf (tmp, sizeof (tmp), "%u", (unsigned int) rand ());
-        safe_strncat (buf, len, tmp, safe_strlen (tmp));
+        safe_strncat (buf, len, tmp, mutt_strlen (tmp));
         break;
       case 'R':
         snprintf (tmp, sizeof (tmp), "%x", (unsigned int) rand ());
-        safe_strncat (buf, len, tmp, safe_strlen (tmp));
+        safe_strncat (buf, len, tmp, mutt_strlen (tmp));
         break;
       case 's':
         snprintf (tmp, sizeof (tmp), "%02d", tm->tm_sec);
@@ -1808,11 +1737,11 @@ static void mutt_gen_localpart (char *buf, unsigned int len, char *fmt)
         break;
       case 'T':
         snprintf (tmp, sizeof (tmp), "%u", (unsigned int) now);
-        safe_strncat (buf, len, tmp, safe_strlen (tmp));
+        safe_strncat (buf, len, tmp, mutt_strlen (tmp));
         break;
       case 'X':
         snprintf (tmp, sizeof (tmp), "%x", (unsigned int) now);
-        safe_strncat (buf, len, tmp, safe_strlen (tmp));
+        safe_strncat (buf, len, tmp, mutt_strlen (tmp));
         break;
       case 'Y':
         snprintf (tmp, sizeof (tmp), "%04d", tm->tm_year + 1900);       /* this will break in the year 10000 ;-) */
@@ -1845,7 +1774,7 @@ char *mutt_gen_msgid (void)
   if (!(fqdn = mutt_fqdn (0)))
     fqdn = NONULL (Hostname);
 
-  localpart_length = sizeof (buf) - safe_strlen (fqdn) - 4;  /* the 4 characters are '<', '@', '>' and '\0' */
+  localpart_length = sizeof (buf) - mutt_strlen (fqdn) - 4;  /* the 4 characters are '<', '@', '>' and '\0' */
 
   mutt_gen_localpart (localpart, localpart_length, MsgIdFormat);
 
@@ -2027,19 +1956,6 @@ static char **add_option (char **args, size_t * argslen, size_t * argsmax,
   return (args);
 }
 
-static const char *strsysexit (int e)
-{
-  int i;
-
-  for (i = 0; sysexits_h[i].str; i++) {
-    if (e == sysexits_h[i].v)
-      break;
-  }
-
-  return sysexits_h[i].str;
-}
-
-
 static int mutt_invoke_sendmail (ADDRESS * from,        /* the sender */
                                  ADDRESS * to, ADDRESS * cc, ADDRESS * bcc,     /* recips */
                                  const char *msg,       /* file containing message */
@@ -2122,9 +2038,9 @@ static int mutt_invoke_sendmail (ADDRESS * from,        /* the sender */
 
   if ((i = send_msg (path, args, msg, &childout)) != (EX_OK & 0xff)) {
     if (i != S_BKG) {
-      const char *e = strsysexit (i);
+      const char *e = mutt_strsysexit (i);
 
-      e = strsysexit (i);
+      e = mutt_strsysexit (i);
       mutt_error (_("Error sending message, child exited %d (%s)."), i,
                   NONULL (e));
       if (childout) {
@@ -2170,9 +2086,9 @@ int mutt_invoke_mta (ADDRESS * from,    /* the sender */
    string. */
 char *mutt_append_string (char *a, const char *b)
 {
-  size_t la = safe_strlen (a);
+  size_t la = mutt_strlen (a);
 
-  safe_realloc (&a, la + safe_strlen (b) + 1);
+  safe_realloc (&a, la + mutt_strlen (b) + 1);
   strcpy (a + la, b);           /* __STRCPY_CHECKED__ */
   return (a);
 }
@@ -2200,7 +2116,7 @@ char *mutt_quote_string (const char *s)
   char *r, *pr;
   size_t rlen;
 
-  rlen = safe_strlen (s) + 3;
+  rlen = mutt_strlen (s) + 3;
   pr = r = (char *) safe_malloc (rlen);
   *pr++ = '"';
   while (*s) {