// // g++ get_host.cc -o get_host.exe // //============================================================================== #include #include #include #include #include #include #include #include #include #include #include #include #include //-- #include "get_host.hh" #include //--------------------------------------------------------------------------- int str2int (std::string ss, int base) { char *end; long l; const char *s=ss.c_str(); errno = 0; l = strtol(s, &end, base); if (errno == ERANGE) { printf("ERROR::str2int ERANGE:: %s \n",s); exit(1); } if (*s == '\0' || *end != '\0') { printf("\n **** ERROR:: str2int INCONVERTIBLE:: %s \n",s); exit(1); } return l; } //--------------------------------------------------------------------------- int main(int argc, char ** argv) { char *FileName; char *COMP; //printf("%d\n",argc); if (argc < 3) { printf("usage: %s path/hosts comp \n",argv[0]); exit(1); } else { FileName=argv[1]; COMP=argv[2]; } TIniFile *IniFile = new TIniFile(string(FileName)); if(IniFile->iniFile->is_open() != true) { std::cout << "Cannot open input file: " << string(FileName) << "\n"; delete IniFile; return 1; } if (DEBUG>0) printf("========================================================================================== \n" ); std::string host = IniFile->GetHost(string(COMP)); std::cout << host ; //<< "\n"; delete IniFile; return 0; }