home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #include <ctype.h>
- #include "global.h"
- #include "mbuf.h"
- #include "ax25.h"
- #include "timer.h"
- #include "iface.h"
- #include "lapb.h"
- #include "netrom.h"
- #include "nr4.h"
- #include "ax_mbx.h"
- #include "cmdparse.h"
- #include "smtp.h"
- #include "misc.h"
-
- /*
- #define MBDEBUG
- */
-
- struct mbx *mbox[NUMMBX] ;
- int ax25mbox ;
-
- static char mbbanner[] =
- "[NET-$]\rWelcome %s to the %s TCP/IP Personal Mailbox.\r(C)hat, (S)end, (B)ye >\r" ;
- static char mbmenu[] = "(C)hat, (S)end, (B)ye >\r" ;
-
- static void domboxdisplay(void);
- static struct mbx *newmbx(void);
- static void free_mbx(struct mbx *);
- static int mbx_line(struct mbx *);
- static int mbx_msg(struct mbx *, char *);
- static int mbx_to(struct mbx *);
- static int mbx_data(struct mbx *);
-
- int dombox(int argc, char **argv)
- {
- if (argc < 2)
- {
- domboxdisplay() ;
- return 0 ;
- }
-
- if (argv[1][0] == 'y' || (strcmp(argv[1],"on") == 0))
- ax25mbox = 1 ;
- else if (argv[1][0] == 'n' || (strcmp(argv[1],"off") == 0))
- ax25mbox = 0 ;
- else if (argv[1][0] == '?')
- cwprintf(NULL, "ax25 mailbox is %s\r\n", ax25mbox ? "on" : "off") ;
- else
- cwprintf(NULL, "usage: mbox [y|n|?]\r\n") ;
-
- return 0 ;
- }
-
- static void domboxdisplay(void)
- {
- int i ;
- struct mbx *m ;
- static char *states[] = {
- "NONE","CMD","SUBJ","DATA" }
- ;
- static char *mbtype[] = {
- "NONE","AX25 ","NET/ROM" }
- ;
-
- cwprintf(NULL, " User State Type &cb &mbx BBS\r\n") ;
-
- for (i = 0 ; i < NUMMBX ; i++)
- if ((m = mbox[i]) != NULLMBX)
- cwprintf(NULL, "%-10s %-4s %-7s %04x %04x %s\r\n", m->name,
- states[m->state], mbtype[m->type],
- m->type == MBX_AX25 ? (int)m->cb.ax25_cb : (int)m->cb.nr4_cb,
- (int)m, m->mblforw ? "Yes" : " No") ;
- }
-
-
- static struct mbx *newmbx(void)
- {
- int i ;
- struct mbx *m ;
-
- for (i = 0 ; i < NUMMBX ; i++)
- if (mbox[i] == NULLMBX)
- {
- if ((m = mbox[i] = (struct mbx *)calloc(1,sizeof(struct mbx))) == NULLMBX)
- return NULLMBX ;
- m->mbnum = i ;
- return m ;
- }
-
- /* If we get here, there are no free mailbox sessions */
-
- return NULLMBX ;
- }
-
-
- /* Incoming mailbox session via ax.25 */
-
- void mbx_incom(register struct ax25_cb *axp, int16 cnt)
- {
- struct mbx *m ;
- struct mbuf *bp;
- char *cp ;
- extern char hostname[] ;
-
- if ((m = newmbx()) == NULLMBX)
- {
- disc_ax25(axp) ; /* no memory! */
- return ;
- }
-
- m->state = MBX_CMD ; /* start in command state */
- m->type = MBX_AX25 ; /* this is an ax.25 mailbox session */
- m->cb.ax25_cb = axp ;
-
- pax25(m->name,&axp->addr.dest) ;
- cp = strchr(m->name,'-') ;
- if (cp != NULLCHAR) /* get rid of SSID */
- *cp = '\0' ;
-
- m->lp = m->line ; /* point line pointer at buffer */
- axp->r_upcall = (void(*)())mbx_rx ;
- axp->s_upcall = mbx_state ;
- axp->user = (char *)m ;
-
- /* The following is necessary because we didn't know we had a */
- /* "real" ax25 connection until a data packet came in. We */
- /* can't be spitting banners out at every station who connects, */
- /* since they might be a net/rom or IP station. Sorry. */
-
- bp = recv_ax25(axp,cnt) ; /* get the initial input */
- free_p(bp) ; /* and throw it away to avoid confusion */
-
- /* Now say hi */
-
- if ((bp = alloc_mbuf(strlen(hostname) + strlen(m->name)
- + strlen(mbbanner) + 2)) == NULLBUF)
- {
- disc_ax25(axp) ; /* mbx_state will fix stuff up */
- return ;
- }
-
- *bp->data = PID_NO_L3 ; /* pid */
- sprintf(bp->data+1,mbbanner,m->name,hostname) ;
- bp->cnt = strlen(bp->data+1) + 1 ;
-
- send_ax25(axp,bp) ; /* send greeting message and menu */
- log_event(NULL,"AX25 Mailbox session requested : %s",m->name);
-
- }
-
- /* receive upcall for ax.25 */
- /* mbx_rx collects lines, and calls mbx_line when they are complete. */
- /* If the lines get too long, it arbitrarily breaks them. */
-
- void mbx_rx(struct ax25_cb *axp, int16 cnt)
- {
- struct mbuf *bp;
- struct mbx *m ;
- char c ;
-
- m = (struct mbx *)axp->user ;
-
- if ((bp = recv_ax25(axp,cnt)) == NULLBUF)
- return ;
-
- while (pullone(&bp,&c) == 1)
- {
- if (c == '\r')
- {
- *m->lp = '\0' ; /* null terminate */
- if (mbx_line(m) == -1)
- { /* call the line processor */
- free_p(bp) ; /* toss the rest */
- break ; /* get out - we're obsolete */
- }
- m->lp = m->line ; /* reset the pointer */
- }
- else if ((m->lp - m->line) == (MBXLINE - 1)) {
- *m->lp++ = c ;
- *m->lp = '\0' ;
- if (mbx_line(m) == -1) {
- free_p(bp) ;
- break ;
- }
- m->lp = m->line ;
- }
- else
- *m->lp++ = c ;
- }
- }
-
- /* state upcall for ax.25 */
-
- void mbx_state(struct ax25_cb *axp, int old, int new)
- {
- struct mbx *m ;
-
- old = old;
-
- m = (struct mbx *)axp->user ;
-
- /* dummy for now ... */
- if (new == DISCONNECTED && axp->user != NULLCHAR) {
- axp->user = NULLCHAR ;
- free_mbx(m) ;
- }
- }
-
-
- /* Incoming mailbox session via net/rom */
-
- void mbx_nr4incom(register struct nr4cb *cb)
- {
- struct mbx *m ;
- struct mbuf *bp ;
- char *cp ;
- extern char hostname[] ;
-
- if ((m = newmbx()) == NULLMBX) {
- disc_nr4(cb) ; /* no memory! */
- return ;
- }
-
- m->state = MBX_CMD ; /* start in command state */
- m->type = MBX_NETROM ; /* mailbox session type is net/rom */
- m->cb.nr4_cb = cb ;
-
- pax25(m->name,&cb->user) ;
- cp = strchr(m->name,'-') ;
- if (cp != NULLCHAR) /* get rid of SSID */
- *cp = '\0' ;
-
- m->lp = m->line ; /* point line pointer at buffer */
- cb->r_upcall = (void(*)())mbx_nr4rx ;
- cb->s_upcall = mbx_nr4state ;
- cb->puser = (char *)m ;
-
- /* Say hi */
-
- if ((bp = alloc_mbuf(strlen(hostname) + strlen(m->name)
- + strlen(mbbanner) + 1)) == NULLBUF) {
- disc_nr4(cb) ; /* mbx_nr4state will fix stuff up */
- return ;
- }
-
- sprintf(bp->data,mbbanner,m->name,hostname) ;
- bp->cnt = strlen(bp->data) ;
-
- send_nr4(cb,bp) ; /* send greeting message and menu */
- log_event(NULL,"NET/ROM Mailbox session requested : %s",m->name);
-
- }
-
- /* receive upcall for net/rom */
- /* mbx_nr4rx collects lines, and calls mbx_line when they are complete. */
- /* If the lines get too long, it arbitrarily breaks them. */
-
- void mbx_nr4rx(struct nr4cb *cb, int16 cnt)
- {
- struct mbuf *bp ;
- struct mbx *m ;
- char c ;
-
- m = (struct mbx *)cb->puser ;
-
- if ((bp = recv_nr4(cb,cnt)) == NULLBUF)
- return ;
-
- while (pullone(&bp,&c) == 1)
- {
- if (c == '\r')
- {
- *m->lp = '\0' ; /* null terminate */
- if (mbx_line(m) == -1) { /* call the line processor */
- free_p(bp) ; /* toss the rest */
- break ; /* get out - we're obsolete */
- }
- m->lp = m->line ; /* reset the pointer */
- }
- else if ((m->lp - m->line) == (MBXLINE - 1)) {
- *m->lp++ = c ;
- *m->lp = '\0' ;
- if (mbx_line(m) == -1) {
- free_p(bp) ;
- break ;
- }
- m->lp = m->line ;
- }
- else
- *m->lp++ = c ;
- }
- }
-
- /* state upcall for net/rom */
-
- void mbx_nr4state(struct nr4cb *cb, int old, int new)
- {
- struct mbx *m ;
-
- old = old;
-
- m = (struct mbx *)cb->puser ;
-
- if (new == NR4STDISC && cb->puser != NULLCHAR) {
- cb->puser = NULLCHAR ;
- free_mbx(m) ;
- }
- }
-
- static void free_mbx(struct mbx *m)
- {
- if (m->to != NULLCHAR)
- free(m->to) ;
-
- if (m->tofrom != NULLCHAR)
- free(m->tofrom) ;
-
- if (m->tomsgid != NULLCHAR)
- free(m->tomsgid) ;
-
- if (m->tfile != NULLFILE)
- fclose(m->tfile) ;
-
- mbox[m->mbnum] = NULLMBX ;
-
- free(m) ;
- }
-
-
- static int mbx_line(struct mbx *m)
- {
- char *host ;
- extern char hostname[] ;
- extern int attended;
- char fullfrom[80] ;
-
- if (m->state == MBX_CMD) {
- switch (tolower(m->line[0])) {
- case '*': /* could be MBL/RLI *** Done */
- if (!m->mblforw || strncmp(m->line,"*** Done",8))
- {
- mbx_msg(m,"Huh?\r") ;
- mbx_msg(m, m->mblforw ? ">\r" : mbmenu) ;
- break ;
- } /* drop thru if MBL and *** Done */
- case 'b': /* bye - bye */
- switch (m->type) {
- case MBX_AX25:
- m->cb.ax25_cb->user = NULLCHAR ;
- disc_ax25(m->cb.ax25_cb) ;
- break ;
- case MBX_NETROM:
- m->cb.nr4_cb->puser = NULLCHAR ;
- disc_nr4(m->cb.nr4_cb) ;
- break ;
- }
- free_mbx(m);
- return -1 ; /* tell line processor to quit */
- break ;
- case 'c': /* chat */
- if(attended)
- {
- switch (m->type) {
- case MBX_AX25:
- m->cb.ax25_cb->user = NULLCHAR ;
- log_event(NULL,"AX25 Mailbox -> Chat requested : %s",m->name);
- ax_session(m->cb.ax25_cb,0) ; /* make it a chat session */
- break ;
- case MBX_NETROM:
- m->cb.nr4_cb->puser = NULLCHAR ;
- log_event(NULL,"NET/ROM Mailbox -> Chat requested : %s",m->name);
- nr4_session(m->cb.nr4_cb) ;
- break ;
- }
- free_mbx(m);
- }
- else
- {
- mbx_msg(m,"Sorry..the system is UNATTENDED at the moment.\r") ;
- mbx_msg(m, m->mblforw ? ">\r" : mbmenu) ;
- break ;
- }
- return -1 ;
- break ;
- case 's': {
- int badsubj = 0 ;
-
- /* Get S-command type (B,P,T, etc.) */
-
- if (m->line[1] == '\0')
- m->stype = ' ' ;
- else
- m->stype = toupper(m->line[1]) ;
-
- if (mbx_to(m) == -1) {
- if (m->mblforw)
- mbx_msg(m,"NO\r") ;
- else {
- mbx_msg(m,
- "S command syntax error - format is:\r") ;
- mbx_msg(m,
- " S name [@ host] [< from_addr] [$bulletin_id]\r") ;
- }
- badsubj++ ;
- }
- else if (validate_address(m->to) == 0) {
- if (m->mblforw)
- mbx_msg(m, "NO\r") ;
- else
- mbx_msg(m, "Bad user or host name\r") ;
- free(m->to) ;
- m->to = NULLCHAR ;
- if (m->tofrom) {
- free(m->tofrom) ;
- m->tofrom = NULLCHAR ;
- }
- if (m->tomsgid) {
- free(m->tomsgid) ;
- m->tomsgid = NULLCHAR ;
- }
- badsubj++ ;
- }
-
- if (badsubj)
- mbx_msg(m, m->mblforw ? ">\r" : mbmenu) ;
- else {
- m->state = MBX_SUBJ ;
- mbx_msg(m, m->mblforw ? "OK\r" : "Subject:\r") ;
- }
- break ;
- }
- case '[':
- if (m->line[strlen(m->line)-1] == ']')
- {
- m->mblforw = 1 ;
- mbx_msg(m,">\r") ;
- }
- else
- {
- mbx_msg(m,"Huh?\r") ;
- mbx_msg(m, m->mblforw ? ">\r" : mbmenu) ;
- }
- break ;
- case 'f':
- if (m->line[1] == '>' && m->mblforw)
- {
- mbx_msg(m,"*** Done\r>\r") ;
- break ;
- }
- /* Otherwise drop through to "huh?" */
- default:
- mbx_msg(m,"Huh?\r") ;
- mbx_msg(m, m->mblforw ? ">\r" : mbmenu) ;
- }
- return 0 ;
- }
- else if (m->state == MBX_SUBJ) {
- if (mbx_data(m) == -1) {
- mbx_msg(m,"Can't create temp file for mail\r") ;
- mbx_msg(m, m->mblforw ? ">\r" : mbmenu) ;
- free(m->to) ;
- m->to = NULLCHAR ;
- if (m->tofrom) {
- free(m->tofrom) ;
- m->tofrom = NULLCHAR ;
- }
- if (m->tomsgid) {
- free(m->tomsgid) ;
- m->tomsgid = NULLCHAR ;
- }
- m->state = MBX_CMD ;
- return 0 ;
- }
- m->state = MBX_DATA ;
- if (m->mblforw == 0)
- mbx_msg(m,
- "Enter message. Terminate with /EX or ^Z in first column:\r") ;
- return 0 ;
- }
- else if (m->state == MBX_DATA) {
- if (m->line[0] == 0x1a ||
- strcmp(m->line, "/ex") == 0 ||
- strcmp(m->line, "/EX") == 0) {
- if ((host = strchr(m->to,'@')) == NULLCHAR)
- host = hostname ; /* use our hostname */
- else
- host++ ; /* use the host part of address */
-
- /* make up full from name for work file */
- sprintf(fullfrom,"%s@%s",m->name,hostname) ;
-
- fseek(m->tfile,0L,0) ; /* reset to beginning */
- if (queuejob((void *)0,m->tfile,host,m->to,fullfrom) != 0)
- mbx_msg(m,"Couldn't queue message for delivery\r") ;
-
- free(m->to) ;
- m->to = NULLCHAR ;
- if (m->tofrom) {
- free(m->tofrom) ;
- m->tofrom = NULLCHAR ;
- }
- if (m->tomsgid) {
- free(m->tomsgid) ;
- m->tomsgid = NULLCHAR ;
- }
- fclose(m->tfile) ;
- m->tfile = NULLFILE ;
- m->state = MBX_CMD ;
- smtptick();
- mbx_msg(m, m->mblforw ? ">\r" : mbmenu) ;
- return 0 ;
- }
- /* not done yet! */
- fprintf(m->tfile,"%s\r\n",m->line) ;
- return 0 ;
- }
-
- return 0; /* JSN Not sure */
- }
-
- static int mbx_msg(struct mbx *m, char *msg)
- {
- int len ;
- struct mbuf *bp ;
- struct ax25_cb *axp ;
- struct nr4cb *cb ;
-
- len = strlen(msg) ;
-
- switch (m->type) {
- case MBX_AX25:
- axp = m->cb.ax25_cb ;
-
- if ((bp = alloc_mbuf(len+1)) == NULLBUF) {
- disc_ax25(axp) ;
- return -1 ;
- }
-
- bp->cnt = len + 1 ;
-
- *bp->data = PID_NO_L3 ;
-
- memcpy(bp->data+1, msg, len) ;
-
- send_ax25(axp,bp) ;
-
- break ;
-
- case MBX_NETROM:
- cb = m->cb.nr4_cb ;
-
- if ((bp = alloc_mbuf(len)) == NULLBUF) {
- disc_nr4(cb) ;
- return -1 ;
- }
-
- bp->cnt = len ;
-
- memcpy(bp->data, msg, len) ;
-
- send_nr4(cb, bp) ;
-
- break ;
- }
- return 0 ;
- }
-
-
- /* States for send line parser state machine */
-
- #define SKIP_CMD 1
- #define LOOK_FOR_USER 2
- #define IN_USER 3
- #define AFTER_USER 4
- #define LOOK_FOR_HOST 5
- #define IN_HOST 6
- #define AFTER_HOST 7
- #define LOOK_FOR_FROM 8
- #define IN_FROM 9
- #define AFTER_FROM 10
- #define LOOK_FOR_MSGID 11
- #define IN_MSGID 12
- #define FINAL_STATE 13
- #define ERROR_STATE 14
-
- /* Prepare the addressee. If the address is bad, return -1, otherwise
- * return 0
- */
- static int mbx_to(struct mbx *m)
- {
- register char *cp;
- int state ;
- char *user, *host, *from, *msgid ;
- int userlen = 0, hostlen = 0, fromlen = 0, msgidlen = 0 ;
-
- cp = m->line ;
-
- for (state = SKIP_CMD ; state < FINAL_STATE ; cp++) {
- #ifdef MBDEBUG
- cwprintf(NULL, "State is %d, char is %c\r\n", state, *cp) ;
- #endif
- switch (state) {
- case SKIP_CMD:
- if (*cp == '\0')
- state = ERROR_STATE ; /* no user */
- else if (isspace(*cp))
- state = LOOK_FOR_USER ;
- break ;
- case LOOK_FOR_USER:
- if (*cp == '\0' || *cp == '@' || *cp == '<' || *cp == '$')
- state = ERROR_STATE ; /* no user */
- else if (!isspace(*cp)) { /* found start of user */
- user = cp ; /* point at start */
- userlen++ ; /* start counting */
- state = IN_USER ;
- }
- break ;
- case IN_USER:
- switch (*cp) {
- case '\0': /* found username only */
- state = FINAL_STATE ;
- break ;
- case '@':
- state = LOOK_FOR_HOST ; /* hostname should follow */
- break ;
- case '<':
- state = LOOK_FOR_FROM ; /* from name should follow */
- break ;
- case '$':
- state = LOOK_FOR_MSGID ; /* message id should follow */
- break ;
- default:
- if (isspace(*cp))
- state = AFTER_USER ; /* white space */
- else
- userlen++ ; /* part of username */
- }
- break ;
- case AFTER_USER:
- switch (*cp) {
- case '\0':
- state = FINAL_STATE ; /* found username only */
- break ;
- case '@':
- state = LOOK_FOR_HOST ; /* hostname follows */
- break ;
- case '<':
- state = LOOK_FOR_FROM ; /* fromname follows */
- break ;
- case '$':
- state = LOOK_FOR_MSGID ; /* message id follows */
- break ;
- default:
- if (!isspace(*cp))
- state = ERROR_STATE ;
- }
- break ;
- case LOOK_FOR_HOST:
- switch (*cp) {
- case '\0': /* user@? */
- case '@': /* user@@ */
- case '<': /* user@< */
- case '$': /* user@$ */
- state = ERROR_STATE ;
- break ;
- default:
- if (!isspace(*cp)) {
- host = cp ;
- hostlen++ ;
- state = IN_HOST ;
- }
- }
- break ;
- case IN_HOST:
- switch (*cp) {
- case '\0':
- state = FINAL_STATE ; /* found user@host */
- break ;
- case '@':
- state = ERROR_STATE ; /* user@host@? */
- break ;
- case '<':
- state = LOOK_FOR_FROM ; /* fromname follows */
- break ;
- case '$':
- state = LOOK_FOR_MSGID ; /* message id follows */
- break ;
- default:
- if (isspace(*cp))
- state = AFTER_HOST ;
- else
- hostlen++ ;
- }
- break ;
- case AFTER_HOST:
- switch (*cp) {
- case '\0':
- state = FINAL_STATE ; /* user@host */
- break ;
- case '@':
- state = ERROR_STATE ; /* user@host @ */
- break ;
- case '<':
- state = LOOK_FOR_FROM ; /* user@host < */
- break ;
- case '$':
- state = LOOK_FOR_MSGID ; /* user@host $ */
- break ;
- default:
- if (!isspace(*cp))
- state = ERROR_STATE ; /* user@host foo */
- }
- break ;
- case LOOK_FOR_FROM:
- switch (*cp) {
- case '\0': /* user@host <? */
- case '@': /* user@host <@ */
- case '<': /* user@host << */
- case '$': /* user@host <$ */
- state = ERROR_STATE ;
- break ;
- default:
- if (!isspace(*cp)) {
- from = cp ;
- fromlen++ ;
- state = IN_FROM ;
- }
- }
- break ;
- case IN_FROM:
- switch (*cp) {
- case '\0':
- state = FINAL_STATE ; /* user@host <foo */
- break ;
- case '<':
- state = ERROR_STATE ; /* user@host <foo< */
- break ;
- case '$':
- state = LOOK_FOR_MSGID ; /* message id follows */
- break ;
- default:
- if (isspace(*cp))
- state = AFTER_FROM ;
- else
- fromlen++ ;
- }
- break ;
- case AFTER_FROM:
- switch (*cp) {
- case '\0':
- state = FINAL_STATE ; /* user@host <foo */
- break ;
- case '@': /* user@host <foo @ */
- case '<': /* user@host <foo < */
- state = ERROR_STATE ;
- break ;
- case '$':
- state = LOOK_FOR_MSGID ; /* user@host <foo $ */
- break ;
- default:
- if (!isspace(*cp))
- state = ERROR_STATE ; /* user@host foo */
- }
- break ;
- case LOOK_FOR_MSGID:
- if (*cp == '\0')
- state = ERROR_STATE ; /* msgid = $? */
- else if (isspace(*cp))
- state = ERROR_STATE ; /* user@host <foo $ bar */
- else {
- msgid = cp ;
- msgidlen++ ;
- state = IN_MSGID ;
- }
- break ;
- case IN_MSGID:
- if (*cp == '\0')
- state = FINAL_STATE ;
- else if (isspace(*cp))
- state = FINAL_STATE ;
- else
- msgidlen++ ;
- break ;
- default:
- /* what are we doing in this state? */
- state = ERROR_STATE ;
- }
- }
-
- if (state == ERROR_STATE)
- return -1 ; /* syntax error */
-
- if ((m->to = malloc(userlen + hostlen + 2)) == NULLCHAR)
- return -1 ; /* no room for to address */
-
- strncpy(m->to, user, userlen) ;
- m->to[userlen] = '\0' ;
-
- if (hostlen) {
- m->to[userlen] = '@' ;
- strncpy(m->to + userlen + 1, host, hostlen) ;
- m->to[userlen + hostlen + 1] = '\0' ;
- }
-
- if (fromlen) {
- if ((m->tofrom = malloc(fromlen + 1)) == NULLCHAR) {
- free(m->to) ;
- m->to = NULLCHAR ;
- return -1 ;
- }
- strncpy(m->tofrom, from, fromlen) ;
- m->tofrom[fromlen] = '\0' ;
- }
-
- if (msgidlen) {
- if ((m->tomsgid = malloc(msgidlen + 1)) == NULLCHAR) {
- free(m->to) ;
- m->to = NULLCHAR ;
- if (fromlen) {
- free(m->tofrom) ;
- m->tofrom = NULLCHAR ;
- }
- return -1 ;
- }
- strncpy(m->tomsgid, msgid, msgidlen) ;
- m->tomsgid[msgidlen] = '\0' ;
- }
-
- return 0 ;
- }
-
- /* This opens the data file and writes the mail header into it.
- * Returns 0 if OK, and -1 if not.
- */
-
- static int mbx_data(struct mbx *m)
- {
- time_t t;
- extern char hostname[] ;
-
- if ((m->tfile = tmpfile()) == NULLFILE)
- return -1 ;
-
- time(&t) ;
- fprintf(m->tfile,"Date: %s",ptime(&t)) ;
-
- if (m->tomsgid)
- fprintf(m->tfile, "Message-Id: <%s@%s>\n", m->tomsgid, hostname) ;
- else
- fprintf(m->tfile,"Message-Id: <%ld@%s>\n",get_msgid(),hostname) ;
-
- fprintf(m->tfile,"From: %s%%%s.BBS@%s\n",m->tofrom ? m->tofrom : m->name, m->name, hostname) ;
-
- fprintf(m->tfile,"Reply-To: %s@%s\n",m->tofrom ? m->tofrom : m->name, m->name) ;
-
- fprintf(m->tfile,"To: %s\n",m->to) ;
-
- fprintf(m->tfile,"Subject: %s\n\n",m->line) ;
-
- if (m->stype != ' ')
- fprintf(m->tfile,"X-BBS-Msg-Type: %c\n", m->stype) ;
-
- fprintf(m->tfile,"\n") ;
-
- return 0 ;
- }
-