/* * any.c * * "Bug" ASN.1 module encode/decode/print/free C src. * * This file was generated by snacc on Mon Oct 1 17:36:35 2001 * * UBC snacc written by Mike Sample * * NOTE: This is a machine generated file - editing not recommended */ #include "asn-incl.h" #include "any.h" AsnOid id_phoneNumber = { 7, "\174\2\5\105\1\0\2" }; void InitAnyBug() { /* Since no INTEGER/OID to ANY type relations were defined * (usually done via MACROs) you must manually do the code * to fill the hash tbl. * if the ids are INTEGER use the following: * InstallAnyByInt (??_ANY_ID, intVal, sizeof (Foo), (EncodeFcn) DEncFoo, (DecodeFcn)DDecFoo, (FreeFcn)FreeFoo, (PrintFcn)PrintFoo); * if the ids are OBJECT IDENTIFIERs use the following: * InstallAnyByOid (??_ANY_ID, oidVal, sizeof (Foo), (EncodeFcn) DEncFoo, (DecodeFcn)DDecFoo, (FreeFcn)FreeFoo, (PrintFcn)PrintFoo); * put the ??_ANY_IDs in the AnyId enum. * For example if you have some thing like * T1 ::= SEQUENCE { id INTEGER, ANY DEFINED BY id } * and the id 1 maps to the type BOOLEAN use the following: * InstallAnyByInt (SOMEBOOL_ANY_ID, 1, sizeof (AsnBool), (EncodeFcn) DEncAsnBool, (DecodeFcn)DDecAsnBool, (FreeFcn)NULL, (PrintFcn)PrintAsnBool);; */ ??????? } /* InitAnyBug */ AsnLen DEncContentContent PARAMS ((b, v), BUF_TYPE b _AND_ Content *v) { AsnLen totalLen = 0; AsnLen itemLen; AsnLen listLen; void *component; SetAnyTypeByOid ((&v->content), (&v->type)); itemLen = DEncAsnAnyDefinedBy (b, (&v->content)); totalLen += itemLen; itemLen = DEncAsnOidContent (b, (&v->type)); itemLen += DEncDefLen (b, itemLen); itemLen += DEncTag1 (b, UNIV, PRIM, 6); totalLen += itemLen; return totalLen; } /* DEncContentContent */ void DDecContentContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), BUF_TYPE b _AND_ AsnTag tagId0 _AND_ AsnLen elmtLen0 _AND_ Content *v _AND_ AsnLen *bytesDecoded _AND_ ENV_TYPE env) { int seqDone = FALSE; AsnLen totalElmtsLen1 = 0; AsnLen elmtLen1; AsnTag tagId1; int mandatoryElmtCount1 = 0; tagId1 = DDecTag (b, &totalElmtsLen1, env); if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))) { elmtLen1 = DDecLen (b, &totalElmtsLen1, env); DDecAsnOidContent (b, tagId1, elmtLen1, (&v->type), &totalElmtsLen1, env); } else longjmp (env, -100); { SetAnyTypeByOid ((&v->content), (&v->type)); DDecAsnAnyDefinedBy (b, (&v->content), &totalElmtsLen1, env); seqDone = TRUE; if (elmtLen0 == INDEFINITE_LEN) DDecEoc (b, &totalElmtsLen1, env); else if (totalElmtsLen1 != elmtLen0) longjmp (env, -101); } if (!seqDone) longjmp (env, -102); (*bytesDecoded) += totalElmtsLen1; } /* DDecContentContent */ void PrintContent PARAMS ((f, v, indent), FILE* f _AND_ Content *v _AND_ unsigned short int indent) { if (v == NULL) return; fprintf (f,"{ -- SEQUENCE --\n"); Indent (f, indent + stdIndentG); fprintf (f,"type "); PrintAsnOid (f, (&v->type), indent + stdIndentG); fprintf (f, ",\n"); Indent (f, indent + stdIndentG); fprintf (f,"content "); PrintAsnAnyDefinedBy (f, (&v->content), indent + stdIndentG); fprintf (f,"\n"); Indent (f, indent); fprintf (f,"}"); } /* PrintContent */ void FreeContent PARAMS ((v), Content *v) { if (v == NULL) return; FreeAsnOid ((&v->type)); FreeAsnAnyDefinedBy ((&v->content)); } /* FreeContent */ AsnLen DEncPhoneNumberContent PARAMS ((b, v), BUF_TYPE b _AND_ PhoneNumber *v) { AsnLen totalLen = 0; AsnLen itemLen; AsnLen listLen; void *component; itemLen = DEncAsnIntContent (b, (&v->number)); DEncDefLenTo127 (b, itemLen); itemLen++; itemLen += DEncTag1 (b, UNIV, PRIM, 2); totalLen += itemLen; itemLen = DEncAsnIntContent (b, (&v->area)); DEncDefLenTo127 (b, itemLen); itemLen++; itemLen += DEncTag1 (b, UNIV, PRIM, 2); totalLen += itemLen; itemLen = DEncAsnIntContent (b, (&v->country)); DEncDefLenTo127 (b, itemLen); itemLen++; itemLen += DEncTag1 (b, UNIV, PRIM, 2); totalLen += itemLen; return totalLen; } /* DEncPhoneNumberContent */ void DDecPhoneNumberContent PARAMS ((b, tagId0, elmtLen0, v, bytesDecoded, env), BUF_TYPE b _AND_ AsnTag tagId0 _AND_ AsnLen elmtLen0 _AND_ PhoneNumber *v _AND_ AsnLen *bytesDecoded _AND_ ENV_TYPE env) { int seqDone = FALSE; AsnLen totalElmtsLen1 = 0; AsnLen elmtLen1; AsnTag tagId1; int mandatoryElmtCount1 = 0; tagId1 = DDecTag (b, &totalElmtsLen1, env); if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) { elmtLen1 = DDecLen (b, &totalElmtsLen1, env); DDecAsnIntContent (b, tagId1, elmtLen1, (&v->country), &totalElmtsLen1, env); tagId1 = DDecTag (b, &totalElmtsLen1, env); } else longjmp (env, -103); if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) { elmtLen1 = DDecLen (b, &totalElmtsLen1, env); DDecAsnIntContent (b, tagId1, elmtLen1, (&v->area), &totalElmtsLen1, env); tagId1 = DDecTag (b, &totalElmtsLen1, env); } else longjmp (env, -104); if (((tagId1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))) { elmtLen1 = DDecLen (b, &totalElmtsLen1, env); DDecAsnIntContent (b, tagId1, elmtLen1, (&v->number), &totalElmtsLen1, env); seqDone = TRUE; if (elmtLen0 == INDEFINITE_LEN) DDecEoc (b, &totalElmtsLen1, env); else if (totalElmtsLen1 != elmtLen0) longjmp (env, -105); } else longjmp (env, -106); if (!seqDone) longjmp (env, -107); (*bytesDecoded) += totalElmtsLen1; } /* DDecPhoneNumberContent */ void PrintPhoneNumber PARAMS ((f, v, indent), FILE* f _AND_ PhoneNumber *v _AND_ unsigned short int indent) { if (v == NULL) return; fprintf (f,"{ -- SEQUENCE --\n"); Indent (f, indent + stdIndentG); fprintf (f,"country "); PrintAsnInt (f, (&v->country), indent + stdIndentG); fprintf (f, ",\n"); Indent (f, indent + stdIndentG); fprintf (f,"area "); PrintAsnInt (f, (&v->area), indent + stdIndentG); fprintf (f, ",\n"); Indent (f, indent + stdIndentG); fprintf (f,"number "); PrintAsnInt (f, (&v->number), indent + stdIndentG); fprintf (f,"\n"); Indent (f, indent); fprintf (f,"}"); } /* PrintPhoneNumber */ void FreePhoneNumber PARAMS ((v), PhoneNumber *v) { if (v == NULL) return; FreeAsnInt ((&v->country)); FreeAsnInt ((&v->area)); FreeAsnInt ((&v->number)); } /* FreePhoneNumber */