コード例 #1
0
ファイル: Controller.c プロジェクト: mweser/vig_prog
/*--------------------------------------------------------------------------------------------------------------
 * 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);
}
コード例 #2
0
ファイル: Controller.c プロジェクト: Team24Rocks/vig_prog
/*--------------------------------------------------------------------------------------------------------------
 * 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);
}