Mostly Completed Step 5.

+- configops.c/h
+- metadataops.c/h
This commit is contained in:
Charles Descamps 2024-01-30 23:15:13 -07:00
parent dc4eca7285
commit e19542c060
4 changed files with 879 additions and 12 deletions

View file

@ -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;
}