home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / BBS / MISC / HSRC_117.ZIP / MAILIN.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-08  |  17.2 KB  |  680 lines

  1. /* Tosser for net/echo mail */
  2.  
  3. #include "msgg.h"
  4. #include "twindow.h"
  5. #include "keys.h"
  6. #include "headedit.h"
  7.  
  8.  
  9. #define MAXKLUDGE 133
  10.  
  11.  
  12. static ulong totalmsgs=0;
  13. static word *anum;           /* Pointer to area # msgs array */
  14. static word pmnum;           /* # messages in packet */
  15. static struct _pkthdr pi;  /* The current incoming packet's header */
  16. static struct _xmsg xmsg;  /* The current msg's header */
  17. static char *text;         /* Pointer to current msg's text body */
  18. static char *pathline;     /* Pointer to current msg's PATH line(s) */
  19. static char *seenby;       /* Pointer to current msg's SEEN-BY line(s) */
  20. static char *area;         /* Pointer to current msg's AREA: tag */
  21. static char *kludge;       /* Pointer to first kludge line in msg */
  22. static char *endptr;       /* End-of-msg pointer */
  23. static char *arcext[]={"MO","TU","WE","TH","FR","SA","SU",NULL};
  24. static char mailerless;
  25.  
  26. char no_strip=0;    /* Don't remove EID's & SEENBYs if > 0 */
  27. char no_fillin=0;   /* Don't complete addresses from kludges if > 0 */
  28.  
  29.  
  30. /* Function declarations */
  31.  
  32. void   pascal import_mail(void);
  33. FILE * pascal open_pkt (word zone,word net,word dest,word d_point,char *domain,word attr,word m_attr);
  34. void   pascal close_pkt (FILE *fp);
  35. static void   pascal close_msg_files(void);
  36. int    pascal write_pkt_msg (FILE *fp,struct _xmsg *amsg,char *text,char *area);
  37. static int    pascal are_we_in_here (char *buf,word net,word node);
  38. static int    pascal crack_pkt (char *pktname);
  39. static int    pascal crack_arc (char *in, char *arcname);
  40. static int    pascal import (void);
  41. static int    pascal move_2_safety (char *pktname);
  42. static int    pascal unknown_msg ();
  43. static int    pascal get_msg (word buflen,char *buffer,FILE *fp);
  44. static void   pascal report(void);
  45.  
  46.  
  47.  
  48.  
  49.  
  50. void pascal import_mail (void) {
  51.  
  52.     register int x;
  53.     word areanum[4096];
  54.     struct ffblk f;
  55.     char s[133];
  56.     char ss[133];
  57.  
  58.     printf("\x1b[2J");
  59.     if(!*inbound) {
  60.         printf("\07I don't know where your Inbound directory is!\n");
  61.         return;
  62.     }
  63.  
  64.     anum=areanum;    /* So it can be accessed globally */
  65.  
  66.     printf("\nImporting mail...");
  67.  
  68.     for(x=0;x<4096;x++) {
  69.         anum[x]=0;
  70.     }
  71.     if(!netboard)netboard=1;
  72.  
  73.     sprintf(s,"%s*.PKT",inbound);
  74.     if(!findfirst(s,&f,0)) {        /* Got naked packet(s) */
  75.         do {
  76.             sprintf(s,"%s%s",inbound,f.ff_name);
  77.             crack_pkt(s);
  78.         } while(!findnext(&f));
  79.     }
  80.  
  81.     x=0;
  82.     while(arcext[x]!=NULL) {
  83.         sprintf(s,"%s*.%s?",inbound,arcext[x]);
  84.         if(!findfirst(s,&f,0)) {        /* Got archived mail */
  85.             do {
  86.                 strcpy(s,inbound);
  87.                 s[strlen(s)-1]=0;
  88.                 if(crack_arc(s,f.ff_name)) continue;
  89.                 else {
  90.                     sprintf(ss,"%s*.PKT",inbound);
  91.                     if(!findfirst(ss,&f,0)) {        /* Got naked packet(s) */
  92.                         unlink(s);
  93.                         do {
  94.                             sprintf(ss,"%s%s",inbound,f.ff_name);
  95.                             crack_pkt(ss);
  96.                         } while(!findnext(&f));
  97.                     }
  98.                 }
  99.  
  100.             } while(!findnext(&f));
  101.         }
  102.         x++;
  103.     }
  104.  
  105.     close_msg_files();    /* All done; pack the bags and go home */
  106.  
  107.     report();
  108. }
  109.  
  110.  
  111.  
  112. void pascal report (void) {
  113.  
  114.     register int x;
  115.  
  116.     printf("\n");
  117.     if(!totalmsgs) {
  118.         printf("No messages imported.\n");
  119.         return;
  120.     }
  121.     for(x=0;x<maxareas;x++) {
  122.         if(anum[x]) {
  123.             printf("Imported %u msgs to area #%u %s.\n",anum[x],marea[x].number,marea[x].name);
  124.         }
  125.     }
  126.     printf("\nTotal msgs imported: %lu\n",totalmsgs);
  127.     if(domail!=2 && domail!=4 && domail!=6) get_char();
  128. }
  129.  
  130.  
  131.  
  132. int pascal crack_arc (char *in,char *arcname) {
  133.  
  134.     char s[256];
  135.  
  136.     sprintf(s,"%s /c UNARC.BAT %s %s",getenv("COMSPEC"),in,arcname);
  137.     do_spawn(s);
  138. }
  139.  
  140.  
  141.  
  142. int pascal crack_pkt (char *pktname) {
  143.  
  144.     register word x;
  145.     FILE *fp;
  146.     long pos;
  147.     long len;
  148.     char *buffer;
  149.     word buflen;
  150.     int  temp;
  151.  
  152.     pmnum=0;
  153.     fp=fopen(pktname,"rb");
  154.     if(!fp) return -1;      /* Return Can't Open */
  155.     fseek(fp,0L,SEEK_END);    /* Get packet size */
  156.     len=ftell(fp);
  157.     if(len<=(long)sizeof(struct _pkthdr)) {
  158.         fclose(fp);
  159.         unlink(pktname);
  160.         printf("\nShort packet discarded.\n");
  161.         return 0;            /* Ignore 'short' packet */
  162.     }
  163.     fseek(fp,0L,SEEK_SET);
  164.  
  165.     if((len-(long)sizeof(struct _pkthdr))<65533L) buflen=(word)((len-(long)sizeof(struct _pkthdr))+1L);
  166.     else buflen=65534;        /* Set minimum buffer length */
  167.     buffer=(char *)malloc(buflen+1);        /* Allocate text buffer */
  168.     if(!buffer) {
  169.         fclose(fp);
  170.         return -2;        /* Return OOM */
  171.     }
  172.  
  173.     fread(&pi,sizeof(struct _pkthdr),1,fp);    /* Get packet header */
  174.  
  175.     printf("\nPacket `%s' is from address %u:%u/%u.%u@%s\n",pktname,pi.orig_zone,pi.orig_net,pi.orig_node,pi.orig_point,pi.domain);
  176.     if(!strcmp(pi.domain,"XBBS")) {
  177.         printf("Mailerless point packet.\n");
  178.         mailerless=1;
  179.     }
  180.     else mailerless=0;
  181.     for(x=0;x<(word)noaddress;x++) {
  182.         if((pi.dest_zone==0 || pi.dest_zone==address[x]->zone) && (pi.dest_net==address[x]->net) && (pi.dest_node==address[x]->node) && (pi.dest_point==0 || pi.dest_point==address[x]->point)) {
  183.             curaddress.zone=address[x]->zone;
  184.             curaddress.net=address[x]->net;
  185.             curaddress.node=address[x]->node;
  186.             curaddress.point=address[x]->point;
  187.             strcpy(curaddress.domain,address[x]->domain);
  188.             break;
  189.         }
  190.     }
  191.     if((pi.dest_zone!=0 && pi.dest_zone!=curaddress.zone) || (pi.dest_net!=curaddress.net) || (pi.dest_node!=curaddress.node) || (pi.dest_point!=0 && pi.dest_point!=curaddress.point)) {
  192.         printf("Packet isn't ours; addressed to %u:%u/%u.%u\n",pi.dest_zone,pi.dest_net,pi.dest_node,pi.dest_point);
  193.         fclose(fp);
  194.         if(buffer)free(buffer);
  195. /*        return(forward_pkt(pktname));    */
  196.         move_2_safety(pktname);
  197.         return 0;
  198.     }
  199.  
  200.     while(!feof(fp)) {
  201.         temp=get_msg(buflen,buffer,fp);
  202.         if(temp==-1) {
  203.             fclose(fp);
  204.             if(buffer)free(buffer);
  205.             move_2_safety(pktname);
  206.             return -3;    /* Return 'minor' error */
  207.         }
  208.         if(temp<0) break;    /* End of packet */
  209.         if(text==NULL || !*text) {
  210.             printf("\nNULL message discarded.\r");
  211.             continue;    /* NULL message */
  212.         }
  213.         if(!temp) {
  214.             for(x=0;x<(word)noaddress;x++) {
  215.                 if(xmsg.dest_net==address[x]->net && xmsg.dest==address[x]->node) {
  216.                     curaddress.zone=address[x]->zone;
  217.                     curaddress.net=address[x]->net;
  218.                     curaddress.node=address[x]->node;
  219.                     curaddress.point=address[x]->point;
  220.                     strcpy(curaddress.domain,address[x]->domain);
  221.                     break;
  222.                 }
  223.             }
  224.             if(xmsg.dest_net==curaddress.net && xmsg.dest==curaddress.node) temp=import();
  225. /*            else forward_msg(buffer);    */
  226.             if(temp) {
  227. /*              unknown_msg();    */
  228.             }
  229.         }
  230.     }
  231.     fclose(fp);         /* Close packet */
  232.     unlink(pktname);     /* Get rid of packet after unpacking */
  233.     if(buffer)free(buffer);
  234.     return 0;            /* Return success */
  235. }
  236.  
  237.  
  238.     static FILE *dataptr=NULL,*textptr=NULL;
  239.  
  240. void pascal close_msg_files (void) {
  241.  
  242.     if(dataptr) fclose(dataptr);
  243.     if(textptr) fclose(textptr);
  244.     dataptr=textptr=NULL;
  245. }
  246.  
  247.  
  248. int pascal import () {  /* Put msg in XBBS base */
  249.  
  250.     register int x;
  251.     static word lastarea=0;
  252.     static word lastmarea;
  253.     word temp=0;
  254.     char textname[133];
  255.     char dataname[133];
  256.  
  257.     if(area==NULL) temp=netboard;
  258.     else {
  259.         for(x=0;x<maxareas;x++) {    /* Find the area tag */
  260.             if(!stricmp(area,marea[x].name)) {
  261.                 temp=marea[x].number;
  262.                 break;
  263.             }
  264.         }
  265.         lastmarea=x;
  266.     }
  267.  
  268.     if(!temp) {
  269.         printf("\nMsg in unknown area \"%s\" ignored.\n",area);
  270.         return 1;        /* Unknown area */
  271.     }
  272.  
  273.     if(temp!=lastarea) {
  274.         if(dataptr)fclose(dataptr);
  275.         if(textptr)fclose(textptr);
  276.         lastarea=temp;
  277.         sprintf(textname,"%sXTEXT.%03x",path,temp);
  278.         sprintf(dataname,"%sXDATA.%03x",path,temp);
  279.         dataptr=fopen(dataname,"a+b");
  280.         textptr=fopen(textname,"a+b");
  281.         if(!dataptr || !textptr) {
  282.             if(dataptr)fclose(dataptr);
  283.             if(textptr)fclose(textptr);
  284.             dataptr=textptr=NULL;
  285.             printf("\nCan't open message base file(s)\n");
  286.             return 2;        /* Error opening message area */
  287.         }
  288.         printf("\n");
  289.     }
  290.  
  291.     if(!area) printf("\x1b[KPkt area NETMAIL (#%u) -=> Msg area %u (#%u)\r",++pmnum,lastarea,++anum[lastmarea]);
  292.     else printf("\x1b[KPkt area %s (#%u) -=> Msg area %u (#%u)\r",area,++pmnum,lastarea,++anum[lastmarea]);
  293.     totalmsgs++;
  294.  
  295.     fseek(dataptr,0L,SEEK_END);
  296.     fseek(textptr,0L,SEEK_END);
  297.  
  298.     xmsg.start=ftell(textptr);
  299.     if((marea[lastmarea].attr & COMPRESS) && xmsg.length>packsize) {
  300.  
  301.         char *hold;
  302.         unsigned int temp;
  303.  
  304.         temp=strlen(text);
  305.         if(temp>65100) {
  306.             text[65099]=0;
  307.             temp=65100;
  308.         }
  309.         hold=(char *)malloc(temp+256);
  310.         if(!hold) {
  311.             printf("\nInsufficient memory for compression\n");
  312.             fwrite(text,temp,1,textptr);
  313.         }
  314.         else {
  315.             hold=pack_msg(hold);
  316.             if(!hold) {
  317.                printf("\nCompression failed\n");
  318.                fwrite(text,temp,1,textptr);
  319.             }
  320.             else {
  321.                 msg.m_attr = xmsg.m_attr | MSGPACKED;
  322.                 fwrite(hold,xmsg.length,1,textptr);
  323.             }
  324.             if(hold)free(hold);
  325.        }
  326.     }
  327.     else fwrite(text,strlen(text),1,textptr);
  328.     fwrite(&xmsg,sizeof(struct _xmsg),1,dataptr);
  329.     fputc(0,textptr);
  330.     return 0;
  331. }
  332.  
  333.  
  334.  
  335. int pascal move_2_safety (char *pktname) {    /* Copy indecipherable packet to safe 'place' */
  336.  
  337.     char s[166];
  338.     char newname[133];
  339.     char *p;
  340.  
  341.     strcpy(newname,pktname);
  342.     p=strrchr(newname,'.');
  343.     if(p) {
  344.         *p=0;
  345.     }
  346.     strcat(newname,".BKT");
  347.     sprintf(s,"COPY %s %s > NUL",pktname,newname);
  348.     printf("\n%s\n",s);
  349.     system(s);                             /* Replace with inline code later */
  350.     sprintf(s,"DEL %s > NUL",pktname);
  351.     printf("%s\n",s);
  352.     return (system(s));
  353. }
  354.  
  355.  
  356.  
  357. int pascal unknown_msg () { /* Place unknown echomail msgs into UNKNOWN.PKT XST-style */
  358.  
  359.  
  360.  
  361.  
  362. }
  363.  
  364.  
  365.  
  366. int pascal get_msg (word buflen,char *buffer,FILE *fp) {
  367.  
  368.     /* This could be sped up as explained to me by Wayne Michaels:
  369.        read only 8K on first pass.  If you don't find EOM in that,
  370.        read 8K more, and so on until you find EOM (or run out of
  371.        buffer).  Then process message. */
  372.  
  373.     register word x;
  374.     char *p;
  375.     long pos;
  376.     word len;
  377.     word *temp;
  378.  
  379. Again:
  380.     if(feof(fp)) return -2;
  381.     pos=ftell(fp);
  382.     if(fread(buffer,1,buflen,fp)==0) return -2;
  383.     buffer[buflen]=0;
  384.     p=buffer;
  385.     if(*p!='\02' || p[1]!='\0') {
  386.         if(feof(fp) || (*p=='\0' && p[1]=='\0')) return -2;
  387.         while(*p!='\02' && p<(buffer+buflen)) {
  388.             p++;
  389.             pos++;
  390.         }
  391.         fseek(fp,pos,SEEK_SET);
  392.         goto Again;
  393.     }
  394.     p+=2;
  395.     temp=(word *)p;
  396.     xmsg.orig=*temp;
  397.     p+=2;
  398.     temp=(word *)p;
  399.     xmsg.dest=*temp;
  400.     p+=2;
  401.     temp=(word *)p;
  402.     xmsg.orig_net=*temp;
  403.     p+=2;
  404.     temp=(word *)p;
  405.     xmsg.dest_net=*temp;
  406.     p+=2;
  407.     temp=(word *)p;
  408.     xmsg.attr=*temp;
  409.     if(!mailerless) {
  410.         temp=(word *)p;
  411.         xmsg.cost=*temp;
  412.         p+=2;
  413.     }
  414.     else {
  415.         xmsg.cost=0;
  416.         p+=4;
  417.     }
  418.     strncpy(xmsg.date,p,20);
  419.     xmsg.date[19]=0;
  420.     while(*p)p++;    /* <--This goddamn kludge thanks to Opus & assoc utils */
  421.     p++;
  422.     strncpy(xmsg.to,p,36);
  423.     xmsg.to[35]=0;
  424.     while(*p)p++;
  425.     p++;
  426. #ifdef DEBUG
  427. printf("\x1b[KTo: %s\n",xmsg.to);
  428. #endif
  429.     strncpy(xmsg.from,p,36);
  430.     xmsg.from[35]=0;
  431.     while(*p)p++;
  432.     p++;
  433. #ifdef DEBUG
  434. printf("\x1b[KFrom: %s\n",xmsg.from);
  435. #endif
  436.     strncpy(xmsg.subj,p,64);
  437.     xmsg.subj[63]=0;
  438.     while(*p)p++;
  439.     p++;
  440. #ifdef DEBUG
  441. printf("\x1b[KSubj: %s\n",xmsg.subj);
  442. #endif
  443.     text=p;
  444.     while(*p)p++;
  445.     p++;                            /* Should be start of next msg */
  446.     endptr=p;
  447.     pos+=(long)(endptr-buffer);
  448.     fseek(fp,pos,SEEK_SET);            /* Now positioned to start of next msg */
  449.     len=strlen(text);
  450. #ifdef DEBUG
  451. printf("\x1b[KText: %s\n",text);
  452. #endif
  453.  
  454.     p=text;
  455.     while (*p) {    /* Strip linefeeds and soft cr's FAST */
  456.         if(*p=='\x8d' || *p=='\n') {
  457.             if(*p=='\n') {
  458.                 memmove(p,&p[1],len-((word)p-(word)text));
  459.             }
  460.             else {
  461.                 if(*(p-1)==' ' && p>text) {
  462.                     memmove(p,&p[1],len-((word)p-(word)text));
  463.                 }
  464.                 else *p=' ';
  465.             }
  466.         }
  467.         p++;
  468.     }
  469.  
  470.     if(!strnicmp(text,"AREA:",5)) {    /* Echo area tag */
  471.         area=text;
  472.         while(*text && *text!='\r') {
  473.             text++;
  474.         }
  475.         if(*text) {
  476.             *text=0;                    /* area now = area tag line */
  477.             text++;                        /* text = true start of msg body if any */
  478.         }
  479.         while(*text=='\r' && *text) text++; /* Skip leading cr's in body */
  480.         area+=5;
  481.         lstrip(area);
  482.         rstrip(area);                    /* Points directly to tag */
  483.     }
  484.     else area=NULL;
  485.  
  486. #ifdef DEBUG
  487. printf("\x1b[KArea: %s\n",area);
  488. printf("\x1b[KText2: %s\n",text);
  489. #endif
  490.  
  491.     if (area) {             /* Do ECHO specific BS */
  492.  
  493.         char *tempo=NULL;
  494.         char *origin=NULL;
  495.  
  496.         pathline=NULL;
  497.         seenby=NULL;
  498.         kludge=NULL;
  499.         tempo=text;        /* They oughta outlaw EID's */
  500.         if(!no_strip) {
  501.             while ((tempo=strstr(tempo,"\01EID:"))) memmove(tempo,strchr(&tempo[1],'\r'),strlen(strchr(&tempo[1],'\r'))+1);
  502.             while(*text=='\r' && *text) text++; /* Skip leading cr's in body */
  503.         }
  504.         if(!strncmp(text," * Origin: ",11)) *text=0;    /* Nothin' but origin */
  505.         origin=strstr(text,"\r * Origin:");        /* Find the origin line */
  506.         if (origin) {        /* Ain't one; oh, well, screw it */
  507.             while(tempo=strstr(&origin[1],"\r * Origin:")) origin=tempo; /* Find last */
  508.             pathline=strstr(origin,"\r\01PATH:");   /* Find the PATH line */
  509.             seenby=strstr(origin,"\rSEEN-BY:");    /* Find start of SEEN-BYs */
  510.             if (!seenby) seenby=strstr(origin,"\r\01SEEN-BY:");
  511.             if(pathline) {
  512. /*              for(x=0;x<(word)noaddress;x++) {
  513.                     if(are_we_in_here(pathline,address[x]->net,address[x]->node)) return 1;
  514.                 }
  515. */            }
  516.             else {
  517.                 if(!no_strip) {
  518.                     if (seenby) {
  519.                         *seenby=0;  /* Mercifully kill SEEN-BYs */
  520.                         seenby=NULL;
  521.                     }
  522.                 }
  523.             }
  524.             if ((seenby && pathline) && seenby<pathline) {
  525.                 if(!no_strip) {
  526.                     memmove (seenby,pathline,strlen(pathline)+1); /* Keep PATH */
  527.                     seenby=NULL;
  528.                 }
  529.             }
  530.         }
  531.         if (text[strlen(text)-1]!='\r') strcat(text,"\r");    /* Assure trailing cr for appearance */
  532.         xmsg.attr |= MSGORPHAN;        /* Orphan stripped msgs so they never go back out */
  533.     }
  534.  
  535.     if(!no_fillin) {        /* Fill in header address info from kludges */
  536.  
  537.         char *tempo;
  538.         char message[MAXKLUDGE];
  539.  
  540.         if ((p=strstr(text,"\01FMPT "))) {
  541.             strncpy(message,p,MAXKLUDGE);
  542.             message[MAXKLUDGE-1]=0;
  543.             p=message;
  544.             xmsg.o_point=(char)atoi(&p[5]);
  545.         }
  546.         if ((p=strstr(text,"\01INTL "))) {
  547.             strncpy(message,p,MAXKLUDGE);
  548.             message[MAXKLUDGE-1]=0;
  549.             p=message;
  550.             strtok(p," :");
  551.             strtok(0," ");
  552.             tempo=strtok(0,":");
  553.             if(tempo)if ((word)atol(tempo)) xmsg.o_zone=(word)atol(tempo);
  554.         }
  555.         if ((p=strstr(text,"\01MSGID: "))) {
  556.  
  557.             char *ispoint;
  558.             char *isnumsign;
  559.  
  560.             strncpy(message,p,MAXKLUDGE);
  561.             message[MAXKLUDGE-1]=0;
  562.             p=message;
  563.             isnumsign=strchr(p,'#');
  564.             ispoint=strchr(p,'.');
  565.             if(isnumsign) {
  566.                 if(isnumsign<ispoint || !ispoint) {
  567.                     p=strtok(p,"#");    /* Get past domain */
  568.                     p=strtok(0,"\n");
  569.                 }
  570.             }
  571.             strtok(p," :");
  572.             p=strtok(0,":");
  573.             if(p)xmsg.o_zone=(word)atol(p);
  574.             p=strtok(0,"/");
  575.             xmsg.orig_net=(word)atol(p);
  576.             if(ispoint) p=strtok(0,".");
  577.             else p=strtok(0,"@ ");
  578.             if(p)xmsg.orig=(word)atol(p);
  579.             if(ispoint) {
  580.                 p=strtok(0,"@ ");
  581.                 if(p && (word)atol(p) && atol(p)<65536)
  582.                     xmsg.o_point=(word)atol(p);
  583.             }
  584.         }
  585.         if ((p=strstr(text,"\01MSGTO: "))) {
  586.  
  587.             char *ispoint;
  588.             char *isnumsign;
  589.             char *isdomain;
  590.  
  591.             strncpy(message,p,MAXKLUDGE);
  592.             message[MAXKLUDGE-1]=0;
  593.             p=message;
  594.             isnumsign=strchr(p,'#');
  595.             ispoint=strchr(p,'.');
  596.             isdomain=strchr(p,'@');
  597.             if(isnumsign) {
  598.                 if(isnumsign<isdomain && isdomain) {
  599.                     p=strtok(p,"@");
  600.                     strncpy(msg.to,p,36);
  601.                     msg.to[35]=0;
  602.                     p=strtok(0,"\n");
  603.                 }
  604.                 p=strtok(p,"#");
  605.                 p=strtok(0,"\n");
  606.             }
  607.             strtok(p," :");
  608.             p=strtok(0,":");
  609.             if(p)xmsg.d_zone=(word)atol(p);
  610.             p=strtok(0,"/");
  611.             xmsg.dest_net=(word)atol(p);
  612.             if(ispoint) p=strtok(0,".");
  613.             else p=strtok(0,"@ ");
  614.             if(p)xmsg.dest=(word)atol(p);
  615.             if(ispoint) {
  616.                 p=strtok(0,"@ ");
  617.                 if(p && (word)atol(p) && atol(p)<65536)
  618.                     xmsg.d_point=(word)atol(p);
  619.             }
  620.         }
  621.     }
  622.  
  623.     p=&text[strlen(text)-1];
  624.     while(*p=='\r' && *(p-1)=='\r' && p>text) {
  625.         *p=0;
  626.         p--;
  627.     }
  628.  
  629.     xmsg.length=strlen(text);
  630.     xmsg.m_attr = 0;
  631.     if(area) xmsg.m_attr |= MSGECHO;         /* Is echo */
  632.     else xmsg.m_attr |= MSGNET;                /* Is net  */
  633.     xmsg.attr = xmsg.attr & (~MSGLOCAL);    /* Isn't local! */
  634.     return 0;
  635. }
  636.  
  637.  
  638.  
  639. int pascal are_we_in_here (char *buf,word net,word node) {
  640.  
  641.     /* Check for net/node combination in SEEN-BY/PATH-type string.
  642.        This could probably stand some speed-up optimization */
  643.  
  644.     char s[133];
  645.     register char *p;
  646.     register char *pp;
  647.     char *nomore;
  648.  
  649.     if(!buf) return 0;
  650.     sprintf(s,"%u/%u",net,node);
  651.     pp=buf;
  652. Again:
  653.     if(p=strstr(pp,s)) {
  654.         if(!strchr(" \r",*(p-1)) || !strchr(" \r",*(p+strlen(s)))) {    /* Need whitespace before and after */
  655.             pp=(p+strlen(s));
  656.             goto Again;
  657.         }
  658.         return 1;                        /* Full entry is in there */
  659.     }
  660.     sprintf(s,"%u/",net);
  661.     pp=buf;
  662. Again2:
  663.     if(!(p=strstr(pp,s))) return 0;        /* Our net isn't there */
  664.     if(!strchr(" \r",*(p-1)) || !strchr(" \r",*(p+strlen(s)))) {
  665.         pp=(p+strlen(s));
  666.         goto Again2;
  667.     }
  668.     p+=strlen(s);                        /* Past the net and slash */
  669.     nomore=strchr(p,'/');                /* Find next slash */
  670.     sprintf(s,"%u",node);
  671. Again3:
  672.     if(!(p=strstr(p,s))) return 0;        /* Our node isn't there */
  673.     if(p>=nomore) return 0;                /* Under some other net */
  674.     if(!strchr(" \r",*(p-1)) || !strchr(" \r",*(p+strlen(s)))) {
  675.         pp=(p+strlen(s));
  676.         goto Again3;
  677.     }
  678.     return 1;                            /* We're in there */
  679. }
  680.