|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/access/ent2api.h |
source navigation diff markup identifier search freetext search file search |
1 /* ent2api.h
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information (NCBI)
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government do not place any restriction on its use or reproduction.
13 * We would, however, appreciate having the NCBI and the author cited in
14 * any work or product based on this material
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannot warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * ===========================================================================
25 *
26 * File Name: ent2api.h
27 *
28 * Author: Jonathan Kans
29 *
30 * Version Creation Date: 7/29/99
31 *
32 * $Revision: 1.30 $
33 *
34 * File Description:
35 *
36 * Modifications:
37 * --------------------------------------------------------------------------
38 *
39 * ==========================================================================
40 */
41
42 #ifndef _ENT2API_
43 #define _ENT2API_
44
45 #include <ncbi.h>
46 #include <asn.h>
47 #include <objent2.h>
48 #include <urlquery.h>
49
50 #undef NLM_EXTERN
51 #ifdef NLM_IMPORT
52 #define NLM_EXTERN NLM_IMPORT
53 #else
54 #define NLM_EXTERN extern
55 #endif
56
57
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61
62
63 /* See network connection test functions at bottom of this header */
64
65 /* See synchronous and asynchronous code examples at bottom of this header */
66
67 /* utility functions */
68
69 NLM_EXTERN void EntrezSetProgramName (
70 const char* progname
71 );
72
73 /* use Entrez2Test to override default Entrez2 ncbi named service */
74
75 NLM_EXTERN void EntrezSetService (
76 const char* service
77 );
78
79 /* low-level connection functions */
80
81 /*
82 EntrezOpenConnection now takes optional request
83 pointer, extracts db, and passes that to load
84 balancer.
85 */
86
87 NLM_EXTERN CONN EntrezOpenConnection (
88 Entrez2RequestPtr e2rq
89 );
90
91 NLM_EXTERN Entrez2ReplyPtr EntrezWaitForReply (
92 CONN conn
93 );
94
95 /*
96 EntrezSynchronousQuery opens connection, sends
97 Entrez2Request ASN.1 query, and waits for reply,
98 cleaning up connection afterwards.
99 */
100
101 NLM_EXTERN Entrez2ReplyPtr EntrezSynchronousQuery (
102 Entrez2RequestPtr e2rq
103 );
104
105 /*
106 EntrezAsynchronousQuery opens connection, sends
107 request, and queues completion routine using urlquery
108 queueing mechanism.
109
110 EntrezCheckQueue should be called several times a
111 second with a timer. It calls QUERY_CheckQueue to
112 poll connection, which calls completion routine when
113 result is available, cleaning up connection afterwards.
114
115 EntrezReadReply takes conn and status parameters from
116 completion routine and reads Entrez2ReplyPtr.
117 */
118
119 NLM_EXTERN Boolean EntrezAsynchronousQuery (
120 Entrez2RequestPtr e2rq,
121 QUEUE* queue,
122 QueryResultProc resultproc,
123 VoidPtr userdata
124 );
125
126 NLM_EXTERN Int4 EntrezCheckQueue (
127 QUEUE* queue
128 );
129
130 NLM_EXTERN Entrez2ReplyPtr EntrezReadReply (
131 CONN conn,
132 EIO_Status status
133 );
134
135 /* request creation functions */
136
137 NLM_EXTERN Entrez2IdListPtr EntrezCreateEntrezIdList (
138 const char* db,
139 Int4 uid,
140 Int4 num,
141 const Int4 uids[],
142 ByteStorePtr bs
143 );
144
145 NLM_EXTERN Entrez2LimitsPtr EntrezCreateEntrezLimits (
146 Int4 begin_date,
147 Int4 end_date,
148 const char* type_date,
149 Int4 max_uids,
150 Int4 offset_uids
151 );
152
153 NLM_EXTERN Entrez2RequestPtr EntrezCreateGetInfoRequest (
154 void
155 );
156
157 NLM_EXTERN Entrez2RequestPtr EntrezCreateBooleanRequest (
158 Boolean return_uids,
159 Boolean return_parsed,
160 const char* db,
161 const char* query_string,
162 Int4 begin_date,
163 Int4 end_date,
164 const char* type_date,
165 Int4 max_uids,
166 Int4 offset_uids
167 );
168
169 #define ENTREZ_OP_NONE 0
170 #define ENTREZ_OP_AND 1
171 #define ENTREZ_OP_OR 2
172 #define ENTREZ_OP_BUTNOT 3
173 #define ENTREZ_OP_RANGE 4
174 #define ENTREZ_OP_LEFT_PAREN 5
175 #define ENTREZ_OP_RIGHT_PAREN 6
176
177 NLM_EXTERN void EntrezAddToBooleanRequest (
178 Entrez2RequestPtr e2rp,
179 const char* query_string,
180 Int4 op,
181 const char* field,
182 const char* term,
183 const char* key,
184 Int4 uid,
185 Int4 num,
186 const Int4 uids[],
187 ByteStorePtr bs,
188 Boolean do_not_explode,
189 Boolean do_not_translate
190 );
191
192 #define EntrezCreateDocsumRequest EntrezCreateDocSumRequest
193 NLM_EXTERN Entrez2RequestPtr EntrezCreateDocSumRequest (
194 const char* db,
195 Int4 uid,
196 Int4 num,
197 const Int4 uids[],
198 ByteStorePtr bs
199 );
200
201 #define EntrezCreateGetTermPosRequest EntrezCreateGetTermPositionRequest
202 NLM_EXTERN Entrez2RequestPtr EntrezCreateGetTermPositionRequest (
203 const char* db,
204 const char* field,
205 const char* term
206 );
207
208 NLM_EXTERN Entrez2RequestPtr EntrezCreateGetTermListRequest (
209 const char* db,
210 const char* field,
211 Int4 first_term_pos,
212 Int4 num_terms
213 );
214
215 NLM_EXTERN Entrez2RequestPtr EntrezCreateGetTermHierarchyRequest (
216 const char* db,
217 const char* field,
218 const char* term,
219 Int4 txid
220 );
221
222 NLM_EXTERN Entrez2RequestPtr EntrezCreateGetLinksRequest (
223 const char* db,
224 Int4 uid,
225 Int4 num,
226 const Int4 uids[],
227 ByteStorePtr bs,
228 const char* linktype,
229 Int4 max_uids,
230 Boolean count_only,
231 Boolean parents_persist
232 );
233
234 NLM_EXTERN Entrez2RequestPtr EntrezCreateGetLinkedRequest (
235 const char* db,
236 Int4 uid,
237 Int4 num,
238 const Int4 uids[],
239 ByteStorePtr bs,
240 const char* linktype,
241 Int4 max_uids,
242 Boolean count_only,
243 Boolean parents_persist
244 );
245
246 NLM_EXTERN Entrez2RequestPtr EntrezCreateGetLinkCountsRequest (
247 const char* db,
248 Int4 uid
249 );
250
251 /* history needs to be used for Boolean ids and key queries */
252
253 NLM_EXTERN void EntrezSetUseHistoryFlag (
254 Entrez2RequestPtr e2rq
255 );
256
257 /* reply extraction functions - these free the enclosing Entrez2ReplyPtr */
258
259 NLM_EXTERN char* EntrezExtractErrorReply (
260 Entrez2ReplyPtr e2ry
261 );
262
263 NLM_EXTERN Entrez2InfoPtr EntrezExtractInfoReply (
264 Entrez2ReplyPtr e2ry
265 );
266
267 NLM_EXTERN Entrez2BooleanReplyPtr EntrezExtractBooleanReply (
268 Entrez2ReplyPtr e2ry
269 );
270
271 NLM_EXTERN Entrez2DocsumListPtr EntrezExtractDocsumReply (
272 Entrez2ReplyPtr e2ry
273 );
274
275 NLM_EXTERN Int4 EntrezExtractTermPosReply (
276 Entrez2ReplyPtr e2ry
277 );
278
279 NLM_EXTERN Entrez2TermListPtr EntrezExtractTermListReply (
280 Entrez2ReplyPtr e2ry
281 );
282
283 NLM_EXTERN Entrez2HierNodePtr EntrezExtractHierNodeReply (
284 Entrez2ReplyPtr e2ry
285 );
286
287 NLM_EXTERN Entrez2LinkSetPtr EntrezExtractLinksReply (
288 Entrez2ReplyPtr e2ry
289 );
290
291 NLM_EXTERN Entrez2IdListPtr EntrezExtractLinkedReply (
292 Entrez2ReplyPtr e2ry
293 );
294
295 NLM_EXTERN Entrez2LinkCountListPtr EntrezExtractLinkCountReply (
296 Entrez2ReplyPtr e2ry
297 );
298
299 /* special SeqIdString to UID convenience function */
300
301 NLM_EXTERN Uint4 EntrezGetUIDforSeqIdString (
302 const char* db,
303 const char* seq_id_string
304 );
305
306 /* result validation function */
307
308 NLM_EXTERN Boolean ValidateEntrez2InfoPtr (
309 Entrez2InfoPtr e2ip,
310 ValNodePtr PNTR head
311 );
312
313 NLM_EXTERN Boolean ValidateEntrez2InfoPtrEx (
314 Entrez2InfoPtr e2ip,
315 ValNodePtr PNTR head,
316 Boolean checkMenuNameVariants
317 );
318
319 /* sample synchronous query code:
320
321 {
322 Entrez2RequestPtr e2rq;
323 Entrez2ReplyPtr e2ry;
324
325 e2rq = EntrezCreateDocSumRequest ("nucleotide", 1322283, 0, NULL, NULL);
326 e2ry = EntrezSynchronousQuery (e2rq);
327 e2rq = Entrez2RequestFree (e2rq);
328 ...
329 Entrez2ReplyFree (e2ry); -- except if you already extracted subreply
330
331 }
332
333 */
334
335 /* sample asynchronous query code:
336
337 callback (completion routine):
338
339 static Boolean LIBCALLBACK MyQueryResultProc (
340 CONN conn,
341 VoidPtr userdata,
342 EIO_Status status
343 )
344
345 {
346 Entrez2ReplyPtr e2ry;
347
348 e2ry = EntrezReadReply (conn, status);
349 if (e2ry != NULL) {
350 ...
351 Entrez2ReplyFree (e2ry); -- except if you already extracted subreply
352 return TRUE;
353 }
354 return FALSE;
355 }
356
357 static queue variable:
358
359 static QUEUE myquerylist = NULL;
360
361 calling function:
362
363 {
364 Entrez2RequestPtr e2rq;
365
366 e2rq = EntrezCreateDocSumRequest ("nucleotide", 1322283, 0, NULL, NULL);
367 EntrezAsynchronousQuery (e2rq, &myquerylist, MyQueryResultProc, NULL);
368 e2rq = Entrez2RequestFree (e2rq);
369 }
370
371 via timer call:
372
373 {
374 EntrezCheckQueue (&myquerylist);
375 }
376
377 */
378
379 /* network connection test functions */
380
381 NLM_EXTERN Boolean NetTestAsynchronousQuery (
382 QUEUE* queue,
383 QueryResultProc resultproc,
384 VoidPtr userdata
385 );
386
387 NLM_EXTERN Boolean NetTestReadReply (
388 CONN conn,
389 EIO_Status status
390 );
391
392 NLM_EXTERN Int4 NetTestCheckQueue (
393 QUEUE* queue
394 );
395
396
397
398 #ifdef __cplusplus
399 }
400 #endif
401
402 #undef NLM_EXTERN
403 #ifdef NLM_EXPORT
404 #define NLM_EXTERN NLM_EXPORT
405 #else
406 #define NLM_EXTERN
407 #endif
408
409 #endif /* _ENT2API_ */
410
411 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |