home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / VP2_409E.SZH / LOOK_UP.C < prev    next >
Text File  |  1991-06-27  |  6KB  |  204 lines

  1. /*
  2.   $Header: look_up.c 3.3 87/12/12 00:43:14 Bob Exp $
  3.  
  4.                           The Conference Mail System
  5.  
  6.               This module was originally written by Bob Hartman
  7.                        Sysop of FidoNet node 1:132/101
  8.  
  9.    Spark Software, 427-3 Amherst St, CS 2032, Suite 232, Nashua, NH 03061
  10.  
  11.  The Conference Mail System  is a  complete Echomail processing package.  It
  12.  is a superset of the original  Echomail utilities created by Jeff Rush, and
  13.  also contains ideas gleaned from the  ARCmail,  Renum,  oMMM, MGM, and Opus
  14.  programs that were created by various software authors.
  15.  
  16.  This program source code is being released with the following provisions:
  17.  
  18.  1.  You are  free to make  changes to this source  code for use on your own
  19.  machine,  however,  altered source files may not be distributed without the
  20.  consent of Spark Software.
  21.  
  22.  2.  You may distribute "patches"  or  "diff" files for any changes that you
  23.  have made, provided that the "patch" or "diff" files are also sent to Spark
  24.  Software for inclusion in future releases of the entire package.   A "diff"
  25.  file for the source archives may also contain a compiled version,  provided
  26.  it is  clearly marked as not  being created  from the original source code.
  27.  No other  executable  versions may be  distributed without  the  consent of
  28.  Spark Software.
  29.  
  30.  3.  You are free to include portions of this source code in any program you
  31.  develop, providing:  a) Credit is given to Spark Software for any code that
  32.  may is used, and  b) The resulting program is free to anyone wanting to use
  33.  it, including commercial and government users.
  34.  
  35.  4.  There is  NO  technical support  available for dealing with this source
  36.  code, or the accompanying executable files.  This source  code  is provided
  37.  as is, with no warranty expressed or implied (I hate legalease).   In other
  38.  words, if you don't know what to do with it,  don't use it,  and if you are
  39.  brave enough to use it, you're on your own.
  40.  
  41.  Spark Software may be contacted by modem at (603) 888-8179 (node 1:132/101)
  42.  on the public FidoNet network, or at the address given above.
  43.  
  44.  To use this code you will need Microsoft C version 4.0, and also Microsoft
  45.  Macro Assembler version 4.0.
  46.  
  47. */
  48.  
  49. /*
  50.    $Log:    look_up.c $
  51.  * Revision 3.3  87/12/12  00:43:14  Bob
  52.  * Source code release
  53.  *
  54. */
  55.  
  56. #include <stdio.h>
  57. #include <ctype.h>
  58. #include <fcntl.h>
  59. #include <io.h>
  60. #include <string.h>
  61. #include <time.h>
  62. #include "fastecho.h"
  63.  
  64. #define DEBUG 0
  65.  
  66. extern SEACONFIG config;
  67. extern AREAS_PTR areas[];
  68. extern char board_name[], sysop_name[];
  69. extern int tot_areas;
  70. extern char bbsfile[];
  71. extern char *arc_cmd[];
  72. extern int nread;
  73. extern int arc_args;
  74. extern int last_msg;
  75. extern int high_one;
  76. extern int convert;
  77. extern char seen_byline[];
  78. extern char originline[];
  79. extern char tearline[];
  80. extern int max_msgs;
  81. extern int ctrla;
  82. extern int *msg_nums;
  83. extern char *holder1;
  84. extern int mail_low;
  85. extern int mail_high;
  86. extern char *seen_by;
  87. extern char *origin;
  88. extern char *tear;
  89. extern char *holder;
  90. extern int tearl;
  91. extern int originl;
  92. extern int seen_byl;
  93. extern int msgl;
  94. extern int seen_nets[];
  95. extern int seen_nodes[];
  96. extern int not_seen[];
  97. extern int tot_seen;
  98. extern char arealine[];
  99. extern int areal;
  100. extern MSG_PTR h;
  101. extern int msgs_done;
  102.  
  103. void find_seen(int totread)
  104. {
  105.     char *sb, *sb1;
  106.     char *realend;
  107.     int endline;
  108.  
  109.     sb = origin + originl;
  110.  
  111.     seen_by = origin;
  112.     seen_byl = 0;
  113.     realend = (char *) (holder1+totread-10);
  114.  
  115.     while (sb != NULL)
  116.         {
  117.         /* First find an 'S' */
  118.       endline = (int) (realend - sb);
  119.       if (endline <= 0)
  120.          break;
  121.  
  122.       sb = match_byte (sb, 'S', endline);
  123.  
  124.         /* If we are past the end of the message, then get out */
  125.         if (sb == NULL)
  126.             break;
  127.  
  128.         if (strncmp (sb, "SEEN-BY:", 8) != 0)
  129.             {
  130.             ++sb;
  131.             continue;
  132.             }
  133.  
  134.         /* Back up to the EOL chars */
  135.         sb1 = sb-1;
  136.  
  137.         while ((((*sb1 & 0x7f) == '\n') || ((*sb1 & 0x7f) == 1))
  138.             && (sb1 >= origin))
  139.             --sb1;
  140.  
  141.         if ((*sb1 & 0x7f) == '\r')
  142.             {
  143.             /* We found it! */
  144.             seen_by = sb1 + 1;
  145.  
  146.             seen_byl = strlen (seen_by);
  147.  
  148.             /* If there was no origin line then we have to alter the length
  149.                 of the message to take into account the seen-by's */
  150.             if (originl == 0)
  151.                 msgl = seen_by - holder;
  152.  
  153.             /* We found it, so get out */
  154.             break;
  155.             }
  156.         else
  157.             {
  158.             /* Jump past the SEEN-BY: */
  159.             sb += 10;
  160.             }
  161.         }
  162. }
  163.  
  164. void find_orig(int totread)
  165. {
  166.     char *sb;
  167.     char *sb1;
  168.     int endline;
  169.     char *realend;
  170.     extern char *match_byte();
  171.  
  172.     origin = holder;
  173.     originl = 0;
  174.     sb = sb1 = origin;
  175.     realend = holder1+totread-10;
  176.  
  177.     while (sb != NULL)
  178.     {
  179.       endline = (int) (realend - sb);
  180.       if (endline <= 0)
  181.          break;
  182.  
  183.       sb1 = match_byte (sb, '*', endline);
  184.       if (sb1 == NULL)
  185.          break;
  186.  
  187.         sb = sb1 + 1;
  188.         if (strncmp (sb, " Origin:", 8) != 0)
  189.             continue;
  190.  
  191.         if ((*(sb-2) != ' ') || ((*(sb-3) != '\r') && (*(sb-3) != '\n')))
  192.             continue;
  193.  
  194.         msgl = sb - 2 - holder;
  195.         origin = sb-2;
  196.  
  197.         while ((*sb != '\r') && (sb < (realend + 9)))
  198.             ++sb;
  199.         originl = sb - origin + 1;
  200.         break;
  201.     }
  202. }
  203.  
  204.