1 /* head.h 2 */ 3 /* This software is copyrighted as detailed in the LICENSE file. */ 4 5 6 #define HEAD_FIRST SOME_LINE 7 8 /* types of header lines (if only C really believed in enums) 9 * (These must stay in alphabetic order at least in the first letter. 10 * Within each letter it helps to arrange in increasing likelihood.) 11 */ 12 13 #define PAST_HEADER 0 /* body */ 14 #define SHOWN_LINE (PAST_HEADER+1) /* unrecognized but shown */ 15 #define HIDDEN_LINE (SHOWN_LINE+1) /* unrecognized but hidden */ 16 #define CUSTOM_LINE (HIDDEN_LINE+1) /* to isolate a custom line */ 17 #define SOME_LINE (CUSTOM_LINE+1) /* default for unrecognized */ 18 #define AUTHOR_LINE (SOME_LINE+1) /* Author */ 19 #define BYTES_LINE (AUTHOR_LINE+1) /* Bytes */ 20 #define CONTNAME_LINE (BYTES_LINE+1) /* Content-Name */ 21 #define CONTDISP_LINE (CONTNAME_LINE+1) /* Content-Disposition */ 22 #define CONTLEN_LINE (CONTDISP_LINE+1) /* Content-Length */ 23 #define CONTXFER_LINE (CONTLEN_LINE+1) /* Content-Transfer-Encoding */ 24 #define CONTTYPE_LINE (CONTXFER_LINE+1) /* Content-Type */ 25 #define DIST_LINE (CONTTYPE_LINE+1) /* distribution */ 26 #define DATE_LINE (DIST_LINE+1) /* date */ 27 #define EXPIR_LINE (DATE_LINE+1) /* expires */ 28 #define FOLLOW_LINE (EXPIR_LINE+1) /* followup-to */ 29 #define FROM_LINE (FOLLOW_LINE+1) /* from */ 30 #define INREPLY_LINE (FROM_LINE+1) /* in-reply-to */ 31 #define KEYW_LINE (INREPLY_LINE+1) /* keywords */ 32 #define LINES_LINE (KEYW_LINE+1) /* lines */ 33 #define MIMEVER_LINE (LINES_LINE+1) /* mime-version */ 34 #define MSGID_LINE (MIMEVER_LINE+1) /* message-id */ 35 #define NGS_LINE (MSGID_LINE+1) /* newsgroups */ 36 #define PATH_LINE (NGS_LINE+1) /* path */ 37 #define RVER_LINE (PATH_LINE+1) /* relay-version */ 38 #define REPLY_LINE (RVER_LINE+1) /* reply-to */ 39 #define REFS_LINE (REPLY_LINE+1) /* references */ 40 #define SUMRY_LINE (REFS_LINE+1) /* summary */ 41 #define SUBJ_LINE (SUMRY_LINE+1) /* subject */ 42 #define XREF_LINE (SUBJ_LINE+1) /* xref */ 43 #define HEAD_LAST (XREF_LINE+1) /* total # of headers */ 44 45 struct headtype { 46 char* name; /* header line identifier */ 47 ART_POS minpos; /* pointer to beginning of line in article */ 48 ART_POS maxpos; /* pointer to end of line in article */ 49 char length; /* the header's string length */ 50 char flags; /* the header's flags */ 51 }; 52 53 struct user_headtype { 54 char* name; /* user-defined headers */ 55 char length; /* the header's string length */ 56 char flags; /* the header's flags */ 57 }; 58 59 #define HT_HIDE 0x01 /* hide this line */ 60 #define HT_MAGIC 0x02 /* do any special processing on this line */ 61 #define HT_CACHED 0x04 /* this information is cached article data */ 62 #define HT_DEFHIDE 0x08 /* hidden by default */ 63 #define HT_DEFMAGIC 0x10 /* magic by default */ 64 #define HT_MAGICOK 0x20 /* magic even possible for line */ 65 66 /* This array must stay in the same order as the list above */ 67 68 #ifndef DOINIT 69 EXT struct headtype htype[HEAD_LAST]; 70 #else 71 72 #define HIDDEN (HT_HIDE|HT_DEFHIDE) 73 #define MAGIC_ON (HT_MAGICOK|HT_MAGIC|HT_DEFMAGIC) 74 #define MAGIC_OFF (HT_MAGICOK) 75 76 #ifdef DBM_XREFS 77 #define XREF_CACHED 0 78 #define NGS_CACHED HT_CACHED 79 #else 80 #define XREF_CACHED HT_CACHED 81 #define NGS_CACHED 0 82 #endif 83 #ifdef USE_FILTER 84 #define FILT_CACHED HT_CACHED 85 #else 86 #define FILT_CACHED 0 87 #endif 88 89 struct headtype htype[HEAD_LAST] = { 90 /* name minpos maxpos length flag */ 91 {nullstr,/*BODY*/ 0, 0, 0, 0 }, 92 {nullstr,/*SHOWN*/ 0, 0, 0, 0 }, 93 {nullstr,/*HIDDEN*/ 0, 0, 0, HIDDEN }, 94 {nullstr,/*CUSTOM*/ 0, 0, 0, 0 }, 95 {"unrecognized", 0, 0, 12, HIDDEN }, 96 {"author", 0, 0, 6, 0 }, 97 {"bytes", 0, 0, 5, HIDDEN|HT_CACHED}, 98 {"content-name", 0, 0, 12, HIDDEN }, 99 {"content-disposition", 100 0, 0, 19, HIDDEN }, 101 {"content-length", 0, 0, 14, HIDDEN }, 102 {"content-transfer-encoding", 103 0, 0, 25, HIDDEN }, 104 {"content-type", 0, 0, 12, HIDDEN }, 105 {"distribution", 0, 0, 12, 0 }, 106 {"date", 0, 0, 4, MAGIC_ON }, 107 {"expires", 0, 0, 7, HIDDEN|MAGIC_ON }, 108 {"followup-to", 0, 0, 11, 0 }, 109 {"from", 0, 0, 4, MAGIC_OFF|HT_CACHED}, 110 {"in-reply-to", 0, 0, 11, HIDDEN }, 111 {"keywords", 0, 0, 8, 0 }, 112 {"lines", 0, 0, 5, HT_CACHED }, 113 {"mime-version", 0, 0, 12, MAGIC_ON|HIDDEN }, 114 {"message-id", 0, 0, 10, HIDDEN|HT_CACHED}, 115 {"newsgroups", 0, 0, 10, MAGIC_ON|HIDDEN|NGS_CACHED}, 116 {"path", 0, 0, 4, HIDDEN }, 117 {"relay-version", 0, 0, 13, HIDDEN }, 118 {"reply-to", 0, 0, 8, 0 }, 119 {"references", 0, 0, 10, HIDDEN|FILT_CACHED}, 120 {"summary", 0, 0, 7, 0 }, 121 {"subject", 0, 0, 7, MAGIC_ON|HT_CACHED}, 122 {"xref", 0, 0, 4, HIDDEN|XREF_CACHED}, 123 }; 124 125 #undef HIDDEN 126 #undef MAGIC_ON 127 #undef MAGIC_OFF 128 #undef NGS_CACHED 129 #undef XREF_CACHED 130 131 #endif 132 133 EXT struct user_headtype* user_htype INIT(NULL); 134 EXT short user_htypeix[26]; 135 EXT int user_htype_cnt INIT(0); 136 EXT int user_htype_max INIT(0); 137 138 EXT ART_NUM parsed_art INIT(0); /* the article number we've parsed */ 139 EXT ARTICLE* parsed_artp INIT(NULL); /* the article ptr we've parsed */ 140 EXT int in_header INIT(0); /* are we decoding the header? */ 141 EXT char* headbuf; 142 EXT long headbuf_size; 143 144 #define PREFETCH_SIZE 5 145 146 #define fetchsubj(artnum,copy) prefetchlines(artnum,SUBJ_LINE,copy) 147 #define fetchfrom(artnum,copy) prefetchlines(artnum,FROM_LINE,copy) 148 #ifdef DBM_XREFS 149 #define fetchxref(artnum,copy) prefetchlines(artnum,NGS_LINE,copy) 150 #else 151 #define fetchxref(artnum,copy) prefetchlines(artnum,XREF_LINE,copy) 152 #endif 153 154 /* DON'T EDIT BELOW THIS LINE OR YOUR CHANGES WILL BE LOST! */ 155 156 void head_init _((void)); 157 #ifdef DEBUG 158 void dumpheader _((char*)); 159 #endif 160 int set_line_type _((char*,char*)); 161 int get_header_num _((char*)); 162 void start_header _((ART_NUM)); 163 void end_header_line _((void)); 164 bool parseline _((char*,int,int)); 165 void end_header _((void)); 166 bool parseheader _((ART_NUM)); 167 char* fetchlines _((ART_NUM,int)); 168 #ifdef SCAN 169 char* mp_fetchlines _((ART_NUM,int,int)); 170 #endif 171 char* prefetchlines _((ART_NUM,int,bool_int)); 172