home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / snews-20.zip / DEFS.H < prev    next >
C/C++ Source or Header  |  1992-08-02  |  6KB  |  194 lines

  1. /*
  2.     SNEWS 2.0
  3.  
  4.     General public decls
  5.  
  6.  
  7.     Copyright (C) 1991  John McCombs, Christchurch, NEW ZEALAND
  8.                         john@ahuriri.gen.nz
  9.                         PO Box 2708, Christchurch, NEW ZEALAND
  10.  
  11.     This program is free software; you can redistribute it and/or modify
  12.     it under the terms of the GNU General Public License, version 1, as
  13.     published by the Free Software Foundation.
  14.  
  15.     This program is distributed in the hope that it will be useful,
  16.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.     GNU General Public License for more details.
  19.  
  20.     See the file COPYING, which contains a copy of the GNU General
  21.     Public License.
  22.  
  23.  */
  24.  
  25. #include <malloc.h>
  26. #include <time.h>
  27. #include <string.h>
  28. #include <conio.h>
  29. #include <dos.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <io.h>
  34. #include <sys/types.h>
  35. #include <sys/stat.h>
  36. #include <direct.h>
  37.  
  38. #include "os2defs.h"
  39.  
  40.  
  41. #define VERSION      "SNEWS /2 2.0"
  42. #define COPYRIGHT    "(c) 1991 John McCombs, (c) 1992 Kai Uwe Rommel"
  43.  
  44.  
  45. #define HIST_MEM_LIMIT  75000l  /* leave this much meme free loading history */
  46.  
  47. #define ACTIVE_NUM_LEN   8      /* length of the numbers in the active file */
  48.  
  49. #define TRUE     1
  50. #define FALSE    0
  51.  
  52. #define IOBUFSIZE 32000
  53. extern char iobuf[IOBUFSIZE];
  54.  
  55.  
  56. /* this is the data we get from the UUPC .rc files */
  57. typedef struct {
  58.     char temp_name[256];           /* unbatch temp file             */
  59.     char news_dir[256];            /* news base directory           */
  60.     char incoming_dir[256];        /* incoming news spool directory */
  61.     char spool_dir[256];           /* spool directory, log files    */
  62.     char user[256];                /* current user id               */
  63.     char my_name[256];             /* my full name                  */
  64.     char my_domain[256];           /* our domain                    */
  65.     char my_site[256];             /* site name                     */
  66.     char my_organisation[256];     /* organisation                  */
  67.     char mail_server[256];         /* where posts are routed to     */
  68.     char editor[256];              /* system editor                 */
  69.     char home[256];                /* home mail directory           */
  70.     char signature[256];           /* signature file                */
  71. } INFO;
  72.  
  73.  
  74. extern INFO my_stuff;
  75.  
  76.  
  77. /*
  78.  *  This structure is a linked list of lines that make up an article. The
  79.  *  file is read in and the linked list is built
  80.  */
  81. typedef struct line {
  82.     char   *data;               /* line of text                */
  83.     struct line *next;          /* next line                   */
  84.     struct line *last;          /* last line                   */
  85.     int    index;               /* line number from start      */
  86. } LINE;
  87.  
  88.  
  89.  
  90. /* NOTE - if hi_num and lo_num are the same there are no articles */
  91. typedef struct active {
  92.     char   group[60];           /* group name                               */
  93.     char   gp_file[60];         /* name of the file that the data is in     */
  94.     long   lo_num;              /* lowest number less one                   */
  95.     long   hi_num;              /* highest number                           */
  96.     long   num_pos;             /* file offset of the numbers               */
  97.     struct active *next;        /* next entry                               */
  98.     struct active *last;        /* last entry                               */
  99.     int    index;               /* which number in the list, from 0         */
  100.     char   *read_list;          /* array hi_num-lo_num long. TRUE=read it   */
  101.     int    groups;              /* filled in by load_active_file() in head  */
  102.     int    threads;             /* filled in by get_headers()               */
  103. } ACTIVE;
  104.  
  105.  
  106.  
  107. /*
  108.  *  This singly linked list is used to store the names of the groups
  109.  *  we can post to.
  110.  */
  111. typedef struct post_groups {
  112.     char   group[60];           /* group name                               */
  113.     int    local;               /* local news group                         */
  114.     struct post_groups *next;   /* next entry                               */
  115. } POST_GROUPS;
  116.  
  117.  
  118.  
  119. /*
  120.  *  READ LIST:
  121.  *      The list of articles which has been seen by a user is kept in an
  122.  *      ascii file, which has a newsgroup name followed by the list
  123.  *      of article numbers which have been seen.
  124.  *
  125.  *      The file is read by 'load_read_list', which allocates and array of
  126.  *      flags, one per article, and plugs these into the ACTIVE structure.
  127.  *      The flags are set to TRUE when a user has seen an article.
  128.  *
  129.  *      On shutdown a new 'user.nrc' file is written
  130.  */
  131.  
  132.  
  133.  
  134.  
  135. /*
  136.  *  This structure is an index to the history file.  'mid' is a 32bit hash
  137.  *  of the message id.  'offset' is the offset into the history file, and
  138.  *  'next' makes the linked list
  139.  */
  140. typedef struct hist_list {
  141.     long mid;
  142.     long offset;
  143.     struct hist_list *next;
  144. } HIST_LIST;
  145.  
  146.  
  147. /*
  148.  *  This linked list is returned by 'look_up_history'.  It is a list
  149.  *  of the groups to which an article has been crossposted.  It does
  150.  *  not include self
  151.  */
  152. typedef struct cross_posts {
  153.     char   group[60];            /* group name                               */
  154.     long   art_num;              /* article number in this group             */
  155.     struct cross_posts *next;    /* next entry                               */
  156. } CROSS_POSTS;
  157.  
  158.  
  159.  
  160.  
  161.  
  162. ACTIVE *load_active_file(void);
  163. void close_active_file(void);
  164. void close_active(void);
  165. ACTIVE *find_news_group(char *group);
  166. void update_active_entry(ACTIVE *a);
  167. char *make_news_group_name(char *ng);
  168.  
  169. void save_read_list(void);
  170. void load_read_list(void);
  171.  
  172. int load_stuff(void);
  173.  
  174. FILE *open_out_file(char *ng);
  175. FILE *open_index_file(char *ng);
  176.  
  177. int post_sequence(void);
  178.  
  179. void *xmalloc(size_t size);
  180.  
  181. int check_valid_post_group(char *ng);
  182.  
  183. void free_ng(void);
  184.  
  185. FILE *open_hist_file(void);
  186. void close_hist_file(void);
  187. void add_hist_record(char *msg_id, char *ng);
  188.  
  189. HIST_LIST *load_history_list(void);
  190. void free_hist_list(void);
  191. HIST_LIST *find_msg_id(char *msg_id);
  192. CROSS_POSTS *look_up_history(char *msg_id, char *ng);
  193. void free_cross_post_list(CROSS_POSTS *cx);
  194.