/*-------------------------------------------------------------------------------------------------------------- * FUNCTION: ControllerRun * DESCR: Called after the Controller is initialized in ControllerBegin and after the command line has been * parsed. Reads the key from the specified key file name. Calls ControllerEncryptDecrypt to encrypt * or decrypt a message. Finally calls ViewPrintStr to print the encrypted or decrypted message. * RETURNS: Nothing. * PSEUDOCODE: * Define a char array named key which is of length MAX_MSG_LEN+1. * Define a char array named msgOut which is of length MAX_MSG_LEN+1. * Call ModelGetKeyFilename() to get the key file name that was parsed from the command line. * Call FileReadStr() and pass the key file name and the key array as parameters. This will read the key * from the file. * Call ModelSetKey() to store the key that was read from the file. * Call ModelGetMode() to get the mode from the Model (the mode was parsed from the command line). * Call ControllerEncryptDecrypt() and pass the mode and msgOut as parameters. * Call ViewPrintStr() and pass msgOut as the parameter. *------------------------------------------------------------------------------------------------------------*/ void ControllerRun() { char *key[MAX_MSG_LEN+1]; char *msgOut[MAX_MSG_LEN+1]; *key=ModelGetKeyFilename(); FileReadStr(*key,*msgOut); ModelSetKey(*msgOut); ControllerEncryptDecrypt(ModelGetMode(),*msgOut); ViewPrintStr(*msgOut); }
/*-------------------------------------------------------------------------------------------------------------- * FUNCTION: ControllerRun * DESCR: Called after the Controller is initialized in ControllerBegin and after the command line has been * parsed. Reads the key from the specified key file name. Calls ControllerEncryptDecrypt to encrypt * or decrypt a message. Finally calls ViewPrintStr to print the encrypted or decrypted message. * RETURNS: Nothing. * PSEUDOCODE: * Define a char array named key which is of length MAX_MSG_LEN+1. * Define a char array named msgOut which is of length MAX_MSG_LEN+1. * Call ModelGetKeyFilename() to get the key file name that was parsed from the command line. * Call FileReadStr() and pass the key file name and the key array as parameters. This will read the key * from the file. * Call ModelSetKey() to store the key that was read from the file. * Call ModelGetMode() to get the mode from the Model (the mode was parsed from the command line). * Call ControllerEncryptDecrypt() and pass the mode and msgOut as parameters. * Call ViewPrintStr() and pass msgOut as the parameter. *------------------------------------------------------------------------------------------------------------*/ void ControllerRun ( ) { char key[MAX_MSG_LEN+1]; char msgOut[MAX_MSG_LEN+1]; strcpy(key,ModelGetKeyFilename()); FileReadStr(key,key); ModelSetKey(key); ControllerEncryptDecrypt(ModelGetMode(), msgOut); ViewPrintStr(msgOut); }