- /* Convert underscores to spaces */
- for (a = 0; a < strlen(recp); ++a)
- if (recp[a] == '_')
- recp[a] = ' ';
-
- /* Are we delivering to a room instead of a user? */
- if (!strncasecmp(recp, "room ", 5)) {
- strcpy(targetroom, &recp[5]);
- strcpy(recp, "");
- } else {
- strcpy(targetroom, MAILROOM);
- }
-
- time(&now);
- snprintf(from, sizeof from, "postmaster@%s", config.c_nodename);
-
- snprintf(buf, sizeof buf, "./network/spoolin/citmail.%d", getpid());
- temp = fopen(buf, "w");
-
- strcpy(subject, "");
- strcpy(nodebuf, config.c_nodename);
- strcpy(content_type, "text/plain");
-
- do {
- if (fgets(buf, 128, stdin) == NULL)
- strcpy(buf, ".");
- strip_trailing_whitespace(buf);
-
- if (!strncasecmp(buf, "Subject: ", 9))
- strcpy(subject, &buf[9]);
- else if (!strncasecmp(buf, "Date: ", 6)) {
- now = parsedate(&buf[6]);
- if (now < 0L) now = time(NULL);
- }
- else if (!strncasecmp(buf, "From: ", 6))
- strcpy(from, &buf[6]);
- else if (!strncasecmp(buf, "Content-type: ", 14))
- strcpy(content_type, &buf[14]);
- else if (!strncasecmp(buf, "From ", 5)) { /* ignore */
- } else {
- if (extra_headers == NULL) {
- extra_headers = malloc(strlen(buf) + 2);
- strcpy(extra_headers, "");
- } else {
- extra_headers = realloc(extra_headers,
- (strlen(extra_headers) + strlen(buf) + 2));
- }
- strcat(extra_headers, buf);
- strcat(extra_headers, "\n");
- }
- } while ((strcmp(buf, ".")) && (strcmp(buf, "")));
-
- process_rfc822_addr(from, userbuf, nodebuf, frombuf);
-
- if (!strncasecmp(content_type, "text/plain", 10))
- format_type = 1; /* plain ASCII message */
- else
- format_type = 4; /* MIME message */