- int fd,i, msgcnt, msgnum;
- int len, buflen;
- register char *bp, *msgnam;
- char buffer[BUFSIZ];
-
- msgcnt = 1;
- for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
- if (is_selected (mp, msgnum)) {
- if (digest) {
- strncpy (buffer, msgnum == mp->lowsel ? delim3 : delim4,
- sizeof(buffer));
- } else {
- /* Get buffer ready to go */
- bp = buffer;
- buflen = sizeof(buffer);
-
- strncpy (bp, "\n-------", buflen);
- len = strlen (bp);
- bp += len;
- buflen -= len;
-
- if (msgnum == mp->lowsel) {
- snprintf (bp, buflen, " Forwarded Message%s",
- mp->numsel > 1 ? "s" : "");
- } else {
- snprintf (bp, buflen, " Message %d", msgcnt);
- }
- len = strlen (bp);
- bp += len;
- buflen -= len;
-
- strncpy (bp, "\n\n", buflen);
- }
- write (out, buffer, strlen (buffer));
-
- if ((fd = open (msgnam = m_name (msgnum), O_RDONLY)) == NOTOK) {
- admonish (msgnam, "unable to read message");
- continue;
- }
-
- /*
- * Copy the message. Add RFC934 quoting (dashstuffing)
- * unless given the -nodashstuffing flag.
- */
- if (dashstuff >= 0)
- cpydgst (fd, out, msgnam, file);
- else
- cpydata (fd, out, msgnam, file);
-
- close (fd);
- msgcnt++;
- }
- }
-
- if (digest) {
- strncpy (buffer, delim4, sizeof(buffer));
- } else {
- snprintf (buffer, sizeof(buffer), "\n------- End of Forwarded Message%s\n\n",
- mp->numsel > 1 ? "s" : "");
- }
- write (out, buffer, strlen (buffer));
-
- if (digest) {
- snprintf (buffer, sizeof(buffer), "End of %s Digest [Volume %d Issue %d]\n",
- digest, volume, issue);
- i = strlen (buffer);
- for (bp = buffer + i; i > 1; i--)
- *bp++ = '*';
- *bp++ = '\n';
- *bp = 0;
- write (out, buffer, strlen (buffer));
- }
-}
-