00001 /* This file is part of Cloudy and is copyright (C)1978-2010 by Gary J. Ferland and 00002 * others. For conditions of distribution and use see copyright notice in license.txt */ 00003 /*ParseState save or recover previous state of the code */ 00004 #include "cddefines.h" 00005 #include "parse.h" 00006 #include "state.h" 00007 #include "parser.h" 00008 00009 /*ParseState save or recover previous state of the code */ 00010 void ParseState(Parser &p) 00011 { 00012 char chFilename[INPUT_LINE_LENGTH]; 00013 00014 DEBUG_ENTRY( "ParseState()" ); 00015 00016 /* 00017 * get file name for this save output. 00018 * GetQuote does the following - 00019 * first copy original version of file name into chLabel, 00020 * string does include null termination. 00021 * set filename in OrgCard and second parameter to spaces so 00022 * that not picked up below as keyword 00023 * last parameter says to abort if no quote found 00024 */ 00025 p.GetQuote( chFilename , true ); 00026 00027 /* option to print all contents of arrays - BIG PRINTOUT! */ 00028 if( p.nMatch("PRIN") ) 00029 state.lgState_print = true; 00030 00031 if( p.nMatch(" GET") ) 00032 { 00033 # if 0 00034 state.ioGET_STATE = open_data( chFilename, "rb", AS_LOCAL_ONLY ); 00035 # endif 00036 state.lgGet_state = true; 00037 strcpy( state.chGetFilename , chFilename ); 00038 } 00039 else if( p.nMatch(" PUT") ) 00040 { 00041 # if 0 00042 state.ioPUT_STATE = open_data( chFilename , "wb", AS_LOCAL_ONLY ); 00043 # endif 00044 state.lgPut_state = true; 00045 strcpy( state.chPutFilename , chFilename ); 00046 /* look for keyword ALL - says want to save state for all iterations, 00047 * default is last iteration */ 00048 if( p.nMatch(" ALL") ) 00049 { 00050 state.lgPutAll = true; 00051 } 00052 else 00053 { 00054 state.lgPutAll = false; 00055 } 00056 } 00057 00058 else 00059 { 00060 fprintf( ioQQQ, " The STATE command has two keywords, GET and PUT. One must appear - I did not see it.\n Sorry.\n" ); 00061 cdEXIT(EXIT_FAILURE); 00062 } 00063 return; 00064 }