-}
-\f/*
-** COMMAIZE -- output a header field, making a comma-translated list.
-**
-** Parameters:
-** h -- the header field to output.
-** p -- the value to put in it.
-** fp -- file to put it to.
-** oldstyle -- TRUE if this is an old style header.
-** m -- a pointer to the mailer descriptor.
-**
-** Returns:
-** none.
-**
-** Side Effects:
-** outputs "p" to file "fp".
-*/
-
-commaize(h, p, fp, oldstyle, m)
- register HDR *h;
- register char *p;
- FILE *fp;
- bool oldstyle;
- register MAILER *m;
-{
- register char *obp;
- int opos;
- bool fullsmtp = bitset(M_FULLSMTP, m->m_flags);
- bool firstone = TRUE;
- char obuf[MAXLINE];
-
- /*
- ** Output the address list translated by the
- ** mailer and with commas.
- */
-
-# ifdef DEBUG
- if (tTd(14, 2))
- printf("commaize(%s: %s)\n", h->h_field, p);
-# endif DEBUG
-
- obp = obuf;
- (void) sprintf(obp, "%s: ", capitalize(h->h_field));
- opos = strlen(h->h_field) + 2;
- obp += opos;
-
- /*
- ** Run through the list of values.
- */
-
- while (*p != '\0')
- {
- register char *name;
- char savechar;
- extern char *remotename();
- extern char *DelimChar; /* defined in prescan */
-
- /*
- ** Find the end of the name. New style names
- ** end with a comma, old style names end with
- ** a space character. However, spaces do not
- ** necessarily delimit an old-style name -- at
- ** signs mean keep going.
- */
-
- /* find end of name */
- while (isspace(*p) || *p == ',')
- p++;
- name = p;
- for (;;)
- {
- char *oldp;
- extern bool isatword();
-
- (void) prescan(p, oldstyle ? ' ' : ',');
- p = DelimChar;
-
- /* look to see if we have an at sign */
- oldp = p;
- while (*p != '\0' && isspace(*p))
- p++;
-
- if (*p != '@' && !isatword(p))
- {
- p = oldp;
- break;
- }
- p += *p == '@' ? 1 : 2;
- while (*p != '\0' && isspace(*p))
- p++;
- }
- /* at the end of one complete name */
-
- /* strip off trailing white space */
- while (p >= name && (isspace(*p) || *p == ',' || *p == '\0'))
- p--;
- if (++p == name)
- continue;
- savechar = *p;
- *p = '\0';
-
- /* translate the name to be relative */
- name = remotename(name, m, bitset(H_FROM, h->h_flags));
- if (*name == '\0')
- {
- *p = savechar;
- continue;
- }
-
- /* output the name with nice formatting */
- opos += strlen(name);
- if (!firstone)
- opos += 2;
- if (opos > 78 && !firstone)
- {
- (void) sprintf(obp, ",\n");
- putline(obuf, fp, fullsmtp);
- obp = obuf;
- (void) sprintf(obp, " ");
- obp += strlen(obp);
- opos = 8 + strlen(name);
- }
- else if (!firstone)
- {
- (void) sprintf(obp, ", ");
- obp += 2;
- }
- (void) sprintf(obp, "%s", name);
- obp += strlen(obp);
- firstone = FALSE;
- *p = savechar;
- }
- (void) strcpy(obp, "\n");
- putline(obuf, fp, fullsmtp);