1 /* 2 * binkleyforce -- unix FTN mailer project 3 * 4 * Copyright (c) 1998-2000 Alexander Belkin, 2:5020/1398.11 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * $Id: nodelist.h,v 1.1.1.1 2004/09/09 09:52:40 kstepanenkov Exp $ 12 */ 13 14 #ifndef _NODELIST_H_ 15 #define _NODELIST_H_ 16 17 /* 18 * Each nodelist has corresponding index file. Index file name is the 19 * same as nodelist, but extension is changed to the ".bni", so index 20 * file to the nodelist "net5020.ndl" will be called "net5020.bni" 21 * 22 * Nodelist index header: 23 * 24 * Offset Size Description 25 * ------------------------------- 26 * 0x0000 4 bytes Nodelist file date 27 * 0x0004 4 bytes Nodelist file size 28 * 0x0008 4 bytes Total number of entries in index file 29 * 0x000c 4 bytes Unused 30 * 31 * Nodelist index is an array of next entries: 32 * 33 * Offset Size Description 34 * ------------------------------- 35 * 0x0010 2 bytes Zone number 36 * 0x0012 2 bytes Net number 37 * 0x0014 2 bytes Node number 38 * 0x0016 2 bytes Point number 39 * 0x0018 2 bytes HUB number (I hope HUB is in the same zone:net) 40 * 0x001a 4 bytes Offset of string in nodelist file 41 * 42 */ 43 44 enum 45 { 46 NODELIST_HDRSIZE = 16, /* Don't change! */ 47 NODELIST_ENTRYSIZE = 14, /* Don't change! */ 48 NODELIST_READAHEAD = 50 49 }; 50 51 /* 52 * Modes for nodelist_opendindex() 53 */ 54 enum nodelist_iomode 55 { 56 NODELIST_READ, 57 NODELIST_WRITE 58 }; 59 60 /* 61 * Positions of <...> in nodelist strings 62 */ 63 enum nodelist_positon 64 { 65 NODELIST_POSKEYWORD = 0, 66 NODELIST_POSNUMBER = 1, 67 NODELIST_POSNAME = 2, 68 NODELIST_POSLOCATION = 3, 69 NODELIST_POSSYSOP = 4, 70 NODELIST_POSPHONE = 5, 71 NODELIST_POSSPEED = 6, 72 NODELIST_POSFLAGS = 7 73 }; 74 75 /* 76 * Storage sizes for node structure 77 */ 78 enum nodelist_limit 79 { 80 BNI_MAXNAME = 48, 81 BNI_MAXLOCATION = 48, 82 BNI_MAXSYSOP = 48, 83 BNI_MAXPHONE = 48, 84 BNI_MAXFLAGS = 120 85 }; 86 87 /* 88 * node->keyword values 89 */ 90 enum nodelist_keyword 91 { 92 KEYWORD_EMPTY, 93 KEYWORD_ZONE, 94 KEYWORD_REGION, 95 KEYWORD_HOST, 96 KEYWORD_HUB, 97 KEYWORD_PVT, 98 KEYWORD_HOLD, 99 KEYWORD_DOWN, 100 KEYWORD_BOSS, 101 KEYWORD_POINT 102 }; 103 104 /* 105 * Nodelist procedures error codes 106 */ 107 enum nodelist_error 108 { 109 BNIERR_NOERROR = 0, 110 BNIERR_NODENOTFOUND = 1, 111 BNIERR_IDXIOERR = 2, 112 BNIERR_NDLIOERR = 3, 113 BNIERR_BADINDEX = 4, 114 BNIERR_NONODELIST = 5 115 }; 116 117 typedef struct nodelist 118 { 119 FILE *fp_index; 120 FILE *fp_nodelist; 121 char name_index[BF_MAXPATH+1]; 122 char name_nodelist[BF_MAXPATH+1]; 123 long entries; 124 } 125 s_nodelist; 126 127 typedef struct bni 128 { 129 int zone; 130 int net; 131 int node; 132 int point; 133 int hub; 134 long offset; 135 } 136 s_bni; 137 138 typedef struct node 139 { 140 s_faddr addr; 141 s_faddr addr_hub; 142 enum nodelist_keyword keyword; 143 bool listed; 144 char name[BNI_MAXNAME+1]; 145 char location[BNI_MAXLOCATION+1]; 146 char sysop[BNI_MAXSYSOP+1]; 147 char phone[BNI_MAXPHONE+1]; 148 long speed; 149 char flags[BNI_MAXFLAGS+1]; 150 s_timevec worktime; 151 } 152 s_node; 153 154 int nodelist_checkflag(const char *nodeflags, const char *flag); 155 int nodelist_keywordval(const char *keyword); 156 int nodelist_parsestring(s_node *node, char *str); 157 s_nodelist *nodelist_open(const char *dir, const char *name, int mode); 158 int nodelist_checkheader(s_nodelist *nlp); 159 int nodelist_createheader(s_nodelist *nlp); 160 int nodelist_close(s_nodelist *nlp); 161 int nodelist_putindex(s_nodelist *nlp, const s_bni *bni); 162 int nodelist_findindex(s_nodelist *nlp, s_bni *bni, s_faddr addr); 163 int nodelist_getstr(s_nodelist *nlp, size_t offset, char *buffer, size_t buflen); 164 int nodelist_lookup_string(char *buffer, size_t buflen, s_faddr addr); 165 int nodelist_lookup(s_node *node, s_faddr addr); 166 void nodelist_initnode(s_node *node, s_faddr addr); 167 168 #endif /* _NODELIST_H_ */ 169