📄 fileio.pc
字号:
strcat(value, value3); } else { fprintf(stderr, "Coordinates expression must be either" "(v1, v2) or (v1, v2, v3)\n"); abort(); } } /* * If it matches the index provided by the user, * get the corresponding integer value. */ leftBracketPtr = strstr(key,"["); if (leftBracketPtr != NULL) { assert(strstr(key,"]") != NULL); sscanf(&leftBracketPtr[1], "%d", &instanceNumber); if (instanceNumber != parameterInstanceNumber) { // Wrong instance number, forget it. continue; } // Wack off "[n]" part of string. *leftBracketPtr = 0; } else { instanceNumber = DEFAULT_NO_INSTANCE_NUMBER; } // A matching address specific parameter overides any non-address // specific parameter. A specific instance overrides a default // instance. if (strcmp(key, parameterName) == 0) { if (addressSpecific) { if (instanceNumber == parameterInstanceNumber) { if ((instanceSpecificMatchFound) && (addressSpecificMatchFound)) { AbortBecauseDuplicateParameterFound( nodeInput->inputStrings[i]); }//if// instanceSpecificMatchFound = TRUE; addressSpecificMatchFound = TRUE; *parameterFound = TRUE; strcpy(parameterValue, value); } else if ((fallbackToDefault) && ((!instanceSpecificMatchFound) || (!addressSpecificMatchFound))) { assert(instanceNumber == DEFAULT_NO_INSTANCE_NUMBER); if (addressSpecificMatchFound) { AbortBecauseDuplicateParameterFound( nodeInput->inputStrings[i]); }//if// instanceSpecificMatchFound = FALSE; addressSpecificMatchFound = TRUE; *parameterFound = TRUE; strcpy(parameterValue, value); }//if// } else if (!addressSpecificMatchFound) { if (instanceNumber == parameterInstanceNumber) { if (instanceSpecificMatchFound) { AbortBecauseDuplicateParameterFound( nodeInput->inputStrings[i]); }//if// instanceSpecificMatchFound = TRUE; *parameterFound = TRUE; strcpy(parameterValue, value); } else if ((fallbackToDefault) && (!instanceSpecificMatchFound)) { assert(instanceNumber == DEFAULT_NO_INSTANCE_NUMBER); if (*parameterFound) { AbortBecauseDuplicateParameterFound( nodeInput->inputStrings[i]); }//if// *parameterFound = TRUE; strcpy(parameterValue, value); }//if// }//if// }//if// }//for//}/* * FUNCTION GLOMO_Read{String|Int|Double|Time} * PURPOSE These functions are used for reading a value from * the structure which contains input file information. * * Parameters: * nodeAddr: Node Address for which the info is required * nodeInput: Strcture containing contents of input file. * parameterName: GloMoSim parameter name string. * parameterValue: Value of the parameter. * * TRUE is returned if a match is made correctly. * Otherwise FALSE is returned. * */ BOOL GLOMO_ReadString( const NODE_ADDR nodeAddr, const GlomoNodeInput *nodeInput, const char* parameterName, char* parameterValue){ BOOL WasFound; RetrieveGlomoParameter( nodeAddr, nodeInput, parameterName, DEFAULT_NO_INSTANCE_NUMBER, FALSE, &WasFound, parameterValue); return WasFound;} BOOL GLOMO_ReadInt( const NODE_ADDR nodeAddr, const GlomoNodeInput *nodeInput, const char* parameterName, int* parameterValue){ BOOL WasFound; char stringValue[GLOMO_MAX_STRING_LENGTH]; RetrieveGlomoParameter( nodeAddr, nodeInput, parameterName, DEFAULT_NO_INSTANCE_NUMBER, FALSE, &WasFound, stringValue); if (WasFound) { sscanf(stringValue,"%d", parameterValue); } return WasFound;} BOOL GLOMO_ReadDouble( const NODE_ADDR nodeAddr, const GlomoNodeInput *nodeInput, const char* parameterName, double* parameterValue){ BOOL WasFound; char stringValue[GLOMO_MAX_STRING_LENGTH]; RetrieveGlomoParameter( nodeAddr, nodeInput, parameterName, DEFAULT_NO_INSTANCE_NUMBER, FALSE, &WasFound, stringValue); if (WasFound) { sscanf(stringValue,"%lf", parameterValue); } return WasFound;} BOOL GLOMO_ReadTime( const NODE_ADDR nodeAddr, const GlomoNodeInput *nodeInput, const char* parameterName, clocktype* parameterValue){ BOOL WasFound; char stringValue[GLOMO_MAX_STRING_LENGTH]; RetrieveGlomoParameter( nodeAddr, nodeInput, parameterName, DEFAULT_NO_INSTANCE_NUMBER, FALSE, &WasFound, stringValue); if (WasFound) { *parameterValue = GLOMO_ConvertToClock(stringValue); } return WasFound;} /* * FUNCTION GLOMO_Read{String|Int|Double|Time}Instance * PURPOSE This function is used for reading a string(etc) paramerter * values from the configuration file data structure. * This version of the function can also select different * parameter instances instead of the default (0) instance. * For example in the configuration file: * MAC-PROTOCOL[3] 802.11 * specifies that "instance 3" is "802.11". * * * * * Parameters: * nodeAddr: Node Address for which the info is required * nodeInput: Strcture containing contents of input file. * parameterName: GloMoSim parameter name string. * parameterInstanceNumber: * The retrieve parameter with this "instance number" * * parameterFound : TRUE if the parameter was found. * parameterValue: The value writen here if the parameter was found. * value is placed in readVal. * * */void GLOMO_ReadStringInstance( const NODE_ADDR nodeAddr, const GlomoNodeInput *nodeInput, const char parameterName[], const int parameterInstanceNumber, const BOOL fallbackToDefault, BOOL* WasFound, char parameterValue[]){ RetrieveGlomoParameter( nodeAddr, nodeInput, parameterName, parameterInstanceNumber, fallbackToDefault, WasFound, parameterValue);}void GLOMO_ReadIntInstance( const NODE_ADDR nodeAddr, const GlomoNodeInput *nodeInput, const char parameterName[], const int parameterInstanceNumber, const BOOL fallbackToDefault, BOOL* WasFound, int* parameterValue){ char stringValue[GLOMO_MAX_STRING_LENGTH]; RetrieveGlomoParameter( nodeAddr, nodeInput, parameterName, parameterInstanceNumber, fallbackToDefault, WasFound, stringValue); if (*WasFound) { sscanf(stringValue,"%d", parameterValue); }}void GLOMO_ReadDoubleInstance( const NODE_ADDR nodeAddr, const GlomoNodeInput* nodeInput, const char parameterName[], const int parameterInstanceNumber, const BOOL fallbackToDefault, BOOL* WasFound, double* parameterValue){ char stringValue[GLOMO_MAX_STRING_LENGTH]; RetrieveGlomoParameter( nodeAddr, nodeInput, parameterName, parameterInstanceNumber, fallbackToDefault, WasFound, stringValue); if (*WasFound) { sscanf(stringValue,"%lf", parameterValue); }}void GLOMO_ReadTimeInstance( const NODE_ADDR nodeAddr, const GlomoNodeInput *nodeInput, const char parameterName[], const int parameterInstanceNumber, const BOOL fallbackToDefault, BOOL* WasFound, clocktype* parameterValue){ char stringValue[GLOMO_MAX_STRING_LENGTH]; RetrieveGlomoParameter( nodeAddr, nodeInput, parameterName, parameterInstanceNumber, fallbackToDefault, WasFound, stringValue); if (*WasFound) { *parameterValue = GLOMO_ConvertToClock(stringValue); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -