-static int
-parse_format_string (CT ct, char *cp, char *buffer, int buflen, char *dir)
-{
- int len;
- char *bp;
- CI ci = &ct->c_ctinfo;
-
- /*
- * If storage string is "-", just copy it, and
- * return (send content to standard output).
- */
- if (cp[0] == '-' && cp[1] == '\0') {
- strncpy (buffer, cp, buflen);
- return 0;
- }
-
- bp = buffer;
- bp[0] = '\0';
-
- /*
- * If formatting string is a pathname that doesn't
- * begin with '/', then preface the path with the
- * appropriate directory.
- */
- if (*cp != '/' && *cp != '|' && *cp != '!') {
- snprintf (bp, buflen, "%s/", dir[1] ? dir : "");
- len = strlen (bp);
- bp += len;
- buflen -= len;
- }
-
- for (; *cp; cp++) {
-
- /* We are processing a storage escape */
- if (*cp == '%') {
- switch (*++cp) {
- case 'a':
- /*
- * Insert parameters from Content-Type.
- * This is only valid for '|' commands.
- */
- if (buffer[0] != '|' && buffer[0] != '!') {
- *bp++ = *--cp;
- *bp = '\0';
- buflen--;
- continue;
- } else {
- char **ap, **ep;
- char *s = "";
-
- for (ap = ci->ci_attrs, ep = ci->ci_values;
- *ap; ap++, ep++) {
- snprintf (bp, buflen, "%s%s=\"%s\"", s, *ap, *ep);
- len = strlen (bp);
- bp += len;
- buflen -= len;
- s = " ";
- }
- }
- break;
-
- case 'm':
- /* insert message number */
- snprintf (bp, buflen, "%s", r1bindex (ct->c_file, '/'));
- break;
-
- case 'P':
- /* insert part number with leading dot */
- if (ct->c_partno)
- snprintf (bp, buflen, ".%s", ct->c_partno);
- break;
-
- case 'p':
- /* insert part number withouth leading dot */
- if (ct->c_partno)
- strncpy (bp, ct->c_partno, buflen);
- break;
-
- case 't':
- /* insert content type */
- strncpy (bp, ci->ci_type, buflen);
- break;
-
- case 's':
- /* insert content subtype */
- strncpy (bp, ci->ci_subtype, buflen);
- break;
-
- case '%':
- /* insert the character % */
- goto raw;
+ /*
+ ** If formatting string is a pathname that doesn't
+ ** begin with '/', then preface the path with the
+ ** appropriate directory.
+ */
+ if (*cp != '/' && *cp != '|' && *cp != '!') {
+ snprintf(bp, buflen, "%s/", dir[1] ? dir : "");
+ len = strlen(bp);
+ bp += len;
+ buflen -= len;
+ }