// Copyright (c) 1999-2001 David Muse // See the file COPYING for more information #include #include #include #include #include #include #include #ifdef RUDIMENTS_NAMESPACE using namespace rudiments; #endif int main(int argc, const char **argv) { #include sqlrconfigfile cfgfile; usercontainer *currentnode=NULL; commandline cmdline(argc,argv); const char *host; int16_t port; const char *socket; const char *user; const char *password; const char *query=""; bool debug=false; int exitval=0; const char *config=cmdline.getValue("-config"); if (!(config && config[0])) { config=DEFAULT_CONFIG_FILE; } const char *id=cmdline.getValue("-id"); if (!(id && id[0])) { if (argc<7) { printf("usage: query host port socket " "user password query [debug] \n" " or query [-config configfile] " "-id id query [debug]\n"); exit(1); } host=argv[1]; port=charstring::toInteger(argv[2]); socket=argv[3]; user=argv[4]; password=argv[5]; query=argv[6]; if (argv[7] && !charstring::compare(argv[7],"debug")) { debug=true; } } else { if (cfgfile.parse(config,id)) { // get the host/port/socket/username/password host="localhost"; port=cfgfile.getPort(); socket=cfgfile.getUnixPort(); // FIXME: this can return 0 cfgfile.getUserList()->getDataByIndex(0,¤tnode); user=currentnode->getUser(); password=currentnode->getPassword(); // find the query and optional debug if (cmdline.found("debug")) { debug=true; } // find the query for (int i=1; i