home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / XGRP_000.SZH / MAKEMSG.C < prev    next >
C/C++ Source or Header  |  1991-06-08  |  2KB  |  67 lines

  1. #include "xgroup.h"
  2.  
  3. struct __fidomsg__ {
  4.       char from[36];
  5.       char to[36];
  6.       char subj[63];
  7.       char nodelist[9];    /* OPUS: Name of the nodelist used               */
  8.       char date[20];
  9.       word times;          /* FIDO<tm>: Number of times read                */
  10.       word dest;           /* Destination node                              */
  11.       word orig;           /* Origination node number                       */
  12.       word cost;           /* Unit cost charged to send the message         */
  13.       word orig_net;       /* Origination network number                    */
  14.       word dest_net;       /* Destination network number                    */
  15.       int  msg_filler[4];
  16.       word reply;          /* Current msg is a reply to this msg number     */
  17.       word attr;           /* Attribute (behavior) of the message           */
  18.       word up;             /* Next message in the thread                    */
  19. };
  20. typedef struct __fidomsg__ FIDOMSG;
  21.  
  22. extern char *putmsgs;
  23. extern char buffer[1024];
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. word _fastcall make_message (char *text,XMSG *xmsg) {
  31.  
  32.     int  fp;
  33.     word x = 1;
  34.     FIDOMSG msg;
  35.     struct stat st;
  36.  
  37.  
  38.     do {
  39.         if(putmsgs) sprintf(buffer,"%s/%u.MSG",putmsgs,x);
  40.         else sprintf(buffer,"%u.MSG",x);
  41.         if(stat(buffer,&st)) break;
  42.     } while(++x);
  43.     if(!x) return 0;
  44.  
  45.     fp = sopen(buffer,O_RDWR | O_BINARY | O_CREAT,SH_DENYWR,S_IREAD | S_IWRITE);
  46.     if(fp != -1) {
  47.         memset(&msg,0,sizeof(FIDOMSG));
  48.         strcpy(msg.from,xmsg->from);
  49.         strcpy(msg.to,xmsg->to);
  50.         strcpy(msg.date,xmsg->date);
  51.         strcpy(msg.subj,xmsg->subj);
  52.         msg.attr = xmsg->attr;
  53.         msg.cost = xmsg->cost;
  54.         msg.orig = xmsg->orig;
  55.         msg.dest = xmsg->dest;
  56.         msg.dest_net = xmsg->dest_net;
  57.         msg.orig_net = xmsg->orig_net;
  58.         write(fp,&msg,sizeof(FIDOMSG));
  59.         write(fp,text,strlen(text));
  60.         write(fp,"\0",1);
  61.         close(fp);
  62.         return x;
  63.     }
  64.  
  65.     return 0;
  66. }
  67.