| 1 |
/* HTVMS_WAISUI.h |
| 2 |
* |
| 3 |
* Adaptation for Lynx by F.Macrides ([email protected]) |
| 4 |
* |
| 5 |
* 31-May-1994 FM Initial version. |
| 6 |
*/ |
| 7 |
|
| 8 |
#ifndef HTVMSWAIS_H |
| 9 |
#define HTVMSWAIS_H |
| 10 |
|
| 11 |
#ifndef HTUTILS_H |
| 12 |
#include <HTUtils.h> |
| 13 |
#endif |
| 14 |
|
| 15 |
#ifdef __cplusplus |
| 16 |
extern "C" { |
| 17 |
#endif |
| 18 |
void log_write(char *); |
| 19 |
|
| 20 |
/* |
| 21 |
* Routines originally from Panic.h -- FM |
| 22 |
* |
| 23 |
*----------------------------------------------------------------------*/ |
| 24 |
|
| 25 |
void panic(char *format, ...); |
| 26 |
|
| 27 |
/*----------------------------------------------------------------------*/ |
| 28 |
|
| 29 |
/* |
| 30 |
* Routines originally from CUtil.h -- FM |
| 31 |
* |
| 32 |
*----------------------------------------------------------------------*/ |
| 33 |
|
| 34 |
/* types and constants */ |
| 35 |
|
| 36 |
#ifndef boolean |
| 37 |
#define boolean unsigned long |
| 38 |
#endif /* boolean */ |
| 39 |
|
| 40 |
#ifndef true |
| 41 |
#define true (boolean)1L |
| 42 |
#endif /* true */ |
| 43 |
|
| 44 |
#ifndef false |
| 45 |
#define false (boolean)0L /* used to be (!true), but broke |
| 46 |
some compilers */ |
| 47 |
#endif /* false */ |
| 48 |
|
| 49 |
#ifndef TRUE |
| 50 |
#define TRUE true |
| 51 |
#endif /* TRUE */ |
| 52 |
|
| 53 |
#ifndef FALSE |
| 54 |
#define FALSE false |
| 55 |
#endif /* FALSE */ |
| 56 |
|
| 57 |
/*----------------------------------------------------------------------*/ |
| 58 |
/* functions */ |
| 59 |
|
| 60 |
/* enhanced memory handling functions - don't call them directly, use the |
| 61 |
macros below */ |
| 62 |
void fs_checkPtr(void *ptr); |
| 63 |
void *fs_malloc(size_t size); |
| 64 |
void *fs_realloc(void *ptr, size_t size); |
| 65 |
void fs_free(void *ptr); |
| 66 |
char *fs_strncat(char *dst, char *src, size_t maxToAdd, size_t maxTotal); |
| 67 |
|
| 68 |
/* macros for memory functions. call these in your program. */ |
| 69 |
#define s_checkPtr(ptr) fs_checkPtr(ptr) |
| 70 |
#define s_malloc(size) fs_malloc(size) |
| 71 |
#define s_realloc(ptr,size) fs_realloc((ptr),(size)) |
| 72 |
#define s_free(ptr) { fs_free((char*)ptr); ptr = NULL; } |
| 73 |
#define s_strncat(dst,src,maxToAdd,maxTotal) fs_strncat((dst),(src),(maxToAdd),(maxTotal)) |
| 74 |
|
| 75 |
char *s_strdup(char *s); |
| 76 |
|
| 77 |
#define IS_DELIMITER 1 |
| 78 |
#define NOT_DELIMITER !IS_DELIMITER |
| 79 |
|
| 80 |
char char_downcase(unsigned long ch); |
| 81 |
char *string_downcase(char *word); |
| 82 |
|
| 83 |
/*----------------------------------------------------------------------*/ |
| 84 |
|
| 85 |
/* |
| 86 |
* Routines originally from ZUtil.c -- FM |
| 87 |
* |
| 88 |
*----------------------------------------------------------------------*/ |
| 89 |
|
| 90 |
/* Data types / constants */ |
| 91 |
|
| 92 |
/* bytes to leave for the header size info */ |
| 93 |
#define HEADER_LEN (size_t)2 |
| 94 |
|
| 95 |
typedef long pdu_type; |
| 96 |
|
| 97 |
#define initAPDU (pdu_type)20 |
| 98 |
#define initResponseAPDU (pdu_type)21 |
| 99 |
#define searchAPDU (pdu_type)22 |
| 100 |
#define searchResponseAPDU (pdu_type)23 |
| 101 |
#define presentAPDU (pdu_type)24 |
| 102 |
#define presentResponseAPDU (pdu_type)25 |
| 103 |
#define deteteAPDU (pdu_type)26 |
| 104 |
#define deleteResponseAPDU (pdu_type)27 |
| 105 |
#define accessControlAPDU (pdu_type)28 |
| 106 |
#define accessControlResponseAPDU (pdu_type)29 |
| 107 |
#define resourceControlAPDU (pdu_type)30 |
| 108 |
#define resourceControlResponseAPDU (pdu_type)31 |
| 109 |
|
| 110 |
typedef struct any { /* an any is a non-ascii string of characters */ |
| 111 |
unsigned long size; |
| 112 |
char *bytes; |
| 113 |
} any; |
| 114 |
|
| 115 |
typedef any bit_map; /* a bit_map is a group of packed bits */ |
| 116 |
|
| 117 |
typedef unsigned long data_tag; |
| 118 |
|
| 119 |
#define DT_PDUType (data_tag)1 |
| 120 |
#define DT_ReferenceID (data_tag)2 |
| 121 |
#define DT_ProtocolVersion (data_tag)3 |
| 122 |
#define DT_Options (data_tag)4 |
| 123 |
#define DT_PreferredMessageSize (data_tag)5 |
| 124 |
#define DT_MaximumRecordSize (data_tag)6 |
| 125 |
#define DT_IDAuthentication (data_tag)7 |
| 126 |
#define DT_ImplementationID (data_tag)8 |
| 127 |
#define DT_ImplementationName (data_tag)9 |
| 128 |
#define DT_ImplementationVersion (data_tag)10 |
| 129 |
#define DT_UserInformationField (data_tag)11 |
| 130 |
#define DT_Result (data_tag)12 |
| 131 |
#define DT_SmallSetUpperBound (data_tag)13 |
| 132 |
#define DT_LargeSetLowerBound (data_tag)14 |
| 133 |
#define DT_MediumSetPresentNumber (data_tag)15 |
| 134 |
#define DT_ReplaceIndicator (data_tag)16 |
| 135 |
#define DT_ResultSetName (data_tag)17 |
| 136 |
#define DT_DatabaseNames (data_tag)18 |
| 137 |
#define DT_ElementSetNames (data_tag)19 |
| 138 |
#define DT_QueryType (data_tag)20 |
| 139 |
#define DT_Query (data_tag)21 |
| 140 |
#define DT_SearchStatus (data_tag)22 |
| 141 |
#define DT_ResultCount (data_tag)23 |
| 142 |
#define DT_NumberOfRecordsReturned (data_tag)24 |
| 143 |
#define DT_NextResultSetPosition (data_tag)25 |
| 144 |
#define DT_ResultSetStatus (data_tag)26 |
| 145 |
#define DT_PresentStatus (data_tag)27 |
| 146 |
#define DT_DatabaseDiagnosticRecords (data_tag)28 |
| 147 |
#define DT_NumberOfRecordsRequested (data_tag)29 |
| 148 |
#define DT_ResultSetStartPosition (data_tag)30 |
| 149 |
#define DT_ResultSetID (data_tag)31 |
| 150 |
#define DT_DeleteOperation (data_tag)32 |
| 151 |
#define DT_DeleteStatus (data_tag)33 |
| 152 |
#define DT_NumberNotDeleted (data_tag)34 |
| 153 |
#define DT_BulkStatuses (data_tag)35 |
| 154 |
#define DT_DeleteMSG (data_tag)36 |
| 155 |
#define DT_SecurityChallenge (data_tag)37 |
| 156 |
#define DT_SecurityChallengeResponse (data_tag)38 |
| 157 |
#define DT_SuspendedFlag (data_tag)39 |
| 158 |
#define DT_ResourceReport (data_tag)40 |
| 159 |
#define DT_PartialResultsAvailable (data_tag)41 |
| 160 |
#define DT_ContinueFlag (data_tag)42 |
| 161 |
#define DT_ResultSetWanted (data_tag)43 |
| 162 |
|
| 163 |
#define UNUSED -1 |
| 164 |
|
| 165 |
/* number of bytes required to represent the following sizes in compressed |
| 166 |
integer format |
| 167 |
*/ |
| 168 |
#define CompressedInt1Byte 128 /* 2 ^ 7 */ |
| 169 |
#define CompressedInt2Byte 16384 /* 2 ^ 14 */ |
| 170 |
#define CompressedInt3Byte 2097152 /* 2 ^ 21 */ |
| 171 |
/* others may follow ... */ |
| 172 |
|
| 173 |
/* types of query */ |
| 174 |
#define QT_0 "0" /* query whose non-standard format has been agreed upon |
| 175 |
client and server */ |
| 176 |
/* values for InitAPDU option element */ |
| 177 |
#define WILL_USE TRUE |
| 178 |
#define WILL_NOT_USE FALSE |
| 179 |
#define WILL_SUPPORT TRUE |
| 180 |
#define WILL_NOT_SUPPORT FALSE |
| 181 |
|
| 182 |
/* values for InitResponseAPDU result element */ |
| 183 |
#define ACCEPT TRUE |
| 184 |
#define REJECT FALSE |
| 185 |
|
| 186 |
/* values for SearchResponseAPDU search status element */ |
| 187 |
#define SUCCESS 0 /* intuitive huh? */ |
| 188 |
#define FAILURE 1 |
| 189 |
|
| 190 |
/* values for SearchResponseAPDU result set status element */ |
| 191 |
#define SUBSET 1 |
| 192 |
#define INTERIM 2 |
| 193 |
#define NONE 3 |
| 194 |
|
| 195 |
/* values for SearchResponseAPDU present status element */ |
| 196 |
/* SUCCESS already defined */ |
| 197 |
#define PARTIAL_1 1 |
| 198 |
#define PARTIAL_2 2 |
| 199 |
#define PARTIAL_3 3 |
| 200 |
#define PARTIAL_4 4 |
| 201 |
#define PS_NONE 5 /* can't use NONE since it was used by result |
| 202 |
set status */ |
| 203 |
|
| 204 |
#define DIAGNOSTIC_CODE_SIZE (size_t)3 |
| 205 |
|
| 206 |
typedef struct diagnosticRecord { |
| 207 |
boolean SURROGATE; |
| 208 |
char DIAG[DIAGNOSTIC_CODE_SIZE]; |
| 209 |
char *ADDINFO; |
| 210 |
} diagnosticRecord; |
| 211 |
|
| 212 |
#define D_PermanentSystemError "S1" |
| 213 |
#define D_TemporarySystemError "S2" |
| 214 |
#define D_UnsupportedSearch "S3" |
| 215 |
#define D_TermsOnlyStopWords "S5" |
| 216 |
#define D_TooManyArgumentWords "S6" |
| 217 |
#define D_TooManyBooleanOperators "S7" |
| 218 |
#define D_TooManyTruncatedWords "S8" |
| 219 |
#define D_TooMany IncompleteSubfields "S9" |
| 220 |
#define D_TruncatedWordsTooShort "SA" |
| 221 |
#define D_InvalidFormatForRecordNumber "SB" |
| 222 |
#define D_TooManyCharactersInSearch "SC" |
| 223 |
#define D_TooManyRecordsRetrieved "SD" |
| 224 |
#define D_PresentRequestOutOfRange "SF" |
| 225 |
#define D_SystemErrorInPresentRecords "SG" |
| 226 |
#define D_RecordNotAuthorizedToBeSent "SH" |
| 227 |
#define D_RecordExceedsPrefMessageSize "SI" |
| 228 |
#define D_RecordExceedsMaxRecordSize "SJ" |
| 229 |
#define D_ResultSetNotSuppAsSearchTerm "SK" |
| 230 |
#define D_OnlyOneRsltSetAsSrchTermSupp "SL" |
| 231 |
#define D_OnlyANDingOfASnglRsltSetSupp "SM" |
| 232 |
#define D_RsltSetExistsNoReplace "SN" |
| 233 |
#define D_ResultSetNamingNotSupported "SO" |
| 234 |
#define D_CombinationDatabasesNotSupp "SP" |
| 235 |
#define D_ElementSetNamesNotSupported "SQ" |
| 236 |
#define D_ElementSetNameNotValid "SR" |
| 237 |
#define D_OnlyASingleElmntSetNameSupp "SS" |
| 238 |
#define D_ResultSetDeletedByTarget "ST" |
| 239 |
#define D_ResultSetIsInUse "SU" |
| 240 |
#define D_DatabasesIsLocked "SV" |
| 241 |
#define D_TerminatedByNoContinueResp "SW" |
| 242 |
#define D_ResultSetDoesNotExist "SX" |
| 243 |
#define D_ResExNoResultsAvailable "SY" |
| 244 |
#define D_ResExUnpredictableResults "SZ" |
| 245 |
#define D_ResExValidSubsetOfResults "T1" |
| 246 |
#define D_AccessControlFailure "T2" |
| 247 |
#define D_SecurityNotIssuedReqTerm "T3" |
| 248 |
#define D_SecurityNotBeIssuedRecNotInc "T4" |
| 249 |
|
| 250 |
/*----------------------------------------------------------------------*/ |
| 251 |
|
| 252 |
/* for internal error handling */ |
| 253 |
|
| 254 |
extern char *readErrorPosition; /* pos where buf stopped making sense */ |
| 255 |
|
| 256 |
/* the following are macros so that they can return OUT of the function |
| 257 |
which calls them |
| 258 |
*/ |
| 259 |
|
| 260 |
#define RETURN_ON_NULL(var) \ |
| 261 |
if (var == NULL) \ |
| 262 |
return(NULL); /* jump out of caller */ |
| 263 |
|
| 264 |
#define REPORT_READ_ERROR(pos) \ |
| 265 |
{ readErrorPosition = (pos); \ |
| 266 |
return(NULL); /* jump out of caller */ \ |
| 267 |
} |
| 268 |
|
| 269 |
#define CHECK_FOR_SPACE_LEFT(spaceNeeded,spaceLeft) \ |
| 270 |
{ if (*spaceLeft >= spaceNeeded) \ |
| 271 |
(*spaceLeft) -= spaceNeeded; \ |
| 272 |
else \ |
| 273 |
{ *spaceLeft = 0; \ |
| 274 |
return(NULL); /* jump out of the caller */ \ |
| 275 |
} \ |
| 276 |
} |
| 277 |
|
| 278 |
/*----------------------------------------------------------------------*/ |
| 279 |
|
| 280 |
diagnosticRecord *makeDiag(boolean surrogate, char *code, char *addInfo); |
| 281 |
void freeDiag(diagnosticRecord * diag); |
| 282 |
char *writeDiag(diagnosticRecord * diag, char *buffer, long *len); |
| 283 |
char *readDiag(diagnosticRecord ** diag, char *buffer); |
| 284 |
|
| 285 |
char *writeCompressedInteger(unsigned long num, char *buf, long *len); |
| 286 |
char *readCompressedInteger(unsigned long *num, char *buf); |
| 287 |
char *writeCompressedIntWithPadding(unsigned long num, unsigned long size, |
| 288 |
char *buffer, long *len); |
| 289 |
unsigned long writtenCompressedIntSize(unsigned long num); |
| 290 |
|
| 291 |
char *writeTag(data_tag tag, char *buf, long *len); |
| 292 |
char *readTag(data_tag *tag, char *buf); |
| 293 |
data_tag peekTag(char *buf); |
| 294 |
unsigned long writtenTagSize(data_tag tag); |
| 295 |
|
| 296 |
any *makeAny(unsigned long size, char *data); |
| 297 |
void freeAny(any *a); |
| 298 |
any *duplicateAny(any *a); |
| 299 |
char *writeAny(any *a, data_tag tag, char *buffer, long *len); |
| 300 |
char *readAny(any **anAny, char *buffer); |
| 301 |
unsigned long writtenAnySize(data_tag tag, any *a); |
| 302 |
|
| 303 |
any *stringToAny(char *s); |
| 304 |
char *anyToString(any *a); |
| 305 |
unsigned long writtenStringSize(data_tag tag, char *s); |
| 306 |
|
| 307 |
any *longToAny(long Num); |
| 308 |
long anyToLong(any *a); |
| 309 |
|
| 310 |
char *writeString(char *s, data_tag tag, char *buffer, long *len); |
| 311 |
char *readString(char **s, char *buffer); |
| 312 |
|
| 313 |
bit_map *makeBitMap(unsigned long numBits, ...); |
| 314 |
|
| 315 |
void freeBitMap(bit_map *bm); |
| 316 |
boolean bitAtPos(unsigned long pos, bit_map *bm); |
| 317 |
char *writeBitMap(bit_map *bm, data_tag tag, char *buffer, long *len); |
| 318 |
char *readBitMap(bit_map **bm, char *buffer); |
| 319 |
|
| 320 |
char *writeByte(unsigned long byte, char *buf, long *len); |
| 321 |
char *readByte(unsigned char *byte, char *buf); |
| 322 |
|
| 323 |
char *writeBoolean(boolean flag, char *buf, long *len); |
| 324 |
char *readBoolean(boolean *flag, char *buf); |
| 325 |
|
| 326 |
char *writePDUType(pdu_type pduType, char *buf, long *len); |
| 327 |
char *readPDUType(pdu_type *pduType, char *buf); |
| 328 |
pdu_type peekPDUType(char *buf); |
| 329 |
|
| 330 |
char *writeBinaryInteger(long num, unsigned long size, |
| 331 |
char *buf, long *len); |
| 332 |
char *readBinaryInteger(long *num, unsigned long size, char *buf); |
| 333 |
unsigned long writtenCompressedBinIntSize(long num); |
| 334 |
|
| 335 |
char *writeNum(long num, data_tag tag, char *buffer, long *len); |
| 336 |
char *readNum(long *num, char *buffer); |
| 337 |
unsigned long writtenNumSize(data_tag tag, long num); |
| 338 |
|
| 339 |
void doList(void **list, void (*func) (void *)); |
| 340 |
|
| 341 |
char *writeProtocolVersion(char *buf, long *len); |
| 342 |
char *defaultImplementationID(void); |
| 343 |
char *defaultImplementationName(void); |
| 344 |
char *defaultImplementationVersion(void); |
| 345 |
|
| 346 |
/*----------------------------------------------------------------------*/ |
| 347 |
|
| 348 |
/* |
| 349 |
* Routines originally from ZType1.c -- FM |
| 350 |
* |
| 351 |
*----------------------------------------------------------------------*/ |
| 352 |
|
| 353 |
/* This file implements the type 1 query defined in appendices B & C |
| 354 |
of the SR 1 spec. |
| 355 |
*/ |
| 356 |
|
| 357 |
/*----------------------------------------------------------------------*/ |
| 358 |
/* types and constants */ |
| 359 |
|
| 360 |
/* new data tags */ |
| 361 |
#define DT_AttributeList (data_tag)44 |
| 362 |
#define DT_Term (data_tag)45 |
| 363 |
#define DT_Operator (data_tag)46 |
| 364 |
|
| 365 |
#define QT_BooleanQuery "1" /* standard boolean query */ |
| 366 |
|
| 367 |
/* general attribute code - use in place of any attribute */ |
| 368 |
#define IGNORE "ig" |
| 369 |
|
| 370 |
/* use value codes */ |
| 371 |
#define UV_ISBN "ub" |
| 372 |
#define CORPORATE_NAME "uc" |
| 373 |
#define ISSN "us" |
| 374 |
#define PERSONAL_NAME "up" |
| 375 |
#define SUBJECT "uj" |
| 376 |
#define TITLE "ut" |
| 377 |
#define GEOGRAPHIC_NAME "ug" |
| 378 |
#define CODEN "ud" |
| 379 |
#define SUBJECT_SUBDIVISION "ue" |
| 380 |
#define SERIES_TITLE "uf" |
| 381 |
#define MICROFORM_GENERATION "uh" |
| 382 |
#define PLACE_OF_PUBLICATION "ui" |
| 383 |
#define NUC_CODE "uk" |
| 384 |
#define LANGUAGE "ul" |
| 385 |
#define COMBINATION_OF_USE_VALUES "um" |
| 386 |
#define SYSTEM_CONTROL_NUMBER "un" |
| 387 |
#define DATE "uo" |
| 388 |
#define LC_CONTROL_NUMBER "ur" |
| 389 |
#define MUSIC_PUBLISHERS_NUMBER "uu" |
| 390 |
#define GOVERNMENT_DOCUMENTS_NUMBER "uv" |
| 391 |
#define SUBJECT_CLASSIFICATION "uw" |
| 392 |
#define RECORD_TYPE "uy" |
| 393 |
|
| 394 |
/* relation value codes */ |
| 395 |
#define EQUAL "re" |
| 396 |
#define GREATER_THAN "rg" |
| 397 |
#define GREATER_THAN_OR_EQUAL "ro" |
| 398 |
#define LESS_THAN "rl" |
| 399 |
#define LESS_THAN_OR_EQUAL "rp" |
| 400 |
#define NOT_EQUAL "rn" |
| 401 |
|
| 402 |
/* position value codes */ |
| 403 |
#define FIRST_IN_FIELD "pf" |
| 404 |
#define FIRST_IN_SUBFIELD "ps" |
| 405 |
#define FIRST_IN_A_SUBFIELD "pa" |
| 406 |
#define FIRST_IN_NOT_A_SUBFIELD "pt" |
| 407 |
#define ANY_POSITION_IN_FIELD "py" |
| 408 |
|
| 409 |
/* structure value codes */ |
| 410 |
#define PHRASE "sp" |
| 411 |
#define WORD "sw" |
| 412 |
#define KEY "sk" |
| 413 |
#define WORD_LIST "sl" |
| 414 |
|
| 415 |
/* truncation value codes */ |
| 416 |
#define NO_TRUNCATION "tn" |
| 417 |
#define RIGHT_TRUNCATION "tr" |
| 418 |
#define PROC_NUM_INCLUDED_IN_SEARCH_ARG "ti" |
| 419 |
|
| 420 |
/* completeness value codes */ |
| 421 |
#define INCOMPLETE_SUBFIELD "ci" |
| 422 |
#define COMPLETE_SUBFIELD "cs" |
| 423 |
#define COMPLETEFIELD "cf" |
| 424 |
|
| 425 |
/* operator codes */ |
| 426 |
#define AND "a" |
| 427 |
#define OR "o" |
| 428 |
#define AND_NOT "n" |
| 429 |
|
| 430 |
/* term types */ |
| 431 |
#define TT_Attribute 1 |
| 432 |
#define TT_ResultSetID 2 |
| 433 |
#define TT_Operator 3 |
| 434 |
|
| 435 |
#define ATTRIBUTE_SIZE 3 |
| 436 |
#define OPERATOR_SIZE 2 |
| 437 |
|
| 438 |
typedef struct query_term { |
| 439 |
/* type */ |
| 440 |
long TermType; |
| 441 |
/* for term */ |
| 442 |
char Use[ATTRIBUTE_SIZE + 1]; |
| 443 |
char Relation[ATTRIBUTE_SIZE + 1]; |
| 444 |
char Position[ATTRIBUTE_SIZE + 1]; |
| 445 |
char Structure[ATTRIBUTE_SIZE + 1]; |
| 446 |
char Truncation[ATTRIBUTE_SIZE + 1]; |
| 447 |
char Completeness[ATTRIBUTE_SIZE + 1]; |
| 448 |
any *Term; |
| 449 |
/* for result set */ |
| 450 |
any *ResultSetID; |
| 451 |
/* for operator */ |
| 452 |
char Operator[OPERATOR_SIZE]; |
| 453 |
} query_term; |
| 454 |
|
| 455 |
/*----------------------------------------------------------------------*/ |
| 456 |
/* functions */ |
| 457 |
|
| 458 |
query_term *makeAttributeTerm(char *use, char *relation, char *position, char *structure, |
| 459 |
char *truncation, char *completeness, any *term); |
| 460 |
query_term *makeResultSetTerm(any *resultSet); |
| 461 |
query_term *makeOperatorTerm(char *operatorCode); |
| 462 |
void freeTerm(void *qt); |
| 463 |
char *writeQueryTerm(query_term *qt, char *buffer, long *len); |
| 464 |
char *readQueryTerm(query_term **qt, char *buffer); |
| 465 |
any *writeQuery(query_term **terms); |
| 466 |
query_term **readQuery(any *info); |
| 467 |
|
| 468 |
/*----------------------------------------------------------------------*/ |
| 469 |
|
| 470 |
/* |
| 471 |
* Routines originally from UI.c -- FM |
| 472 |
* |
| 473 |
*----------------------------------------------------------------------*/ |
| 474 |
|
| 475 |
char *generate_retrieval_apdu(char *buff, |
| 476 |
long *buff_len, |
| 477 |
any *docID, |
| 478 |
long chunk_type, |
| 479 |
long start_line, long end_line, |
| 480 |
char *type, |
| 481 |
char *database_name); |
| 482 |
|
| 483 |
long interpret_message(char *request_message, |
| 484 |
long request_length, |
| 485 |
char *response_message, |
| 486 |
long response_buffer_length, /* length of the buffer (modified) */ |
| 487 |
long connection, |
| 488 |
boolean verbose); |
| 489 |
|
| 490 |
char *trim_junk(char *headline); |
| 491 |
|
| 492 |
/* |
| 493 |
* Routines originally from ZProt.c -- FM |
| 494 |
* |
| 495 |
*----------------------------------------------------------------------*/ |
| 496 |
|
| 497 |
/* APDU types */ |
| 498 |
|
| 499 |
typedef struct InitAPDU { |
| 500 |
pdu_type PDUType; |
| 501 |
boolean willSearch, willPresent, willDelete; |
| 502 |
boolean supportAccessControl, supportResourceControl; |
| 503 |
long PreferredMessageSize; |
| 504 |
long MaximumRecordSize; |
| 505 |
char *IDAuthentication; |
| 506 |
char *ImplementationID; |
| 507 |
char *ImplementationName; |
| 508 |
char *ImplementationVersion; |
| 509 |
any *ReferenceID; |
| 510 |
void *UserInformationField; |
| 511 |
} InitAPDU; |
| 512 |
|
| 513 |
typedef struct InitResponseAPDU { |
| 514 |
pdu_type PDUType; |
| 515 |
boolean Result; |
| 516 |
boolean willSearch, willPresent, willDelete; |
| 517 |
boolean supportAccessControl, supportResourceControl; |
| 518 |
long PreferredMessageSize; |
| 519 |
long MaximumRecordSize; |
| 520 |
char *IDAuthentication; |
| 521 |
char *ImplementationID; |
| 522 |
char *ImplementationName; |
| 523 |
char *ImplementationVersion; |
| 524 |
any *ReferenceID; |
| 525 |
void *UserInformationField; |
| 526 |
} InitResponseAPDU; |
| 527 |
|
| 528 |
typedef struct SearchAPDU { |
| 529 |
pdu_type PDUType; |
| 530 |
long SmallSetUpperBound; |
| 531 |
long LargeSetLowerBound; |
| 532 |
long MediumSetPresentNumber; |
| 533 |
boolean ReplaceIndicator; |
| 534 |
char *ResultSetName; |
| 535 |
char **DatabaseNames; |
| 536 |
char *QueryType; |
| 537 |
char **ElementSetNames; |
| 538 |
any *ReferenceID; |
| 539 |
void *Query; |
| 540 |
} SearchAPDU; |
| 541 |
|
| 542 |
typedef struct SearchResponseAPDU { |
| 543 |
pdu_type PDUType; |
| 544 |
long SearchStatus; |
| 545 |
long ResultCount; |
| 546 |
long NumberOfRecordsReturned; |
| 547 |
long NextResultSetPosition; |
| 548 |
long ResultSetStatus; |
| 549 |
long PresentStatus; |
| 550 |
any *ReferenceID; |
| 551 |
void *DatabaseDiagnosticRecords; |
| 552 |
} SearchResponseAPDU; |
| 553 |
|
| 554 |
typedef struct PresentAPDU { |
| 555 |
pdu_type PDUType; |
| 556 |
long NumberOfRecordsRequested; |
| 557 |
long ResultSetStartPosition; |
| 558 |
char *ResultSetID; |
| 559 |
char *ElementSetNames; |
| 560 |
any *ReferenceID; |
| 561 |
void *PresentInfo; |
| 562 |
} PresentAPDU; |
| 563 |
|
| 564 |
typedef struct PresentResponseAPDU { |
| 565 |
pdu_type PDUType; |
| 566 |
boolean PresentStatus; |
| 567 |
long NumberOfRecordsReturned; |
| 568 |
long NextResultSetPosition; |
| 569 |
any *ReferenceID; |
| 570 |
void *DatabaseDiagnosticRecords; |
| 571 |
} PresentResponseAPDU; |
| 572 |
|
| 573 |
/*----------------------------------------------------------------------*/ |
| 574 |
/* Functions */ |
| 575 |
|
| 576 |
InitAPDU *makeInitAPDU(boolean search, boolean present, boolean deleteIt, |
| 577 |
boolean accessControl, boolean resourceControl, long prefMsgSize, |
| 578 |
long maxMsgSize, |
| 579 |
char *auth, |
| 580 |
char *id, |
| 581 |
char *name, |
| 582 |
char *version, |
| 583 |
any *refID, |
| 584 |
void *userInfo); |
| 585 |
void freeInitAPDU(InitAPDU * init); |
| 586 |
char *writeInitAPDU(InitAPDU * init, char *buffer, long *len); |
| 587 |
char *readInitAPDU(InitAPDU ** init, char *buffer); |
| 588 |
|
| 589 |
InitResponseAPDU *makeInitResponseAPDU(boolean result, |
| 590 |
boolean search, |
| 591 |
boolean present, |
| 592 |
boolean deleteIt, |
| 593 |
boolean accessControl, |
| 594 |
boolean resourceControl, |
| 595 |
long prefMsgSize, |
| 596 |
long maxMsgSize, |
| 597 |
char *auth, |
| 598 |
char *id, |
| 599 |
char *name, |
| 600 |
char *version, |
| 601 |
any *refID, |
| 602 |
void *userInfo); |
| 603 |
void freeInitResponseAPDU(InitResponseAPDU *init); |
| 604 |
char *writeInitResponseAPDU(InitResponseAPDU *init, char *buffer, long *len); |
| 605 |
char *readInitResponseAPDU(InitResponseAPDU **init, char *buffer); |
| 606 |
InitResponseAPDU *replyToInitAPDU(InitAPDU * init, boolean result, void *userInfo); |
| 607 |
|
| 608 |
SearchAPDU *makeSearchAPDU(long small, long large, long medium, |
| 609 |
boolean replace, char *name, char **databases, |
| 610 |
char *type, char **elements, any *refID, void *queryInfo); |
| 611 |
void freeSearchAPDU(SearchAPDU *query); |
| 612 |
char *writeSearchAPDU(SearchAPDU *query, char *buffer, long *len); |
| 613 |
char *readSearchAPDU(SearchAPDU **query, char *buffer); |
| 614 |
|
| 615 |
SearchResponseAPDU *makeSearchResponseAPDU(long result, long count, |
| 616 |
long recordsReturned, long nextPos, |
| 617 |
long resultStatus, long presentStatus, |
| 618 |
any *refID, void *records); |
| 619 |
void freeSearchResponseAPDU(SearchResponseAPDU *queryResponse); |
| 620 |
char *writeSearchResponseAPDU(SearchResponseAPDU *queryResponse, char |
| 621 |
*buffer, long *len); |
| 622 |
char *readSearchResponseAPDU(SearchResponseAPDU **queryResponse, char *buffer); |
| 623 |
|
| 624 |
PresentAPDU *makePresentAPDU(long recsReq, long startPos, |
| 625 |
char *resultID, any *refID, void *info); |
| 626 |
void freePresentAPDU(PresentAPDU * present); |
| 627 |
char *writePresentAPDU(PresentAPDU * present, char *buffer, long *len); |
| 628 |
char *readPresentAPDU(PresentAPDU ** present, char *buffer); |
| 629 |
|
| 630 |
PresentResponseAPDU *makePresentResponseAPDU(boolean status, long recsRet, |
| 631 |
long nextPos, any *refID, |
| 632 |
void *records); |
| 633 |
void freePresentResponseAPDU(PresentResponseAPDU * present); |
| 634 |
char *writePresentResponseAPDU(PresentResponseAPDU * present, char |
| 635 |
*buffer, long *len); |
| 636 |
char *readPresentResponseAPDU(PresentResponseAPDU ** present, char *buffer); |
| 637 |
|
| 638 |
/*----------------------------------------------------------------------*/ |
| 639 |
/* user extension hooks: */ |
| 640 |
|
| 641 |
extern char *writeInitInfo(InitAPDU * init, char *buffer, long *len); |
| 642 |
extern char *readInitInfo(void **info, char *buffer); |
| 643 |
|
| 644 |
extern char *writeInitResponseInfo(InitResponseAPDU *init, char *buffer, long *len); |
| 645 |
extern char *readInitResponseInfo(void **info, char *buffer); |
| 646 |
|
| 647 |
extern char *writeSearchInfo(SearchAPDU *query, char *buffer, long *len); |
| 648 |
extern char *readSearchInfo(void **info, char *buffer); |
| 649 |
|
| 650 |
extern char *writeSearchResponseInfo(SearchResponseAPDU *query, char |
| 651 |
*buffer, long *len); |
| 652 |
extern char *readSearchResponseInfo(void **info, char *buffer); |
| 653 |
|
| 654 |
extern char *writePresentInfo(PresentAPDU * present, char *buffer, long *len); |
| 655 |
extern char *readPresentInfo(void **info, char *buffer); |
| 656 |
|
| 657 |
extern char *writePresentResponseInfo(PresentResponseAPDU * present, char |
| 658 |
*buffer, long *len); |
| 659 |
extern char *readPresentResponseInfo(void **info, char *buffer); |
| 660 |
|
| 661 |
#ifdef __cplusplus |
| 662 |
} |
| 663 |
#endif |
| 664 |
#endif /* HTVMSWAIS_H */ |