1 /* asn.h 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: asn.h 27 * 28 * Author: James Ostell 29 * 30 * Version Creation Date: 1/1/91 31 * 32 * $Revision: 6.22 $ 33 * 34 * File Description: 35 * This header the interface to all the routines in the ASN.1 libraries 36 * that an application should ever use. It also includes the necessary 37 * typedefs -- however the application programmer is not meant to use 38 * the internal structures directly outside of the specified functions, 39 * as the internal structures may be changed without notice. 40 * 41 * Modifications: 42 * -------------------------------------------------------------------------- 43 * Date Name Description of modification 44 * ------- ---------- ----------------------------------------------------- 45 * 46 * ========================================================================== 47 */ 48 49 #ifndef _ASNTOOL_ 50 #define _ASNTOOL_ 51 52 /*** depends on NCBI core routines ***/ 53 #ifndef _NCBI_ 54 #include <ncbi.h> 55 #endif 56 57 #undef NLM_EXTERN 58 #ifdef NLM_IMPORT 59 #define NLM_EXTERN NLM_IMPORT 60 #else 61 #define NLM_EXTERN extern 62 #endif 63 64 #ifdef __cplusplus 65 extern "C" { 66 #endif 67 68 /**** ValNode is used for internal representation of values from 69 **** CHOICE, SET OF, SEQ OF and combinations for many cases. 70 **** it is provided in ncbimisc for build object routines ****/ 71 72 /*** The following defines can be used for backward compatibility 73 #define AsnValue DataVal 74 #define AsnNode ValNode 75 ***/ 76 /*** In addition, AsnValueNode was changed to AsnValxNode so it would 77 not conflict with the AsnValue define above 78 ****/ 79 80 #ifndef START_STRUCT 81 #define START_STRUCT 411 /* { found */ 82 #define END_STRUCT 412 /* } found */ 83 #endif 84 85 /******* AsnOptions allow customization of AsnIo and AsnType ****/ 86 87 typedef Pointer (LIBCALLBACK * AsnOptFreeFunc) PROTO ((Pointer)); 88 #define DefAsnOptionFree Nlm_MemFree /* default function for freeing AsnOption's */ 89 90 typedef struct asnopt { 91 Int2 ao_class; /* class of option. all negative numbers res.*/ 92 Int2 type; /* type within ao_class */ 93 DataVal data; /* data used for setting option */ 94 AsnOptFreeFunc freefunc; /* function to free data.ptrvalue */ 95 struct asnopt PNTR next; 96 } AsnOption, PNTR AsnOptionPtr; 97 98 /******** AsnValXNode holds ENUM, Named Integer, Default values *****/ 99 100 typedef struct asnvaluenode { 101 Int2 valueisa; 102 CharPtr name; /* use for strings and named int */ 103 Int8 intvalue; /* use for int and boolean */ 104 FloatHi realvalue; 105 struct asnvaluenode PNTR next; 106 AsnOptionPtr aop; /* for comments */ 107 } AsnValxNode, PNTR AsnValxNodePtr; 108 109 /******** AsnType is a node in the AsnTool parse tree *******/ 110 111 typedef struct asntype { 112 Int2 isa; /* holds types like BOOLEAN_TYPE, etc. You can use the ISA_ macros on it */ 113 CharPtr name; 114 Uint1 tagclass; /* holds TAG_UNIVERSAL, TAG_APPLICATION, etc. */ 115 Int2 tagnumber; /* holds TAG_BOOLEAN, etc. */ 116 unsigned implicit : 1; 117 unsigned optional : 1; 118 unsigned hasdefault : 1; 119 unsigned exported : 1; 120 unsigned imported : 1; 121 unsigned resolved : 1; 122 AsnValxNodePtr defaultvalue; /* used for default value, range, subtypes */ 123 struct asntype PNTR type; 124 Pointer branch; /* used for named ints, enum, set, sequence */ 125 Int2 tmp; /* for temporary ->type link to local tree */ 126 struct asntype PNTR next; 127 AsnOptionPtr hints; /* used to customize the type by application */ 128 CharPtr XMLname; /* for reading/writing XML */ 129 Boolean been_here; /* needed for printing DTD */ 130 } AsnType, PNTR AsnTypePtr; 131 132 typedef struct asnmodule { 133 CharPtr modulename; 134 CharPtr filename; /* if module to be loaded from disk */ 135 AsnTypePtr types; 136 AsnTypePtr values; 137 struct asnmodule PNTR next; /* for chain of modules */ 138 Int2 lasttype; /* for isa defined types */ 139 Int2 lastvalue; /* for isa defined values */ 140 } AsnModule, PNTR AsnModulePtr; 141 142 #define ASNIO_BUFSIZE 1024 /* default size of AsnIo.buf */ 143 #define ASNIO_BUFSIZE_RESERVE 200 /* default size of reserved room in AsnIo.buf */ 144 145 /* AsnIo.type bit[0] = text? bit[1]=binary?*/ 146 /* bit[2]=input? bit[3]=output? */ 147 #define ASNIO_TEXT 1 148 #define ASNIO_BIN 2 149 #define ASNIO_IN 4 150 #define ASNIO_OUT 8 151 #define ASNIO_FILE 16 152 #define ASNIO_CARRIER 32 /* is a pure iterator */ 153 #define ASNIO_XML 64 154 155 #define ASNIO_TEXT_IN 21 /* AsnIo.type for files */ 156 #define ASNIO_TEXT_OUT 25 157 #define ASNIO_BIN_IN 22 158 #define ASNIO_BIN_OUT 26 159 160 typedef struct pstack { 161 AsnTypePtr type; /* type at this level of stack */ 162 Int4 len; /* length of item for binary decode */ 163 Boolean resolved; /* resolution of type for binary decode */ 164 Boolean tag_indef; /* indefinate tag length on input? */ 165 } Pstack, PNTR PstackPtr; 166 167 typedef struct asnexpoptstruct { 168 struct asnio PNTR aip; 169 AsnTypePtr atp; 170 DataValPtr dvp; 171 Int2 the_choice; 172 Pointer the_struct; 173 Pointer data; 174 } AsnExpOptStruct, PNTR AsnExpOptStructPtr; 175 176 typedef void (LIBCALLBACK * AsnExpOptFunc) PROTO ((AsnExpOptStructPtr)); 177 #define NO_CHOICE_SET INT2_MIN /* for AsnExpOptStruct.the_choice */ 178 179 typedef struct expopt { 180 Int2 numtypes; 181 AsnTypePtr PNTR types; /* the type to check */ 182 Pointer user_data; /* user supplied data */ 183 AsnExpOptFunc user_callback; /* user supplied callback function */ 184 struct expopt PNTR next; 185 } AsnExpOpt, PNTR AsnExpOptPtr; 186 187 typedef void (LIBCALLBACK * AsnErrorFunc) PROTO((Int2, CharPtr)); 188 #define ErrorRetType AsnErrorFunc /* for backward compatibility */ 189 typedef Int2 (LIBCALLBACK * AsnIoFunc) PROTO((Pointer, CharPtr, Uint2)); 190 #define IoFuncType AsnIoFunc /* for backward compatibility */ 191 192 193 typedef struct asnio { 194 CharPtr linebuf; 195 Int1 type; /* type- text-in, text-out, bin-in, bin-out */ 196 Int2 linepos; /* current offset in linebuf */ 197 FILE * fp; /* file to write or read to */ 198 BytePtr buf; /* buffer for I/O */ 199 Int2 bufsize; /* sizeof this buffer */ 200 Int2 bytes, /* bytes of data available in buf */ 201 offset; /* current offset of processing in buf */ 202 Uint1 tagclass; /* last BER tag-id-len read */ 203 Int2 tagnumber; 204 Boolean constructed; 205 Int4 length; /* length of BER encoded data */ 206 Boolean tagsaved; /* TRUE if tag info already here - stops read */ 207 Int4 used; /* if tagsaved, bytes used recorded here */ 208 Int1 tabsize, /* spaces per tab */ 209 indent_level, /* current indent level for print output */ 210 max_indent, /* current maximum indent levels for first */ 211 state; /* parsing state */ 212 Int2 linelength; /* max line length on output */ 213 BoolPtr first; /* for first element on indented line for printing */ 214 Int4 linenumber; /* for reporting errors */ 215 CharPtr word; /* current word in linebuf */ 216 Int2 wordlen, /* length of word in linebuf */ 217 token; /* current parsing token for word */ 218 PstackPtr typestack; /* the parsing stack for input and output */ 219 Int1 type_indent, /* used like indent_level and max_indent, but for */ 220 max_type; /* typestack */ 221 ErrorRetType error_ret; /* user error return */ 222 Pointer iostruct; /* non-FILE io structure */ 223 IoFuncType readfunc, /* read/write functions for sockets */ 224 writefunc; /* open and close MUST be done outside AsnIo */ 225 Boolean read_id; /* for checking AsnReadId AsnReadVal alternation */ 226 CharPtr fname; /* name of file in use */ 227 AsnOptionPtr aop; /* head of options chain */ 228 AsnExpOptPtr aeop; /* exploration options chain */ 229 AsnExpOptStructPtr aeosp; 230 Boolean io_failure; /* set on failed write, or read */ 231 Uint1 fix_non_print; /* fix non-printing chars in VisibleStrings (see below) */ 232 Boolean utf8_read; /* VisibleString expected but UTF8String encountered */ 233 Uint1 fix_utf8_in; /* policy on reporting VisibleString/UTF8String mismatches (see below) */ 234 Boolean utf8_sent; /* UTF8String converted to VisibleString in output */ 235 Uint1 fix_utf8_out; /* policy on converting UTF8String to VisibleString (see below) */ 236 Boolean scan_for_start; /* if TRUE, scan over garbage in print form */ 237 Int2 spec_version; /* used for filtering between asn.1 spec versions */ 238 Boolean no_newline; /* to suppress internal newlines in long XML strings */ 239 Boolean XMLModuleWritten; /* to put header on first XML DTD only */ 240 /* the following fields are used for easier ASN.1 comparisons, not normal operations */ 241 Boolean asn_no_newline; /* to suppress internal newlines in long ASN.1 strings */ 242 Boolean asn_alt_struct; /* structure ending braces on separate lines */ 243 } AsnIo, PNTR AsnIoPtr; 244 245 246 /***************************************************************************** 247 * 248 * fix_non_print 249 * Non-printing chars (like \t, \n) are illegal in VisibleStrings. The 250 * default case is to replace it with '#' and post an error message. Whether 251 * the error will be fatal or not depends on ERR_SET_OPTS. Supported values 252 * of fix_non_print are: 253 * 254 * 0 = (default) replace with '#', post an error of SEV_ERROR, 255 * do not set aip->io_failure 256 * 1 = replace with '#' silently 257 * 2 = pass non-printing char through unchanged with no error message 258 * 3 = replace with '#', post an error of SEV_FATAL, do set aip->io_failure 259 * 260 * NOTE: if you are using a pure iterator (AsnIoNullOpen()) instead of really 261 * writing... 262 * 263 * To avoid checking all strings, set aip->fix_non_print = 2 264 * To check, get an error message, but not die, leave aip->fix_non_print=0 265 * To check and fail with non printing chars, set aip->fix_non_print=3 266 * 267 * 268 *****************************************************************************/ 269 270 271 /***************************************************************************** 272 * 273 * fix_utf8_in 274 * Supported values of fix_utf8_in are: 275 * 276 * 0 = (default) do not post any errors, set aip->utf8_read 277 * 1 = post an error of SEV_WARNING the first time, set aip->utf8_read 278 * 2 = post an error of SEV_WARNING every time, set aip->utf8_read 279 * 3 = do not do input conversion 280 * 281 *****************************************************************************/ 282 283 284 /***************************************************************************** 285 * 286 * fix_utf8_out 287 * Supported values of fix_utf8_out are: 288 * 289 * 0 = (default) do not post any errors, set aip->utf8_sent 290 * 1 = post an error of SEV_WARNING the first time, set aip->utf8_sent 291 * 2 = post an error of SEV_WARNING every time, set aip->utf8_sent 292 * 3 = do not do output conversion 293 * 294 *****************************************************************************/ 295 296 297 typedef struct asniomem { /* for AsnIo to and from a memory block */ 298 AsnIoPtr aip; /* the AsnIoPtr for this */ 299 BytePtr buf; /* a buffer for the data */ 300 Int4 size, /* size of this buffer (w) or bytes_to_read (r) */ 301 count; /* count of bytes read from or written to buffer */ 302 } AsnIoMem, PNTR AsnIoMemPtr; 303 304 typedef struct asniobs { /* for AsnIo to and from a memory ByteStore */ 305 AsnIoPtr aip; /* the AsnIoPtr for this */ 306 ByteStorePtr bsp; /* byte store for this */ 307 } AsnIoBS, PNTR AsnIoBSPtr; 308 309 /***** typedefs used often in object loaders **********/ 310 311 typedef Pointer (LIBCALL *AsnReadFunc) PROTO((AsnIoPtr aip, AsnTypePtr atp)); 312 typedef Boolean (LIBCALL *AsnWriteFunc) PROTO((Pointer object, AsnIoPtr aip, AsnTypePtr atp)); 313 314 typedef Boolean (LIBCALLBACK *AsnStreamStringFunc) (Pointer object, AsnIoPtr aip); 315 316 /***************************************************************************** 317 * 318 * prototypes 319 * 320 *****************************************************************************/ 321 /*** asngen.c ****/ 322 323 NLM_EXTERN AsnTypePtr LIBCALL AsnReadId PROTO((AsnIoPtr aip, AsnModulePtr amp, AsnTypePtr atp)); 324 NLM_EXTERN Int2 LIBCALL AsnReadVal PROTO((AsnIoPtr aip, AsnTypePtr atp, DataValPtr vp)); 325 NLM_EXTERN Boolean LIBCALL AsnWrite PROTO((AsnIoPtr aip, AsnTypePtr atp, DataValPtr dvp)); 326 NLM_EXTERN Boolean LIBCALL AsnWriteEx (AsnIoPtr aip, AsnTypePtr atp, DataValPtr dvp, AsnStreamStringFunc stream); 327 NLM_EXTERN Boolean LIBCALL AsnSkipValue PROTO((AsnIoPtr aip, AsnTypePtr atp)); 328 329 NLM_EXTERN Boolean LIBCALL AsnOpenStruct PROTO((AsnIoPtr aip, AsnTypePtr atp, 330 Pointer the_struct)); 331 NLM_EXTERN Boolean LIBCALL AsnCloseStruct PROTO((AsnIoPtr aip, AsnTypePtr atp, 332 Pointer the_struct)); 333 NLM_EXTERN Boolean LIBCALL AsnWriteChoice PROTO((AsnIoPtr aip, AsnTypePtr atp, Int2 choice, 334 DataValPtr the_value)); 335 NLM_EXTERN void LIBCALL AsnCheckExpOpt PROTO((AsnIoPtr aip, AsnTypePtr atp, DataValPtr dvp)); 336 NLM_EXTERN AsnExpOptPtr LIBCALL AsnExpOptNew PROTO((AsnIoPtr aip, CharPtr path, 337 Pointer user_data, AsnExpOptFunc user_func)); 338 NLM_EXTERN AsnExpOptPtr LIBCALL AsnExpOptFree PROTO((AsnIoPtr aip, AsnExpOptPtr aeop)); 339 NLM_EXTERN VoidPtr LIBCALL AsnFindNthPieceOfObject PROTO((AsnWriteFunc wfunc, Pointer datum, CharPtr string, Int4 n)); 340 341 NLM_EXTERN Int2 LIBCALL AsnGetLevel PROTO((AsnIoPtr aip)); 342 NLM_EXTERN void LIBCALL AsnNullValueMsg PROTO((AsnIoPtr aip, AsnTypePtr node)); 343 344 /*** asntypes.c ***/ 345 346 NLM_EXTERN void LIBCALL AsnKillValue PROTO((AsnTypePtr atp, DataValPtr dvp)); 347 NLM_EXTERN AsnTypePtr PNTR LIBCALL AsnTypePathFind PROTO((AsnModulePtr amp, CharPtr str, Int2Ptr numtypes)); 348 NLM_EXTERN AsnTypePtr LIBCALL AsnTypeFind PROTO((AsnModulePtr amp, CharPtr str)); 349 #define AsnFind(x) AsnTypeFind(NULL,x) /* find type (all) */ 350 NLM_EXTERN CharPtr LIBCALL AsnFindPrimName PROTO((AsnTypePtr atp)); 351 NLM_EXTERN AsnTypePtr LIBCALL AsnFindBaseType PROTO((AsnTypePtr atp)); 352 NLM_EXTERN AsnTypePtr LIBCALL AsnFindBaseTypeDTD PROTO((AsnTypePtr atp)); 353 NLM_EXTERN CharPtr LIBCALL AsnFindBaseName PROTO((AsnTypePtr atp)); 354 NLM_EXTERN Int2 LIBCALL AsnFindBaseIsa PROTO((AsnTypePtr atp)); 355 NLM_EXTERN AsnTypePtr LIBCALL AsnLinkType PROTO((AsnTypePtr type, AsnTypePtr localtype)); 356 NLM_EXTERN void LIBCALL AsnUnlinkType PROTO((AsnTypePtr type)); 357 NLM_EXTERN CharPtr LIBCALL AsnTypeDumpStack PROTO((CharPtr str, AsnIoPtr aip)); 358 NLM_EXTERN Boolean LIBCALL AsnTreeLoad PROTO((char * file, AsnValxNodePtr * avnptr, AsnTypePtr * atptr, AsnModulePtr * ampptr)); 359 NLM_EXTERN void LIBCALL AsnStoreTree PROTO((CharPtr file, AsnModulePtr amp)); 360 #define AsnLoad() AsnTreeLoad(asnfilename, &avn, &at, &) /* simple loader */ 361 NLM_EXTERN void LIBCALL AsnModuleLink PROTO((AsnModulePtr amp)); 362 NLM_EXTERN CharPtr LIBCALL AsnEnumStr PROTO((CharPtr str, Int2 val)); 363 NLM_EXTERN CharPtr LIBCALL AsnEnumTypeStr PROTO((AsnTypePtr atp, Int2 val)); 364 NLM_EXTERN AsnModulePtr LIBCALL AsnAllModPtr PROTO((void)); 365 366 /***************************************************************************** 367 * 368 * Int4 AsnTypeStringToHex(from, len, to, left) 369 * converts an octet string to binary 370 * returns number of hex digits created if all ok 371 * *left is chars left at the end of the buffer including first letter of 372 * a remaining digit (from does not have an even number of letters) 373 * since this could include white space, could be more than 1 374 * returns a negative number on an error 375 * skips over internal or trailing white space 376 * left can be NULL, in which case it is ignored 377 * 378 *****************************************************************************/ 379 NLM_EXTERN Int4 LIBCALL AsnTypeStringToHex (Pointer from, Int4 len, Pointer to, Int4Ptr left); 380 381 /*** asnio.c ****/ 382 383 NLM_EXTERN CharPtr LIBCALL AsnErrGetTypeName PROTO((CharPtr name)); 384 NLM_EXTERN AsnIoPtr LIBCALL AsnIoOpen PROTO((CharPtr file_name, CharPtr mode)); 385 NLM_EXTERN AsnIoPtr LIBCALL AsnIoClose PROTO((AsnIoPtr aip)); 386 NLM_EXTERN AsnIoPtr LIBCALL AsnIoFree PROTO((AsnIoPtr aip, Boolean close_file)); 387 NLM_EXTERN void LIBCALL AsnIoReset PROTO((AsnIoPtr aip)); 388 NLM_EXTERN void LIBCALL AsnIoSetErrorMsg PROTO((AsnIoPtr aip, ErrorRetType error_ret)); 389 NLM_EXTERN Int4 LIBCALL AsnIoSeek PROTO((AsnIoPtr aip, Int4 pos)); 390 NLM_EXTERN Int4 LIBCALL AsnIoTell PROTO((AsnIoPtr aip)); 391 NLM_EXTERN void LIBCALL AsnIoFlush PROTO((AsnIoPtr aip)); 392 NLM_EXTERN AsnIoPtr LIBCALL AsnIoNew PROTO((Int1 type, FILE * fp, Pointer iostruct, IoFuncType readfunc, IoFuncType writefunc)); 393 NLM_EXTERN Boolean LIBCALL AsnIoSetBufsize PROTO((AsnIoPtr aip, Int2 size)); 394 NLM_EXTERN AsnOptionPtr LIBCALL AsnIoOptionNew PROTO((AsnIoPtr aip, Int2 ao_class, Int2 type, DataVal av, AsnOptFreeFunc freefunc)); 395 NLM_EXTERN void LIBCALL AsnIoOptionFree PROTO((AsnIoPtr aip, Int2 ao_class, Int2 type)); 396 NLM_EXTERN Boolean LIBCALL AsnClassTypeMatch PROTO((Int2 ao_class, Int2 type, Int2 this_class, Int2 this_type)); 397 NLM_EXTERN AsnOptionPtr LIBCALL AsnIoOptionGet PROTO((AsnIoPtr aip, Int2 ao_class, Int2 type, AsnOptionPtr last)); 398 NLM_EXTERN AsnOptionPtr LIBCALL AsnOptionNew PROTO((AsnOptionPtr PNTR aopp, Int2 ao_class, Int2 type, DataVal av, AsnOptFreeFunc freefunc)); 399 NLM_EXTERN void LIBCALL AsnOptionFree PROTO((AsnOptionPtr PNTR aopp, Int2 ao_class, Int2 type)); 400 NLM_EXTERN AsnOptionPtr LIBCALL AsnOptionGet PROTO((AsnOptionPtr head, Int2 ao_class, Int2 type, AsnOptionPtr last)); 401 NLM_EXTERN Boolean LIBCALL AsnSetXMLmodulePrefix (CharPtr prefix); 402 NLM_EXTERN Boolean LIBCALL AsnSetXMLmodulePrefixToDefault (void); 403 NLM_EXTERN CharPtr LIBCALL AsnGetXMLmodulePrefix (void); 404 405 /*** calculate hash value from ASN.1 ***/ 406 NLM_EXTERN Uint4 LIBCALL AsnIoHash (Pointer from, AsnWriteFunc writefunc); 407 408 /*** read and write to memory buffer ***/ 409 NLM_EXTERN AsnIoMemPtr LIBCALL AsnIoMemOpen PROTO((CharPtr mode, BytePtr buf, Int4 size)); 410 NLM_EXTERN AsnIoMemPtr LIBCALL AsnIoMemClose PROTO((AsnIoMemPtr aimp)); 411 NLM_EXTERN Boolean LIBCALL AsnIoMemReset PROTO((AsnIoMemPtr aimp, Int4 bytes_to_read)); 412 NLM_EXTERN Int2 LIBCALL AsnIoMemRead PROTO((Pointer, CharPtr, Uint2)); 413 NLM_EXTERN Int2 LIBCALL AsnIoMemWrite PROTO((Pointer, CharPtr, Uint2)); 414 415 /*** read and write to a ByteStore in memory ***/ 416 NLM_EXTERN AsnIoBSPtr LIBCALL AsnIoBSOpen PROTO((CharPtr mode, ByteStorePtr bsp)); 417 NLM_EXTERN AsnIoBSPtr LIBCALL AsnIoBSClose PROTO((AsnIoBSPtr aibp)); 418 NLM_EXTERN Int2 LIBCALL AsnIoBSRead PROTO((Pointer, CharPtr, Uint2)); 419 NLM_EXTERN Int2 LIBCALL AsnIoBSWrite PROTO((Pointer, CharPtr, Uint2)); 420 421 /** Copy and Compare functions ***/ 422 NLM_EXTERN Pointer LIBCALL AsnIoCopy PROTO((Pointer from, AsnReadFunc readfunc, AsnWriteFunc writefunc)); 423 NLM_EXTERN Pointer LIBCALL AsnIoMemCopy PROTO((Pointer from, AsnReadFunc readfunc, AsnWriteFunc writefunc)); 424 NLM_EXTERN Boolean LIBCALL AsnIoMemComp PROTO((Pointer a, Pointer b, AsnWriteFunc writefunc)); 425 426 #define AsnIoNullOpen() AsnIoNew((ASNIO_OUT | ASNIO_TEXT | ASNIO_CARRIER), NULL, NULL, NULL, NULL) 427 428 /*** asndebin.c ***/ 429 430 NLM_EXTERN AsnTypePtr LIBCALL AsnBinReadId PROTO((AsnIoPtr aip, AsnTypePtr atp)); 431 NLM_EXTERN Int2 LIBCALL AsnBinReadVal PROTO((AsnIoPtr aip, AsnTypePtr atp, DataValPtr vp)); 432 433 /*** asnenbin.c ***/ 434 435 NLM_EXTERN Boolean LIBCALL AsnBinWrite PROTO((AsnIoPtr aip, AsnTypePtr atp, DataValPtr dvp)); 436 /** expert use only ***/ 437 NLM_EXTERN Boolean LIBCALL AsnEnBinTheBytes PROTO((Pointer ptr, Uint4 len, AsnIoPtr aip, Boolean is_string)); 438 #define AsnEnBinBytes(a,b,c) AsnEnBinTheBytes(a, b, c, FALSE) 439 440 /*** asnlex.c ***/ 441 442 NLM_EXTERN AsnTypePtr LIBCALL AsnTxtReadId PROTO((AsnIoPtr aip, AsnModulePtr amp, AsnTypePtr atp)); 443 NLM_EXTERN Int2 LIBCALL AsnTxtReadVal PROTO((AsnIoPtr aip, AsnTypePtr atp, DataValPtr vp)); 444 445 /*** asnprint.c ***/ 446 447 NLM_EXTERN Boolean LIBCALL AsnTxtWrite PROTO((AsnIoPtr aip, AsnTypePtr atp, DataValPtr dvp)); 448 NLM_EXTERN Boolean LIBCALL AsnTxtWriteEx (AsnIoPtr aip, AsnTypePtr atp, DataValPtr dvp, AsnStreamStringFunc stream); 449 450 /*** asnlext.c ***/ 451 452 NLM_EXTERN AsnModulePtr LIBCALL AsnLoadModules PROTO((AsnIoPtr aip)); 453 454 /*** asngenob.c ***/ 455 NLM_EXTERN ValNodePtr LIBCALL AsnGenericBaseSeqOfAsnRead PROTO ((AsnIoPtr aip, AsnModulePtr amp, AsnTypePtr orig, int whichvalslot, BoolPtr isError)); 456 NLM_EXTERN Boolean LIBCALL AsnGenericBaseSeqOfAsnWrite PROTO ((ValNodePtr ptr, int whichvalslot, AsnIoPtr aip, AsnTypePtr bag_atp, AsnTypePtr element_atp)); 457 NLM_EXTERN Boolean LIBCALL AsnGenericBaseSeqOfFree PROTO ((ValNodePtr ptr, int whichvalslot)); 458 NLM_EXTERN Pointer AsnGenericUserSeqOfAsnRead PROTO ((AsnIoPtr aip, AsnModulePtr amp, AsnTypePtr orig, BoolPtr isError, AsnReadFunc readfunc, AsnOptFreeFunc freefunc)); 459 NLM_EXTERN Boolean LIBCALL AsnGenericUserSeqOfAsnWrite PROTO ((Pointer ptr, AsnWriteFunc writefunc, AsnIoPtr aip, AsnTypePtr bag_atp, AsnTypePtr element_atp)); 460 NLM_EXTERN Boolean LIBCALL AsnGenericUserSeqOfFree PROTO ((Pointer ptr, AsnOptFreeFunc freefunc)); 461 NLM_EXTERN Pointer LIBCALL AsnGenericChoiceSeqOfAsnRead PROTO ((AsnIoPtr aip, AsnModulePtr amp, AsnTypePtr orig, BoolPtr isError, AsnReadFunc readfunc, AsnOptFreeFunc freefunc)); 462 NLM_EXTERN Boolean LIBCALL AsnGenericChoiceSeqOfAsnWrite PROTO ((Pointer ptr, AsnWriteFunc writefunc, AsnIoPtr aip, AsnTypePtr bag_atp, AsnTypePtr element_atp)); 463 NLM_EXTERN Boolean LIBCALL AsnGenericChoiceSeqOfFree PROTO ((Pointer ptr, AsnOptFreeFunc freefunc)); 464 465 NLM_EXTERN ValNodePtr LIBCALL AsnGenericValNodeSetAsnRead ( 466 AsnIoPtr aip, 467 AsnModulePtr amp, 468 AsnTypePtr orig, 469 BoolPtr isError, 470 AsnReadFunc readfunc, 471 AsnOptFreeFunc freefunc 472 ); 473 NLM_EXTERN Boolean LIBCALL AsnGenericValNodeSetAsnWrite ( 474 ValNodePtr ptr, 475 AsnWriteFunc writefunc, 476 AsnIoPtr aip, 477 AsnTypePtr bag_atp, 478 AsnTypePtr element_atp 479 ); 480 NLM_EXTERN ValNodePtr LIBCALL AsnGenericValNodeSetFree ( 481 ValNodePtr ptr, 482 AsnOptFreeFunc freefunc 483 ); 484 485 /*** asnbufo.c ***/ 486 NLM_EXTERN Boolean LIBCALL AsnBufWrite PROTO ((AsnIoPtr aip, AsnTypePtr atp, CharPtr buf, size_t buflen)); 487 NLM_EXTERN Boolean LIBCALL AsnBinBufWrite PROTO ((AsnIoPtr aip, AsnTypePtr atp, CharPtr buf, size_t buflen)); 488 NLM_EXTERN Boolean LIBCALL AsnTxtBufWrite PROTO ((AsnIoPtr aip, AsnTypePtr atp, CharPtr buf, size_t buflen)); 489 490 491 492 /******** temporary defines for older code *************/ 493 494 #define AsnStartStruct(x,y) AsnOpenStruct(x, y, NULL) 495 #define AsnEndStruct(x,y) AsnCloseStruct(x, y, NULL) 496 497 /***** AsnOption ao_class values - do not reuse ***************/ 498 /***** all positive numbers > 0 are available to non-NCBI applications ***/ 499 500 #define OP_ANY 0 501 #define OP_TOGENBNK -1 502 #define OP_BB2ASN -2 503 #define OP_NCBIOBJSSET -3 504 #define OP_NCBIOBJSEQ -4 505 #define OP_GET_MUID -5 506 #define OP_NCBIASNTOOL -6 507 #define OP_NCBIHINTS -7 508 #define OP_GESTALT -8 509 #define OP_NCBIOBJSTR -9 510 #define OP_TYPEORDER -10 /* for printing out DTD or spec */ 511 #define OP_COMMENTBEFORE -11 /* ditto */ 512 #define OP_COMMENT -12 /* ditto */ 513 514 /****** these are the possible returns from AsnFindBaseIsa() *****/ 515 /****** the numbers are arbitrary, but should never be changed ***/ 516 517 #define BOOLEAN_TYPE 301 /* BOOLEAN */ 518 #define INTEGER_TYPE 302 /* INTEGER */ 519 #define BITS_TYPE 303 /* BIT STRING */ 520 #define OCTETS_TYPE 304 /* OCTET STRING */ 521 #define NULL_TYPE 305 /* NULL */ 522 #define OBID_TYPE 306 /* OBJECT IDENTIFIER */ 523 #define OBDES_TYPE 307 /* ObjectDescriptor */ 524 #define EXTERNAL_TYPE 308 /* EXTERNAL */ 525 #define REAL_TYPE 309 /* REAL */ 526 #define ENUM_TYPE 310 /* ENUMERATED */ 527 #define SEQ_TYPE 311 /* SEQUENCE */ 528 #define SEQOF_TYPE 312 /* SEQUENCE OF */ 529 #define SET_TYPE 313 /* SET */ 530 #define SETOF_TYPE 314 /* SET OF */ 531 #define CHOICE_TYPE 315 /* CHOICE */ 532 #define ANY_TYPE 316 /* ANY */ 533 #define NUMERICSTRING_TYPE 317 /* String Types */ 534 #define PRINTABLESTRING_TYPE 318 535 #define TELETEXSTRING_TYPE 319 536 #define UTF8STRING_TYPE 320 537 #define IA5STRING_TYPE 321 538 #define GRAPHICSTRING_TYPE 322 539 #define VISIBLESTRING_TYPE 323 540 #define GENERALSTRING_TYPE 324 541 #define CHARACTERSTRING_TYPE 325 542 #define GENTIME_TYPE 326 /* Time types */ 543 #define UTCTIME_TYPE 327 544 545 #define STRSTORE_TYPE 351 /* Application: StringStore */ 546 #define BIGINT_TYPE 352 /* Application: Int8 */ 547 548 /******* grouping macros on ISA defines above ********************/ 549 550 #define ISA_STRINGTYPE(x) (((x) >= 317) && ((x) <= 325)) 551 #define ISA_STRUCTTYPE(x) (((x) >= 311) && ((x) <= 314)) 552 #define ISA_INTTYPE(x) (((x) == 302) || ((x) == 310)) 553 554 /* #defines used by automatically-generated object loaders */ 555 #define ASNCODE_PTRVAL_SLOT 1 556 #define ASNCODE_REALVAL_SLOT 2 557 #define ASNCODE_INTVAL_SLOT 3 558 #define ASNCODE_BOOLVAL_SLOT 4 559 #define ASNCODE_BYTEVAL_SLOT 5 560 #define ASNCODE_BIGINTVAL_SLOT 6 561 562 #ifdef __cplusplus 563 } 564 #endif 565 566 #undef NLM_EXTERN 567 #ifdef NLM_EXPORT 568 #define NLM_EXTERN NLM_EXPORT 569 #else 570 #define NLM_EXTERN 571 #endif 572 573 #endif 574