00001
00002
00003
00004
00005
00006
00007
00008 #include "cddefines.h"
00009 #include "trace.h"
00010 #include "input.h"
00011
00012
00013
00014
00015
00016 bool lgInputComment( const char *chLine )
00017 {
00018 bool lgReturn;
00019
00020 DEBUG_ENTRY( "lgInputComment()" );
00021
00022
00023 if( chLine[0] == 0 )
00024 TotalInsanity();
00025
00026
00027 if( chLine[0] == '#' || chLine[0] == '*' || chLine[0] == '%' || chLine[0] == ' ' )
00028 {
00029 lgReturn = true;
00030 }
00031 else if( strncmp(chLine,"//", 2 ) == 0 )
00032 {
00033 lgReturn = true;
00034 }
00035
00036 else if( chLine[0] == 'C' || chLine[0] == 'c' )
00037 {
00038
00039
00040
00041
00042 if( chLine[1] == '\n' || chLine[1] == ' ' || chLine[1] == '\r' )
00043 {
00044 lgReturn = true;
00045 }
00046 else
00047 {
00048 lgReturn = false;
00049 }
00050 }
00051 else
00052 {
00053 lgReturn = false;
00054 }
00055
00056
00057 return lgReturn;
00058 }
00059
00060
00061 void t_input::init(void)
00062 {
00063
00064 DEBUG_ENTRY( "t_input::init()" );
00065
00066
00067
00068
00069 if( iReadWay > 0 )
00070 {
00071
00072 nRead = -1;
00073 }
00074 else if( iReadWay < 0 )
00075 {
00076
00077
00078 nReadSv = nRead;
00079
00080
00081 nRead = NKRD;
00082 }
00083
00084 return;
00085 }
00086
00087 void t_input::echo( FILE *ipOUT)
00088 {
00089 char chCard[INPUT_LINE_LENGTH];
00090
00091
00092 init();
00093
00094 bool lgEOF = false;
00095 while( !lgEOF )
00096 {
00097 readarray(chCard,&lgEOF);
00098 if( !lgEOF )
00099 {
00100 char chCAPS[INPUT_LINE_LENGTH];
00101 strcpy( chCAPS , chCard );
00102 caps( chCAPS );
00103
00104 if( !nMatch( "HIDE" , chCAPS ) )
00105 fprintf( ipOUT, "%s\n", chCard );
00106 }
00107 }
00108
00109 }
00110
00111
00112 void t_input::readarray(char *chCard,
00113 bool *lgEOF)
00114 {
00115 long int last;
00116
00117 DEBUG_ENTRY( "t_input::readarray()" );
00118
00119 if( iReadWay > 0 )
00120 {
00121
00122
00123
00124 ++nRead;
00125
00126
00127
00128
00129
00130 if( nRead > nSave )
00131 {
00132 *lgEOF = true;
00133 }
00134 else
00135 {
00136
00137 strcpy( chCard, chCardSav[nRead] );
00138
00139 *lgEOF = false;
00140 }
00141 }
00142 else
00143 {
00144
00145
00146
00147 nRead -= 1;
00148
00149
00150 last = NKRD - nSaveIni;
00151
00152
00153 if( nRead < last )
00154 {
00155
00156 iReadWay = 1;
00157
00158
00159 nRead = nReadSv+1;
00160 }
00161
00162
00163 if( iReadWay == 1 && nRead > nSave )
00164 {
00165 *lgEOF = true;
00166 }
00167 else
00168 {
00169 strcpy( chCard, chCardSav[nRead] );
00170
00171
00172 *lgEOF = false;
00173 }
00174 }
00175
00176
00177
00178 if( trace.lgTrace )
00179 {
00180 fprintf( ioQQQ, "t_input::readarray returns=%s=\n",chCard );
00181 }
00182
00183 return;
00184 }
00185
00187 void input_readvector(const char* chFile,
00188 double vector[],
00189 long n,
00190 bool* lgEOF)
00191 {
00192 DEBUG_ENTRY( "input_readvector()" );
00193
00194 fstream ioDATA;
00195 open_data( ioDATA, chFile, mode_r, AS_LOCAL_ONLY );
00196
00197 for( long i=0; i < n; ++i )
00198 ioDATA >> vector[i];
00199
00200 *lgEOF = !ioDATA.good();
00201 return;
00202 }