HTVMS_WaisProt.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. /* HTVMS_WAISProt.h
  2. *
  3. * Adaptation for Lynx by F.Macrides (macrides@sci.wfeb.edu)
  4. *
  5. * 31-May-1994 FM Initial version.
  6. *
  7. *----------------------------------------------------------------------*/
  8. /*
  9. * Routines originally from WProt.h -- FM
  10. *
  11. *----------------------------------------------------------------------*/
  12. /* WIDE AREA INFORMATION SERVER SOFTWARE:
  13. * No guarantees or restrictions. See the readme file for the full standard
  14. * disclaimer.
  15. *
  16. * 3.26.90 Harry Morris, morris@think.com
  17. * 3.30.90 Harry Morris
  18. * - removed chunk code from WAISSearchAPDU,
  19. * - added makeWAISQueryType1Query() and readWAISType1Query() which
  20. * replace makeWAISQueryTerms() and makeWAISQueryDocs().
  21. * 4.11.90 HWM - added definitions of wais element set names
  22. * 4.14.90 HWM - changed symbol for relevance feedback query from QT_3 to
  23. * QT_RelevanceFeedbackQuery added QT_TextRetrievalQuery as a
  24. * synonym for QT_BooleanQuery
  25. * - renamed makeWAISType1Query() to makeWAISTextQuery()
  26. * renamed readWAISType1Query() to readWAISTextQuery()
  27. * 5.29.90 TS - added CSTFreeWAISFoo functions
  28. */
  29. #ifndef _H_WAIS_protocol_
  30. #define _H_WAIS_protocol_
  31. #ifndef HTUTILS_H
  32. #include <HTUtils.h>
  33. #endif
  34. #include <HTVMS_WaisUI.h>
  35. /*----------------------------------------------------------------------*/
  36. /* Data types / constants */
  37. /* date factor constants */
  38. #define DF_INDEPENDENT 1
  39. #define DF_LATER 2
  40. #define DF_EARLIER 3
  41. #define DF_SPECIFIED_RANGE 4
  42. /* chunk types */
  43. #define CT_document 0
  44. #define CT_byte 1
  45. #define CT_line 2
  46. #define CT_paragraph 3
  47. /* relevance feedback query */
  48. #define QT_RelevanceFeedbackQuery "3"
  49. #define QT_TextRetrievalQuery QT_BooleanQuery
  50. /* new data tags */
  51. #define DT_UserInformationLength (data_tag)99
  52. #define DT_ChunkCode (data_tag)100
  53. #define DT_ChunkIDLength (data_tag)101
  54. #define DT_ChunkMarker (data_tag)102
  55. #define DT_HighlightMarker (data_tag)103
  56. #define DT_DeHighlightMarker (data_tag)104
  57. #define DT_NewlineCharacters (data_tag)105
  58. #define DT_SeedWords (data_tag)106
  59. #define DT_DocumentIDChunk (data_tag)107
  60. #define DT_ChunkStartID (data_tag)108
  61. #define DT_ChunkEndID (data_tag)109
  62. #define DT_TextList (data_tag)110
  63. #define DT_DateFactor (data_tag)111
  64. #define DT_BeginDateRange (data_tag)112
  65. #define DT_EndDateRange (data_tag)113
  66. #define DT_MaxDocumentsRetrieved (data_tag)114
  67. #define DT_SeedWordsUsed (data_tag)115
  68. #define DT_DocumentID (data_tag)116
  69. #define DT_VersionNumber (data_tag)117
  70. #define DT_Score (data_tag)118
  71. #define DT_BestMatch (data_tag)119
  72. #define DT_DocumentLength (data_tag)120
  73. #define DT_Source (data_tag)121
  74. #define DT_Date (data_tag)122
  75. #define DT_Headline (data_tag)123
  76. #define DT_OriginCity (data_tag)124
  77. #define DT_PresentStartByte (data_tag)125
  78. #define DT_TextLength (data_tag)126
  79. #define DT_DocumentText (data_tag)127
  80. #define DT_StockCodes (data_tag)128
  81. #define DT_CompanyCodes (data_tag)129
  82. #define DT_IndustryCodes (data_tag)130
  83. /* added by harry */
  84. #define DT_DocumentHeaderGroup (data_tag)150
  85. #define DT_DocumentShortHeaderGroup (data_tag)151
  86. #define DT_DocumentLongHeaderGroup (data_tag)152
  87. #define DT_DocumentTextGroup (data_tag)153
  88. #define DT_DocumentHeadlineGroup (data_tag)154
  89. #define DT_DocumentCodeGroup (data_tag)155
  90. #define DT_Lines (data_tag)131
  91. #define DT_TYPE_BLOCK (data_tag)132
  92. #define DT_TYPE (data_tag)133
  93. /* wais element sets */
  94. #define ES_DocumentHeader "Document Header"
  95. #define ES_DocumentShortHeader "Document Short Header"
  96. #define ES_DocumentLongHeader "Document Long Header"
  97. #define ES_DocumentText "Document Text"
  98. #define ES_DocumentHeadline "Document Headline"
  99. #define ES_DocumentCodes "Document Codes"
  100. typedef struct DocObj { /* specifies a section of a document */
  101. any *DocumentID;
  102. char *Type;
  103. long ChunkCode;
  104. union {
  105. long Pos;
  106. any *ID;
  107. } ChunkStart;
  108. union {
  109. long Pos;
  110. any *ID;
  111. } ChunkEnd;
  112. } DocObj;
  113. /*----------------------------------------------------------------------*/
  114. /* WAIS APDU extensions */
  115. typedef struct WAISInitResponse {
  116. long ChunkCode;
  117. long ChunkIDLength;
  118. char *ChunkMarker;
  119. char *HighlightMarker;
  120. char *DeHighlightMarker;
  121. char *NewlineCharacters;
  122. /* XXX need to add UpdateFrequency and Update Time */
  123. } WAISInitResponse;
  124. typedef struct WAISSearch {
  125. char *SeedWords;
  126. DocObj **Docs;
  127. char **TextList;
  128. long DateFactor;
  129. char *BeginDateRange;
  130. char *EndDateRange;
  131. long MaxDocumentsRetrieved;
  132. } WAISSearch;
  133. typedef struct WAISDocumentHeader {
  134. any *DocumentID;
  135. long VersionNumber;
  136. long Score;
  137. long BestMatch;
  138. long DocumentLength;
  139. long Lines;
  140. char **Types;
  141. char *Source;
  142. char *Date;
  143. char *Headline;
  144. char *OriginCity;
  145. } WAISDocumentHeader;
  146. typedef struct WAISDocumentShortHeader {
  147. any *DocumentID;
  148. long VersionNumber;
  149. long Score;
  150. long BestMatch;
  151. long DocumentLength;
  152. long Lines;
  153. } WAISDocumentShortHeader;
  154. typedef struct WAISDocumentLongHeader {
  155. any *DocumentID;
  156. long VersionNumber;
  157. long Score;
  158. long BestMatch;
  159. long DocumentLength;
  160. long Lines;
  161. char **Types;
  162. char *Source;
  163. char *Date;
  164. char *Headline;
  165. char *OriginCity;
  166. char *StockCodes;
  167. char *CompanyCodes;
  168. char *IndustryCodes;
  169. } WAISDocumentLongHeader;
  170. typedef struct WAISDocumentText {
  171. any *DocumentID;
  172. long VersionNumber;
  173. any *DocumentText;
  174. } WAISDocumentText;
  175. typedef struct WAISDocumentHeadlines {
  176. any *DocumentID;
  177. long VersionNumber;
  178. char *Source;
  179. char *Date;
  180. char *Headline;
  181. char *OriginCity;
  182. } WAISDocumentHeadlines;
  183. typedef struct WAISDocumentCodes {
  184. any *DocumentID;
  185. long VersionNumber;
  186. char *StockCodes;
  187. char *CompanyCodes;
  188. char *IndustryCodes;
  189. } WAISDocumentCodes;
  190. typedef struct WAISSearchResponse {
  191. char *SeedWordsUsed;
  192. WAISDocumentHeader **DocHeaders;
  193. WAISDocumentShortHeader **ShortHeaders;
  194. WAISDocumentLongHeader **LongHeaders;
  195. WAISDocumentText **Text;
  196. WAISDocumentHeadlines **Headlines;
  197. WAISDocumentCodes **Codes;
  198. diagnosticRecord **Diagnostics;
  199. } WAISSearchResponse;
  200. /*----------------------------------------------------------------------*/
  201. /* Functions */
  202. char *generate_search_apdu(char *buff, /* buffer to hold the apdu */
  203. long *buff_len, /* number of bytes written to the buffer */
  204. char *seed_words, /* string of the seed words */
  205. char *database_name,
  206. DocObj **docobjs,
  207. long maxDocsRetrieved);
  208. DocObj *makeDocObjUsingWholeDocument(any *aDocID, char *type);
  209. DocObj *makeDocObjUsingBytes(any *aDocID, char *type, long start, long end);
  210. DocObj *makeDocObjUsingLines(any *aDocID, char *type, long start, long end);
  211. DocObj *makeDocObjUsingParagraphs(any *aDocID, char *type, any *start, any *end);
  212. void freeDocObj(DocObj *doc);
  213. WAISInitResponse *makeWAISInitResponse(long chunkCode, long chunkIDLen,
  214. char *chunkMarker, char *highlightMarker,
  215. char *deHighlightMarker, char *newLineChars);
  216. void freeWAISInitResponse(WAISInitResponse *init);
  217. WAISSearch *makeWAISSearch(char *seedWords,
  218. DocObj **docs,
  219. char **textList,
  220. long dateFactor,
  221. char *beginDateRange,
  222. char *endDateRange,
  223. long maxDocsRetrieved);
  224. void freeWAISSearch(WAISSearch *query);
  225. WAISDocumentHeader *makeWAISDocumentHeader(any *aDocID,
  226. long versionNumber,
  227. long score,
  228. long bestMatch,
  229. long docLen,
  230. long lines,
  231. char **types,
  232. char *source,
  233. char *date,
  234. char *headline,
  235. char *originCity);
  236. void freeWAISDocumentHeader(WAISDocumentHeader *header);
  237. char *writeWAISDocumentHeader(WAISDocumentHeader *header, char *buffer, long *len);
  238. char *readWAISDocumentHeader(WAISDocumentHeader **header, char *buffer);
  239. WAISDocumentShortHeader *makeWAISDocumentShortHeader(any *aDocID,
  240. long versionNumber,
  241. long score,
  242. long bestMatch,
  243. long docLen,
  244. long lines);
  245. void freeWAISDocumentShortHeader(WAISDocumentShortHeader *header);
  246. char *writeWAISDocumentShortHeader(WAISDocumentShortHeader *header,
  247. char *buffer, long *len);
  248. char *readWAISDocumentShortHeader(WAISDocumentShortHeader **header, char *buffer);
  249. WAISDocumentLongHeader *makeWAISDocumentLongHeader(any *aDocID,
  250. long versionNumber,
  251. long score,
  252. long bestMatch,
  253. long docLen,
  254. long lines,
  255. char **types,
  256. char *source,
  257. char *date, char *headline,
  258. char *originCity,
  259. char *stockCodes,
  260. char *companyCodes,
  261. char *industryCodes);
  262. void freeWAISDocumentLongHeader(WAISDocumentLongHeader *header);
  263. char *writeWAISDocumentLongHeader(WAISDocumentLongHeader *header,
  264. char *buffer,
  265. long *len);
  266. char *readWAISDocumentLongHeader(WAISDocumentLongHeader **header, char *buffer);
  267. WAISSearchResponse *makeWAISSearchResponse(char *seedWordsUsed,
  268. WAISDocumentHeader **docHeaders,
  269. WAISDocumentShortHeader **shortHeaders,
  270. WAISDocumentLongHeader **longHeaders,
  271. WAISDocumentText **text, WAISDocumentHeadlines **headlines,
  272. WAISDocumentCodes **codes,
  273. diagnosticRecord ** diagnostics);
  274. void freeWAISSearchResponse(WAISSearchResponse * response);
  275. WAISDocumentText *makeWAISDocumentText(any *aDocID, long versionNumber,
  276. any *documentText);
  277. void freeWAISDocumentText(WAISDocumentText *docText);
  278. char *writeWAISDocumentText(WAISDocumentText *docText, char *buffer, long *len);
  279. char *readWAISDocumentText(WAISDocumentText **docText, char *buffer);
  280. WAISDocumentHeadlines *makeWAISDocumentHeadlines(any *aDocID,
  281. long versionNumber,
  282. char *source,
  283. char *date,
  284. char *headline,
  285. char *originCity);
  286. void freeWAISDocumentHeadlines(WAISDocumentHeadlines *docHeadline);
  287. char *writeWAISDocumentHeadlines(WAISDocumentHeadlines *docHeadline,
  288. char *buffer,
  289. long *len);
  290. char *readWAISDocumentHeadlines(WAISDocumentHeadlines **docHeadline, char *buffer);
  291. WAISDocumentCodes *makeWAISDocumentCodes(any *aDocID,
  292. long versionNumber,
  293. char *stockCodes,
  294. char *companyCodes,
  295. char *industryCodes);
  296. void freeWAISDocumentCodes(WAISDocumentCodes *docCodes);
  297. char *writeWAISDocumentCodes(WAISDocumentCodes *docCodes, char *buffer, long *len);
  298. char *readWAISDocumentCodes(WAISDocumentCodes **docCodes, char *buffer);
  299. any *makeWAISTextQuery(DocObj **docs);
  300. DocObj **readWAISTextQuery(any *terms);
  301. void CSTFreeWAISInitResponse(WAISInitResponse *init);
  302. void CSTFreeWAISSearch(WAISSearch *query);
  303. void CSTFreeDocObj(DocObj *doc);
  304. void CSTFreeWAISDocumentHeader(WAISDocumentHeader *header);
  305. void CSTFreeWAISDocumentShortHeader(WAISDocumentShortHeader *header);
  306. void CSTFreeWAISDocumentLongHeader(WAISDocumentLongHeader *header);
  307. void CSTFreeWAISSearchResponse(WAISSearchResponse * response);
  308. void CSTFreeWAISDocumentText(WAISDocumentText *docText);
  309. void CSTFreeWAISDocHeadlines(WAISDocumentHeadlines *docHeadline);
  310. void CSTFreeWAISDocumentCodes(WAISDocumentCodes *docCodes);
  311. void CSTFreeWAISTextQuery(any *query);
  312. /*----------------------------------------------------------------------*/
  313. #endif /* ndef _H_WAIS_protocol_ */
  314. /*
  315. * Routines originally from WMessage.h -- FM
  316. *
  317. *----------------------------------------------------------------------*/
  318. /* WIDE AREA INFORMATION SERVER SOFTWARE
  319. * No guarantees or restrictions. See the readme file for the full standard
  320. * disclaimer.
  321. * 3.26.90
  322. */
  323. /* wais-message.h
  324. *
  325. * This is the header outside of WAIS Z39.50 messages. The header will be
  326. * printable ascii, so as to be transportable. This header will precede each
  327. * Z39.50 APDU, or zero-length message if it is an ACK or NACK. Be sure to
  328. * change hdr_vers current value if you change the structure of the header.
  329. *
  330. * The characters in the header are case insensitive so that the systems from
  331. * the past that only handle one case can at least read the header.
  332. *
  333. * 7.5.90 HWM - added constants
  334. * 7/5/90 brewster added funtion prototypes and comments
  335. * 11/30/90 HWM - went to version 2 (inits and typed retrieval)
  336. */
  337. #ifndef WMESSAGE_H
  338. #define WMESSAGE_H
  339. #ifndef HTUTILS_H
  340. #include <HTUtils.h>
  341. #endif
  342. #include <HTVMS_WaisUI.h>
  343. typedef struct wais_header {
  344. char msg_len[10]; /* length in bytes of following message */
  345. char msg_type; /* type of message: 'z'=Z39.50 APDU,
  346. 'a'=ACK, 'n'=NACK */
  347. char hdr_vers; /* version of this header, currently = '2' */
  348. char server[10]; /* name or address of server */
  349. char compression; /* <sp>=no compression, 'u'=unix compress */
  350. char encoding; /* <sp>=no encoding, 'h'=hexize,
  351. 'u'=uuencode */
  352. char msg_checksum; /* XOR of every byte of message */
  353. } WAISMessage;
  354. #define HEADER_LENGTH 25 /* number of bytes needed to write a
  355. wais-header (not sizeof(wais_header)) */
  356. #define HEADER_VERSION (long)'2'
  357. /* message type */
  358. #define Z3950 'z'
  359. #define ACK 'a'
  360. #define NAK 'n'
  361. /* compression */
  362. #define NO_COMPRESSION ' '
  363. #define UNIX_COMPRESSION 'u'
  364. /* encoding */
  365. #define NO_ENCODING ' '
  366. #define HEX_ENCODING 'h' /* Swartz 4/3 encoding */
  367. #define IBM_HEXCODING 'i' /* same as h but uses characters acceptable for IBM mainframes */
  368. #define UUENCODE 'u'
  369. void readWAISPacketHeader(char *msgBuffer, WAISMessage * header_struct);
  370. long getWAISPacketLength(WAISMessage * header);
  371. void writeWAISPacketHeader(char *header, long dataLen, long type,
  372. char *server, long compression,
  373. long encoding, long version);
  374. #endif /* ndef WMESSAGE_H */