home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume22 / nn6.4 / part15 / data.h next >
Encoding:
C/C++ Source or Header  |  1990-06-07  |  6.4 KB  |  195 lines

  1. /*
  2.  *    (c) Copyright 1990, Kim Fabricius Storm.  All rights reserved.
  3.  *
  4.  *    Internal representation of the master, group, and article
  5.  *    information read from the database.
  6.  *
  7.  *    For each article read from the database, an article_header
  8.  *    structure is initialized.
  9.  */
  10.  
  11. /*
  12.  *    The magic number allows us to change the format of the database
  13.  *    and tell the users about it
  14.  */
  15.  
  16. #define NNDB_MAGIC    0x4e4e2302    /* NN#2 */
  17.  
  18. /*
  19.  *    global master data
  20.  */
  21.  
  22. #define    DB_LOCK_MESSAGE        80
  23.  
  24. typedef struct {
  25.     int32        db_magic;
  26.     char        db_lock[DB_LOCK_MESSAGE];
  27.     time_t        db_created; /* when database was last built */
  28.     time_t        last_scan; /* age of active file at last scan */
  29.     off_t        last_size; /* size of active file at last scan */
  30.     group_number    number_of_groups;
  31.     int            free_groups;
  32. } master_header;
  33.  
  34. /*
  35.  *    group information
  36.  */
  37.  
  38. typedef struct group_header {
  39.  
  40.     /* this part of the header is read from the MASTER file */
  41.  
  42.     flag_type        master_flag;    /* master's flags */
  43.  
  44. #    define M_VALID        FLAG(1)    /* group present in active file */
  45. #    define M_CONTROL    FLAG(2)    /* group is control group */
  46. #    define M_NO_DIRECTORY    FLAG(3)    /* group directory not found */
  47. #    define M_ALWAYS_DIGEST    FLAG(4)    /* D in GROUPS */
  48. #    define M_NEVER_DIGEST    FLAG(5)    /* N in GROUPS */
  49. #    define M_EXPIRE        FLAG(6)    /* expire in progress or pending */
  50. #    define M_BLOCKED    FLAG(7)    /* don't trust this entry */
  51. #    define M_MUST_CLEAN    FLAG(8) /* group should be cleaned */
  52. #    define M_MODERATED    FLAG(9)    /* group is moderated */
  53. #    define M_ALIASED    FLAG(10) /* =xxx in active file */
  54. #    define M_NOPOST        FLAG(11) /* 'n' in active file */
  55. #    define M_AUTO_RECOLLECT    FLAG(12) /* R in GROUPS */
  56. #    define M_AUTO_ARCHIVE    FLAG(13) /* >file in GROUPS */
  57. #    define M_INCLUDE_OLD    FLAG(14) /* O in GROUPS */
  58. #    define M_IGNORE_G    FLAG(15) /* ignore this group (GROUPS X) */
  59. #    define M_IGNORE_A    FLAG(16) /* ignore this group (ACTIVE x) */
  60. #    define M_IGNORE_GROUP    (M_IGNORE_G | M_IGNORE_A)
  61.  
  62.     article_number    first_db_article; /* min article in db */
  63.     article_number    last_db_article;  /* max article in db */
  64.  
  65.     article_number    first_a_article; /* min article in active */
  66.     article_number    last_a_article;  /* max article in active */
  67.  
  68.     off_t        index_write_offset;
  69.     off_t        data_write_offset;
  70.  
  71.     time_t        creation_time; /* when group was created */
  72.  
  73.     int            group_name_length;
  74.  
  75.     /* this part is initialized during reading of the GROUPS file */
  76.  
  77.     /* DO NOT CHANGE THE POSITION OF group_flag AS THE FIRST FIELD */
  78.     /* AFTER THE PART WHICH IS SAVED IN THE MASTER FILE */
  79.  
  80.     flag_type        group_flag;    /* client's flags */
  81.  
  82. #    define G_UNSUBSCRIBED    FLAG(1)    /* ! in .newsrc */
  83. #    define G_READ        FLAG(2)    /* group has been visited */
  84. #    define G_FAKED        FLAG(3)    /* faked group - not in .newsrc */
  85. #    define G_NEW        FLAG(5)    /* new group */
  86. #    define G_FOLDER        FLAG(6)    /* "group" is a folder file */
  87. #    define G_DIRECTORY    FLAG(7)    /* "group" is directory */
  88. #    define G_SEQUENCE    FLAG(8)    /* in presentation sequence */
  89. #    define G_DONE        FLAG(9)    /* sequence is done with group */
  90. #    define G_MAILBOX    FLAG(10) /* user's mail box file */
  91. #    define G_MERGE_HEAD    FLAG(11) /* merged group head */
  92. #    define G_MERGE_SUB    FLAG(12) /* merged group sub element */
  93. #    define G_MERGED     (G_MERGE_HEAD | G_MERGE_SUB)
  94. #    define G_COUNTED    FLAG(13) /* counted in unread_count */
  95.  
  96.     group_number    group_num;
  97.     group_number    preseq_index;
  98.  
  99.     char *        group_name;
  100.  
  101.     char *        archive_file;
  102.  
  103.     article_number    first_article;
  104.     article_number    last_article;
  105.  
  106.     article_number    current_first;    /* first article currently read in */
  107.  
  108.     struct group_header *next_group;    /* group sequence */
  109.     struct group_header    *prev_group;
  110.  
  111.     struct group_header    *merge_with;     /* merged groups */
  112.  
  113.     char        *kill_list;
  114.     char        *save_file;     /* default save file from init */
  115.     char        *enter_macro;
  116.  
  117.     struct group_header    *newsrc_seq;    /* .newsrc sequence        */
  118.     char        *newsrc_line;     /* .newsrc line for this group */
  119.     char        *newsrc_orig;     /* original newsrc_line if changed */
  120.     char        *select_line;    /* .nn/select line for this group */
  121.     char        *select_orig;    /* original select_line if changed */
  122.  
  123.     int32        unread_count;    /* number of unread articles */
  124. } group_header;
  125.  
  126.  
  127. /* size of the part of the group header placed on backing storage */
  128.  
  129.  
  130. #define SAVED_GROUP_HEADER_SIZE(group) \
  131.     (((char *)(&((group).group_flag))) - ((char *)(&(group))))
  132.  
  133. /*
  134.  *    Internal article header information.
  135.  */
  136.  
  137. typedef struct {
  138.     union {
  139.     article_number au_number;    /* article number in the group    */
  140.     char *au_string;
  141.     } au_union;
  142.     group_header *a_group;    /* if merged article menu    */
  143.  
  144.                 /* indexes to header line text    */
  145.     off_t    hpos;        /* first byte of header        */
  146.     off_t    fpos;        /* first byte in article text    */
  147.     off_t    lpos;        /* last pos of article        */
  148.  
  149.     time_stamp     t_stamp;    /* encoded time_stamp        */
  150.     time_stamp     root_t_stamp;    /* subject's time_stamp        */
  151.  
  152.     char *    sender;        /* sender's name        */
  153.     char *    subject;    /* subject (w/o Re:)        */
  154.  
  155.     int16    replies;    /* no of Re:            */
  156.     int16    lines;        /* no of lines        */
  157.  
  158.     int8    subj_length;    /* length of subject        */
  159.     int8    name_length;    /* length of sender        */
  160.  
  161.     attr_type    attr;        /* attributes:             */
  162.     attr_type    disp_attr;    /* currently displayed attr.    */
  163.     /* warning: notice relation between A_SELECT and A_AUTO_SELECT */
  164.  
  165. #    define A_READ        0x01    /* article has been read    */
  166. #    define A_SEEN        0x02    /* article presented on menu    */
  167. #    define A_LEAVE        0x03    /* marked for later activity    */
  168. #    define A_LEAVE_NEXT    0x04    /* marked for next invokation    */
  169. #    define A_CANCEL        0x05    /* folder entry cancelled    */
  170. #    define A_KILL        0x06    /* eliminate article        */
  171. #    define A_SELECT       0x08    /* article has been selected    */
  172. #    define A_AUTO_SELECT    0x09    /* will match & A_SELECT    */
  173.  
  174. #    define A_NOT_DISPLAYED    0x7f    /* not currently on menu    */
  175.  
  176.     flag_type    flag;        /* attributes and flags:    */
  177.  
  178. #    define A_SAME            FLAG(1)    /* same subject as prev. article */
  179. #    define A_ALMOST_SAME    FLAG(2)    /* A_SAME (match-limit)        */
  180. #    define A_NEXT_SAME    FLAG(4)    /* next is same subject        */
  181. #    define A_DIGEST       FLAG(5)    /* digest sub article        */
  182. #    define A_FULL_DIGEST    FLAG(6)    /* full digest            */
  183. #    define A_FOLDER        FLAG(7)    /* article file = "folder_path"    */
  184. #    define A_FAKED        FLAG(8)    /* only 'number' is valid    */
  185. #    define A_ST_FILED    FLAG(10) /* articles is saved        */
  186. #    define A_ST_REPLY    FLAG(11) /* sent reply to article    */
  187. #    define A_ST_FOLLOW    FLAG(12) /* sent followup to article    */
  188.  
  189. } article_header;
  190.  
  191.  
  192. #define    a_number    au_union.au_number
  193. #define a_string    au_union.au_string
  194.  
  195.