Search.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /* $TOG: Search.h /main/12 1998/04/03 17:10:35 mgreess $
  24. *
  25. * (c) Copyright 1996 Digital Equipment Corporation.
  26. * (c) Copyright 1996 Hewlett-Packard Company.
  27. * (c) Copyright 1996 International Business Machines Corp.
  28. * (c) Copyright 1996 Sun Microsystems, Inc.
  29. * (c) Copyright 1996 Novell, Inc.
  30. * (c) Copyright 1996 FUJITSU LIMITED.
  31. * (c) Copyright 1996 Hitachi.
  32. */
  33. /*
  34. * COMPONENT_NAME: austext
  35. *
  36. * FUNCTIONS: none
  37. *
  38. * ORIGINS: 27
  39. *
  40. *
  41. * (C) COPYRIGHT International Business Machines Corp. 1994,1995
  42. * All Rights Reserved
  43. * Licensed Materials - Property of IBM
  44. * US Government Users Restricted Rights - Use, duplication or
  45. * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  46. */
  47. #ifndef _Search_h
  48. #define _Search_h
  49. /********************** Search.h ***********************
  50. * $TOG: Search.h /main/12 1998/04/03 17:10:35 mgreess $
  51. * Jan 1994.
  52. * Public header file for DtSearch/AusText API.
  53. * Formerly named ausapi.h. Externals renamed
  54. * from ausapi_... or aa_... to DtSearch conventions.
  55. * Documentation in dtsearch.doc.
  56. *
  57. */
  58. #ifndef _XOPEN_SOURCE
  59. #define _XOPEN_SOURCE 1
  60. #endif
  61. #include <time.h>
  62. #include <stdio.h>
  63. #include <string.h>
  64. #if defined(__linux__)
  65. # define __SVR4_I386_ABI_L1__
  66. #endif
  67. #include <limits.h>
  68. #if defined(__linux__)
  69. # undef __SVR4_I386_ABI_L1__
  70. # ifndef WORD_BIT
  71. # define WORD_BIT 32
  72. # endif
  73. # ifndef LONG_BIT
  74. # define LONG_BIT 32
  75. # endif
  76. #endif
  77. #define DtSrVERSION "0.6"
  78. #define DtSrMAXHITS 20
  79. #define DtSrMAX_KTNAME 13
  80. #define DtSrMAX_DB_KEYSIZE 32
  81. #define DtSrMAXWIDTH_HWORD 134
  82. #define DtSrMAX_STEMCOUNT 8
  83. /****************************************/
  84. /* */
  85. /* RETURN CODES */
  86. /* */
  87. /****************************************/
  88. #define DtSrOK 0 /* normal, successful response */
  89. #define DtSrPASSWD 1 /* failed communications authentication */
  90. #define DtSrNOTAVAIL 2 /* no hits on search, no such rec, etc */
  91. #define DtSrFAIL 3 /* misc unsuccessful engine returns */
  92. #define DtSrREINIT 4 /* engine reinitialized, request canceled */
  93. #define DtSrERROR 5 /* fatal caller (client) program error */
  94. #define DtSrABORT 6 /* fatal engine failure, caller must abort */
  95. #define DtSrCOMM 7 /* fatal communications failure */
  96. /* In order to share databases among heterogenous machines,
  97. * certain integer types must be defined that are invariably
  98. * 2 and 4 bytes on all architectures.
  99. * Note WORD_BIT == 32 does not guarantee short == 16.
  100. */
  101. #if (WORD_BIT == 16)
  102. typedef int DtSrINT16;
  103. typedef unsigned int DtSrUINT16;
  104. #elif (WORD_BIT == 32)
  105. typedef short DtSrINT16;
  106. typedef unsigned short DtSrUINT16;
  107. #else
  108. #error Unable to typedef DtSrINT16 and DtSrUINT16
  109. #endif
  110. #if (WORD_BIT == 32)
  111. typedef int DtSrINT32;
  112. typedef unsigned int DtSrUINT32;
  113. #elif (LONG_BIT == 32)
  114. typedef long DtSrINT32;
  115. typedef unsigned long DtSrUINT32;
  116. #else
  117. #error Unable to typedef DtSrINT32 and DtSrUINT32
  118. #endif
  119. #ifndef DB_ADDR
  120. typedef DtSrINT32 DB_ADDR; /* vista.h: must be 4 bytes */
  121. #endif
  122. #ifndef TRUE
  123. #define TRUE 1
  124. #endif
  125. #ifndef FALSE
  126. #define FALSE 0
  127. #endif
  128. typedef DtSrUINT32 DtSrObjdate;
  129. /****************************************/
  130. /* */
  131. /* DtSrKeytype */
  132. /* */
  133. /****************************************/
  134. typedef struct {
  135. char is_selected; /* TRUE: user has selected this keytype */
  136. char ktchar; /* first char of opera record key */
  137. char name [DtSrMAX_KTNAME+1]; /* label string used in UI */
  138. } DtSrKeytype;
  139. /****************************************/
  140. /* */
  141. /* DtSrResult */
  142. /* */
  143. /****************************************/
  144. /* DtSrResult ormerly DITTO. DtSrObj types formerly ORT_. */
  145. typedef struct _DtSrResult {
  146. struct _DtSrResult *link; /* ptr to next list node */
  147. DtSrUINT32 flags; /* (reserved) */
  148. DtSrINT32 objflags; /* flags from object record */
  149. #define DtSrFlDELETE (1<<0) /* (reserved) */
  150. #define DtSrFlOLDNOTES (1<<1) /* (reserved) */
  151. #define DtSrFlNOTAVAIL (1<<2) /* object not retrievable from engine */
  152. DtSrUINT32 objuflags; /* user flags from database rec */
  153. DtSrINT32 objsize; /* in uncompressed bytes */
  154. DtSrObjdate objdate; /* zero means object 'undated' */
  155. DtSrINT16 objtype; /* from database record */
  156. #define DtSrObjUNKNOWN 0 /* object type unknown or not applicable */
  157. #define DtSrObjTEXT 1 /* generic, unformatted flat text */
  158. #define DtSrObjBINARY 2 /* generic binary object */
  159. #define DtSrObjSGML 3 /* generic SGML formatted document */
  160. #define DtSrObjHTML 4 /* HTML formatted document */
  161. #define DtSrObjPOSTSCR 6 /* Postscript document */
  162. #define DtSrObjINTERLF 7 /* Interleaf document */
  163. #define DtSrObjDTINFO 8 /* DtInfo document */
  164. DtSrINT16 objcost; /* (reserved) */
  165. int dbn; /* dbnamesv index */
  166. DB_ADDR dba; /* data base addr within database */
  167. DtSrINT16 language; /* language of the database */
  168. #define DtSrLaENG 0 /* English, ASCII char set (default) */
  169. #define DtSrLaENG2 1 /* English, ISO Latin-1 char set */
  170. #define DtSrLaESP 2 /* Spanish, ISO Latin-1 char set */
  171. #define DtSrLaFRA 3 /* French, ISO Latin-1 char set */
  172. #define DtSrLaITA 4 /* Italian, ISO Latin-1 char set */
  173. #define DtSrLaDEU 5 /* German, ISO Latin-1 char set */
  174. #define DtSrLaJPN 6 /* Japanese, EUC, auto kanji compounds */
  175. #define DtSrLaJPN2 7 /* Japanese, EUC, listed kanji compounds */
  176. #define DtSrLaLAST 7 /* Last supported DtSrLa constant */
  177. char reckey [DtSrMAX_DB_KEYSIZE]; /* object's db key */
  178. int proximity; /* 'distance' of object from query */
  179. char *abstractp; /* object's abstract from db*/
  180. } DtSrResult;
  181. /****************************************/
  182. /* */
  183. /* DtSrHitword */
  184. /* */
  185. /****************************************/
  186. typedef struct {
  187. long offset; /* word location in cleartext */
  188. long length; /* length of word */
  189. } DtSrHitword;
  190. /************************************************/
  191. /* */
  192. /* Functions */
  193. /* */
  194. /************************************************/
  195. extern void DtSearchAddMessage (char *msg);
  196. extern int DtSearchHasMessages (void);
  197. extern char *DtSearchGetMessages (void);
  198. extern void DtSearchFreeMessages (void);
  199. extern int DtSearchGetMaxResults (void);
  200. extern void DtSearchSetMaxResults (int new_max_results);
  201. extern char *DtSearchFormatObjdate (DtSrObjdate objdate);
  202. extern void DtSearchExit (int return_code);
  203. extern void DtSearchAddUserExit (void (*user_exit)(int));
  204. extern void DtSearchRemoveUserExit (void);
  205. extern int DtSearchSortResults (DtSrResult **list, int sort_type);
  206. #define DtSrSORT_PROX 1 /* sort on proximity */
  207. #define DtSrSORT_DATE 2 /* sort on objdate */
  208. extern int DtSearchMergeResults (DtSrResult **targ, DtSrResult **src);
  209. extern int DtSearchFreeResults (DtSrResult **list);
  210. extern DtSrObjdate
  211. DtSearchValidDateString (char *date_string);
  212. extern int DtSearchInit (
  213. char *argv0,
  214. char *userid,
  215. long switches,
  216. char *config_file,
  217. FILE *err_file,
  218. char ***dbnames,
  219. int *dbcount);
  220. /* Bit values valid for switches argument: */
  221. #define DtSrInNOLOCALE 0x0001L /* do not exec setlocale() */
  222. #define DtSrInSIGNAL 0x0002L /* register abort signal handlers */
  223. #define DtSrInUSEROCF 0x0004L /* (reserved) */
  224. #define DtSrInENAB_NOHUP 0x0008L /* enab nohup for backgnd progms */
  225. #define DtSrInIDEBUG 0x0010L /* set initialization debugging */
  226. #define DtSrInSDEBUG 0x0020L /* set search debugging */
  227. #define DtSrInRDEBUG 0x0040L /* set retrieval debugging */
  228. #define DtSrInCDEBUG 0x0080L /* set communications debugging */
  229. #define DtSrInANY_DEBUG \
  230. (DtSrInIDEBUG | DtSrInSDEBUG | DtSrInRDEBUG | DtSrInCDEBUG)
  231. #define DtSrInRDWR 0x0100L /* open db files for read and write */
  232. extern int DtSearchReinit (
  233. char ***dbnames,
  234. int *dbcount);
  235. extern int DtSearchGetKeytypes (
  236. char *dbname,
  237. int *ktcount,
  238. DtSrKeytype **keytypes);
  239. extern int DtSearchQuery (
  240. void *qry,
  241. char *dbname,
  242. int search_type,
  243. char *date1,
  244. char *date2,
  245. DtSrResult **results,
  246. long *resultscount,
  247. char *stems,
  248. int *stemcount);
  249. extern int DtSearchRetrieve (
  250. char *dbname,
  251. DB_ADDR dba,
  252. char **cleartext,
  253. long *clearlen,
  254. int *fzkeyi);
  255. extern int DtSearchHighlight (
  256. char *dbname,
  257. char *cleartext,
  258. DtSrHitword **hitwptr,
  259. long *hitwcount,
  260. int search_type,
  261. char *stems,
  262. int stemcount);
  263. /********************** Search.h ***********************/
  264. #endif /* _Search_h */