📄 type-info.c
字号:
{ if (ParseBool (attrValue, &result) < 0) BAD_VALUE (attrValue, attrName); else ctdi->genPrintRoutine = result; Free (attrValue); } else if (strcmp (attrName, "genEncodeRoutine") == 0) { if (ParseBool (attrValue, &result) < 0) BAD_VALUE (attrValue, attrName); else ctdi->genEncodeRoutine = result; Free (attrValue); } else if (strcmp (attrName, "genDecodeRoutine") == 0) { if (ParseBool (attrValue, &result) < 0) BAD_VALUE (attrValue, attrName); else ctdi->genDecodeRoutine = result; Free (attrValue); } else if (strcmp (attrName, "genFreeRoutine") == 0) { if (ParseBool (attrValue, &result) < 0) BAD_VALUE (attrValue, attrName); else ctdi->genFreeRoutine = result; Free (attrValue); } else fprintf (stderr,"Warning: ignoring unrecognized type def attribute value pair (%s/%s)\n", attrName, attrValue); } /* end while */ } /* end for */} /* ParseTypeDefAttribs */void ParseTypeRefAttribs PARAMS ((ctri, attrList), CTRI *ctri _AND_ AttributeList *attrList){ char *attrName; char *attrValue; int loc; int result; MyString attr; if (attrList == NULL) return; FOR_EACH_LIST_ELMT (attr, attrList) { loc = 0; /* loc is location to start/continue parse from */ while (1) { ParseAttr (attr, &loc, &attrName, &attrValue); if (attrName == NULL) break; if (strcmp (attrName, "cTypeId") == 0) { if (ParseCTypeId (attrValue, &result) < 0) BAD_VALUE (attrValue, attrName); else ctri->cTypeId = result; Free (attrValue); } else if (strcmp (attrName, "cTypeName") == 0) ctri->cTypeName = attrValue; else if (strcmp (attrName, "cFieldName") == 0) ctri->cFieldName = attrValue; else if (strcmp (attrName, "isPtr") == 0) { if (ParseBool (attrValue, &result) < 0) BAD_VALUE (attrValue, attrName); else ctri->isPtr = result; Free (attrValue); } else if (strcmp (attrName, "choiceIdValue") == 0) { if (ParseInt (attrValue, &result) < 0) BAD_VALUE (attrValue, attrName); else ctri->choiceIdValue = result; Free (attrValue); } else if (strcmp (attrName, "choiceIdSymbol") == 0) ctri->choiceIdSymbol = attrValue; else if (strcmp (attrName, "choiceIdEnumName") == 0) ctri->choiceIdEnumName = attrValue; else if (strcmp (attrName, "choiceIdEnumFieldName") == 0) ctri->choiceIdEnumFieldName = attrValue; else if (strcmp (attrName, "optTestRoutineName") == 0) ctri->optTestRoutineName = attrValue; else if (strcmp (attrName, "printRoutineName") == 0) ctri->printRoutineName = attrValue; else if (strcmp (attrName, "encodeRoutineName") == 0) ctri->encodeRoutineName = attrValue; else if (strcmp (attrName, "decodeRoutineName") == 0) ctri->decodeRoutineName = attrValue; else if (strcmp (attrName, "isEncDec") == 0) { if (ParseBool (attrValue, &result) < 0) BAD_VALUE (attrValue, attrName); else ctri->isEncDec = result; Free (attrValue); } else fprintf (stderr,"Warning: ignoring unrecognized type ref attribute value pair (%s/%s)\n", attrName, attrValue); } /* end while/ per comment */ } /* end per att str */} /* ParseTypeRefAttribs */intParseBool PARAMS ((str, result), char *str _AND_ int *result){ if (strcmp (str,"TRUE")==0) { *result = TRUE; return 0; } if (strcmp (str,"FALSE")==0) { *result = FALSE; return 0; } return -1;}intParseInt PARAMS ((str, result), char *str _AND_ int *result){ *result = atoi (str); return 0;}intParseCTypeId PARAMS ((str, result), char *str _AND_ int *result){ if (strcmp (str,"C_CHOICE")) { *result = C_CHOICE; return 0; } if (strcmp (str,"C_LIST")) { *result = C_LIST; return 0; } if (strcmp (str,"C_ANY")) { *result = C_ANY; return 0; } if (strcmp (str,"C_ANYDEFINEDBY")) { *result = C_ANYDEFINEDBY; return 0; } if (strcmp (str,"C_LIB")) { *result = C_LIB; return 0; } if (strcmp (str,"C_STRUCT")) { *result = C_STRUCT; return 0; } if (strcmp (str,"C_TYPEREF")) { *result = C_TYPEREF; return 0; } if (strcmp (str,"C_TYPEDEF")) { *result = C_TYPEDEF; return 0; } if (strcmp (str,"C_NO_TYPE")) { *result = C_NO_TYPE; return 0; } return -1;}intParseTypeId PARAMS ((str, result), char *str _AND_ int *result){ if (strcmp (str,"UNKNOWN")) { *result = BASICTYPE_UNKNOWN; return 0; } if (strcmp (str,"BOOLEAN")) { *result = BASICTYPE_BOOLEAN; return 0; } if (strcmp (str,"INTEGER")) { *result = BASICTYPE_INTEGER; return 0; } if (strcmp (str,"BITSTRING")) { *result = BASICTYPE_BITSTRING; return 0; } if (strcmp (str,"OCTETSTRING")) { *result = BASICTYPE_OCTETSTRING; return 0; } if (strcmp (str,"NULL")) { *result = BASICTYPE_NULL; return 0; } if (strcmp (str,"OID")) { *result = BASICTYPE_OID; return 0; } if (strcmp (str,"REAL")) { *result = BASICTYPE_REAL; return 0; } if (strcmp (str,"ENUMERATED")) { *result = BASICTYPE_ENUMERATED; return 0; } if (strcmp (str,"SEQUENCE")) { *result = BASICTYPE_SEQUENCE; return 0; } if (strcmp (str,"SEQUENCEOF")) { *result = BASICTYPE_SEQUENCEOF; return 0; } if (strcmp (str,"SET")) { *result = BASICTYPE_SET; return 0; } if (strcmp (str,"SETOF")) { *result = BASICTYPE_SETOF; return 0; } if (strcmp (str,"CHOICE")) { *result = BASICTYPE_CHOICE; return 0; } if (strcmp (str,"ANY")) { *result = BASICTYPE_ANY; return 0; } if (strcmp (str,"ANYDEFINEDBY")) { *result = BASICTYPE_ANYDEFINEDBY; return 0; } if (strcmp (str,"LOCALTYPEREF")) { *result = BASICTYPE_LOCALTYPEREF; return 0; } if (strcmp (str,"IMPORTYPEREF")) { *result = BASICTYPE_IMPORTTYPEREF; return 0; } return -1;} /* ParseTypeId *//* * read attribute value pair from given str starting * at str[loc]. Allocate and return attibute value * in the attrValue parameter. The attribute name is * returned in the attrName parameter - do not free this * as it is statically defined and overwritten with * each call to ParseAttr. * str must be NULL terminated. * */voidParseAttr PARAMS ((str, startLoc, attrName, attrValue), char *str _AND_ int *startLoc _AND_ char **attrName _AND_ char **attrValue){ int len; int loc; int attrNameStart; int attrNameEnd; int attrValueStart; int attrValueEnd; static char retAttrName[200]; char *retAttrValue; loc = *startLoc; len = strlen (str)-1; /* skip whitespc */ for (; (loc <= len) && str[loc] == ' '; loc++) ; if (loc >= len) { *attrName = NULL; *attrValue = NULL; return; } attrNameStart = loc; for (; (loc <= len) && str[loc] != ':'; loc++) ; if (loc > len) { *attrName = NULL; *attrValue = NULL; return; } attrNameEnd = loc-1; loc++; /* skip: */ /* check for and skip " */ if (str[loc++] != '"') { *attrName = NULL; *attrValue = NULL; fprintf (stderr,"ERROR in snacc comment attribute string \"%s\". Missing quote at beggining of field value\n",str); return; } attrValueStart = loc; for (; (loc <= len) && str[loc] != '"'; loc++) ; attrValueEnd = loc-1; if ((loc > len) || (str[attrValueStart-1] != '"')) { *attrName = NULL; *attrValue = NULL; fprintf (stderr,"Parsing Error after position %d in snacc attribute string \"%s\".\n",*startLoc, str); return; } *startLoc = loc + 1; retAttrValue = (char*) Malloc (attrValueEnd - attrValueStart + 2); strncpy (retAttrName, &str[attrNameStart], attrNameEnd-attrNameStart+1); strncpy (retAttrValue, &str[attrValueStart], attrValueEnd-attrValueStart+1); retAttrValue[attrValueEnd-attrValueStart+1] = '\0'; retAttrName[attrNameEnd-attrNameStart+1] = '\0'; *attrName = retAttrName; *attrValue = retAttrValue;} /* ParseAttr *//* 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));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -