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