1 /******************************************************************** 2 * $Author: s2mdalle $ 3 * $Revision: 1.2 $ 4 * $Date: 2000/12/26 22:48:54 $ 5 * $Source: /home/jgoerzen/tmp/gopher-umn/gopher/head/object/GSgopherobj.h,v $ 6 * $State: Exp $ 7 * 8 * Paul Lindner, University of Minnesota CIS. 9 * 10 * Copyright 1991, 1992 by the Regents of the University of Minnesota 11 * see the file "Copyright" in the distribution for conditions of use. 12 ********************************************************************* 13 * MODULE: GSgopherobj.h 14 * Header file, abstraction of a gopher type 15 ********************************************************************* 16 * Revision History: 17 * $Log: GSgopherobj.h,v $ 18 * Revision 1.2 2000/12/26 22:48:54 s2mdalle 19 * Changed prototype for GSsendHeader(int, int) => GSsendHeader(int, long) 20 * 21 * Revision 1.1.1.1 2000/08/19 00:28:56 jgoerzen 22 * Import from UMN Gopher 2.3.1 after GPLization 23 * 24 * Revision 3.25 1995/11/03 18:01:08 lindner 25 * Coen: changes 26 * 27 * Revision 3.24 1995/09/25 22:07:18 lindner 28 * Ansification 29 * 30 * Revision 3.23 1995/06/12 15:34:17 lindner 31 * Add WORLD type to list of Gopher Objects 32 * 33 * Revision 3.22 1995/02/06 22:12:02 lindner 34 * Make GSsetAbstract a define 35 * 36 * Revision 3.21 1994/12/05 22:40:11 lindner 37 * add prototype for GSfromURL 38 * 39 * Revision 3.20 1994/11/17 06:34:00 lindner 40 * Fixes for VMS internationalization 41 * 42 * Revision 3.19 1994/10/24 22:15:54 lindner 43 * Add PDF type 44 * 45 * Revision 3.18 1994/08/19 16:18:14 lindner 46 * Bitty fix from Alan 47 * 48 * Revision 3.17 1994/07/21 22:25:06 lindner 49 * GINTERNATIONAL stuff 50 * 51 * Revision 3.16 1994/06/29 06:53:21 lindner 52 * ifdef GINTERNATIONAL, use a function instead of a macro for 53 * GSgetModDate(), so we can localize the date string 54 * 55 * Move GSfromURL() return code definitions from code so other 56 * files can call it. (Coopersmith) 57 * 58 * Revision 3.15 1994/06/29 05:45:57 lindner 59 * Mods to pump tickets to the net 60 * 61 * Revision 3.14 1994/04/01 04:38:08 lindner 62 * Fix for conditional macros 63 * 64 * Revision 3.13 1994/03/31 21:02:40 lindner 65 * Add some error and NULL checking to GS macros 66 * 67 * Revision 3.12 1993/12/27 16:22:43 lindner 68 * Added more prototypes for GS functions 69 * 70 * Revision 3.11 1993/11/02 06:15:27 lindner 71 * HTML additions 72 * 73 * Revision 3.10 1993/10/22 20:03:32 lindner 74 * Add Movie (;) and Info (i) type support 75 * 76 * Revision 3.9 1993/09/18 04:44:43 lindner 77 * Additions to fix caching of Multiple view items 78 * 79 * Revision 3.8 1993/09/11 06:33:06 lindner 80 * URL support 81 * 82 * Revision 3.7 1993/07/27 20:18:09 lindner 83 * Sorry can't take address of conditionals... 84 * 85 * Revision 3.6 1993/07/27 05:30:25 lindner 86 * Mondo Debug overhaul from Mitra 87 * 88 * Revision 3.5 1993/07/27 00:30:11 lindner 89 * plus patch from Mitra 90 * 91 * Revision 3.4 1993/07/23 04:50:59 lindner 92 * Additional stored askdata 93 * 94 * Revision 3.3 1993/04/15 17:55:18 lindner 95 * GSgetAdmin fix, plus more protos 96 * 97 * Revision 3.2 1993/03/24 17:09:42 lindner 98 * Additions for Localfile for each GopherObj 99 * 100 * Revision 3.1.1.1 1993/02/11 18:03:03 lindner 101 * Gopher+1.2beta release 102 * 103 * Revision 2.1 1993/02/09 22:47:54 lindner 104 * Added new def GSSfindBlock 105 * 106 * Revision 1.2 1993/01/31 00:31:12 lindner 107 * Gopher+ structures and macros. 108 * 109 * Revision 1.1 1992/12/10 23:27:52 lindner 110 * gopher 1.1 release 111 * 112 * 113 *********************************************************************/ 114 115 116 #ifndef GSGOPHEROBJ_H 117 #define GSGOPHEROBJ_H 118 119 #include "boolean.h" 120 #include "STRstring.h" 121 #include "STAarray.h" 122 123 typedef struct g_struct GopherObj; 124 #include "BLblock.h" 125 126 #include "VIews.h" 127 #include "url.h" 128 #include "Locale.h" 129 #include "compatible.h" 130 #include "fileio.h" 131 132 #define A_FILE '0' /* Types of objects */ 133 #define A_DIRECTORY '1' 134 #define A_CSO '2' 135 #define A_ERROR '3' 136 #define A_MACHEX '4' 137 #define A_PCBIN '5' 138 #define A_INDEX '7' 139 #define A_TELNET '8' 140 #define A_UNIXBIN '9' 141 #define A_SOUND 's' 142 #define A_EVENT 'e' 143 #define A_CALENDAR 'c' 144 #define A_GIF 'g' 145 #define A_HTML 'h' 146 #define A_TN3270 'T' 147 #define A_MIME 'M' 148 #define A_IMAGE 'I' 149 #define A_INFO 'i' 150 #define A_MOVIE ';' 151 #define A_PDF 'P' 152 #define A_WORLD 'v' 153 #define A_APP '!' 154 #define A_EOI '.' 155 156 157 /*** Formats for GStoNet() ***/ 158 #define GSFORM_G0 0 159 #define GSFORM_GPLUS 1 160 #define GSFORM_HTML 2 161 162 /*** Part codes for GSfromLink() & GSfromURL() ***/ 163 #define G_PATH 1 164 #define G_TYPE 2 165 #define G_NAME 4 166 #define G_PORT 8 167 #define G_HOST 16 168 #define G_ALL (G_PATH | G_TYPE | G_NAME | G_PORT | G_HOST) 169 170 typedef int GSformat; 171 172 /*** Our gopher+ attributes structure ***/ 173 174 struct gplus_struct 175 { 176 /** Abstract Block **/ 177 /* String *abstract; Superceeded by BlockArray */ 178 179 /** Admin Block **/ 180 String *Admin; 181 String *ModDate; 182 183 VIewArray *Views; 184 /** Others Blocks**/ 185 BlockArray *OtherBlocks; 186 187 /** Filled in askdata **/ 188 char **Askdata; 189 }; 190 191 typedef struct gplus_struct GplusObj; 192 193 /** Our Gopher Object Type **/ 194 195 struct g_struct 196 { 197 char sFileType; /* The type of object (A_FILE, A_CSO, etc)*/ 198 String *Title; /* User displayable title */ 199 String *Selstr; /* Selector string on host... */ 200 String *Host; /* Internet name of host */ 201 int iPort; /* Port number on host */ 202 int Itemnum; /* The number of the item in the directory*/ 203 int weight; /* The weight, expressed as a # from 0-1000 */ 204 int ttl; /* The Time-To-Live, how long the item is good */ 205 206 String *Localfile; /* The local file of the item */ 207 String *Localview; /* The view of the local file of the item */ 208 209 boolean isgplus; /* Item can be queried gopher+ style */ 210 boolean isask; /* Item contains an ASK block */ 211 GplusObj *gplus; /* Gopher + attributes */ 212 Url *url; /* The Unix^H^H^Hniversal Resource Locator */ 213 }; 214 215 216 typedef struct g_struct GopherStruct; 217 218 #define GSgetType(a) ((a)->sFileType) 219 #define GSsetType(a,b) (a)->sFileType=(b) 220 221 #define GSgetTitle(a) ((STRget((a)->Title))) 222 #define GSsetTitle(a,b) ((STRset((a)->Title, b))) 223 224 #define GSgetPath(a) ((STRget((a)->Selstr))) 225 #define GSsetPath(a,b) ((STRset((a)->Selstr, b))) 226 227 #define GSgetHost(a) ((STRget((a)->Host))) 228 #define GSsetHost(a,b) ((STRset((a)->Host, b))) 229 230 #define GSgetPort(a) ((a)->iPort) 231 #define GSsetPort(a,b) (a)->iPort=(b) 232 233 #define GSgetNum(a) ((a)->Itemnum) 234 #define GSsetNum(a,b) ((a)->Itemnum=(b)) 235 236 #define GSgetWeight(a) ((a)->weight) 237 #define GSsetWeight(a,b) ((a)->weight=(b)) 238 239 #define GSgetTTL(a) ((a)->ttl) 240 #define GSsetTTL(a,b) ((a)->ttl=(b)) 241 242 #define GSgetLocalFile(a) ((STRget((a)->Localfile))) 243 #define GSsetLocalFile(a,b) ((STRset((a)->Localfile, (b)))) 244 245 #define GSgetLocalView(a) ((STRget((a)->Localview))) 246 #define GSsetLocalView(a,b) ((STRset((a)->Localview, (b)))) 247 248 /****************** Gopher Plus attributes *******************/ 249 #define GSisGplus(a) ((a)->isgplus) 250 #define GSsetGplus(a,b) ((a)->isgplus=(b)) 251 252 #define GSisAsk(a) ((a)->isask) 253 #define GSsetAsk(a,b) ((a)->isask=(b)) 254 255 #define GSgplusInited(a) ((a)->gplus != NULL) 256 257 #define GSgetAdmin(a) (((a)->gplus == NULL) ? NULL : (STRget((a)->gplus->Admin))) 258 259 #if defined(VMS) || (defined(GINTERNATIONAL) && !defined(NO_STRFTIME)) 260 char *GSgetModDate(GopherObj *); 261 #else 262 # define GSgetModDate(a) (((a)->gplus == NULL) ? NULL : (((a)->gplus->ModDate == NULL) ? NULL : (STRget((a)->gplus->ModDate)))) 263 #endif 264 265 #define GSgetOtherBlocks(a) (BlockArray*)(((a)->gplus == NULL) ? NULL : ((a)->gplus->OtherBlocks)) 266 267 #define GSgetAskdata(a) (GSgplusInited(a) ? (a)->gplus->Askdata : NULL) 268 #define GSsetAbstract(g,b) (GSsetBlock(g,"ABSTRACT",b,TRUE)) 269 270 /*** Real live functions defined in GSgopherobj.c ***/ 271 272 GopherObj *GSnew(); 273 void GSdestroy(GopherObj *gs); 274 void GSinit(GopherObj *gs); 275 void GSplusnew(GopherObj *); 276 void GStoNet(GopherObj *gs, int sockfd, GSformat fmt, char *ticket); 277 void GStoNetHTML(); 278 int GSfromNet(GopherObj *gs, int sockfd); 279 int GSplusfromNet(GopherObj *gs, int fd); 280 int GSfromLink(GopherObj *, FileIO *, char*, int, char *, char*); 281 void GStoLink(GopherObj *gs, int fd, BOOLEAN AddInfo); 282 void GScpy(GopherObj *dest, GopherObj *orig); 283 void GScpy(); 284 void GSsetBlock(GopherObj *gs, char *blockname, char *text, boolean); 285 void GSsetURL(GopherObj *, char *url); 286 void GSsetAdmin(GopherObj *gs, char *admin); 287 void GSsetModDate(GopherObj *gs, char *str); 288 void GSaddView(GopherObj *gs, char *view, char *language, int estsize); 289 void GSaddBlock(GopherObj *gs, char *Blockname, char *file); 290 void GSmerge(GopherObj *gs, GopherObj *overlay); 291 void GSgetginfo(GopherObj *gs, boolean savename); 292 boolean GSisText(GopherObj *gs, char *view); 293 294 295 char *GSgetURL(GopherObj *gs, char *ticket); 296 char *GSgetURLhtml(GopherObj *gs, char *ticket); 297 298 299 struct tm *GSgetModDateTM(GopherObj *); 300 301 int GSgetNumViews(GopherObj *); 302 VIewobj *GSgetView(GopherObj *, int); 303 304 int GSgetNumBlocks(GopherObj *); 305 Blockobj *GSgetBlock(GopherObj *, int); 306 Blockobj *GSfindBlock(GopherObj *gs, char *blockname); 307 308 int GSfromURL(GopherObj *gs, char *urltxt, char *host, int port, int doneflags); 309 310 /****** Protocol transmission functions *******/ 311 int GSconnect(GopherObj*); 312 void GStransmit(GopherObj *gs, int sockfd, char *search, char *, char *); 313 void GSsendHeader(int, long); 314 void GSsendErrorHeader(GopherObj *gs, int sockfd, int errortype, char *); 315 int GSrecvHeader(GopherObj *gs, int sockfd); 316 void GStransmit(); 317 318 /******Gopher+ functions *******/ 319 void GSplusnew(); 320 void GSplusdestroy(GopherObj*); 321 void GSplusInit(GopherObj*); 322 void GSplustoNet(GopherObj *gs, int sockfd, char **filter, char *ticket); 323 void GSpluscpy(GopherObj *dest, GopherObj *orig); 324 325 326 char **GSsetAskdata(GopherObj *gs, char **askdata); 327 328 /***** Debugging functions *******/ 329 void GSplusPrint(GopherObj *gs, char *head); 330 331 #endif /*GSGOPHEROBJ_H*/ 332 333