⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gen-code.c

📁 asn to c编译器 源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
    PrintConditionalIncludeClose (hdr, m->cHdrFileName);} /* PrintCCode */voidPrintConstraintValueCheckingCode PARAMS ((src, td, t, nt),	FILE *src _AND_	TypeDef *td _AND_	Type *t _AND_	NamedType *nt){	if(t == NULL || nt == NULL)		return;	fprintf (src, "\tfor(index=0; index < %s_Size; index++)\n", t->tableConstraint->objSetAssignment->objectSetName);	fprintf (src, "\t{\n");	fprintf (src, "\t\tif(&v->%s == &%s[index].%s)\n", nt->fieldName, t->tableConstraint->objSetAssignment->objectSetName, nt->fieldName);	fprintf (src, "\t\t\tbreak;\n");	fprintf (src, "\t}\n");	fprintf (src, "\n");	fprintf (src, "\tif(&v->%s == %s_Size)\n", nt->fieldName, t->tableConstraint->objSetAssignment->objectSetName);	fprintf (src, "\t\treturn 0;\n");	fprintf (src, "\n");	td=td; } /* PrintConstraintValueCheckingCode */static void		// Deepak: 24/Mar/2003PrintCHdrObjectDeclaration_and_Init PARAMS ((hdr, m, r), 	FILE *hdr _AND_	Module *m _AND_	CRules *r){	ObjectAssignment *oa;	ObjectSetAssignment *osa;	//RWC;ObjectAssignmentField *oaf;	//RWC;TypeOrValue* tOrV;	char* moduleName;	int osaCount=0, currOsa=0;	char *osaName="";	//RWC;char *objName="";		////////////////////////////////////////////////////////////////////////////////////	/* Declare Object Assignments */		// Deepak: 13/Mar/2003	fprintf (hdr, "/* ========== Object Declarations ========== */\n");	FOR_EACH_LIST_ELMT (oa, m->objAssignments)	{		fprintf (hdr, "%s %s;\n", Asn1ValueName2CValueName(oa->objectClassName), Asn1ValueName2CValueName(oa->objectName));	}	fprintf (hdr, "\n");	////////////////////////////////////////////////////////////////////////////////////	////////////////////////////////////////////////////////////////////////////////////	/* Declare Object Set Assignments */	// Deepak: 13/Mar/2003	fprintf (hdr, "\n/* ========== Object Set Declarations ========== */\n");	FOR_EACH_LIST_ELMT (osa, m->objSetAssignments)	{		currOsa = 0;		osaCount = osa->objectNameList->count;		osaName = Asn1ValueName2CValueName(osa->objectSetName);		fprintf (hdr, "%s %s[%d];\n", Asn1ValueName2CValueName(osa->objectClassName), osaName, osaCount);		fprintf (hdr, "int %s_Size = %d;\n", osaName, osaCount);		fprintf (hdr, "\n");	}	////////////////////////////////////////////////////////////////////////////////////	////////////////////////////////////////////////////////////////////////////////////	// Init Module Objects	moduleName = Asn1ValueName2CValueName(m->modId->name);	//RWC;REMOVED;fprintf (hdr, "/* ========== init_%sObjects() ========== */\n", moduleName);    /*RWC;REMOVED;	fprintf (hdr, "void init_%sObjects()\n", moduleName);	fprintf (hdr, "{\n");		FOR_EACH_LIST_ELMT (oa, m->objAssignments)	{		objName = Asn1ValueName2CValueName(oa->objectName);		FOR_EACH_LIST_ELMT (oaf, oa->objectAssignmentField)		{			PrintCHdrObjectField (hdr, m, r, objName, oaf);		}		fprintf (hdr, "\n");	}	fprintf (hdr, "}\n");	fprintf (hdr, "\n");	////////////////////////////////////////////////////////////////////////////////////	////////////////////////////////////////////////////////////////////////////////////	// Init Module Object Sets		FOR_EACH_LIST_ELMT (osa, m->objSetAssignments)	{		currOsa = 0;		osaCount = osa->objectNameList->count;		osaName = Asn1ValueName2CValueName(osa->objectSetName);		fprintf (hdr, "void init_%s()\n", osaName);		fprintf (hdr, "{\n");		FOR_EACH_LIST_ELMT (tOrV, osa->objectNameList)		// Deepak: 24/Mar/2003		{			if(tOrV->choiceId)				oa = tOrV->a.value->basicValue->a.objAssignment;			else	// this tOrV can never be type as per my knowledge.				continue;			sprintf(osaName, "%s[%d]", Asn1ValueName2CValueName(osa->objectSetName), currOsa);			FOR_EACH_LIST_ELMT (oaf, oa->objectAssignmentField)			{				PrintCHdrObjectField (hdr, m, r, osaName, oaf);			}			fprintf (hdr, "\n");			currOsa++;		}		fprintf (hdr, "}\n");		fprintf (hdr, "\n");	}	////////////////////////////////////////////////////////////////////////////////////	////////////////////////////////////////////////////////////////////////////////////	// Module Init           	fprintf (hdr, "void %s_init()\n", moduleName);	fprintf (hdr, "{\n");	fprintf (hdr, "\tinit_%sValue();\n", moduleName);	fprintf (hdr, "\tinit_%sObjects();\n", moduleName);	FOR_EACH_LIST_ELMT (osa, m->objSetAssignments)	{		fprintf (hdr, "\tinit_%s()\n", Asn1ValueName2CValueName(osa->objectSetName));	}	fprintf (hdr, "}\n");	fprintf (hdr, "\n");	////////////////////////////////////////////////////////////////////////////////////     *RWC;REMOVED;*/	r=r;} /* PrintCHdrObjectDeclaration_and_Init *//*RWC;REMOVED;static void		// Deepak: 24/Mar/2003PrintCHdrObjectField PARAMS ((hdr, m, r, objName, oaf), 	FILE *hdr _AND_	Module *m _AND_	CRules *r _AND_	char *objName _AND_	ObjectAssignmentField *oaf){	char *objFieldName="";	objFieldName = Asn1ValueName2CValueName(oaf->objectFieldName);	if(oaf->bPresent && oaf->typeOrValue->choiceId)		{	// value		fprintf (hdr, "\t%s.%s = ", objName, objFieldName);		PrintCValueInstantiation (hdr, r, oaf->typeOrValue->a.value);		fprintf (hdr, ";\n");	}		// Print here if optional arguments are present or not	if(oaf->bOptional)	// Deepak: 22/Mar/2003	{		fprintf (hdr, "\t%s.m.%sPresent = %d;\n", objName, objFieldName, oaf->bPresent?1:0);	}		// Now write the BasicType_Unknown initialisation here...	if(oaf->bPresent && oaf->bUnknownType)	// Unknown Type	 Deepak: 22/Mar/2003	{	// value		char *typeName = Asn1ValueName2CValueName(oaf->typeOrValue->a.type->basicType->a.localTypeRef->typeName);		//fprintf (hdr, "\t%s.%sName = \"%s\";\n", objName, objFieldName, typeName);		fprintf (hdr, "\t%s.%s = %s;\n", objName, objFieldName, typeName);		fprintf (hdr, "\t%s.%sSize = sizeof(%s);\n", objName, objFieldName, typeName);		fprintf (hdr, "\t%s.encode%s = &%s%s%sContent;\n", objName, objFieldName, GetEncRulePrefix(), r->encodeRoutineBaseName, typeName);		fprintf (hdr, "\t%s.decode%s = &%s%s%sContent;\n", objName, objFieldName, GetEncRulePrefix(), r->decodeRoutineBaseName, typeName);//		fprintf (hdr, "\t%s.tag = %d;\n", objName, LIBTYPE_GET_UNIV_TAG_CODE(oaf->typeOrValue->a.type->basicType->a.localTypeRef->link->type->basicType->choiceId));		typeName = Code2UnivCodeStr(LIBTYPE_GET_UNIV_TAG_CODE(oaf->typeOrValue->a.type->basicType->a.localTypeRef->link->type->basicType->choiceId));		fprintf (hdr, "\t%s.tagId = %s;\n", objName, typeName);	}	m;} / * PrintCHdrObjectField * /***RWC;REMOVED **/static voidPrintCSrcComment PARAMS ((src, m),    FILE *src _AND_    Module *m){    long int t;    t = time (0);    fprintf (src, "/*\n");    fprintf (src, " *    %s\n", m->cSrcFileName);    fprintf (src, " *    \"%s\" ASN.1 module encode/decode/print/free C src.\n", m->modId->name);    fprintf (src, " *    This file was generated by Coral WinSnacc on %s", ctime (&t));    fprintf (src, " *    Coral WinSnacc written by Deepak Gupta\n");    fprintf (src, " *    NOTE: This is a machine generated file - editing not recommended\n");    fprintf (src, " */\n\n");} /* PrintSrcComment */static char *GetImportFileName (char *Impname, ModuleList *mods){	Module *currMod;	char *fileName = NULL;    FOR_EACH_LIST_ELMT (currMod, mods)	{		/* Find the import Module in the Modules and		 * return the header file name		 */		if ((strcmp(Impname, currMod->modId->name) == 0))		{			/* Set the file name and break */			fileName = currMod->cHdrFileName;			break;		}	}	return fileName;}/* RWC; CHANGED to print to hdr file instead of src file to avoid*  interaction of multiple include references; this way all files*  will appropriately pull in their respective references.*/static voidPrintCSrcIncludes PARAMS ((inFile, m, mods ),    FILE *inFile _AND_    Module *m _AND_    ModuleList *mods /* _AND_	char *srcref*/){    void *tmp;    Module *currMod;    AsnListNode *currModTmp;    /*     * include snacc runtime library related hdrs     */    fprintf (inFile, "\n#include \"asn-incl.h\"\n");    /*     * print out include files in same order of the module     * list. every module in the list includes the others and it's     * own .h     */    tmp = (void*)CURR_LIST_NODE (mods);    FOR_EACH_LIST_ELMT (currMod, mods)    {		if ((strcmp(m->cHdrFileName, currMod->cHdrFileName) == 0))		{			ImportModuleList *ModLists;			ImportModule *impMod;			char *ImpFile = NULL;			ModLists = currMod->imports;            currModTmp = mods->curr;    //RWC;FIXES infinite loop problem.                                        //  IN case changed inside loop.			FOR_EACH_LIST_ELMT(impMod, ModLists)			{				ImpFile = GetImportFileName (impMod->modId->name, mods);				if (ImpFile != NULL)					fprintf (inFile, "#include \"%s\"\n", ImpFile);			}            mods->curr = currModTmp;    // RWC;RESET loop control        }//		if ((ImportedFilesG == FALSE) || (impMod->ImportedFlag == TRUE))//		{//			// Only include if Module was exported//			if (impMod->exportStatus != 0)//			{//				// Check that the source header is not part of //				// These references.//				if ((strcmp(impMod->cHdrFileName, srcref) != 0))//					fprintf (src, "#include \"%s\"\n", impMod->cHdrFileName);//			}//		} // endif //       fprintf (src, "#include \"%s\"\n", impMod->cHdrFileName);    }	//RWC;if (m->cHdrFileName != NULL)	//RWC;	fprintf (inFile, "#include \"%s\"\n", m->cHdrFileName);    SET_CURR_LIST_NODE (mods, tmp);   m=m; /* AVOIDS warning. */}  /* PrintCSrcIncludes */static voidPrintCHdrComment PARAMS ((f, m),    FILE *f _AND_    Module *m){    long int t;    t = time (0);    fprintf (f, "/*\n");    fprintf (f, " *    %s\n", m->cHdrFileName);    fprintf (f, " *    \"%s\" ASN.1 module C type definitions and prototypes\n", m->modId->name);    fprintf (f, " *    This .h file was generated by Coral WinSnacc on %s", ctime (&t));    fprintf (f, " *    Coral WinSnacc written compiler by Deepak Gupta\n");    fprintf (f, " *    NOTE: This is a machine generated file--editing not recommended\n");    fprintf (f, " */\n\n");} /* PrintCHdrComment */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -