NCBI C Toolkit Cross Reference

C/asnlib/asnout.c


  1 /* asnout.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:  asnout.c
 27 *
 28 * Author:  James Ostell
 29 *
 30 * Version Creation Date: 3/4/91
 31 *
 32 * $Revision: 6.3 $
 33 *
 34 * File Description:
 35 *   Routines for outputing ASN.1 parse trees from asntool
 36 *
 37 * Modifications:  
 38 * --------------------------------------------------------------------------
 39 * Date     Name        Description of modification
 40 * -------  ----------  -----------------------------------------------------
 41 * 3/4/91   Kans        Stricter typecasting for GNU C and C++
 42 *
 43 * $Log: asnout.c,v $
 44 * Revision 6.3  2009/10/02 19:28:19  kans
 45 * address clang static analyzer warnings
 46 *
 47 * Revision 6.2  2001/01/10 17:42:47  beloslyu
 48 * fix to resolve the problem with buggy optimizer of Forte compiler on Solaris/Intel
 49 *
 50 * Revision 6.1  1999/03/11 23:43:17  kans
 51 * fprintf casts
 52 *
 53 * Revision 6.0  1997/08/25 18:10:14  madden
 54 * Revision changed to 6.0
 55 *
 56 * Revision 5.1  1996/12/03 21:43:48  vakatov
 57 * Adopted for 32-bit MS-Windows DLLs
 58 *
 59  * Revision 5.0  1996/05/28  14:00:29  ostell
 60  * Set to revision 5.0
 61  *
 62  * Revision 4.0  1995/07/26  13:47:38  ostell
 63  * force revision to 4.0
 64  *
 65  * Revision 2.3  1995/05/15  18:38:28  ostell
 66  * added Log line
 67  *
 68 *
 69 * ==========================================================================
 70 */
 71 
 72 /*****************************************************************************
 73 *
 74 *   asnout.c
 75 *       routines to output a set of modules to a header file
 76 *
 77 *****************************************************************************/
 78 
 79 #include "asnbuild.h"
 80 
 81 #ifdef WIN_MSWIN
 82 static char * headerlines[] = {     
 83 #else
 84 static CharPtr headerlines[] = {
 85 #endif
 86         "/***********************************************************************\n",
 87         "*\n",
 88         "*",
 89         "*\n",
 90         "*        Automatic header module from ASNTOOL\n",
 91         "*\n",
 92         "************************************************************************/\n",
 93         "\n",
 94         "#ifndef _ASNTOOL_\n",
 95         "#include <asn.h>\n",
 96         "#endif\n",
 97         "\n"};
 98 /*****************************************************************************
 99 *
100 *   void AsnOutput(filename)
101 *       in loader file, pointers are repesented as numbers
102 *           -32000 = NULL
103 *           -32001 = &avn[0]
104 *           any other negative number &avn[positive number]
105 *           0 or any positive number = &at[number]
106 *   
107 *
108 *****************************************************************************/
109 NLM_EXTERN void AsnOutput (CharPtr filename, AsnModulePtr amp, Boolean loader, Int2 maxDefineLength)
110 
111 {
112         FILE *fp, *ld;
113         int i, numvalue = 0, numtype = 0, nummod = 0, j;
114         AsnProc p;
115         AsnModulePtr curr_mod;
116         AsnTypePtr curr_type, atp;
117         AsnTmpTypePtr attp, attp2;
118         AsnTmpValuePtr attvp;
119         AsnValxNodePtr atvp;
120         Int2 isa;
121         char buf[200];
122     char * pnt;
123     CharPtr ptr;
124 
125         StringCpy(buf, filename);
126 
127         fp = fopen(buf, "w");
128         
129         if (fp == NULL)
130         {
131                 AsnIoErrorMsg(NULL, 82, buf);
132                 return;
133         }
134 
135     pnt = buf;
136     while (* pnt != '\0')
137         pnt++;
138     while ((pnt > buf) && (*pnt != '.'))
139         pnt--;
140     pnt++;
141         if (loader)
142                 *pnt = 'l';
143         pnt++;
144 
145         if (amp->filename != NULL)    /* the $Revision extension */
146         {
147                 if (StringLen(amp->filename) <= 1)
148                 {
149                         *pnt = '0';
150                         pnt++;
151                 }
152                 StringMove(pnt, amp->filename);
153                 MemFree(amp->filename);    /* get rid of the extension */
154         }
155         amp->filename = StringSave(buf);
156 
157     if (loader)
158         ld = fopen(buf, "w");
159     else
160         ld = NULL;
161 
162         for (i = 0; i < 12; i++)
163                 fprintf(fp, "%s", headerlines[i]);
164         fprintf(fp, "static char * asnfilename = \"%s\";\n", buf);
165 
166         curr_mod = amp;
167         p.curr_tmptype = &p.root_tmptype;      /* fake node to start */
168         p.curr_tmpvalue = &p.root_tmpvalue;
169         p.root_tmptype.next = NULL;
170         p.root_tmpvalue.next = NULL;
171 
172         while (curr_mod != NULL)
173         {
174                 nummod++;
175                 curr_type = curr_mod->types;
176                 while (curr_type != NULL)
177                 {
178                         curr_type = AsnOutAddType(&p, curr_type);
179                 }
180                 curr_mod = curr_mod->next;
181         }
182 
183         /******************** set index values ***************************/
184         
185         attvp = p.root_tmpvalue.next;
186         while (attvp != NULL)
187         {
188                 attvp->index = numvalue;
189                 numvalue++;
190                 attvp = attvp->next;
191         }
192 
193         attp = p.root_tmptype.next;
194         while (attp != NULL)
195         {
196                 attp->index = numtype;
197                 numtype++;
198                 attp = attp->next;
199         }
200 
201         /****************** write values *********************************/
202     if (loader)     /* always put in all pointers and counts */
203     {
204         fprintf(ld, "%d %d %d\n", numvalue, numtype, nummod);
205 
206         fprintf(fp, "static AsnValxNodePtr avn;\n");
207         fprintf(fp, "static AsnTypePtr at;\n");
208         fprintf(fp, "static AsnModulePtr amp;\n");
209     }
210 
211         if (numvalue)
212         {
213         if (! loader)   
214                 fprintf(fp, "static AsnValxNode avnx[%d] = {\n", numvalue);
215 
216                 attvp = p.root_tmpvalue.next;
217 
218                 while (attvp != NULL)
219                 {
220                         atvp = attvp->val;
221             if (! loader)
222             {
223                         fprintf(fp, "    {%d,", atvp->valueisa);
224                         if (atvp->name == NULL)
225                                 fprintf(fp, "NULL,");
226                             else
227                                     fprintf(fp, "\"%s\" ,", atvp->name);
228                         fprintf(fp,"%ld,", (long) atvp->intvalue);
229                         if (atvp->realvalue == (FloatHi) 0.0)
230                                 fprintf(fp,"0.0,");
231                             else
232                                     fprintf(fp,"%f,", atvp->realvalue);
233                         if (atvp->next == NULL)
234                                 fprintf(fp, "NULL }");
235                         else
236                                 fprintf(fp, "&avnx[%d] }", AsnOutFindValue(&p, atvp->next));
237                         if (attvp->next == NULL)
238                                 fprintf(fp, " };\n\n");
239                         else
240                                 fprintf(fp, " ,\n");
241             }
242             else
243             {
244                         fprintf(ld, "%d ", atvp->valueisa);
245                         if (atvp->name == NULL)
246                                 fprintf(ld, "-32000 ");
247                             else
248                                     fprintf(ld, "%s ", atvp->name);
249                         fprintf(ld,"%ld ", (long) atvp->intvalue);
250                         if (atvp->realvalue == (FloatHi) 0.0)
251                                 fprintf(ld,"0.0 ");
252                             else
253                                     fprintf(ld,"%f ", atvp->realvalue);
254                         if (atvp->next == NULL)
255                                 fprintf(ld, "-32000\n");
256                         else
257                 {
258                     j = AsnOutFindValue(&p, atvp->next);
259                     if (j == 0)
260                        j = 32001; 
261                                 fprintf(ld, "-%d\n", j);
262                 }
263             }
264                         attvp = attvp->next;
265                 }
266         }
267 
268         /****************** write types *********************************/
269 
270     if (! loader)
271         fprintf(fp, "static AsnType atx[%d] = {\n", numtype);
272 
273         attp = p.root_tmptype.next;
274 
275         while (attp != NULL)
276         {
277                 atp = attp->ptr;
278                 isa = atp->isa;
279         if (! loader)
280         {
281                 fprintf(fp, "  {%d,", isa);
282                 if (atp->name == NULL)
283                         fprintf(fp, " NULL,");
284                 else
285                         fprintf(fp, " \"%s\" ,", atp->name);
286                     fprintf(fp, "%d,%d,", atp->tagclass, atp->tagnumber);
287 
288                 if (ISA_BASETYPE(isa))    /* primitive type, fake it */
289                         fprintf(fp, "0,0,0,0,0,0,NULL,NULL,NULL,0,NULL}");
290                     else
291                 {
292                         if (atp->implicit)
293                                 i = 1;
294                             else
295                                     i = 0;
296                         fprintf(fp,"%d,", i);
297                         if (atp->optional)
298                                 i = 1;
299                             else
300                                     i = 0;
301                         fprintf(fp,"%d,", i);
302                         if (atp->hasdefault)
303                                 i = 1;
304                             else
305                                     i = 0;
306                         fprintf(fp,"%d,", i);
307                         if (atp->exported)
308                                 i = 1;
309                             else        
310                                     i = 0;
311                         fprintf(fp,"%d,", i);
312                         if (atp->imported)
313                                 i = 1;
314                             else
315                                     i = 0;
316                         fprintf(fp, "%d,", i);
317                         fprintf(fp, "0,");   /* resolved is FALSE */
318                         if (atp->defaultvalue == NULL)
319                                 fprintf(fp, "NULL,");
320                         else
321                                 fprintf(fp, "&avnx[%d],", AsnOutFindValue(&p, atp->defaultvalue));
322                         attp2 = AsnOutFindType(&p, atp->type);
323                             if (attp2 == NULL)    /* imported */
324                                     fprintf(fp, "NULL,");
325                         else
326                                 fprintf(fp, "&atx[%d],", attp2->index);
327                         if (atp->type != NULL)
328                                 isa = atp->type->isa;    /* get base type */
329                         else    
330                                 isa = -32000;
331                         if ((atp->branch == NULL) || (atp->imported))
332                                 fprintf(fp, "NULL,");
333                         else if ((isa == INTEGER_TYPE) || (isa == ENUM_TYPE))
334                                 fprintf(fp, "&avnx[%d],", AsnOutFindValue(&p, (AsnValxNodePtr) atp->branch));
335                         else
336                             {
337                                     attp2 = AsnOutFindType(&p, (AsnTypePtr) atp->branch);
338                                 fprintf(fp, "&atx[%d],", attp2->index);
339                         }
340                         fprintf(fp, "0,");     /* ->tmp */
341                             if (atp->next == NULL)
342                                 fprintf(fp, "NULL}");
343                         else
344                         {
345                                 attp2 = AsnOutFindType(&p, atp->next);
346                                     fprintf(fp, "&atx[%d]}", attp2->index);
347                         }
348                 }
349                 if (attp->next == NULL)
350                         fprintf(fp, " };\n\n");
351                     else
352                             fprintf(fp, " ,\n");
353         }
354         else
355         {
356                 fprintf(ld, "%d ", isa);
357                 if (atp->name == NULL)
358                         fprintf(ld, "-32000 ");
359                 else
360             {
361                 ptr = atp->name;
362                 pnt = buf;
363                 while (*ptr != '\0')  /* fix SEQ OF, SET OF */
364                 {
365                     *pnt = *ptr;
366                     if (*ptr == ' ')
367                         *pnt = '!';
368                     ptr++;  pnt++;
369                 }
370                 *pnt = '\0';
371                         fprintf(ld, "%s ", buf);
372             }
373                     fprintf(ld, "%d %d ", atp->tagclass, atp->tagnumber);
374 
375                 if (ISA_BASETYPE(isa))    /* primitive type, fake it */
376                         fprintf(ld, "0 0 0 0 0 -32000 -32000 -32000 -32000\n");
377                     else
378                 {
379                         if (atp->implicit)
380                                 i = 1;
381                             else
382                                     i = 0;
383                         fprintf(ld,"%d ", i);
384                         if (atp->optional)
385                                 i = 1;
386                             else
387                                     i = 0;
388                         fprintf(ld,"%d ", i);
389                         if (atp->hasdefault)
390                                 i = 1;
391                             else
392                                     i = 0;
393                         fprintf(ld,"%d ", i);
394                         if (atp->exported)
395                                 i = 1;
396                             else        
397                                     i = 0;
398                         fprintf(ld,"%d ", i);
399                         if (atp->imported)
400                                 i = 1;
401                             else
402                                     i = 0;
403                         fprintf(ld, "%d ", i);
404                         if (atp->defaultvalue == NULL)
405                                 fprintf(ld, "-32000 ");
406                         else
407                 {
408                     j = AsnOutFindValue(&p, atp->defaultvalue);
409                     if (j == 0)
410                         j = 32001;
411                                 fprintf(ld, "-%d ", j);
412                 }
413                         attp2 = AsnOutFindType(&p, atp->type);
414                             if (attp2 == NULL)    /* imported */
415                                     fprintf(ld, "-32000 ");
416                         else
417                                 fprintf(ld, "%d ", attp2->index);
418                         if (atp->type != NULL)
419                                 isa = atp->type->isa;    /* get base type */
420                         else    
421                                 isa = -32000;
422                         if ((atp->branch == NULL) || (atp->imported))
423                                 fprintf(ld, "-32000 ");
424                         else if ((isa == INTEGER_TYPE) || (isa == ENUM_TYPE))
425                 {
426                                 j = AsnOutFindValue(&p, (AsnValxNodePtr) atp->branch);
427                     if (j == 0)
428                         j = 32001;
429                     fprintf(ld, "-%d ", j);
430                 }
431                         else
432                             {
433                                     attp2 = AsnOutFindType(&p, (AsnTypePtr) atp->branch);
434                                 fprintf(ld, "%d ", attp2->index);
435                         }
436                             if (atp->next == NULL)
437                                 fprintf(ld, "-32000\n");
438                         else
439                         {
440                                 attp2 = AsnOutFindType(&p, atp->next);
441                                     fprintf(ld, "%d\n", attp2->index);
442                         }
443                 }
444         }
445                 attp = attp->next;
446         }
447 
448         /*********************** print the modules ***********************/
449 
450     if (! loader)
451         fprintf(fp, "static AsnModule ampx[%d] = {\n", nummod);
452 
453         i = 1;
454         curr_mod = amp;
455         while (curr_mod != NULL)
456         {
457         if (! loader)
458         {
459                 fprintf(fp, "  { \"%s\" ,", curr_mod->modulename);
460                 if (curr_mod->filename == NULL)
461                         fprintf(fp, " NULL,");
462                 else
463                         fprintf(fp, " \"%s\",", curr_mod->filename);
464                     attp = AsnOutFindType(&p, curr_mod->types);
465                 fprintf(fp, "&atx[%d],", attp->index);
466                 fprintf(fp, "NULL,");
467                     if (curr_mod->next == NULL)
468                 {
469                         fprintf(fp, "NULL,0,0}");
470                         fprintf(fp, " };\n\n");
471                 }
472                 else
473                         fprintf(fp, "&ampx[%d],0,0} ,\n", i);
474         }
475         else
476         {
477                 fprintf(ld, "%s ", curr_mod->modulename);
478                 if (curr_mod->filename == NULL)
479                         fprintf(ld, "-32000 ");
480                 else
481                         fprintf(ld, "%s ", curr_mod->filename);
482                     attp = AsnOutFindType(&p, curr_mod->types);
483                 fprintf(ld, "%d ", attp->index);
484                     if (curr_mod->next == NULL)
485                         fprintf(ld, "-32000\n");
486                 else
487                         fprintf(ld, "%d\n", i);
488         }
489         i++;
490             curr_mod = curr_mod->next;
491         }
492 
493     if (loader)
494         fclose(ld);
495     else
496     {
497         if (numvalue)
498             fprintf(fp, "static AsnValxNodePtr avn = avnx;\n");
499         else
500             fprintf(fp, "static AsnValxNodePtr avn = NULL;\n");
501         fprintf(fp, "static AsnTypePtr at = atx;\n");
502         fprintf(fp, "static AsnModulePtr amp = ampx;\n\n");
503     }
504 
505         curr_mod = amp;
506         while (curr_mod != NULL)
507         {
508                 atp = curr_mod->types;
509                 fprintf(fp, "\n\n/**************************************************\n");
510                 fprintf(fp, "*\n");
511                 fprintf(fp, "*    Defines for Module %s\n", curr_mod->modulename);
512                 fprintf(fp, "*\n");
513                 fprintf(fp, "**************************************************/\n");
514                 while (atp != NULL)
515                 {
516                         if (! atp->imported)    /* must be defined elsewhere */
517                                 AsnOutDefineType(fp, &p, atp, maxDefineLength);
518                         atp = atp->next;
519                 }
520                 curr_mod = curr_mod->next;
521         }
522 
523         fclose(fp);
524         return; 
525 }
526 
527 /*****************************************************************************
528 *
529 *   void AsnOutDefineType(fp, app, atp, maxDefineLength)
530 *
531 *****************************************************************************/
532 NLM_EXTERN void AsnOutDefineType (FILE *fp, AsnProcPtr app, AsnTypePtr atp, Int2 maxDefineLength)
533 
534 {
535         char buf[200];
536 
537         AsnOutDefineElement(fp, app, atp, buf, NULL, maxDefineLength);
538         return;
539 }
540 
541 /*****************************************************************************
542 *
543 *   void AsnOutDefineElement(fp, app, atp, buf, pnt, maxDefineLength)
544 *
545 *****************************************************************************/
546 NLM_EXTERN void AsnOutDefineElement (FILE *fp, AsnProcPtr app, AsnTypePtr atp, CharPtr buf, CharPtr pnt, Int2 maxDefineLength)
547 
548 {
549         CharPtr to, from, symbol;
550         AsnTmpTypePtr attp;
551         Boolean first;
552         int i;
553 
554         if (pnt == NULL)
555                 first = TRUE;
556         else
557                 first = FALSE;
558 
559         while (atp != NULL)
560         {
561                 to = pnt;
562                 if (atp->name != NULL)
563                 {
564                         from = atp->name;
565                         if (first)
566                                 to = buf;
567                         else
568                         {
569                                 *to = '_';
570                                 to++;
571                         }
572                         while (*from != '\0')
573                         {
574                                 if (first)
575                                         *to = TO_UPPER(*from);
576                                 else
577                                         *to = *from;
578                                 if (*to == '-')
579                                         *to = '_';
580                                 to++; from++;
581                         }
582                         *to = '\0';
583                         attp = AsnOutFindType(app, atp);
584                         if (first)
585                                 fprintf(fp, "\n");
586                         symbol = to;
587                         i = maxDefineLength;    /* max symbol length */
588                         while ((i) && (symbol > buf))
589                         {
590                                 i--; symbol--;
591                         }
592                         if (symbol != buf && StrChr(symbol, '_') != NULL)   /* longer than maxDefineLength */
593                         {
594                                 while (*symbol != '_')   /* end neatly */
595                                         symbol++;
596                                 symbol++;
597                         }
598                         fprintf(fp, "#define %s &at[%d]\n", symbol, attp->index);
599                 }
600                 switch(atp->type->isa)
601                 {
602                         case SEQ_TYPE:
603                         case SET_TYPE:
604                         case CHOICE_TYPE:
605                                 AsnOutDefineElement(fp, app, (AsnTypePtr) atp->branch, buf, to, maxDefineLength);
606                                 break;
607                         case SEQOF_TYPE:
608                         case SETOF_TYPE:
609                                 StringCpy(to, "_E");
610                                 symbol = to + 2;
611                                 i = maxDefineLength;     /* max symbol length */
612                                 while ((i) && (symbol > buf))
613                                 {
614                                         i--; symbol--;
615                                 }
616                                 if (symbol != buf)   /* longer than maxDefineLength */
617                                 {
618                                         while (*symbol != '_')   /* end neatly */
619                                                 symbol++;
620                                         symbol++;
621                                 }
622                                 attp = AsnOutFindType(app, (AsnTypePtr) atp->branch);
623                                 fprintf(fp, "#define %s &at[%d]\n", symbol, attp->index);
624                                 switch (((AsnTypePtr)atp->branch)->type->isa)
625                                 {
626                                         case CHOICE_TYPE:
627                                         case SET_TYPE:
628                                         case SEQ_TYPE:
629                                         case SEQOF_TYPE:
630                                         case SETOF_TYPE:
631                                                 AsnOutDefineElement(fp, app, (AsnTypePtr) atp->branch, buf, to+2, maxDefineLength);
632                                                 break;
633                                         default:
634                                                 break;
635                                 }
636                                 break;
637                         default:
638                                 break;
639                 }
640                 if (first)
641                         return;
642                 atp = atp->next;
643         }
644         return;
645 }
646 
647 /*****************************************************************************
648 *
649 *   Int2 AsnOutFindValue(app, avnp)
650 *       returns index of a value node ptr
651 *
652 *****************************************************************************/
653 NLM_EXTERN Int2 AsnOutFindValue (AsnProcPtr app, AsnValxNodePtr avnp)
654 
655 {
656         AsnTmpValuePtr attvp;
657 
658         attvp = app->root_tmpvalue.next;
659         while (attvp != NULL)
660         {
661                 if (attvp->val == avnp)
662                         return attvp->index;
663                 attvp = attvp->next;
664         }
665         return -32000;
666 }
667 /*****************************************************************************
668 *
669 *   AsnTypePtr AsnOutAddType(AsnProcPtr, AsnTypePtr)
670 *       builds temporaries for this type
671 *       returns the next type
672 *
673 *****************************************************************************/
674 NLM_EXTERN AsnTypePtr AsnOutAddType (AsnProcPtr app, AsnTypePtr atp)
675 
676 {
677         AsnTypePtr atp2;
678         AsnTypePtr next;
679 
680         if (atp == NULL)        /* protection */
681                 return NULL;
682 
683         if (! AsnOutNewType(app, atp))      /* already have it */
684         {
685                 if (ISA_BASETYPE(atp->isa))
686                         return NULL;
687                 return atp->next;
688         }
689 
690         if (ISA_BASETYPE(atp->isa))     /* all done if primitive */
691                 return NULL;
692 
693         if (atp->type == NULL)       /* externally defined type */
694                 return atp->next;        /* no more to do */
695 
696         switch (atp->type->isa)        /* load any subvalues */
697         {
698                 case INTEGER_TYPE:
699                         if (atp->branch == NULL)    /* not named */
700                                 break;
701                 case ENUM_TYPE:
702                         AsnOutNewValueChain(app, (AsnValxNodePtr) atp->branch);
703                         break;
704                 case SETOF_TYPE:
705                 case SEQOF_TYPE:
706                 case SEQ_TYPE:
707                 case SET_TYPE:
708                 case CHOICE_TYPE:
709                         atp2 = (AsnTypePtr) atp->branch;
710                         while (atp2 != NULL)
711                                 atp2 = AsnOutAddType(app, atp2);
712                         break;
713                 default:
714                         break;
715         }
716 
717         if (atp->hasdefault)
718                 AsnOutNewValueChain(app, atp->defaultvalue);
719 
720         AsnOutAddType(app, atp->type);
721 
722         next = atp->next;
723         return next;
724 }
725 
726 
727 /*****************************************************************************
728 *
729 *   Boolean AsnOutNewType(app, atp)
730 *       if type is on tmp list already, returns FALSE
731 *       if not, adds it, and returns TRUE
732 *
733 *****************************************************************************/
734 NLM_EXTERN Boolean AsnOutNewType (AsnProcPtr app, AsnTypePtr atp)
735 
736 {
737         AsnTmpTypePtr attp;
738 
739         attp = AsnOutFindType(app, atp);
740         if (attp != NULL)      /* have it already */
741                 return FALSE;
742                 
743                     /* not found, add it */
744         attp = (AsnTmpTypePtr) MemNew(sizeof(AsnTmpType));
745         app->curr_tmptype->next = attp;
746         app->curr_tmptype = attp;
747         attp->ptr = atp;
748         return TRUE;
749 }
750 
751 /*****************************************************************************
752 *
753 *   AsnTmpTypePtr AsnOutFindType(app, atp)
754 *       returns a pointer to the tmptype matching atp
755 *
756 *****************************************************************************/
757 NLM_EXTERN AsnTmpTypePtr AsnOutFindType (AsnProcPtr app, AsnTypePtr atp)
758 
759 {
760         AsnTmpTypePtr attp;
761 
762         if (atp == NULL)      /* imported, no type set */
763                 return NULL;
764 
765         attp = app->root_tmptype.next;
766         while (attp != NULL)
767         {
768                 if (attp->ptr == atp)     /* found it */
769                         return attp;
770                 attp = attp->next;
771         }
772         return attp;         /* didn't find it */
773 }
774 
775 /*****************************************************************************
776 *
777 *   void AsnOutNewValueChain(app, avnp)
778 *       values are always used by just one type
779 *
780 *****************************************************************************/
781 NLM_EXTERN void AsnOutNewValueChain (AsnProcPtr app, AsnValxNodePtr avnp)
782 
783 {
784         AsnTmpValuePtr curr;
785 
786         curr = app->curr_tmpvalue;
787 
788         while (avnp != NULL)
789         {
790                 curr->next = (AsnTmpValuePtr) MemNew(sizeof(AsnTmpValue));
791                 curr = curr->next;
792                 curr->val = avnp;
793                 avnp = avnp->next;
794         }
795         app->curr_tmpvalue = curr;
796         return;
797 }
798 
799 

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.