#include #include #include //#include #include "d_stdio.h" // ------------------------------------------------------------------------ d_stdio::d_stdio( void ) { unsigned int i; char ch; string tmp; // go through stdin while( !cin.eof() ) //for( i = 0; i < count; i++ ) { cin.get( ch ); if( ch == '&' ) { if( !cin.eof() ) { data.push_back( tmp ); tmp = ""; } } else { if( !cin.eof() ) tmp += ch; } } if( tmp.size() > 0 ) { data.push_back( tmp ); } } // ------------------------------------------------------------------------ // displays entire content of data void d_stdio::spit( void ) { int i; for( i = 0; i < data.size(); i++ ) { cout << i << "\t" << data[i] << endl; } } // ------------------------------------------------------------------------ // returns line that contains string w //string d_stdio::get( char * w ) //{ // int i, l; // // for( i = 0; i < data.size(); i++ ) // { // l = data[i].find( w ); // // if( l == 0 ) return data[i]; // } // return string(""); //} // ------------------------------------------------------------------------ // returns string value of the line that contains string w string d_stdio::gets( char * w ) { int i, l, r1, r2; for( i = 0; i < data.size(); i++ ) { l = data[i].find( w ); if( l == 0 ) { r1 = data[i].find( "=", 0 ) + 1; r2 = data[i].size() - r1; return data[i].substr(r1, r2); } } return string(""); } // ------------------------------------------------------------------------ // returns integer value of the line that contains string w int d_stdio::geti( char * w ) //string d_env::getv( char * w ) { int i, l, r1, r2; char tmp[12]; string tmp2; for( i = 0; i < data.size(); i++ ) { l = data[i].find( w ); if( l == 0 ) { r1 = data[i].find( "=", 0 ) + 1; r2 = data[i].size() - r1; //return envar[i].substr(r1, r2); tmp2 = data[i].substr(r1, r2); //strcpy( tmp, envar[i].substr(r1,r2); strcpy( tmp, tmp2.c_str() ); return( atoi( tmp ) ); } } //return string(""); return( -1 ); } // ------------------------------------------------------------------------