~ubuntu-branches/ubuntu/precise/ncbi-tools6/precise

« back to all changes in this revision

Viewing changes to network/spell/client/objspell.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2005-03-27 12:00:15 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050327120015-embhesp32nj73p9r
Tags: 6.1.20041020-3
* Fix FTBFS under GCC 4.0 caused by inconsistent use of "static" on
  functions.  (Closes: #295110.)
* Add a watch file, now that we can.  (Upstream's layout needs version=3.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
*
 
3
*
 
4
* RCS Modification History:
 
5
* $Log: objspell.c,v $
 
6
* Revision 6.0  1997/08/25 18:40:24  madden
 
7
* Revision changed to 6.0
 
8
*
 
9
* Revision 4.0  1995/07/26 13:55:42  ostell
 
10
* force revision to 4.0
 
11
*
 
12
 * Revision 1.2  1995/05/17  17:59:51  epstein
 
13
 * add RCS log revision history
 
14
 *
 
15
*/
 
16
 
 
17
#include <asn.h>
 
18
 
 
19
#define NLM_GENERATED_CODE_PROTO
 
20
 
 
21
#include "objspell.h"
 
22
 
 
23
static Boolean loaded = FALSE;
 
24
 
 
25
#include "spell.h"
 
26
 
 
27
#ifndef NLM_EXTERN_LOADS
 
28
#define NLM_EXTERN_LOADS {}
 
29
#endif
 
30
 
 
31
static Boolean
 
32
objspellAsnLoad(void)
 
33
{
 
34
 
 
35
   if ( ! loaded) {
 
36
      NLM_EXTERN_LOADS
 
37
 
 
38
      if ( ! AsnLoad ())
 
39
      return FALSE;
 
40
      loaded = TRUE;
 
41
   }
 
42
 
 
43
   return TRUE;
 
44
}
 
45
 
 
46
 
 
47
 
 
48
/**************************************************
 
49
*    Generated object loaders for Module NCBI-SPELL
 
50
*
 
51
**************************************************/
 
52
 
 
53
 
 
54
/**************************************************
 
55
*
 
56
*    SpellRequestFree()
 
57
*
 
58
**************************************************/
 
59
 
 
60
SpellRequestPtr LIBCALL
 
61
SpellRequestFree(ValNodePtr anp)
 
62
{
 
63
   Pointer pnt;
 
64
 
 
65
   if (anp == NULL) {
 
66
      return NULL;
 
67
   }
 
68
 
 
69
   pnt = anp->data.ptrvalue;
 
70
   switch (anp->choice)
 
71
   {
 
72
   default:
 
73
      break;
 
74
   case SpellRequest_spelltext:
 
75
      MemFree(anp -> data.ptrvalue);
 
76
      break;
 
77
   }
 
78
   return MemFree(anp);
 
79
}
 
80
 
 
81
 
 
82
/**************************************************
 
83
*
 
84
*    SpellRequestAsnRead()
 
85
*
 
86
**************************************************/
 
87
 
 
88
SpellRequestPtr LIBCALL
 
89
SpellRequestAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
90
{
 
91
   DataVal av;
 
92
   AsnTypePtr atp;
 
93
   ValNodePtr anp;
 
94
   Uint1 choice;
 
95
   Boolean isError;
 
96
   AsnReadFunc func;
 
97
 
 
98
   if (! loaded)
 
99
   {
 
100
      if (! objspellAsnLoad()) {
 
101
         return NULL;
 
102
      }
 
103
   }
 
104
 
 
105
   if (aip == NULL) {
 
106
      return NULL;
 
107
   }
 
108
 
 
109
   if (orig == NULL) {         /* SpellRequest ::= (self contained) */
 
110
      atp = AsnReadId(aip, amp, SPELL_REQUEST);
 
111
   } else {
 
112
      atp = AsnLinkType(orig, SPELL_REQUEST);    /* link in local tree */
 
113
   }
 
114
   if (atp == NULL) {
 
115
      return NULL;
 
116
   }
 
117
 
 
118
   anp = ValNodeNew(NULL);
 
119
   if (anp == NULL) {
 
120
      goto erret;
 
121
   }
 
122
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
 
123
      goto erret;
 
124
   }
 
125
 
 
126
   func = NULL;
 
127
 
 
128
   atp = AsnReadId(aip, amp, atp);  /* find the choice */
 
129
   if (atp == NULL) {
 
130
      goto erret;
 
131
   }
 
132
   if (atp == SPELL_REQUEST_init) {
 
133
      choice = SpellRequest_init;
 
134
      if (AsnReadVal(aip, atp, &av) <= 0) {
 
135
         goto erret;
 
136
      }
 
137
      anp->data.intvalue = av.intvalue;
 
138
   }
 
139
   else if (atp == SPELL_REQUEST_spelltext) {
 
140
      choice = SpellRequest_spelltext;
 
141
      if (AsnReadVal(aip, atp, &av) <= 0) {
 
142
         goto erret;
 
143
      }
 
144
      anp->data.ptrvalue = av.ptrvalue;
 
145
   }
 
146
   else if (atp == SPELL_REQUEST_fini) {
 
147
      choice = SpellRequest_fini;
 
148
      if (AsnReadVal(aip, atp, &av) <= 0) {
 
149
         goto erret;
 
150
      }
 
151
      anp->data.intvalue = av.intvalue;
 
152
   }
 
153
   anp->choice = choice;
 
154
   if (func != NULL)
 
155
   {
 
156
      anp->data.ptrvalue = (* func)(aip, atp);
 
157
      if (anp->data.ptrvalue == NULL) {
 
158
         goto erret;
 
159
      }
 
160
   }
 
161
 
 
162
ret:
 
163
   AsnUnlinkType(orig);       /* unlink local tree */
 
164
   return anp;
 
165
 
 
166
erret:
 
167
   anp = MemFree(anp);
 
168
   goto ret;
 
169
}
 
170
 
 
171
 
 
172
/**************************************************
 
173
*
 
174
*    SpellRequestAsnWrite()
 
175
*
 
176
**************************************************/
 
177
Boolean LIBCALL 
 
178
SpellRequestAsnWrite(SpellRequestPtr anp, AsnIoPtr aip, AsnTypePtr orig)
 
179
 
 
180
{
 
181
   DataVal av;
 
182
   AsnTypePtr atp, writetype = NULL;
 
183
   Pointer pnt;
 
184
   AsnWriteFunc func = NULL;
 
185
   Boolean retval = FALSE;
 
186
 
 
187
   if (! loaded)
 
188
   {
 
189
      if (! objspellAsnLoad())
 
190
      return FALSE;
 
191
   }
 
192
 
 
193
   if (aip == NULL)
 
194
   return FALSE;
 
195
 
 
196
   atp = AsnLinkType(orig, SPELL_REQUEST);   /* link local tree */
 
197
   if (atp == NULL) {
 
198
      return FALSE;
 
199
   }
 
200
 
 
201
   if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
202
 
 
203
   av.ptrvalue = (Pointer)anp;
 
204
   if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
 
205
      goto erret;
 
206
   }
 
207
 
 
208
   pnt = anp->data.ptrvalue;
 
209
   av.intvalue = anp->data.intvalue;
 
210
   switch (anp->choice)
 
211
   {
 
212
   case SpellRequest_init:
 
213
      retval = AsnWrite(aip, SPELL_REQUEST_init, &av);
 
214
      break;
 
215
   case SpellRequest_spelltext:
 
216
      retval = AsnWrite(aip, SPELL_REQUEST_spelltext, &av);
 
217
      break;
 
218
   case SpellRequest_fini:
 
219
      retval = AsnWrite(aip, SPELL_REQUEST_fini, &av);
 
220
      break;
 
221
   }
 
222
   if (writetype != NULL) {
 
223
      retval = (* func)(pnt, aip, writetype);   /* write it out */
 
224
   }
 
225
   if (!retval) {
 
226
      goto erret;
 
227
   }
 
228
   retval = TRUE;
 
229
 
 
230
erret:
 
231
   AsnUnlinkType(orig);       /* unlink local tree */
 
232
   return retval;
 
233
}
 
