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