Mostly Completed Step 5.
+- configops.c/h +- metadataops.c/h
This commit is contained in:
parent
dc4eca7285
commit
e19542c060
4 changed files with 879 additions and 12 deletions
|
|
@ -15,10 +15,33 @@ Dependencies: ???
|
|||
*/
|
||||
ConfigDataType *clearConfigData(ConfigDataType *configData)
|
||||
{
|
||||
// return NULL (temp)
|
||||
// initialize function and variables
|
||||
// check that config data pointer is not null
|
||||
// free data structure memory
|
||||
// fct: free
|
||||
// set config pointer to NULL
|
||||
// set config data pointer to null
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: configCodeToString
|
||||
Process: utility fct converts configuration code numbers to string they represent
|
||||
Function Input/Parameters: configuration code (int)
|
||||
Function Output/Parameters: resulting output string (char *)
|
||||
Function Output/Returned: none
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: copyString
|
||||
*/
|
||||
void configCodeToString(int code, char *outString)
|
||||
{
|
||||
// define array with eight items, and short (10) lengths
|
||||
// copy string to return parameter
|
||||
// fct: copyString
|
||||
// void function, no return.
|
||||
}
|
||||
|
||||
/*
|
||||
Name: displayConfigData
|
||||
Process: screen dump/display of all config data
|
||||
|
|
@ -31,6 +54,9 @@ Dependencies: ???
|
|||
*/
|
||||
void displayConfigData(ConfigDataType *configData)
|
||||
{
|
||||
// initialize function and variables
|
||||
// print lines of display for all member values
|
||||
// fct: printf, codeToString
|
||||
// void function, no return.
|
||||
}
|
||||
|
||||
|
|
@ -43,11 +69,221 @@ Function Output/Parameters: pointer to config data pointer (ConfigDataType **)
|
|||
Function Output/Returned: Boolean result of data access operation (bool)
|
||||
Device Input/File: config data uploaded
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
Dependencies: copyString, fopen, getStringToDelimiter, compareString, fclose,
|
||||
malloc, free, stripTrailingSpaces, getDataLineCode, fscanf,
|
||||
setStrToLowerCase, valueInRange, getCpuSchedCode, getLogToCode
|
||||
*/
|
||||
bool getConfigData(const char *fileName,
|
||||
ConfigDataType **configData, char *endStateMsg)
|
||||
{
|
||||
// initialize function and variables
|
||||
// set constant number of data lines
|
||||
// set read only constant
|
||||
// create pointer for data input
|
||||
// declare other variables
|
||||
// set endStateMsg to success
|
||||
// fct: copyString
|
||||
// initialize config data pointer in case of return error
|
||||
// open file
|
||||
// fct: fopen
|
||||
// check for file open failure
|
||||
// set end state message to config file access error
|
||||
// fct: copyString
|
||||
// return file access error
|
||||
// get first line, check for failure
|
||||
// fct: getStringToDelimiter, compareString
|
||||
// close file access
|
||||
// fct: fclose
|
||||
// set end state message to corrupt leader line error
|
||||
// fct: copyString
|
||||
// return corrupt file data
|
||||
// create temporary pointer to configuration data structure
|
||||
// fct: malloc
|
||||
// loop to end of config data items
|
||||
// get line leader, check for failure
|
||||
// fct: getStringToDelimiter
|
||||
// free temp struct memory
|
||||
// fct: free
|
||||
// close file access
|
||||
// fct: fclose
|
||||
// set end state message to line capture failure
|
||||
// fct: copyString
|
||||
// return incomplete file error
|
||||
// strip trailing spaces of config leader lines
|
||||
// for use in other fcts
|
||||
// fct: stripTrailingSpaces
|
||||
// find correct data line code number from string
|
||||
// fct: getDataLineCode
|
||||
// check for data line found
|
||||
// get data value
|
||||
// check for version number (double value)
|
||||
// get version number
|
||||
// fct: fscanf
|
||||
// otherwise, check for metaData, fileNames,
|
||||
// CPU Scheduling names, or memory display setting (strings)
|
||||
// get string input
|
||||
// fct: fscanf
|
||||
// set string to lower case for testing in valueInRange
|
||||
// fct: setStrToLowerCase
|
||||
// otherwise, assume integer data
|
||||
// get integer input
|
||||
// check for data value in range
|
||||
// fct: valueInRange
|
||||
// assign to data pointer depending on config item
|
||||
// (all config line possibilities)
|
||||
// fct: copyString, getCpuSchedCode,
|
||||
// compareString, getLogToCode, as needed
|
||||
// otherwise, assume data value not in range
|
||||
// free temp struct memory
|
||||
// fct: free
|
||||
// close file access
|
||||
// fct: fclose
|
||||
// set end state message to configuration data out of range
|
||||
// fct: copyString
|
||||
// return data out of range
|
||||
// otherwise, check for data line not found
|
||||
// free temp struct memory
|
||||
// fct: free
|
||||
// close file access
|
||||
// fct: fclose
|
||||
// set end state message to configuration corrupt prompt error
|
||||
// fct: copyString
|
||||
// return corrupt config file code
|
||||
// increment line counter
|
||||
// end loop to end of config data items
|
||||
// acquire end of sim config string
|
||||
// fct: getStringToDelimiter, compareString
|
||||
// free temp struct memory
|
||||
// fct: free
|
||||
// close file access
|
||||
// fct: fclose
|
||||
// set end state message to corrupt configuration end line
|
||||
// fct: copyString
|
||||
// return corrupt file data
|
||||
// test for "file only" output so memory diagnostics do not display
|
||||
// assign temp ptr to parameter return ptr
|
||||
// close file access
|
||||
// fct: fclose
|
||||
// return no error code
|
||||
// return false (temp)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: getDataLineCode
|
||||
Process: converts leader line string to configuration code value
|
||||
(processes all config file leader lines)
|
||||
Function Input/Parameters: config leader line string (const char *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: configuration code value (ConfigCodeMessages)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: compareString
|
||||
*/
|
||||
ConfigCodeMessages getDataLineCode(const char *dataBuffer)
|
||||
{
|
||||
// iniitalize function and variables
|
||||
// return appropriate code depending on prompt string provided
|
||||
// fct: compareString
|
||||
// return corrupt leader line error code
|
||||
// return zero (temp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: getLogToCode
|
||||
Process: ???
|
||||
Function Input/Parameters: none
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: none
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
*/
|
||||
ConfigDataCodes getLogToCode(const char *lowerCaseLogToStr)
|
||||
{
|
||||
// initialize function and variables
|
||||
// set default to log to monitor
|
||||
// check for BOTH
|
||||
// fct: compareString
|
||||
// set return value to both code
|
||||
// check for FILE
|
||||
// fct: compareString
|
||||
// set return value to file code
|
||||
// return selected code
|
||||
// return zero (temp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: stripTrailingSpaces
|
||||
Process: removes trailing spaces from input config leader lines
|
||||
Function Input/Parameters: config leader line string (char *)
|
||||
Function Output/Parameters: updates config leader line string (char *)
|
||||
Function Output/Returned: none
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: getStringLength
|
||||
*/
|
||||
void stripTrailingSpaces(char *str)
|
||||
{
|
||||
// initialize index to length of string - 1 to get highest array index
|
||||
// loop while space is found at the end of string
|
||||
// set element to NULL_CHAR
|
||||
// decrement index
|
||||
// end loop from end of string
|
||||
// void function, no return.
|
||||
}
|
||||
|
||||
/*
|
||||
Name: valueInRange
|
||||
Process: checks for config data values in range, including str values
|
||||
Function Input/Parameters: line code number for specific config value (int),
|
||||
integer value, as needed (int),
|
||||
double value, as needed (double),
|
||||
string value, as needed (const char *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: Boolean result of the range test (bool)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: compareString
|
||||
*/
|
||||
bool valueInRange(int lineCode, int intVal, double doubleVal,
|
||||
const char *lowerCaseStringVal)
|
||||
{
|
||||
// initialize function and variables
|
||||
// set result to true, all tests are to find false
|
||||
// use line code to identify prompt line
|
||||
// for version code
|
||||
// check if limits of version code are exceeded
|
||||
// set bool to false
|
||||
// break
|
||||
// for cpu scheduling code
|
||||
// check for not finding one of the scheduling strings
|
||||
// fct: compareString
|
||||
// set bool to false
|
||||
// break
|
||||
// for quantum cycles
|
||||
// check for quantum cycles limits exceeded
|
||||
// set bool to false
|
||||
// for memory display
|
||||
// check for not finding either on or off
|
||||
// fct: compareString
|
||||
// set bool to false
|
||||
// break
|
||||
// for memory available
|
||||
// check for memory limits exceeded
|
||||
// set bool to false
|
||||
// break
|
||||
// check for process cycles
|
||||
// check for process cycles limits exceeded
|
||||
// set bool to false
|
||||
// break
|
||||
// check for log to operation
|
||||
// check for not finding one of the log to strings
|
||||
// fct: compareString
|
||||
// set bool to false
|
||||
// break
|
||||
// return result of limits analysis
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2,6 +2,35 @@
|
|||
#define CONFIGOPS
|
||||
|
||||
#include "StandardConstants.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
typedef enum {CFG_FILE_ACCESS_ERR,
|
||||
CFG_CORRUPT_DESCRIPTOR_ERR,
|
||||
CFG_DATA_OUT_OF_RANGE_ERR,
|
||||
CFG_CORRUPT_PROMPT_ERR,
|
||||
CFG_VERSION_CODE,
|
||||
CFG_MD_FILE_NAME_CODE,
|
||||
CFG_CPU_SCHED_CODE,
|
||||
CFG_QUANT_CYCLES_CODE,
|
||||
CFG_MEM_DISPLAY_CODE,
|
||||
CFG_MEM_AVAILABLE_CODE,
|
||||
CFG_PROC_CYCLES_CODE,
|
||||
CFG_IO_CYCLES_CODE,
|
||||
CFG_LOG_TO_CODE,
|
||||
CFG_LOG_FILE_NAME_CODE
|
||||
} ConfigCodeMessages;
|
||||
|
||||
typedef enum {CPU_SCHED_SJF_N_CODE,
|
||||
CPU_SCHED_SRTF_P_CODE,
|
||||
CPU_SCHED_FCFS_P_CODE,
|
||||
CPU_SCHED_RR_P_CODE,
|
||||
CPU_SCHED_FCFS_N_CODE,
|
||||
LOGTO_MONITOR_CODE,
|
||||
LOGTO_FILE_CODE,
|
||||
LOGTO_BOTH_CODE,
|
||||
NON_PREEMPTIVE_CODE,
|
||||
PREEMPTIVE_CODE
|
||||
} ConfigDataCodes;
|
||||
|
||||
typedef struct ConfigDataTypeStruct
|
||||
{
|
||||
|
|
@ -21,6 +50,18 @@ Dependencies: ???
|
|||
*/
|
||||
ConfigDataType *clearConfigData(ConfigDataType *configData);
|
||||
|
||||
/*
|
||||
Name: configCodeToString
|
||||
Process: utility fct converts configuration code numbers to string they represent
|
||||
Function Input/Parameters: configuration code (int)
|
||||
Function Output/Parameters: resulting output string (char *)
|
||||
Function Output/Returned: none
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: copyString
|
||||
*/
|
||||
void configCodeToString(int code, char *outString);
|
||||
|
||||
/*
|
||||
Name: displayConfigData
|
||||
Process: screen dump/display of all config data
|
||||
|
|
@ -42,9 +83,64 @@ Function Output/Parameters: pointer to config data pointer (ConfigDataType **)
|
|||
Function Output/Returned: Boolean result of data access operation (bool)
|
||||
Device Input/File: config data uploaded
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
Dependencies: copyString, fopen, getStringToDelimiter, compareString, fclose,
|
||||
malloc, free, stripTrailingSpaces, getDataLineCode, fscanf,
|
||||
setStrToLowerCase, valueInRange, getCpuSchedCode, getLogToCode
|
||||
*/
|
||||
bool getConfigData(const char *fileName,
|
||||
ConfigDataType **configData, char *endStateMsg);
|
||||
ConfigDataType **configData, char *endStateMsg);
|
||||
|
||||
/*
|
||||
Name: getDataLineCode
|
||||
Process: converts leader line string to configuration code value
|
||||
(processes all config file leader lines)
|
||||
Function Input/Parameters: config leader line string (const char *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: configuration code value (ConfigCodeMessages)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: compareString
|
||||
*/
|
||||
ConfigCodeMessages getDataLineCode(const char *dataBuffer);
|
||||
|
||||
/*
|
||||
Name: getLogToCode
|
||||
Process: ???
|
||||
Function Input/Parameters: none
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: none
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
*/
|
||||
ConfigDataCodes getLogToCode(const char *lowerCaseLogToStr);
|
||||
|
||||
/*
|
||||
Name: stripTrailingSpaces
|
||||
Process: removes trailing spaces from input config leader lines
|
||||
Function Input/Parameters: config leader line string (char *)
|
||||
Function Output/Parameters: updates config leader line string (char *)
|
||||
Function Output/Returned: none
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: getStringLength
|
||||
*/
|
||||
void stripTrailingSpaces(char *str);
|
||||
|
||||
/*
|
||||
Name: valueInRange
|
||||
Process: checks for config data values in range, including str values
|
||||
Function Input/Parameters: line code number for specific config value (int),
|
||||
integer value, as needed (int),
|
||||
double value, as needed (double),
|
||||
string value, as needed (const char *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: Boolean result of the range test (bool)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: compareString
|
||||
*/
|
||||
bool valueInRange(int lineCode, int intVal, double doubleVal,
|
||||
const char *lowerCaseStringVal);
|
||||
|
||||
#endif // CONFIGOPS
|
||||
|
|
@ -2,6 +2,34 @@
|
|||
#include "StandardConstants.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
/*
|
||||
Name: addNode
|
||||
Process: adds metadata node to linked list recursively, handles empty list
|
||||
Function Input/Parameters: ptr to head or next linked node (OpCodeType *),
|
||||
ptr to new node (OpCodeType *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: pointer to previous node, or head node (OpCodeType *)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: malloc, copyString
|
||||
*/
|
||||
OpCodeType *addNode(OpCodeType *localPtr, OpCodeType *newNode)
|
||||
{
|
||||
// initialize function and variables
|
||||
// check for local pointer assigned to null
|
||||
// access memory for new link/node
|
||||
// fct: malloc
|
||||
// assign all three values to newly created node
|
||||
// assign next pointer to null
|
||||
// fct: copyString
|
||||
// return current local pointer
|
||||
// assume end of list not found
|
||||
// assign recursive fct to current node's next link
|
||||
// fct: addNode
|
||||
// return current local ptr
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: clearMetaDataList
|
||||
Process: recursively traverses list, frees dynamically allocated nodes
|
||||
|
|
@ -14,7 +42,14 @@ Dependencies: ???
|
|||
*/
|
||||
OpCodeType *clearMetaDataList(OpCodeType *localPtr)
|
||||
{
|
||||
// return NULL (temp)
|
||||
// initialize function and variables
|
||||
// check for local pointer not set to null (list not empty)
|
||||
// call recursive function with next pointer
|
||||
// fct: clearMetaDataList
|
||||
// after recursive call, release mem to OS
|
||||
// fct: free
|
||||
// set given pointer to NULL
|
||||
// return NULL to calling fct
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -24,16 +59,64 @@ Process: data dump/display of all opcode items
|
|||
Function Input/Parameters: pointer to
|
||||
head of opcode/metadata list (const OpCodeType *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: none
|
||||
Function Output/Returned: calculated time (int)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
Dependencies: printf, compareString
|
||||
*/
|
||||
void displayMetaData(const OpCodeType *localPtr)
|
||||
{
|
||||
// initialize function and variables
|
||||
// display title, with underline
|
||||
// fct: printf
|
||||
// loop to end of linked list
|
||||
// print leader
|
||||
// fct: printf
|
||||
// print opcode pid
|
||||
// fct: printf
|
||||
// print opcode command
|
||||
// fct: printf
|
||||
// check for dev op
|
||||
// print in/out parameter
|
||||
// fct: printf
|
||||
// otherwise, assume other than dev
|
||||
// print NA
|
||||
// fct: printf
|
||||
// print first string argument
|
||||
// fct: printf
|
||||
// print first int argument
|
||||
// fct: printf
|
||||
// print second int argument
|
||||
// fct: printf
|
||||
// print op end time
|
||||
// endline print
|
||||
// fct: printf
|
||||
// assign local pointer to next node
|
||||
// void function, no return.
|
||||
}
|
||||
|
||||
/*
|
||||
Name: getCommand
|
||||
Process: parses thre letter command part of opcode str
|
||||
Function Input/Parameters: input opcode str (const char *),
|
||||
starting index (int)
|
||||
Function Output/Parameters: parsed command (char *)
|
||||
Function Output/Returned: updated starting index for use by calling fct (int)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: none
|
||||
*/
|
||||
int getCommand(char *cmd, const char *inputStr, int index)
|
||||
{
|
||||
// initialize function and variables
|
||||
// loop across command length
|
||||
// assign character from input string to buffer string
|
||||
// increment index
|
||||
// set next character to null character
|
||||
// return current index
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: getMetaData
|
||||
Process: main driver function to upload, parse, and store list
|
||||
|
|
@ -44,13 +127,315 @@ Function Output/Parameters: ptr to opcode linked list head ptr (OpCodeType **),
|
|||
Function Output/Returned: Boolean result of operation (bool)
|
||||
Device Input/File: op code list uploaded
|
||||
Device Output/Device: none
|
||||
Dependencies: copyString fopen, getStringToDelimiter, compareString, fclose,
|
||||
Dependencies: copyString, fopen, getStringToDelimiter, compareString, fclose,
|
||||
malloc, getOpCommand, updateStartCount, updateEndCount,
|
||||
clearMetaDataList, free, addNode
|
||||
*/
|
||||
bool getMetaData(const char *fileName,
|
||||
OpCodeType **opCodeDataHead, char *endStateMsg)
|
||||
{
|
||||
// return false (temp)
|
||||
// initialize function and variables
|
||||
// iniitialize read only constant
|
||||
// initialize variables
|
||||
// initialize opcode data pointer in case of return error
|
||||
// initialize end state message
|
||||
// fct: copyString
|
||||
// open file for reading
|
||||
// fct: fopen
|
||||
// check for file open failure
|
||||
// set end state message
|
||||
// fct: copyString
|
||||
// return file access error
|
||||
// check first line for correct leader
|
||||
// fct: getStringToDelimiter, compareString
|
||||
// close file
|
||||
// fct: fclose
|
||||
// set end state message
|
||||
// fct: copyString
|
||||
// return corrupt descriptor error
|
||||
// allocate memory for the temporary data structure
|
||||
// fct: malloc
|
||||
// get the first op command
|
||||
// fct: getOpCommand
|
||||
// get start and end counts for later comparison
|
||||
// fct: updateStartCount, updateEndCount
|
||||
// check for failure of first complete op command
|
||||
// close file
|
||||
// fct: fclose
|
||||
// clear data from the structure list
|
||||
// fct: clearMetaDataList
|
||||
// free temporary structure memory
|
||||
// fct: free
|
||||
// set end state message
|
||||
// fct: copyString
|
||||
// return result of operation
|
||||
// loop across all remaining op commands
|
||||
// (while complete op commands are found)
|
||||
// add the new op command to the linked list
|
||||
// fct: addNode
|
||||
// get a new op command
|
||||
// fct: getOpCommand
|
||||
// update start and end counts for later comparison
|
||||
// fct: updateStartCount, updateEndCount
|
||||
// end loop across all remaining op commands
|
||||
// check for last op command found
|
||||
// check for start and end opcode counts equal
|
||||
// add the last node to the linked list
|
||||
// fct: addNode
|
||||
// set access result to no error for later operation
|
||||
// check last line for incorrect end descriptor
|
||||
// fct: getStringToDelimiter, compareString
|
||||
// set access result to corrupted descriptor error
|
||||
// set end state message
|
||||
// fct: copyString
|
||||
// otherwise, assume start/end counts not equal
|
||||
// close file
|
||||
// fct: fclose
|
||||
// clear data from the structure list
|
||||
// fct: clearMetaDataList
|
||||
// free temporary structure memory
|
||||
// fct: free
|
||||
// set access result to error
|
||||
// set end state message
|
||||
// fct: copyString
|
||||
// return result of operation
|
||||
// otherwise, assume didn't find end
|
||||
// set end state message
|
||||
// fct: copyString
|
||||
// unset return state
|
||||
// check for any errors found (not no error)
|
||||
// clear the op command list
|
||||
// fct: clearMetaDataList
|
||||
// close access file
|
||||
// fct: free
|
||||
// assign temporary local head ptr to parameter return ptr
|
||||
// return access result
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: getOpCommand
|
||||
Process: acquires one op command line from a previously opened file,
|
||||
parses it, and sets various struct members according to the
|
||||
three letter command
|
||||
Function Input/Parameters: ptr to open file handle (FILE *)
|
||||
Function Output/Parameters: ptr to one opcode struct (OpCodeType *)
|
||||
Function Output/Returned: coded result of operation (OpCodeMessages)
|
||||
Device Input/File: opcode line uploaded
|
||||
Device Output/Device: none
|
||||
Dependencies: getStringToDelimiter, getCommand, copyString, verifyValidCommand,
|
||||
compareString, getStringArg, verifyFirstStringArg, getNumberArg
|
||||
*/
|
||||
OpCodeMessages getOpCommand(FILE *filePtr, OpCodeType *inData)
|
||||
{
|
||||
// initialize function and variables
|
||||
// initialize local constants
|
||||
// initialize other variables
|
||||
// get whole op command as string, check for successful access
|
||||
// fct: getStringToDelimiter
|
||||
// get three-letter command
|
||||
// fct: getCommand
|
||||
// assign op command to node
|
||||
// fct: copyString
|
||||
// otherwise, assume unsuccessful access
|
||||
// set ptr to data structure to null
|
||||
// return op command access failure
|
||||
// verify op command
|
||||
// return op command error
|
||||
// set all struct values that may not be initialized to defaults
|
||||
// check for device command
|
||||
// get in/out arg
|
||||
// set device in/out arg
|
||||
// check correct argument
|
||||
// return argument error
|
||||
// get first string arg
|
||||
// set device in/out arg
|
||||
// check for legit first string arg
|
||||
// return arg error
|
||||
// check for last op command found
|
||||
// return last op command found message
|
||||
// check for app start seconds argument
|
||||
// get number argument
|
||||
// fct: getNumberArg
|
||||
// check for failed number access
|
||||
// set failure flag
|
||||
// set first int argument to number
|
||||
// check for cpu cycle time
|
||||
// get number argument
|
||||
// fct: getNumberArg
|
||||
// check for failed number access
|
||||
// set failure flag
|
||||
// set first int argument to number
|
||||
// check for device cycle time
|
||||
// get number argument
|
||||
// fct: getNumberArg
|
||||
// check for failed number access
|
||||
// set failure flag
|
||||
// set first int argument to number
|
||||
// check for memory base and offset
|
||||
// get number argument for base
|
||||
// fct: getNumberArg
|
||||
// check for failed number access
|
||||
// set failure flag
|
||||
// set first int argument to number
|
||||
// get number argument for offset
|
||||
// fct: getNumberArg
|
||||
// check for failed number access
|
||||
// set failure flag
|
||||
// set second int argument to number
|
||||
// check int args for upload failure
|
||||
// return corrupt op command found message
|
||||
// return complete op command found message
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: getNumberArg
|
||||
Process: starts at given index, captures
|
||||
and assembles int arg, returns as parameter
|
||||
Function Input/Parameters: input str (const char *), starting index (int)
|
||||
Function Output/Parameters: pointer to captured integer value
|
||||
Function Output/Returned: updated index for next function start
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: isDigit
|
||||
*/
|
||||
int getNumberArg(int *number, const char *inputStr, int index)
|
||||
{
|
||||
// initialize function and variables
|
||||
// loop to skip whitespace
|
||||
// increment the index
|
||||
// loop across string length
|
||||
// set digit found flag
|
||||
// assign digit to output
|
||||
// increment index and multiplier
|
||||
// check for digit not founf
|
||||
// set number to BAD_ARG_VAL, use dereference for ptr
|
||||
// return current index
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: getStringArg
|
||||
Process: starts at given index, captures
|
||||
and assembles str arg, returns as parameter
|
||||
Function Input/Parameters: input str (const char *), starting index (int)
|
||||
Function Output/Parameters: ptr to captured string argument (char *)
|
||||
Function Output/Returned: updated index for next fct start
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: none
|
||||
*/
|
||||
int getStringArg(char *strArg, const char *inputStr, int index)
|
||||
{
|
||||
// initialize function and variables
|
||||
// loop to skip whitespace
|
||||
// increment index
|
||||
// loop across string length
|
||||
// assign character from input string to buffer string
|
||||
// increment index
|
||||
// set next character to null character
|
||||
// return current index
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: isDigit
|
||||
Process: tests character parameter for digit,
|
||||
returns true if is digit, false otherwise
|
||||
Function Input/Parameters: test character (char)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: bool result of test (bool)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: none
|
||||
*/
|
||||
bool isDigit(char testChar)
|
||||
{
|
||||
// check for test character between characters '0' - '9'
|
||||
// return true
|
||||
// otherwise, assume character if not digit, return false
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: updateEndCount
|
||||
Process: manages count of "end" arguments
|
||||
to be compared at end of process input
|
||||
Function Input/Parameters: initial count (int),
|
||||
test string for "end" (const char *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: updated count, if "end" string found,
|
||||
otherwise no change
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: compareString
|
||||
*/
|
||||
int updateEndCount(int count, const char *opString)
|
||||
{
|
||||
// check for "end" in op string
|
||||
// fct: compareString
|
||||
// return incremented end count
|
||||
// return unchanged end count
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: updateStartCount
|
||||
Process: manages count of "start" arguments
|
||||
to be compared at start of process input
|
||||
Function Input/Parameters: initial count (int),
|
||||
test string for "start" (const char *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: updated count, if "start" string found,
|
||||
otherwise no change
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: compareString
|
||||
*/
|
||||
int updateStartCount(int count, const char *opString)
|
||||
{
|
||||
// check for "start" in op string
|
||||
// fct: compareString
|
||||
// return incremented start count
|
||||
// return unchanged start count
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: verifyFirstStringArg
|
||||
Process: checks for all possibilities of first argument string of op command
|
||||
Function Input/Parameters: test string (const char *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: bool result of test (bool)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: compareString
|
||||
*/
|
||||
bool verifyFirstStringArg(const char *strArg)
|
||||
{
|
||||
// check for string holding correct first argument
|
||||
// fct: compareString
|
||||
// return true
|
||||
// otherwise, assume test fail, return false
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Name: verifyValidCommand
|
||||
Process: checks for all possibilities of three-letter opcode command
|
||||
Function Input/Parameters: test string for command (const char *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: bool result of test (bool)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: compareString
|
||||
*/
|
||||
bool verifyValidCommand(char *testCmd)
|
||||
{
|
||||
// check for string holding three-letter opcode command
|
||||
// fct: compareString
|
||||
// return true
|
||||
// otherwise, assume test failure, return false
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2,12 +2,41 @@
|
|||
#define METADATAOPS
|
||||
|
||||
#include "StandardConstants.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
typedef enum {UNKNOWN_ERR
|
||||
} OpCodeMessages;
|
||||
|
||||
// typedef enum {CPU_SCHED_SJF_N_CODE,
|
||||
// CPU_SCHED_SRTF_P_CODE,
|
||||
// CPU_SCHED_FCFS_P_CODE,
|
||||
// CPU_SCHED_RR_P_CODE,
|
||||
// CPU_SCHED_FCFS_N_CODE,
|
||||
// LOGTO_MONITOR_CODE,
|
||||
// LOGTO_FILE_CODE,
|
||||
// LOGTO_BOTH_CODE,
|
||||
// NON_PREEMPTIVE_CODE,
|
||||
// PREEMPTIVE_CODE
|
||||
// } ConfigDataCodes;
|
||||
|
||||
typedef struct OpCodeTypeStruct
|
||||
{
|
||||
int temp;
|
||||
} OpCodeType;
|
||||
|
||||
/*
|
||||
Name: addNode
|
||||
Process: adds metadata node to linked list recursively, handles empty list
|
||||
Function Input/Parameters: ptr to head or next linked node (OpCodeType *),
|
||||
ptr to new node (OpCodeType *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: pointer to previous node, or head node (OpCodeType *)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: malloc, copyString
|
||||
*/
|
||||
OpCodeType *addNode(OpCodeType *localPtr, OpCodeType *newNode);
|
||||
|
||||
/*
|
||||
Name: clearMetaDataList
|
||||
Process: recursively traverses list, frees dynamically allocated nodes
|
||||
|
|
@ -26,13 +55,26 @@ Process: data dump/display of all opcode items
|
|||
Function Input/Parameters: pointer to
|
||||
head of opcode/metadata list (const OpCodeType *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: none
|
||||
Function Output/Returned: calculated time (int)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: ???
|
||||
Dependencies: printf, compareString
|
||||
*/
|
||||
void displayMetaData(const OpCodeType *localPtr);
|
||||
|
||||
/*
|
||||
Name: getCommand
|
||||
Process: parses thre letter command part of opcode str
|
||||
Function Input/Parameters: input opcode str (const char *),
|
||||
starting index (int)
|
||||
Function Output/Parameters: parsed command (char *)
|
||||
Function Output/Returned: updated starting index for use by calling fct (int)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: none
|
||||
*/
|
||||
int getCommand(char *cmd, const char *inputStr, int index);
|
||||
|
||||
/*
|
||||
Name: getMetaData
|
||||
Process: main driver function to upload, parse, and store list
|
||||
|
|
@ -43,11 +85,119 @@ Function Output/Parameters: ptr to opcode linked list head ptr (OpCodeType **),
|
|||
Function Output/Returned: Boolean result of operation (bool)
|
||||
Device Input/File: op code list uploaded
|
||||
Device Output/Device: none
|
||||
Dependencies: copyString fopen, getStringToDelimiter, compareString, fclose,
|
||||
Dependencies: copyString, fopen, getStringToDelimiter, compareString, fclose,
|
||||
malloc, getOpCommand, updateStartCount, updateEndCount,
|
||||
clearMetaDataList, free, addNode
|
||||
*/
|
||||
bool getMetaData(const char *fileName,
|
||||
OpCodeType **opCodeDataHead, char *endStateMsg);
|
||||
|
||||
/*
|
||||
Name: getOpCommand
|
||||
Process: acquires one op command line from a previously opened file,
|
||||
parses it, and sets various struct members according to the
|
||||
three letter command
|
||||
Function Input/Parameters: ptr to open file handle (FILE *)
|
||||
Function Output/Parameters: ptr to one opcode struct (OpCodeType *)
|
||||
Function Output/Returned: coded result of operation (OpCodeMessages)
|
||||
Device Input/File: opcode line uploaded
|
||||
Device Output/Device: none
|
||||
Dependencies: getStringToDelimiter, getCommand, copyString, verifyValidCommand,
|
||||
compareString, getStringArg, verifyFirstStringArg, getNumberArg
|
||||
*/
|
||||
OpCodeMessages getOpCommand(FILE *filePtr, OpCodeType *inData);
|
||||
|
||||
/*
|
||||
Name: getNumberArg
|
||||
Process: starts at given index, captures
|
||||
and assembles int arg, returns as parameter
|
||||
Function Input/Parameters: input str (const char *), starting index (int)
|
||||
Function Output/Parameters: pointer to captured integer value
|
||||
Function Output/Returned: updated index for next function start
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: isDigit
|
||||
*/
|
||||
int getNumberArg(int *number, const char *inputStr, int index);
|
||||
|
||||
/*
|
||||
Name: getStringArg
|
||||
Process: starts at given index, captures
|
||||
and assembles str arg, returns as parameter
|
||||
Function Input/Parameters: input str (const char *), starting index (int)
|
||||
Function Output/Parameters: ptr to captured string argument (char *)
|
||||
Function Output/Returned: updated index for next fct start
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: none
|
||||
*/
|
||||
int getStringArg(char *strArg, const char *inputStr, int index);
|
||||
|
||||
/*
|
||||
Name: isDigit
|
||||
Process: tests character parameter for digit,
|
||||
returns true if is digit, false otherwise
|
||||
Function Input/Parameters: test character (char)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: bool result of test (bool)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: none
|
||||
*/
|
||||
bool isDigit(char testChar);
|
||||
|
||||
/*
|
||||
Name: updateEndCount
|
||||
Process: manages count of "end" arguments
|
||||
to be compared at end of process input
|
||||
Function Input/Parameters: initial count (int),
|
||||
test string for "end" (const char *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: updated count, if "end" string found,
|
||||
otherwise no change
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: compareString
|
||||
*/
|
||||
int updateEndCount(int count, const char *opString);
|
||||
|
||||
/*
|
||||
Name: updateStartCount
|
||||
Process: manages count of "start" arguments
|
||||
to be compared at start of process input
|
||||
Function Input/Parameters: initial count (int),
|
||||
test string for "start" (const char *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: updated count, if "start" string found,
|
||||
otherwise no change
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: compareString
|
||||
*/
|
||||
int updateStartCount(int count, const char *opString);
|
||||
|
||||
/*
|
||||
Name: verifyFirstStringArg
|
||||
Process: checks for all possibilities of first argument string of op command
|
||||
Function Input/Parameters: test string (const char *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: bool result of test (bool)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: compareString
|
||||
*/
|
||||
bool verifyFirstStringArg(const char *strArg);
|
||||
|
||||
/*
|
||||
Name: verifyValidCommand
|
||||
Process: checks for all possibilities of three-letter opcode command
|
||||
Function Input/Parameters: test string for command (const char *)
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: bool result of test (bool)
|
||||
Device Input/Device: none
|
||||
Device Output/Device: none
|
||||
Dependencies: compareString
|
||||
*/
|
||||
bool verifyValidCommand(char *testCmd);
|
||||
|
||||
#endif // METADATAOPS
|
||||
Loading…
Add table
Add a link
Reference in a new issue