home *** CD-ROM | disk | FTP | other *** search
/ synchro.net / synchro.net.tar / synchro.net / modem.madness / SMMNETML / AMAX_230.ZIP / SOURCES.ZIP / AMAXQMSG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-15  |  25.4 KB  |  777 lines

  1. /*---------------------------------------------------------------------------*/
  2. /*                                                                           */
  3. /* Module Name:   AMAXQMSG.C                                                 */
  4. /* Program Name:  AMAX                                                       */
  5. /* Revision:      2.xx                                                       */
  6. /* Purpose:       Quick Message Entry Module                                 */
  7. /* Programmer:    Alan Bryant                                                */
  8. /* Programmer:    Charles Frnka                                              */
  9. /*                                                                           */
  10. /* Copyright (C) 1988, 89, 90, 92 Alan D. Bryant, All Rights Reserved.       */
  11. /* Portions Copyright (C) 1988, 89 Charles Frnka, All Rights Reserved.       */
  12. /*                                                                           */
  13. /* NOTICE:  This source code is copyrighted material.  You are granted a     */
  14. /* limited license to use and distribute the code.  The complete text of     */
  15. /* the license can be found in the document LICENSE.DOC which accompanies    */
  16. /* this source code, or can be obtained directly from the author.            */
  17. /*                                                                           */
  18. /* Inquiries regarding this package should be directed to:                   */
  19. /*                                                                           */
  20. /*     AMAX                                                                  */
  21. /*     Alan D. Bryant                                                        */
  22. /*     P. O. Box 101612                                                      */
  23. /*     Denver, CO  80250                                                     */
  24. /*     USA                                                                   */
  25. /*                                                                           */
  26. /*---------------------------------------------------------------------------*/
  27.  
  28. #include <stdio.h>
  29. #include <time.h>
  30. #include <dir.h>
  31. #include "amax.h"
  32.  
  33. extern char tearline;
  34. extern unsigned char sysname[100];
  35.  
  36. void qmsg(int, int, char *, char, char *, char *);
  37. char save_msg(char *, int, int, int, int, char [20][85], char *, char *, char *, int, int, char *, char);
  38. // char *find_sysop(char *);
  39. void get_date(char *);
  40.  
  41. /*  char type is 0 if called from the menu, 1 if called from the bomber  */
  42. /*  char *list is a pointer to the name of the list file for bomber calls  */
  43. /*  char *key is the keyname in the list for bomber calls  */
  44.  
  45.  
  46.  
  47. void qmsg(int from_net, int from_node, char *name, char type, char *list, char *key)
  48. {
  49.     struct tm *tm_now;
  50.     long secs_now;
  51.     char *str_now;
  52.     struct ffblk ffblk;
  53.  
  54.     FILE *stream;
  55.  
  56.     char ch = 0;
  57.     char exists = 0;
  58.     char route_type = 0;
  59.     char to[36] = "";
  60.     char from[36] = "";
  61.     char subject[72] = "";
  62.     char nodestring[50] = "";
  63.     char text[20][85];
  64.     char string[100] = "";
  65.     char hexname[20] = "";
  66.     char info[70] = "";
  67.     char oldpart[80] = "";
  68.     char newpart[80] = "";
  69.     char pick = 0x00;
  70.     char inter[80] = "";
  71.     char fileopen[100] = "";
  72.     char destination[100] = "";
  73.     char line[100] = "";
  74.     char part[40] = "";
  75.     char eolarea[3] = "";
  76.     char out[100] = "";
  77.     char suffix[5] = "";
  78.     char entry[5] = "";
  79.     char textfile[100] = "";
  80.     char drive[MAXDRIVE];
  81.     char dir[MAXDIR];
  82.     char filefoo[MAXFILE];
  83.     char ext[MAXEXT];
  84.     char beep = 0;
  85.  
  86.     int x = 0;
  87.     int y = 0;
  88.     int start = 0;
  89.     int offset = 0;
  90.     int done;
  91.     int to_net = 0;
  92.     int to_node = 0;
  93.     int attrib = 0;
  94.     int flag;
  95.     int maxlen;
  96.  
  97.  
  98.     strcpy(from, name);
  99.     for (x = 0; x < 20; x++) {
  100.         text[x][0] = 0x00;
  101.     }
  102.     if (type == 0) {
  103.         cls();
  104.         output("$1AMAX $4Enter a Message Directly to Outbound Area$0");
  105.         cursor(2, 0);
  106.     }
  107.     else {
  108.         minicls();
  109.         cursor(2, 0);
  110.     }
  111.     output("Message TO:       ");
  112.     vpanel(35);
  113.     getln(to, 35);
  114.     if (strlen(to) == 0) return;
  115.     strcpy(nodestring, findaddress(to));
  116.     output("Message FROM:     ");
  117.     vpanel(35);
  118.     getln(from, 35);
  119.     if (strlen(from) == 0) return;
  120.     if (type == 0) {
  121.         output("Node Address TO:  ");
  122.         vpanel(20);
  123.         getln(nodestring, 20);
  124.         if (strchr(nodestring, '/') == NULL) {
  125.             output("\r\nSystem node address must be in the format NET/NODE...");
  126.             pressanykey();
  127.             return;
  128.         }
  129.         strcpy(hexname, parseaddress(nodestring));
  130.         to_net = extractnet(hexname);
  131.         to_node = extractnode(hexname);
  132.         strcpy(info, lookinfo(to_net, to_node, 0));
  133.         sprintf(string, "   %s\r\n", info);
  134.         output(string);
  135.  
  136.         strcpy(string, to);
  137.         strupr(string);
  138.  
  139.         strcpy(fileopen, nodelist);
  140.         strcat(fileopen, "fidouser.lst");
  141.  
  142.         done = findfirst(fileopen, &ffblk, 0);
  143.  
  144.  
  145. /*
  146.         if (((strstr(string, "SYSOP") || strlen(to) < 2)) && ! done) {
  147.             output("Want to locate SYSOP name? ");
  148.             ch = agetch();
  149.             if (ch == 'Y' || ch == 'y') {
  150.                 output("Y     Searching...");
  151.                 strcpy(line, (char *) find_sysop(nodestring));
  152.                 if (line) {
  153.                     output("\r\nWill send message to ");
  154.                     output(line);
  155.                     output(" - send? ");
  156.                     ch = agetch();
  157.                     if (ch == 'Y' || ch == 'y') ch = 0x01;
  158.                     else ch = 0x00;
  159.                     if (ch) {
  160.                         strcpy(to, line);
  161.                         cursor(2, 18);
  162.                         vpanel(35);
  163.                         output("$6");
  164.                         output(to);
  165.                         output("$0");
  166.                     }  /* end if ch */
  167.                 } /* end if line */
  168.             } /* end want to locate */
  169.         } /* end if we should locate */
  170.     */
  171.  
  172.     }
  173.  
  174.     ch = 0x00;
  175.     bottomcls(6);
  176.     cursor(6, 0);
  177.     output("$1P$0)rivate  $1F$0)ile Attached  ");
  178.     while (ch != 0x0D) {
  179.         ch = agetch();
  180.         if (ch > 90) ch = ch - 32;
  181.         if (ch == 'P') {
  182.             attrib = attrib ^ 1;
  183.             cursor(6, 0);
  184.             if (attrib & 1) output ("$1P$0)RIVATE ");
  185.             else output("$1P$0)rivate ");
  186.             cursor(6, 26);
  187.         }
  188.         if (ch == 'F') {
  189.             attrib = attrib ^ 16;
  190.             cursor(6, 10);
  191.             if (attrib & 16) {
  192.                 output("$1F$0)ILE ATTACHED ");
  193.             }
  194.             else {
  195.                 output("$1F$0)ile Attached ");
  196.             }
  197.             cursor(6, 26);
  198.         }
  199.     }
  200.     cursor(7, 0);
  201.     if (attrib & 16) output("Filename:         ");
  202.     else output("Subject:          ");
  203.     vpanel(50);
  204.     getln(subject, 50);
  205.     if (strlen(subject) == 0) return;
  206.     if (attrib & 16) {
  207.         done = findfirst(subject, &ffblk, 0);
  208.         if (done) {
  209.             output("File cannot be located...");
  210.             pressanykey();
  211.             return;
  212.         }
  213.         flag = fnsplit(subject, drive, dir, filefoo, ext);
  214.         if (! (flag & DRIVE) || ! (flag & DIRECTORY)) {
  215.             output("You MUST enter a complete filespec including drive and directory.\r\n");
  216.             output("To return, ");
  217.             pressanykey();
  218.             return;
  219.         }
  220.     }
  221.     ch = 0x00;
  222.     output("\r\n\r\nUse text file for bottom portion of message text?  $1Y$0)es  $1N$0)o  ");
  223.     ch = menu_select("YN\x1B\x0D");
  224.     if (ch == 0x1B) return;
  225.     stream = NULL;
  226.     if (ch == 'Y') {
  227.         aputch(ch);
  228.         output("\r\n");
  229.         while (stream == NULL) {
  230.             textfile[0] = 0x00;
  231.             cursor(10, 0);
  232.             clearline();
  233.             output("Name of text file to use?  ");
  234.             vpanel(40);
  235.             getln(textfile, 40);
  236.             if (strlen(textfile) == 0) return;
  237.             stream = fopen(textfile, "rb");
  238.         }
  239.         fclose(stream);
  240.     }
  241.  
  242.     bottomcls(2);
  243.  
  244.     while(pick == 0x00) {
  245.         for (x = start; x < 20; x++) {
  246.             if (x > 14 && x < 19) {
  247.                 cursor(22, 0);
  248. /*!!!!                if (x > 18) printf("\a"); */
  249.                 sprintf(out, "Including this one, only %d lines left!", 20 - x);
  250.                 output(out);
  251.             }
  252.             if (x == 19) {
  253.                 cursor(22, 0);
  254. /*!!!                printf("\a");  */
  255.                 sprintf(out, "This is your last line.  For longer messages, use text file option.");
  256.                 output(out);
  257.             }
  258.             cursor(x + 2, 0);
  259.             sprintf(string, "%02d > ", x);
  260.             output(string);
  261.             vpanel(70);
  262.             getln(text[x], 570);
  263.             scolor(7);
  264.             cursor(x + 2, 0);
  265.             if (direct) clreol();
  266.             else output("\x1B[0K");
  267.             cursor(x + 2, 0);
  268.             sprintf(out, "%02d > %s", x, text[x]);
  269.             output(out);
  270.             if (strlen(text[x]) == 0) break;
  271.         }
  272.         if (x == 20) {
  273.             cursor(22, 0);
  274.             clearline();
  275.             if (! beep) {
  276.                 beep = 1;
  277.             }
  278.             sprintf(out, "END OF ALLOWABLE TEXT!  For longer messages, use text file option.");
  279.             output(out);
  280.             sleep(2);
  281.             while (kbhit()) {
  282.                 agetch();
  283.             }
  284.         }
  285.         start = x;
  286.         cursor(22, 0);
  287.         clearline();
  288.         output("$1E$0)dit  $1S$0)ave  $1A$0)bort  $1I$0)nsert  $1D$0)elete  $1C$0)ontinue  ");
  289.         pick = menu_select("ESIDAC\x1B");
  290.  
  291.         switch (pick) {
  292.             case 'I':
  293.             case 'i':
  294.                 cursor(22, 0);
  295.                 clearline();
  296.                 output("Insert AFTER which line? ");
  297.                 vpanel(2);
  298.                 entry[0] = 0x00;
  299.                 getln(entry, 2);
  300.                 for (x = 0; x < strlen(entry); x++) {
  301.                     if (entry[x] < 48 || entry[x] > 57) {
  302.                         cursor(22, 0);
  303.                         clearline();
  304.                         output("Invalid entry...");
  305.                         break;
  306.                     }
  307.                 }
  308.                 ch = atoi(entry);
  309.                 if (ch > 19 || ch > (start - 1)) {
  310.                     cursor(22, 0);
  311.                     clearline();
  312.                     output("Invalid entry...");
  313.                     break;
  314.                 }
  315.                 for (x = 19; x >= ch; --x) {
  316.                     strcpy(text[x+1], text[x]);
  317.                 }
  318.                 text[ch+1][0] = 0x00;
  319.                 ++start;
  320.                 for (x = 0; x <= start; x++) {
  321.                     cursor(x + 2, 0);
  322.                     if (direct) clreol();
  323.                     else output("\x1B[0K");
  324.                     sprintf(string, "%02d > %s", x, text[x]);
  325.                     output(string);
  326.                 }
  327.                 clearline();
  328.                 cursor(ch + 3, 0);
  329.                 sprintf(string, "%02d > ", ch+1);
  330.                 output(string);
  331.                 vpanel(70);
  332.                 getln(text[ch+1], 570);
  333.                 scolor(7);
  334.                 cursor(ch + 3, 0);
  335.                 if (direct) clreol();
  336.                 else output("\x1B[0K");
  337.                 cursor(ch + 3, 0);
  338.                 sprintf(out, "%02d > %s", ch+1, text[ch+1]);
  339.                 output(out);
  340.                 break;
  341.             case 'D':
  342.             case 'd':
  343.                 cursor(22, 0);
  344.                 clearline();
  345.                 output("Delete which line? ");
  346.                 vpanel(2);
  347.                 entry[0] = 0x00;
  348.                 getln(entry, 2);
  349.                 for (x = 0; x < strlen(entry); x++) {
  350.                     if (entry[x] < 48 || entry[x] > 57) {
  351.                         cursor(22, 0);
  352.                         clearline();
  353.                         output("Invalid entry...");
  354.                         break;
  355.                     }
  356.                 }
  357.                 ch = atoi(entry);
  358.                 if (ch >= start) break;
  359.                 for (x = ch; x < 20; x++) {
  360.                     strcpy(text[x], text[x+1]);
  361.                 }
  362.                 text[20][0] = 0x00;
  363.                 --start;
  364.                 if (start < 0) start = 0;
  365.                 for (x = 0; x <= start; x++) {
  366.                     cursor(x + 2, 0);
  367.                     if (direct) clreol();
  368.                     else output("\x1B[0K");
  369.                     sprintf(string, "%02d > %s", x, text[x]);
  370.                     output(string);
  371.                 }
  372.                 break;
  373.             case 'C':
  374.             case 'c':
  375.                 clearline();
  376.                 break;
  377.             case 'A':
  378.             case 'a':
  379.             case 0x1B:
  380.                 return;
  381.             case 'E':
  382.             case 'e':
  383.                 clearline();
  384.                 cursor(22, 0);
  385.                 entry[0] = 0x00;
  386.                 output("Which line? ");
  387.                 vpanel(2);
  388.                 getln(entry, 3);
  389.                 for (x = 0; x < strlen(entry); x++) {
  390.                     if (entry[x] < 48 || entry[x] > 57) {
  391.                         cursor(22, 0);
  392.                         clearline();
  393.                         output("Invalid entry...");
  394.                         break;
  395.                     }
  396.                 }
  397.                 ch = atoi(entry);
  398.                 clearline();
  399.                 if (ch >= start) {
  400.                     cursor(22, 0);
  401.                     output("You haven't written that line yet...");
  402.                     pressanykey();
  403.                     break;
  404.                 }
  405.                 oldpart[0] = NULL;
  406.                 newpart[0] = NULL;
  407.                 cursor(22, 0);
  408.                 clearline();
  409.                 output("Old string? ");
  410.                 vpanel(60);
  411.                 getln(oldpart, 60);
  412.                 cursor(22, 0);
  413.                 clearline();
  414.                 output("New string? ");
  415.                 maxlen = 75 - (strlen(text[ch]) - strlen(oldpart));
  416.                 if (maxlen > 66) maxlen = 66;
  417.                 vpanel(maxlen);
  418.                 getln(newpart, maxlen);
  419.                 offset = strlen(text[ch]) - strlen(strstr(text[ch], oldpart));
  420.                 if (offset == strlen(text[ch])) {
  421.                     cursor(22, 0);
  422.                     clearline();
  423.                     output("Not found!  Press any key... ");
  424.                     agetch();
  425.                     break;
  426.                 }
  427.                 for (x = 0; x < offset; x++) {
  428.                     inter[x] = text[ch][x];
  429.                 }
  430.                 inter[x] = 0x00;
  431.                 strcat(inter, newpart);
  432.  
  433.                 y = strlen(inter);
  434.                 for (x = offset + strlen(oldpart); x < strlen(text[ch]); x++) {
  435.                     inter[y] = text[ch][x];
  436.                     ++y;
  437.                 }
  438.                 inter[y] = 0x00;
  439.                 strcpy(text[ch], inter);
  440.                 cursor(ch + 2, 0);   /*  !!!!  */
  441.                 sprintf(string, "%02d > %s", ch, text[ch]);
  442.                 clearline();
  443.                 output(string);
  444.                 break;
  445.             case 'S':
  446.             case 's':
  447.                 cursor(22, 0);
  448.                 clearline();
  449.                 output("Flavor?  $1C$0)ontinuous  $1N$0)ormal  $1D$0)irect  $1H$0)old  $1A$0)bort  ");
  450.                 route_type = menu_select("CNDHA\x1B");
  451.                 cursor(22, 0);
  452.                 clearline();
  453.                 if (route_type == 'C') {
  454.                     strcpy(suffix, ".CUT");
  455.                     output("Saving as Continuous.  ");
  456.                 }
  457.                 if (route_type == 'N') {
  458.                     strcpy(suffix, ".OUT");
  459.                     output("Saving as Normal.  ");
  460.                 }
  461.                 if (route_type == 'D') {
  462.                     strcpy(suffix, ".DUT");
  463.                     output("Saving as Direct.  ");
  464.                 }
  465.                 if (route_type == 'H') {
  466.                     strcpy(suffix, ".HUT");
  467.                     output("Saving as Hold.  ");
  468.                 }
  469.                 if (route_type == 'A' || route_type == 0x1B) {
  470.                     return;
  471.                 }
  472.  
  473.                 if (type == 0) {
  474.                     strcpy(fileopen, outbound);
  475.                     strcat(fileopen, hexname);
  476.                     strcat(fileopen, suffix);
  477.  
  478.                     done = findfirst(fileopen, &ffblk, 0);
  479.                     if (! done) {
  480.                         exists = 1;
  481.                         strcpy(destination, fileopen);
  482.                         fileopen[strlen(fileopen) - 3] = 'T';
  483.                         output("Append existing packet.  ");
  484.                     }
  485.  
  486.                     else {
  487.                         exists = 0;
  488.                         output("Creating new packet.  ");
  489.                     }
  490.  
  491.                     if (! save_msg(fileopen, from_node, to_node, from_net, to_net, text, to, from, subject, start, attrib, textfile, route_type)) return;
  492.  
  493.                     if (exists == 1) {
  494.                         append_packet(fileopen, destination);
  495.                     }
  496.                 }
  497.                 else {
  498.                     stream = fopen(list, "rb");
  499.                     if (stream == NULL) {
  500.                         output("  Invalid list file...");
  501.                         pressanykey();
  502.                         return;
  503.                     }
  504.                     ch = 0;
  505.                     minicls();
  506.                     cursor(2, 0);
  507.                     output("Sending message to list members...\r\n\r\n");
  508.                     while (! feof(stream)) {
  509.                         fscanf(stream, "%s", part);
  510.                         if (! strcmp(part, ";")) fgetln(line, sizeof(line), eolarea, stream);
  511.                         if (! stricmp(part, key)) {
  512.                             while (strcmp(part, ".")) {
  513.                                 fscanf(stream, "%s ", part);
  514.                                 if (! strcmp(part, ".")) continue;
  515.                                 /*  if (! strchr(part, '/')) continue;  */
  516.                                 strcpy(hexname, parseaddress(part));
  517.                                 to_node = extractnode(hexname);
  518.                                 to_net = extractnet(hexname);
  519.                                 if (to_net == 0 && to_node == 0) continue;
  520.                                 ++ch;
  521.                                 if (ch > 12) {
  522.                                     bottomcls(4);
  523.                                     cursor(4, 0);
  524.                                     ch = 0;
  525.                                 }
  526.                                 strcpy(fileopen, outbound);
  527.                                 strcat(fileopen, hexname);
  528.                                 strcat(fileopen, suffix);
  529.                                 done = findfirst(fileopen, &ffblk, 0);
  530.                                 if (! done) {
  531.                                     exists = 1;
  532.                                     strcpy(destination, fileopen);
  533.                                     fileopen[strlen(fileopen) - 3] = 'T';
  534.                                     sprintf(out, "Append existing packet for %d:%d/%d.  ", zone_num, to_net, to_node);
  535.                                     output(out);
  536.                                 }
  537.                                 else {
  538.                                     exists = 0;
  539.                                     sprintf(out, "Creating new packet for %d:%d/%d.  ", zone_num, to_net, to_node);
  540.                                     output(out);
  541.                                 }
  542.  
  543.  
  544.                                 if (! save_msg(fileopen, from_node, to_node, from_net, to_net, text, to, from, subject, start, attrib, textfile, route_type)) return;
  545.  
  546.                                 output("\r\n");
  547.  
  548.                                 if (exists == 1) append_packet(fileopen, destination);
  549.  
  550.                             }  /*  while !  .  */
  551.                         }  /*  end if !  */
  552.                     }  /* end while ! feof  */
  553.                     fclose(stream);
  554.                 }  /*  end else  */
  555.             if (type == 0) {
  556.                 cursor(22, 0);
  557.                 clearline();
  558.                 output("Operation complete...");
  559.                 pressanykey();
  560.             }
  561.             else output("\r\n");
  562.             continue;
  563.         }  /*  end switch  */
  564.  
  565.         pick = 0x00;
  566.         bottomcls(start + 2);
  567.         cursor(start + 2, 0);
  568.         continue;
  569.     }  /*  end while  */
  570.  
  571. }  /*  end function  */
  572.  
  573.  
  574. char save_msg(char *fileopen, int from_node, int to_node, int from_net,
  575.               int to_net, char text[20][85], char *to, char *from, char *subject,
  576.               int start, int attrib, char *textfile, char route_type) {
  577.  
  578.     struct tm *tm_now;
  579.     long secs_now;
  580.     char *str_now;
  581.     struct ffblk ffblk;
  582.  
  583.     FILE *stream;
  584.     FILE *stream2;
  585.  
  586.     char date_time[20];
  587.     char address[15];
  588.     char existtext = 0;
  589.     char ch;
  590.  
  591.     char drive[MAXDRIVE];
  592.     char dir[MAXDIR];
  593.     char filefoo[MAXFILE];
  594.     char ext[MAXEXT];
  595.  
  596.  
  597.     int year = 0;
  598.     int month = 0;
  599.     int day = 0;
  600.     int hour = 0;
  601.     int minute = 0;
  602.     int second = 0;
  603.     int baud = 0;
  604.     int y = 0;
  605.     int x = 0;
  606.  
  607.     sprintf(address, "%d/%d", to_net, to_node);
  608.  
  609.     stream = fopen(fileopen, "wb");
  610.     if (stream == NULL) {
  611.         output("\r\nFile error...");
  612.         pressanykey();
  613.         return 0;
  614.     }
  615.     if (strlen(textfile) != 0) {
  616.         stream2 = fopen(textfile, "rb");
  617.         if (stream2 == NULL) existtext = 0;
  618.         else existtext = 1;
  619.     }
  620.  
  621.     putw(from_node, stream);
  622.     putw(to_node, stream);
  623.     time(&secs_now);
  624.     str_now = ctime(&secs_now);
  625.     sscanf(str_now, "%*3s %*3s %*2s %*8s %d", &year);
  626.     tm_now = localtime(&secs_now);
  627.     month = tm_now->tm_mon;
  628.     day = tm_now->tm_mday;
  629.     hour = tm_now->tm_hour;
  630.     minute = tm_now->tm_min;
  631.     second = tm_now->tm_sec;
  632.     putw(year, stream);
  633.     putw(month, stream);
  634.     putw(day, stream);
  635.     putw(hour, stream);
  636.     putw(minute, stream);
  637.     putw(second, stream);
  638.     putw(baud, stream);
  639.     putw(2, stream);
  640.     putw(from_net, stream);
  641.     putw(to_net, stream);
  642.     putc(0x2E, stream);
  643.     for (x = 0; x < 33; x++) {
  644.         putc('\0', stream);
  645.     }
  646.     putw((int) 0x0002, stream);
  647.     putw(from_node, stream);
  648.     putw(to_node, stream);
  649.     putw(from_net, stream);
  650.     putw(to_net, stream);
  651.     putw(attrib, stream);  /*  Attrib  */
  652.     putw((int) 0x0000, stream);  /*  Cost  */
  653.     get_date(date_time);
  654.     fputs(date_time, stream);
  655.     putc('\0', stream);
  656.     fputs(to, stream);
  657.     putc('\0', stream);
  658.     fputs(from, stream);
  659.     putc('\0', stream);
  660.     if (attrib & 16) {   /*  if file attach store only name/ext   */
  661.         fnsplit(subject, drive, dir, filefoo, ext);
  662.         fputs(filefoo, stream);
  663.         fputs(ext, stream);
  664.     }
  665.     else fputs(subject, stream);
  666.     putc('\0', stream);
  667.  
  668.     for (x = 0; x < start; x++) {
  669.         for (y = 0; y < strlen(text[x]); y++) {
  670.             putc(text[x][y], stream);
  671.         }
  672.         if (text[x][strlen(text[x]) - 1] != 0x0A) {
  673.             putc(0x20, stream);
  674.             putc(0x8D, stream);
  675.         }
  676.     }
  677.  
  678.     if (existtext) {
  679.         while (! feof(stream2)) {
  680.             ch = fgetc(stream2);
  681.             if (ch > 0x1F || ch == 0x0A || ch == 0x0D) putc(ch, stream);
  682.         }
  683.         fclose(stream2);
  684.     }
  685.  
  686.     if (tearline) fprintf(stream, "\r\n\r\n--- AMAX %s\r\n * Origin: %s", VERSION, sysname);
  687.  
  688.     fprintf(stream, "\r\n");
  689.     putc('\0', stream);
  690.     putw(0x00, stream);
  691.     fclose(stream);
  692.  
  693.  
  694.     if (attrib & 16) file(subject, address, route_type);
  695.  
  696.     return 1;
  697.  
  698.  
  699. }
  700.  
  701.  
  702.  
  703. void get_date(char *date_time)
  704. {
  705.     long secs, time();
  706.     char *now;
  707.     char day[3], mon[4], tme[9], year[3];
  708.  
  709.     time(&secs);
  710.     now = (char *) ctime(&secs);
  711.     sscanf(now, "%*3s %3s %2s %8s %*2s%2s", mon, day, tme, year);
  712.     sprintf(date_time, "%2s %3s %2s  %8s\0", day, mon, year, tme);
  713. }
  714.  
  715.  
  716. /*
  717.  
  718. char *find_sysop(char *instring)
  719. {
  720.     char fileopen[100];
  721.     char filename[20] = "fidouser.lst";
  722.     char eolarea[3];
  723.     char line[100];
  724.     char last[100];
  725.     char first[100];
  726.     char nodestring[50];
  727.     char ch;
  728.     char *portion;
  729.     char part[50];
  730.  
  731.     FILE *stream;
  732.  
  733.  /*   strcpy(nodestring, " ");
  734.     strcat(nodestring, instring);
  735.     strcat(nodestring, " ");
  736.                                  */
  737.  
  738.     strcpy(nodestring, instring);
  739.  
  740.  
  741.  
  742.     strcpy(fileopen, nodelist);
  743.     strcat(fileopen, filename);
  744.     
  745.     stream = fopen(fileopen, "rb");
  746.     if (stream == NULL) {
  747.         stream = fopen(filename, "rb");
  748.     }
  749.     if (stream) {
  750.         while (! feof(stream)) {
  751.             if (kbhit()) break;
  752.             fgetln(line, sizeof(line), eolarea, stream);
  753.  
  754.             portion = (char *) strstr(line, nodestring);
  755.             if (portion) {
  756.  
  757.                 strcpy(part, portion - 1);
  758.                 if ((part[0] >= 48 && part[0] <= 57) || (part[strlen(nodestring)+1] >= 48 && part[strlen(nodestring)+1] <= 57)) continue;
  759.  
  760.                 sscanf(line, "%s %s", last, first);
  761.                 last[strlen(last) - 1] = 0x00;
  762.                 strcpy(line, first);
  763.                 strcat(line, " ");
  764.                 strcat(line, last);
  765.                 fclose(stream);
  766.                 return line;
  767.             }
  768.         }
  769.         fclose(stream);
  770.         if (kbhit()) getch();
  771.         return NULL;
  772.     }
  773.     return NULL;
  774. }
  775.  
  776. */
  777.