|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/asnlib/asntool.c |
source navigation diff markup identifier search freetext search file search |
1 /* asntool.c
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
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 have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * File Name: asntool.c
27 *
28 * Author: James Ostell
29 *
30 * Version Creation Date: 1/1/91
31 *
32 * $Revision: 6.17 $
33 *
34 * File Description:
35 * Main routine for asntool. Uses the ASN.1 library routines to perform
36 * analysis and display of ASN.1 module specifications and associated
37 * value files. Can also produce the ASN.1 parse tree as a C header file.
38 *
39 * Modifications:
40 * --------------------------------------------------------------------------
41 * Date Name Description of modification
42 * ------- ---------- -----------------------------------------------------
43 *
44 *
45 * $Log: asntool.c,v $
46 * Revision 6.17 2009/11/05 16:54:12 gouriano
47 * Added option to use quoted syntax form to include headers. JIRA: CXX-1402
48 *
49 * Revision 6.16 2005/01/24 17:12:11 kans
50 * added force_choice_struct (-V) to force struct plus object instead of ValNode for choices - for compatibility with old hand-coded object loaders
51 *
52 * Revision 6.15 2004/07/08 15:27:37 kans
53 * commented out second unnecessary call to GetArgs
54 *
55 * Revision 6.14 2004/04/01 13:43:05 lavr
56 * Spell "occurred", "occurrence", and "occurring"
57 *
58 * Revision 6.13 2001/10/11 14:39:08 ostell
59 * added support for XMLModulePrefix
60 *
61 * Revision 6.12 2001/07/07 00:46:15 juran
62 * A vain attempt to plug serious memory leakage.
63 *
64 * Revision 6.11 2001/07/03 20:04:02 juran
65 * Oops, don't redefine NULL after all.
66 *
67 * Revision 6.10 2001/06/28 02:19:39 juran
68 * Mac compatibility:
69 * Redefine NULL to 0L, which gets promoted to any pointer type.
70 * Cast result of MemNew() and MemFree() to appropriate pointer type.
71 *
72 * Revision 6.9 2001/06/12 14:45:17 lewisg
73 * reindent to make readable
74 *
75 * Revision 6.8 2000/08/11 14:01:46 beloslyu
76 * fix the bug. Karl
77 *
78 * Revision 6.7 2000/07/25 20:30:57 ostell
79 * added support for printing multiple ASN.1 modules as multiple XML DTD and .mod files
80 *
81 * Revision 6.6 2000/05/10 17:45:00 ostell
82 * fixed duplicate command line arguments
83 *
84 * Revision 6.5 2000/05/10 03:12:37 ostell
85 * added support for XML DTD and XML data output
86 *
87 * Revision 6.4 1998/03/25 23:31:39 kans
88 * params to register new object manager type, give optional non-default label
89 *
90 * Revision 6.3 1998/03/23 23:07:10 kans
91 * added K parameter for force name of included asn header in asncode-generated object loader
92 *
93 * Revision 6.2 1997/12/16 21:16:50 sirotkin
94 * command line processing fix
95 *
96 * Revision 6.0 1997/08/25 18:10:22 madden
97 * Revision changed to 6.0
98 *
99 * Revision 5.1 1996/11/26 20:02:42 vakatov
100 * Added ErrClear() after GetArgs() to disable warnings occurred during
101 * the reading of configuration files
102 *
103 * Revision 5.0 1996/05/28 14:00:29 ostell
104 * Set to revision 5.0
105 *
106 * Revision 4.1 1995/12/21 22:03:54 epstein
107 * generate clean exit in case of bad amp pointer
108 *
109 * Revision 4.0 1995/07/26 13:47:38 ostell
110 * force revision to 4.0
111 *
112 * Revision 2.6 1995/05/15 18:38:28 ostell
113 * added Log line
114 *
115 *
116 * ==========================================================================
117 */
118 /*****************************************************************************
119 *
120 * asntool.c
121 * -m ModuleFile (an asn.1 specification)
122 * -v ValueFile (print values for input)
123 * -o OutputFile (for module structs header)
124 * -e EncodeFile (for output of BER encode value)
125 * -d DecodeFile (for input of BER encoded value)
126 * -p PrintFile (print value to file)
127 * -f ModoutFile (print modules to file)
128 * -l Loadable File + header file
129 * -b Size (set AsnIo buffer size)
130 * -w Length (Word length for #defines in output header file)
131 *
132 * read, validate, and display an asn1 module specification
133 *
134 *****************************************************************************/
135
136 #include "asnbuild.h"
137 #include "asntool.h"
138
139 extern void AsnTxtReadValFile PROTO((AsnModulePtr amp, AsnIoPtr aip, AsnIoPtr aipout,
140 AsnIoPtr encode, AsnIoPtr xaipout));
141 extern void AsnBinReadValFile PROTO((AsnTypePtr atp, AsnIoPtr aip, AsnIoPtr aipout,
142 AsnIoPtr encode, AsnIoPtr xaipout));
143
144 #define NUMARGS 27
145
146 Args asnargs[NUMARGS] = {
147 {"ASN.1 Module File",NULL,NULL,NULL,FALSE,'m',ARG_FILE_IN,0.0,0,NULL},
148 {"ASN.1 Module File", NULL,NULL,NULL,TRUE,'f',ARG_FILE_OUT,0.0,0,NULL},
149 {"XML DTD File\n\t(\"m\" to print each module to a separate file)", NULL,NULL,NULL,TRUE,'X',ARG_FILE_OUT,0.0,0,NULL},
150 {"ASN.1 Tree Dump File", NULL,NULL,NULL,TRUE,'T',ARG_FILE_OUT,0.0,0,NULL},
151 {"Print Value File",NULL,NULL,NULL,TRUE,'v',ARG_FILE_IN,0.0,0,NULL},
152 {"Print Value File",NULL,NULL,NULL,TRUE,'p',ARG_FILE_OUT,0.0,0,NULL},
153 {"XML Data File", NULL,NULL,NULL,TRUE,'x',ARG_FILE_OUT,0.0,0,NULL},
154 {"Binary Value File (type required)",NULL,NULL,NULL,TRUE,'d',ARG_FILE_IN,0.0,0,NULL},
155 {"Binary Value Type",NULL,NULL,NULL,TRUE,'t',ARG_STRING,0.0,0,NULL},
156 {"Binary Value File",NULL,NULL,NULL,TRUE,'e',ARG_FILE_OUT,0.0,0,NULL},
157 {"Header File",NULL,NULL,NULL,TRUE,'o',ARG_FILE_OUT,0.0,0,NULL},
158 {"Loader File",NULL,NULL,NULL,TRUE,'l',ARG_FILE_OUT,0.0,0,NULL},
159 {"Buffer Size","1024","512","10000",TRUE,'b',ARG_INT,0.0,0,NULL},
160 {"Word length maximum for #defines","31","31","128",TRUE,'w',ARG_INT,0.0,0,NULL},
161
162 {"Generate object loader .c and .h files, \n\tif used, see below parameters:","F",NULL,NULL,TRUE,'G',ARG_BOOLEAN,0.0,0,NULL},
163
164
165 {"ASN.1 module filenames, comma separated used for external refs from the \'m\', but no other action taken", NULL, NULL, NULL, TRUE, 'M', ARG_FILE_IN, 0.0, 0, NULL},
166 {"Base for filename, without extensions, for generated objects and code", NULL, NULL, NULL, TRUE, 'B', ARG_FILE_OUT, 0.0, 0, NULL},
167 {"During code generation, debugging level\n 0 - No debugging\n 1 - Shallow debugging\n 2 - Deep", "0", "0", "9", TRUE, 'D', ARG_INT, 0.0, 0, NULL},
168 {"Debugging filename", "stderr", NULL, NULL, TRUE, 'S', ARG_FILE_OUT, 0.0, 0, NULL},
169 {"In generated .c, add #include to this filename", NULL, NULL, NULL, TRUE, 'I', ARG_STRING, 0.0, 0, NULL},
170 {"Bit twiddle for optional zero value base slots","F",NULL,NULL,TRUE,'Z',ARG_BOOLEAN,0.0,0,NULL},
171 {"In generated .c, forces name of #included asn header", NULL, NULL, NULL, TRUE, 'K', ARG_STRING, 0.0, 0, NULL},
172 {"Register type with object manager", NULL, NULL, NULL, TRUE, 'J', ARG_STRING, 0.0, 0, NULL},
173 {"Label for registered type", NULL, NULL, NULL, TRUE, 'L', ARG_STRING, 0.0, 0, NULL},
174 {"XML module prefix for DOCTYPE", NULL, NULL, NULL, TRUE, 'P', ARG_STRING, 0.0, 0, NULL},
175 {"Force choice to use structure instead of ValNodePtr","F",NULL,NULL,TRUE,'V',ARG_BOOLEAN,0.0,0,NULL},
176 /*-- not used now {"Asnload directory [for parsetrees]", NULL, NULL, NULL, TRUE, 'd', ARG_FILE_IN, 0.0, 0, NULL}, -----------*/
177
178 {"Use quoted syntax form for generated include files","F",NULL,NULL,TRUE,'Q',ARG_BOOLEAN,0.0,0,NULL},
179
180 };
181
182 Int2 Main (void)
183 {
184 Int2 m_argModuleIn=0, f_arg_moduleOut=1,
185 X_argDTDModuleOut=2, T_argTreeDumpOut=3,
186 v_argPrintFileIn = 4, p_argPrintFileOut = 5,
187 x_argXMLDataOut=6, d_argBinaryFileIn = 7
188 , t_argAsnTypeName = 8, e_argBinaryFileOut = 9
189 , o_argHeadFile = 10, l_argLoadFile = 11
190 , b_argBufferSize = 12, w_argTokenMax = 13
191 /*--- args below here are capitilized and for code generation, only--*/
192 /*-- Except for the 'M' arg, which will also affect normal use ---*/
193 , G_argGenerateCode = 14, M_argMoreModuleFiles = 15
194 , B_argCodeFileName = 16, D_argCodeGenDebugLevel = 17
195 , S_argDebugFileName = 18, I_argExtraIncludeName = 19
196 , Z_argBitTwiddle = 20, K_argLoadName = 21
197 , J_objMgrEntry = 22, L_objMgrLabel = 23, P_argXMLmodulePrefix = 24
198 , V_argChoiceStruct = 25, Q_argQuoted = 26;
199
200 AsnIoPtr aip = NULL,
201 aipout = NULL,
202 xaipout = NULL,
203 aipencode = NULL;
204 FILE * fp;
205 AsnModulePtr amp = NULL,
206 currentmod = NULL,
207 nextmod, thisamp;
208 AsnTypePtr atp;
209 Boolean print_each_module = FALSE;
210 AsnCodeInfoPtr acip = (AsnCodeInfoPtr)MemNew(sizeof(AsnCodeInfo));
211 CharPtr filename = NULL, p, last_comma, objmgrentry = NULL;
212 int len;
213
214
215 /* never abort on error, but show it */
216 ErrSetFatalLevel(SEV_MAX);
217 ErrSetMessageLevel(SEV_MIN);
218 asnargs[P_argXMLmodulePrefix].defaultvalue = (const char *)AsnGetXMLmodulePrefix();
219
220 if (! GetArgs("AsnTool 4", NUMARGS, asnargs))
221 return 1;
222 ErrClear();
223
224 AsnSetXMLmodulePrefix((CharPtr)(asnargs[P_argXMLmodulePrefix].strvalue));
225
226 /*
227 if (! GetArgs("AsnTool 4", NUMARGS, asnargs))
228 return 1;
229 ErrClear();
230 */
231
232 if (! AsnIoSetBufsize(NULL, (Int2)asnargs[b_argBufferSize].intvalue))
233 return 1;
234
235 if ((aip = AsnIoOpen(asnargs[m_argModuleIn].strvalue, "r")) == NULL)
236 {
237 ErrShow();
238 return 1;
239 }
240
241 acip -> loadname = asnargs[m_argModuleIn].strvalue;
242
243 if (asnargs[K_argLoadName].strvalue != NULL) {
244 acip -> loadname = asnargs[K_argLoadName].strvalue; /* overrides m_argModuleIn, if set */
245 }
246
247 if (asnargs[e_argBinaryFileOut].strvalue != NULL) /* output a binary value file */
248 if ((aipencode = AsnIoOpen(asnargs[e_argBinaryFileOut].strvalue, "wb")) == NULL)
249 {
250 ErrShow();
251 return 1;
252 }
253
254 /** parse the module(s) ***/
255
256 if (asnargs[f_arg_moduleOut].strvalue != NULL)
257 {
258 if ((aipout = AsnIoOpen(asnargs[f_arg_moduleOut].strvalue, "w")) == NULL)
259 {
260 ErrShow();
261 return 1;
262 }
263 }
264
265 thisamp = NULL;
266 while ((nextmod = AsnLexTReadModule(aip)) != NULL )
267 {
268 if (thisamp == NULL)
269 thisamp = nextmod;
270
271 if (amp == NULL)
272 amp = nextmod;
273 else
274 currentmod->next = nextmod;
275 currentmod = nextmod;
276 }
277 acip -> last_amp = currentmod; /* last module of main file */
278 AsnStoreTree(acip->loadname, thisamp); /* store and link tree */
279
280 /*--- read additional module files that will be used for everything
281 but code generation.
282 ---*/
283
284 if (asnargs[M_argMoreModuleFiles].strvalue != NULL)
285 for (p = asnargs[M_argMoreModuleFiles].strvalue; *p; p = last_comma + 1) {
286 /*--- extract next filename for reading ASN.1 definitions ---*/
287 for (last_comma = p; *last_comma; last_comma++) {
288 if (*last_comma == ',')
289 break;
290 }
291 len = last_comma - p;
292 filename = (char *)MemFree (filename);
293 filename = (char *)MemNew (len + 1);
294 StringNCpy (filename, p, len);
295 filename[len] = '\0';
296 #ifdef WIN_DUMB
297 printf ("Loading %s \n", filename);
298 #endif
299
300 if ((aip = AsnIoOpen(filename, "r")) == NULL)
301 {
302 ErrShow();
303 return 1;
304 }
305 /*--- read the modules in this current file ---*/
306 thisamp = NULL;
307 while ((nextmod = AsnLexTReadModule(aip)) != NULL )
308 {
309 if (thisamp == NULL)
310 thisamp = nextmod;
311 if (amp == NULL)
312 amp = nextmod;
313 else
314 currentmod->next = nextmod;
315 currentmod = nextmod;
316 }
317 AsnStoreTree(filename, thisamp); /* store and link tree */
318 if (!*last_comma)
319 break;
320 aip = AsnIoClose(aip);
321 }
322
323 aip = AsnIoClose(aip);
324
325 if (amp == NULL)
326 {
327 ErrPostEx(SEV_FATAL,0,0, "Unable to continue due to bad ASN.1 module");
328 ErrShow();
329 return 1;
330 }
331
332
333 if (asnargs[f_arg_moduleOut].strvalue != NULL)
334 {
335 if ((aipout = AsnIoOpen(asnargs[f_arg_moduleOut].strvalue, "w")) == NULL)
336 {
337 ErrShow();
338 return 1;
339 }
340
341 currentmod = amp;
342 do
343 {
344 AsnPrintModule(currentmod, aipout);
345 if (currentmod == acip->last_amp) /* last main module */
346 currentmod = NULL;
347 else
348 currentmod = currentmod->next;
349 } while (currentmod != NULL);
350
351 aipout = AsnIoClose(aipout);
352 }
353
354 if (asnargs[X_argDTDModuleOut].strvalue != NULL)
355 {
356 Char tbuf[250];
357 CharPtr ptr;
358
359 if (! StringCmp(asnargs[X_argDTDModuleOut].strvalue, "m"))
360 {
361 print_each_module = TRUE;
362 }
363 else
364 {
365 if ((aipout = AsnIoOpen(asnargs[X_argDTDModuleOut].strvalue, "wx")) == NULL)
366 {
367 ErrShow();
368 return 1;
369 }
370 }
371
372 currentmod = amp;
373 do
374 {
375 if (print_each_module)
376 {
377 StringMove(tbuf, currentmod->modulename);
378 for (ptr = tbuf; *ptr != '\0'; ptr++)
379 {
380 if (*ptr == '-')
381 *ptr = '_';
382 }
383 StringMove(ptr, ".dtd");
384
385 AsnPrintModuleXMLInc(currentmod, tbuf);
386
387 StringMove(ptr, ".mod");
388
389 aipout = AsnIoOpen(tbuf, "wx");
390 }
391
392
393 AsnPrintModuleXML(currentmod, aipout);
394
395 if (print_each_module)
396 aipout = AsnIoClose(aipout);
397
398 if (currentmod == acip->last_amp) /* last main module */
399 currentmod = NULL;
400 else
401 currentmod = currentmod->next;
402 } while (currentmod != NULL);
403
404 if (! print_each_module)
405 aipout = AsnIoClose(aipout);
406 }
407
408 if (asnargs[T_argTreeDumpOut].strvalue != NULL)
409 {
410 if ((fp = FileOpen(asnargs[T_argTreeDumpOut].strvalue, "w")) == NULL)
411 {
412 ErrShow();
413 return 1;
414 }
415
416 currentmod = amp;
417 do
418 {
419 AsnPrintTreeModule(currentmod, fp);
420 if (currentmod == acip->last_amp) /* last main module */
421 currentmod = NULL;
422 else
423 currentmod = currentmod->next;
424 } while (currentmod != NULL);
425
426 FileClose(fp);
427 }
428
429
430 acip -> amp = amp;
431
432 /* print a value file */
433
434 if (asnargs[p_argPrintFileOut].strvalue != NULL)
435 {
436 if ((aipout = AsnIoOpen(asnargs[p_argPrintFileOut].strvalue, "w")) == NULL)
437 {
438 ErrShow();
439 return 1;
440 }
441 }
442 /* print an XML file */
443
444 if (asnargs[x_argXMLDataOut].strvalue != NULL)
445 {
446 if ((xaipout = AsnIoOpen(asnargs[x_argXMLDataOut].strvalue, "wx")) == NULL)
447 {
448 ErrShow();
449 return 1;
450 }
451 }
452
453 if (asnargs[v_argPrintFileIn].strvalue != NULL) /* read a printvalue file */
454 {
455 if ((aip = AsnIoOpen(asnargs[v_argPrintFileIn].strvalue, "r")) == NULL)
456 {
457 ErrShow();
458 return 1;
459 }
460
461 AsnTxtReadValFile(amp, aip, aipout, aipencode, xaipout);
462 ErrShow();
463 }
464
465 aip = AsnIoClose(aip);
466
467 if (asnargs[d_argBinaryFileIn].strvalue != NULL) /* read a ber file */
468 {
469 if ((asnargs[t_argAsnTypeName].strvalue == NULL) || (! TO_UPPER(*asnargs[t_argAsnTypeName].strvalue)))
470 {
471 ErrPostEx(SEV_FATAL,0,0, "Must use -t Type to define contents of decode file");
472 ErrShow();
473 return 1;
474 }
475
476 atp = AsnTypeFind(amp, asnargs[t_argAsnTypeName].strvalue);
477 if (atp == NULL)
478 {
479 #ifdef WIN_MSWIN
480 ErrPostEx(SEV_FATAL,0,0, "Couldn't find Type %Fs", asnargs[t_argAsnTypeName].strvalue);
481 #else
482 ErrPostEx(SEV_FATAL,0,0, "Couldn't find Type %s", asnargs[t_argAsnTypeName].strvalue);
483 #endif
484 ErrShow();
485 return 1;
486 }
487
488 if ((aip = AsnIoOpen(asnargs[d_argBinaryFileIn].strvalue, "rb")) == NULL)
489 {
490 ErrShow();
491 return 1;
492 }
493
494
495 AsnBinReadValFile(atp, aip, aipout, aipencode, xaipout);
496 ErrShow();
497 }
498
499 AsnIoClose(xaipout);
500 AsnIoClose(aipout);
501 AsnIoClose(aip);
502 AsnIoClose(aipencode);
503
504 if (asnargs[o_argHeadFile].strvalue != NULL) /* produce header file */
505 AsnOutput(asnargs[o_argHeadFile].strvalue, amp, FALSE, (Int2)asnargs[w_argTokenMax].intvalue);
506
507 if (asnargs[l_argLoadFile].strvalue != NULL) /* produce loader file */
508 AsnOutput(asnargs[l_argLoadFile].strvalue, amp, TRUE, (Int2)asnargs[w_argTokenMax].intvalue);
509
510 if (asnargs[G_argGenerateCode ].intvalue != 0)
511 {
512 acip -> filename = asnargs[B_argCodeFileName].strvalue;
513 acip -> do_bit_twiddle = asnargs[Z_argBitTwiddle].intvalue;
514 acip -> force_choice_struct = asnargs[V_argChoiceStruct].intvalue;
515 acip -> include_filename = asnargs[I_argExtraIncludeName].strvalue;
516 acip -> maxDefineLength = asnargs[w_argTokenMax].intvalue;
517 acip -> debug_level = asnargs[D_argCodeGenDebugLevel ].intvalue;
518 acip -> object_manager_entry = asnargs[J_objMgrEntry].strvalue;
519 acip -> object_label = asnargs[L_objMgrLabel].strvalue;
520 if (asnargs[S_argDebugFileName].strvalue != NULL) {
521 (acip -> bug_fp) = FileOpen (asnargs[S_argDebugFileName].strvalue, "w");
522 } else {
523 (acip -> bug_fp) = FileOpen ("stderr", "w");
524 }
525 acip -> use_quoted_include = asnargs[Q_argQuoted ].intvalue != 0;
526 AsnCode(acip);
527 }
528
529 MemFree(acip);
530 MemFree(filename);
531
532 return 0;
533 }
534 /*****************************************************************************
535 *
536 * void AsnTxtReadValFile(amp, aip, aipout, aipencode)
537 * reads a file of values
538 * prints to aipout if aipout != NULL
539 *
540 *****************************************************************************/
541 void AsnTxtReadValFile (AsnModulePtr amp, AsnIoPtr aip, AsnIoPtr aipout,
542 AsnIoPtr aipencode, AsnIoPtr xaipout)
543
544 {
545 AsnTypePtr atp;
546 DataVal value;
547 Boolean read_value, print_value, encode_value, restart, xmlvalue;
548
549 if (aipout != NULL)
550 print_value = TRUE;
551 else
552 print_value = FALSE;
553
554 if (xaipout != NULL)
555 xmlvalue = TRUE;
556 else
557 xmlvalue = FALSE;
558
559 if (aipencode != NULL)
560 encode_value = TRUE;
561 else
562 encode_value = FALSE;
563
564 if (print_value || encode_value || xmlvalue)
565 read_value = TRUE;
566 else
567 read_value = FALSE;
568
569
570 atp = NULL;
571 restart = FALSE;
572
573 while ((atp = AsnTxtReadId(aip, amp, atp)) != NULL)
574 {
575 if (restart == TRUE)
576 {
577 if (encode_value)
578 {
579 ErrPostEx(SEV_FATAL,0,0, "Cannot binary encode multiple values in one message");
580 return;
581 }
582 if (print_value) /* new line */
583 {
584 AsnPrintNewLine(aipout);
585 AsnPrintNewLine(aipout);
586 }
587 if (xmlvalue)
588 {
589 AsnPrintNewLine(xaipout);
590 AsnPrintNewLine(xaipout);
591 }
592 restart = FALSE;
593 }
594
595 if (read_value)
596 {
597 if (! AsnTxtReadVal(aip, atp, &value))
598 {
599 return;
600 }
601 if (print_value)
602 {
603 if (! AsnTxtWrite(aipout, atp, &value))
604 return;
605 }
606 if (xmlvalue)
607 {
608 if (! AsnTxtWrite(xaipout, atp, &value))
609 return;
610 }
611 if (encode_value)
612 {
613 if (! AsnBinWrite(aipencode, atp, &value))
614 return;
615 }
616 AsnKillValue(atp, &value);
617 }
618 else
619 {
620 if (! AsnTxtReadVal(aip, atp, NULL))
621 return;
622 }
623
624 if (! aip->type_indent) /* finished reading an object */
625 {
626 atp = NULL; /* restart */
627 restart = TRUE;
628 }
629 }
630 return;
631 }
632
633 /*****************************************************************************
634 *
635 * void AsnBinReadValFile(aip, aipout, aipencode)
636 * reads a file of binary values
637 * MUST start knowing the Type of the value
638 * prints to aipout if aipout != NULL
639 *
640 *****************************************************************************/
641 void AsnBinReadValFile (AsnTypePtr atp, AsnIoPtr aip, AsnIoPtr aipout,
642 AsnIoPtr aipencode, AsnIoPtr xaipout) /* type of message */
643
644 {
645 DataVal value;
646 Boolean read_value, print_value, encode_value, xmlvalue;
647
648 if (aipout != NULL)
649 print_value = TRUE;
650 else
651 print_value = FALSE;
652
653 if (xaipout != NULL)
654 xmlvalue = TRUE;
655 else
656 xmlvalue = FALSE;
657
658 if (aipencode != NULL)
659 encode_value = TRUE;
660 else
661 encode_value = FALSE;
662
663 if (print_value || encode_value || xmlvalue)
664 read_value = TRUE;
665 else
666 read_value = FALSE;
667
668
669 while ((atp = AsnBinReadId(aip, atp)) != NULL)
670 {
671 if (read_value)
672 {
673 if (! AsnBinReadVal(aip, atp, &value))
674 return;
675 if (print_value)
676 {
677 if (! AsnTxtWrite(aipout, atp, &value))
678 return;
679 }
680 if (xmlvalue)
681 {
682 if (! AsnTxtWrite(xaipout, atp, &value))
683 return;
684 }
685 if (encode_value)
686 {
687 if (! AsnBinWrite(aipencode, atp, &value))
688 return;
689 }
690 AsnKillValue(atp, &value);
691 }
692 else
693 AsnBinReadVal(aip, atp, NULL);
694 }
695 return;
696 }
697
698
699
700 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |