📄 type-info.c
字号:
if (ctri->cFieldName == NULL) { if ((et->type->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || (et->type->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) { /* * take ref'd type name as field name * convert first let to lower case */ tmpName = et->type->basicType->a.localTypeRef->link->cTypeDefInfo->cTypeName; tmpName = Asn1TypeName2CTypeName (tmpName); cFieldName = Malloc (strlen (tmpName) + r->maxDigitsToAppend +1); strcpy (cFieldName, tmpName); Free (tmpName); if (isupper (cFieldName[0])) cFieldName[0] = (char)tolower (cFieldName[0]); } else { /* * get default field name for this type */ tmpName = r->typeConvTbl[et->type->basicType->choiceId].defaultFieldName; cFieldName = Malloc (strlen (tmpName) + r->maxDigitsToAppend +1); strcpy (cFieldName, tmpName); if (isupper (cFieldName[0])) cFieldName[0] = (char)tolower (cFieldName[0]); } MakeCStrUnique (fieldNames, cFieldName, r->maxDigitsToAppend, 1); DefineObj (&fieldNames, cFieldName); ctri->cFieldName = cFieldName; } } FreeDefinedObjs (&fieldNames);} /* FillCFieldNames *//* * returns true if this c type for this type should be * be ref'd as a ptr */static intIsCPtr PARAMS ((r, td, t, parentCTypeId), CRules *r _AND_ TypeDef *td _AND_ Type *t _AND_ CTypeId parentCTypeId){ CTDI *ctdi; int retVal = FALSE; /* * inherit ptr attriubutes from ref'd type if any * otherwise grab lib c type def from the CRules */ if ((t->basicType->choiceId == BASICTYPE_LOCALTYPEREF) || (t->basicType->choiceId == BASICTYPE_IMPORTTYPEREF)) { ctdi = t->basicType->a.localTypeRef->link->cTypeDefInfo; } else ctdi = &r->typeConvTbl[GetBuiltinType (t)]; if ((parentCTypeId == C_TYPEDEF) && (ctdi->isPtrForTypeDef)) retVal = TRUE; else if ((parentCTypeId == C_STRUCT) && (ctdi->isPtrForTypeRef)) retVal = TRUE; // Deepak: 18/Apr/2003 else if ((parentCTypeId == C_MACROTYPE) && (ctdi->isPtrForTypeRef)) retVal = TRUE; else if ((parentCTypeId == C_CHOICE) && (ctdi->isPtrInChoice)) retVal = TRUE; else if (((t->optional) || (t->defaultVal != NULL)) && (ctdi->isPtrForOpt)) retVal = TRUE; td = td; /*AVOIDS warning.*/ return retVal;} /* IsCPtr */#define BAD_VALUE(attrValue, attrType)\ fprintf (errFileG, "Warning: ignoring attribute with improper value (%s/%s)\n",\ attrType, attrValue)/* * attrList is a list of strings that hold attribute value * pairs. A list is used in case the attr/value pairs are * given in multiple ASN.1 comments around the type. */void ParseTypeDefAttribs PARAMS ((ctdi, attrList), CTDI *ctdi _AND_ SnaccDirectiveList *attrList){ SnaccDirective* pDirective; if (attrList == NULL) return; FOR_EACH_LIST_ELMT (pDirective, attrList) { switch (pDirective->type) { case ASN1_TypeID: ctdi->asn1TypeId = pDirective->value.asnTypeVal; break; case C_TypeID: ctdi->cTypeId = pDirective->value.cTypeVal; break; case C_TypeName: ctdi->cTypeName = pDirective->value.stringVal; break; case IsPDU: ctdi->isPdu = pDirective->value.boolVal; break; case IsPtrForTypeDef: ctdi->isPtrForTypeDef = pDirective->value.boolVal; break; case IsPtrForTypeRef: ctdi->isPtrForTypeRef = pDirective->value.boolVal; break; case IsPtrInChoice: ctdi->isPtrInChoice = pDirective->value.boolVal; break; case IsPtrForOpt: ctdi->isPtrForOpt = pDirective->value.boolVal; break; case OptionalTestRoutineName: ctdi->optTestRoutineName = pDirective->value.stringVal; break; case DefaultFieldName: ctdi->defaultFieldName = pDirective->value.stringVal; break; case PrintRoutineName: ctdi->printRoutineName = pDirective->value.stringVal; break; case EncodeRoutineName: ctdi->encodeRoutineName = pDirective->value.stringVal; break; case DecodeRoutineName: ctdi->decodeRoutineName = pDirective->value.stringVal; break; case FreeRoutineName: ctdi->freeRoutineName = pDirective->value.stringVal; break; case IsEncDec: ctdi->isEncDec = pDirective->value.boolVal; break; case GenTypeDef: ctdi->genTypeDef = pDirective->value.boolVal; break; case GenPrintRoutine: ctdi->genPrintRoutine = pDirective->value.boolVal; break; case GenEncodeRoutine: ctdi->genEncodeRoutine = pDirective->value.boolVal; break; case GenDecodeRoutine: ctdi->genDecodeRoutine = pDirective->value.boolVal; break; case GenFreeRoutine: ctdi->genFreeRoutine = pDirective->value.boolVal; break; default: fprintf (errFileG, "Warning: ignoring unrecognized type def attribute '%s'\n", GetDirectiveName(pDirective->type)); } } /* end for */} /* ParseTypeDefAttribs */void ParseTypeRefAttribs PARAMS ((ctri, attrList), CTRI *ctri _AND_ SnaccDirectiveList *attrList){ SnaccDirective* pDirective; if (attrList == NULL) return; FOR_EACH_LIST_ELMT (pDirective, attrList) { switch (pDirective->type) { case C_TypeID: ctri->cTypeId = pDirective->value.cTypeVal; break; case C_TypeName: ctri->cTypeName = pDirective->value.stringVal; break; case C_FieldName: ctri->cFieldName = pDirective->value.stringVal; break; case IsPtr: ctri->isPtr = pDirective->value.boolVal; break; case ChoiceIdValue: ctri->choiceIdValue = pDirective->value.integerVal; break; case ChoiceIdSymbol: ctri->choiceIdSymbol = pDirective->value.stringVal; break; case ChoiceIdEnumName: ctri->choiceIdEnumName = pDirective->value.stringVal; break; case ChoiceIdEnumFieldName: ctri->choiceIdEnumFieldName = pDirective->value.stringVal; break; case OptionalTestRoutineName: ctri->optTestRoutineName = pDirective->value.stringVal; break; case PrintRoutineName: ctri->printRoutineName = pDirective->value.stringVal; break; case EncodeRoutineName: ctri->encodeRoutineName = pDirective->value.stringVal; break; case DecodeRoutineName: ctri->decodeRoutineName = pDirective->value.stringVal; break; case FreeRoutineName: ctri->freeRoutineName = pDirective->value.stringVal; break; case IsEncDec: ctri->isEncDec = pDirective->value.boolVal; break; case IsBigInt: if (pDirective->value.boolVal) { ctri->cTypeName = "AsnBigInt"; ctri->printRoutineName = "PrintAsnBigInt"; ctri->encodeRoutineName = "EncAsnBigInt"; ctri->decodeRoutineName = "DecAsnBigInt"; ctri->freeRoutineName = "FreeAsnBigInt"; } break; default: fprintf (errFileG, "Warning: ignoring unrecognized type def attribute '%s'\n", GetDirectiveName(pDirective->type)); } } /* end of for loop */} /* ParseTypeRefAttribs *//* fill given ctdi with defaults from table for given typedef */voidFillCTDIDefaults PARAMS ((r, ctdi, td), CRules *r _AND_ CTDI *ctdi _AND_ TypeDef *td){ CTDI *tblCtdi; int typeIndex; typeIndex = GetBuiltinType (td->type); if (typeIndex < 0) return; tblCtdi = &r->typeConvTbl[typeIndex]; memcpy (ctdi, tblCtdi, sizeof (CTDI));}const char* GetDirectiveName(SnaccDirectiveEnum dirType){ switch (dirType) { case ASN1_TypeID: return "asn1TypeId"; case C_TypeID: return "cTypeId"; case C_TypeName: return "cTypeName"; case C_FieldName: return "cFieldName"; case IsPDU: return "isPdu"; case IsPtr: return "isPtr"; case IsPtrForTypeDef: return "isPtrForTypeDef"; case IsPtrForTypeRef: return "isPtrForTypeRef"; case IsPtrInChoice: return "isPtrInChoice"; case IsPtrForOpt: return "isPtrForOpt"; case OptionalTestRoutineName: return "optTestRoutineName"; case DefaultFieldName: return "defaultFieldName"; case PrintRoutineName: return "printRoutineName"; case EncodeRoutineName: return "encodeRoutineName"; case DecodeRoutineName: return "decodeRoutineName"; case FreeRoutineName: return "freeRoutineName"; case IsEncDec: return "isEncDec"; case GenTypeDef: return "genTypeDef"; case GenPrintRoutine: return "genPrintRoutine"; case GenEncodeRoutine: return "genEncodeRoutine"; case GenDecodeRoutine: return "genDecodeRoutine"; case GenFreeRoutine: return "genFreeRoutine"; case ChoiceIdSymbol: return "choiceIdSymbol"; case ChoiceIdValue: return "choiceIdValue"; case ChoiceIdEnumName: return "choiceIdEnumName"; case ChoiceIdEnumFieldName: return "choiceIdEnumFieldName"; case IsBigInt: return "isBigInt"; default: return "<unknown>"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -