/*---------------------------------------------------------------------* Project: TexConv File: input.cpp Copyright 1998-2001 Nintendo. All rights reserved. These coded instructions, statements and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. Change History: $Log: input.cpp,v $ Revision 1.2 2008/05/23 04:16:03 iwai_yuma Improved for handling of VC2005. Revision 1.1 2006/02/17 09:03:29 mitu 1st version 2 4/11/01 3:19p John Updated header copyrights and pathname. 1 12/03/99 3:48p Ryan 1 10/12/99 7:47p Mikepc renamed copy of io.cpp to resolve (io.h) name conflict. 1 10/08/99 3:06p Mikepc changed old .c to .cpp extension. Required for use of tplConv.h prototypes. 1 10/08/99 3:01p Mikepc changed old .c extension to .cpp to make this a cpp project. This was required for inclusion of tplConv.h prototypes 7 8/26/99 11:36a Mikepc 6 8/26/99 11:06a Mikepc added batch file processing option to main $NoKeywords: $ -----------------------------------------------------------------------*/ #include #include #include "input.h" //--------------------------------------------------------------------- int GetFileNames( char* inputFile, char* outputFile ) { char* inputPrompt = "source file name:"; char* outputPrompt = "destination file name:"; int done; ShowConverterTitle(); if( (done = GetFileName( inputPrompt, inputFile, SRC_TXT_FILE_SIZE )) == IO_QUIT ) { return IO_QUIT; } if( (done = GetFileName( outputPrompt, outputFile, DST_TPL_FILE_SIZE )) == IO_QUIT ) { return IO_QUIT; } return IO_DONE; } //--------------------------------------------------------------------- void ShowConverterTitle() { printf(".tpl file converter.\n"); printf("press 'q' anytime to quit.\n"); printf("\n"); } //--------------------------------------------------------------------- // 'promptString' is one of "source file name:" or "dest. file name:" int GetFileName( char* promptString, char* fileName, const unsigned int bufSize ) { int done; // scan for fileName until user indicates done while(1) { printf("%s\n", promptString); printf("(include full path name, use '/' as separators)\n\n"); gets_s( fileName, bufSize ); // gets(fileName); done = CheckYN(fileName); if(done == IO_QUIT) { return IO_QUIT; } else if(done == IO_DONE) { return IO_DONE; } //else (IO_NOT_DONE) continue to prompt until user is satisfied } return IO_DONE; } //--------------------------------------------------------------------- int CheckYN( char* fileName ) { int check = 0; int done = IO_NOT_DONE; char yn[255]; // first check if user entered 'q' for 'fileName if( ((check = strcmp( fileName, "q")) == 0) || ((check = strcmp( fileName, "Q")) == 0) ) { return IO_QUIT; } // prompt for 'yes', 'no', or 'quit' while(1) { printf("is this correct? (y/n)\n"); // check for quit if( ((check = strcmp( yn, "q")) == 0) || ((check = strcmp( yn, "Q")) == 0) ) { return IO_QUIT; } // check for yes else if( ((check = strcmp( yn, "y")) == 0) || ((check = strcmp( yn, "Y")) == 0) ) { return IO_DONE; } // check for no else if( ((check = strcmp( yn, "n")) == 0) || ((check = strcmp( yn, "N")) == 0) ) { return IO_NOT_DONE; } // invalid response- prompt again else { printf("your response must be one of 'y', 'n', or 'q'\n"); continue; } } return IO_DONE; } //---------------------------------------------------------------------