234
 
 
235
 
 
236
/**************************************************
 
237
*
 
238
*    SpellResponseFree()
 
239
*
 
240
**************************************************/
 
241
 
 
242
SpellResponsePtr LIBCALL
 
243
SpellResponseFree(ValNodePtr anp)
 
244
{
 
245
   Pointer pnt;
 
246
 
 
247
   if (anp == NULL) {
 
248
      return NULL;
 
249
   }
 
250
 
 
251
   pnt = anp->data.ptrvalue;
 
252
   switch (anp->choice)
 
253
   {
 
254
   default:
 
255
      break;
 
256
   case SpellResponse_spelltext:
 
257
      AsnGenericBaseSeqOfFree((ValNodePtr) pnt,ASNCODE_PTRVAL_SLOT);
 
258
      break;
 
259
   }
 
260
   return MemFree(anp);
 
261
}
 
262
 
 
263
 
 
264
/**************************************************
 
265
*
 
266
*    SpellResponseAsnRead()
 
267
*
 
268
**************************************************/
 
269
 
 
270
SpellResponsePtr LIBCALL
 
271
SpellResponseAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
272
{
 
273
   DataVal av;
 
274
   AsnTypePtr atp;
 
275
   ValNodePtr anp;
 
276
   Uint1 choice;
 
277
   Boolean isError;
 
278
   AsnReadFunc func;
 
279
 
 
280
   if (! loaded)
 
281
   {
 
282
      if (! objspellAsnLoad()) {
 
283
         return NULL;
 
284
      }
 
285
   }
 
286
 
 
287
   if (aip == NULL) {
 
288
      return NULL;
 
289
   }
 
290
 
 
291
   if (orig == NULL) {         /* SpellResponse ::= (self contained) */
 
292
      atp = AsnReadId(aip, amp, SPELL_RESPONSE);
 
293
   } else {
 
294
      atp = AsnLinkType(orig, SPELL_RESPONSE);    /* link in local tree */
 
295
   }
 
296
   if (atp == NULL) {
 
297
      return NULL;
 
298
   }
 
299
 
 
300
   anp = ValNodeNew(NULL);
 
301
   if (anp == NULL) {
 
302
      goto erret;
 
303
   }
 
304
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the CHOICE or OpenStruct value (nothing) */
 
305
      goto erret;
 
306
   }
 
307
 
 
308
   func = NULL;
 
309
 
 
310
   atp = AsnReadId(aip, amp, atp);  /* find the choice */
 
311
   if (atp == NULL) {
 
312
      goto erret;
 
313
   }
 
314
   if (atp == SPELL_RESPONSE_error) {
 
315
      choice = SpellResponse_error;
 
316
      if (AsnReadVal(aip, atp, &av) <= 0) {
 
317
         goto erret;
 
318
      }
 
319
      anp->data.intvalue = av.intvalue;
 
320
   }
 
321
   else if (atp == SPELL_RESPONSE_init) {
 
322
      choice = SpellResponse_init;
 
323
      if (AsnReadVal(aip, atp, &av) <= 0) {
 
324
         goto erret;
 
325
      }
 
326
      anp->data.intvalue = av.intvalue;
 
327
   }
 
328
   else if (atp == SPELL_RESPONSE_spelltext) {
 
329
      choice = SpellResponse_spelltext;
 
330
      anp -> data.ptrvalue = 
 
331
      AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_PTRVAL_SLOT, &isError);
 
332
      if (isError && anp -> data.ptrvalue == NULL) {
 
333
         goto erret;
 
334
      }
 
335
   }
 
336
   else if (atp == SPELL_RESPONSE_fini) {
 
337
      choice = SpellResponse_fini;
 
338
      if (AsnReadVal(aip, atp, &av) <= 0) {
 
339
         goto erret;
 
340
      }
 
341
      anp->data.intvalue = av.intvalue;
 
342
   }
 
343
   anp->choice = choice;
 
344
   if (func != NULL)
 
345
   {
 
346
      anp->data.ptrvalue = (* func)(aip, atp);
 
347
      if (anp->data.ptrvalue == NULL) {
 
348
         goto erret;
 
349
      }
 
350
   }
 
351
 
 
352
ret:
 
353
   AsnUnlinkType(orig);       /* unlink local tree */
 
354
   return anp;
 
355
 
 
356
erret:
 
357
   anp = MemFree(anp);
 
358
   goto ret;
 
359
}
 
360
 
 
361
 
 
362
/**************************************************
 
363
*
 
364
*    SpellResponseAsnWrite()
 
365
*
 
366
**************************************************/
 
367
Boolean LIBCALL 
 
368
SpellResponseAsnWrite(SpellResponsePtr anp, AsnIoPtr aip, AsnTypePtr orig)
 
369
 
 
370
{
 
371
   DataVal av;
 
372
   AsnTypePtr atp, writetype = NULL;
 
373
   Pointer pnt;
 
374
   AsnWriteFunc func = NULL;
 
375
   Boolean retval = FALSE;
 
376
 
 
377
   if (! loaded)
 
378
   {
 
379
      if (! objspellAsnLoad())
 
380
      return FALSE;
 
381
   }
 
382
 
 
383
   if (aip == NULL)
 
384
   return FALSE;
 
385
 
 
386
   atp = AsnLinkType(orig, SPELL_RESPONSE);   /* link local tree */
 
387
   if (atp == NULL) {
 
388
      return FALSE;
 
389
   }
 
390
 
 
391
   if (anp == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
392
 
 
393
   av.ptrvalue = (Pointer)anp;
 
394
   if (! AsnWriteChoice(aip, atp, (Int2)anp->choice, &av)) {
 
395
      goto erret;
 
396
   }
 
397
 
 
398
   pnt = anp->data.ptrvalue;
 
399
   av.intvalue = anp->data.intvalue;
 
400
   switch (anp->choice)
 
401
   {
 
402
   case SpellResponse_error:
 
403
      retval = AsnWrite(aip, SPELL_RESPONSE_error, &av);
 
404
      break;
 
405
   case SpellResponse_init:
 
406
      retval = AsnWrite(aip, SPELL_RESPONSE_init, &av);
 
407
      break;
 
408
   case SpellResponse_spelltext:
 
409
      retval = AsnGenericBaseSeqOfAsnWrite((Pointer) pnt,ASNCODE_PTRVAL_SLOT, aip, SPELL_RESPONSE_spelltext, SPELL_RESPONSE_spelltext_E);            break;
 
410
   case SpellResponse_fini:
 
411
      retval = AsnWrite(aip, SPELL_RESPONSE_fini, &av);
 
412
      break;
 
413
   }
 
414
   if (writetype != NULL) {
 
415
      retval = (* func)(pnt, aip, writetype);   /* write it out */
 
416
   }
 
417
   if (!retval) {
 
418
      goto erret;
 
419
   }
 
420
   retval = TRUE;
 
421
 
 
422
erret:
 
423
   AsnUnlinkType(orig);       /* unlink local tree */
 
424
   return retval;
 
425
}