/* * This file is part of rasdaman community. * * Rasdaman community is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Rasdaman community is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with rasdaman community. If not, see . * * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / rasdaman GmbH. * * For more information please see * or contact Peter Baumann via . / /** * SOURCE: rascontrol_class.hh * * MODULE: rascontrol * CLASS: EditLine, RascontrolConfig * * PURPOSE: * RasControl helper classes * * COMMENTS: * */ #include "debug-clt.hh" #include "globals.hh" #include "rascontrol.hh" #include #include #define READLINELIB /* // if we have readline library on this machine ... #ifdef READLINELIB extern "C" { char * rl_gets (char *prompt); char * readline(char *prompt); void add_history (char * line_read); int rl_insert(); int rl_bind_key (int KEY, int (*FUNCTION)()); void using_history (); } #endif */ extern UserLogin userLogin; //int readWholeMessage(int socket,char *destBuffer,int buffSize); //int writeWholeMessage(int socket,char *destBuffer,int buffSize); EditLine::EditLine() { line[0]= EOS_CHAR; #ifdef READLINELIB using_history (); rl_bind_key ('\t', rl_insert); #endif } EditLine::~EditLine() { } const char *EditLine::interactiveCommand(const char *prompt) { #ifdef READLINELIB char *rasp=rl_gets (prompt); #else std::cout< name of host where master rasmgr runs", DEFAULT_HOSTNAME)), cmlPort (cmlInter.addLongParameter(CommandLineParser::noShortName,"port", " rasmgr port",DEFAULT_PORT)), cmlLogin (cmlInter.addFlagParameter('l',"login", "just login prompt, used to set the environment variable RASLOGIN")), cmlTestLogin (cmlInter.addFlagParameter('t',"testlogin", "test if environment variable RASLOGIN is OK to login")), cmlInteractive (cmlInter.addFlagParameter('e',"interactive", "interactive mode, login from environment variable RASLOGIN")), cmlQuiet (cmlInter.addFlagParameter('q',"quiet", "quiet, don't print header (default on for -login and -testlogin)")), #ifdef NO_OFFICIAL_RELEASE cmlHist (cmlInter.addStringParameter(CommandLineParser::noShortName, "hist", " used to store your commands in file, as help for batch file.")), #endif cmlPrompt (cmlInter.addStringParameter(CommandLineParser::noShortName, "prompt", " change rascontrol prompt as following:\n\t\t 0 - prompt '>'\n\t\t 1 - prompt 'rasc>'\n\t\t 2 - prompt 'user:host>'","2")), cmlExecute (cmlInter.addFlagParameter('x',"execute", "batch mode, login from environment variable RASLOGIN\n \ta rasmgr command (only in batch mode)\n\t\tif no command if provided, command is read from stdin\n\t\t(used for batch mode with 'PROMPTFULL) promptType=PROMPTFULL; return true; } bool RascontrolConfig::paramError() { std::cout<<"Invalid parameter combination in command line!"<][" << CommandLineParser::LongSign << cmlPort.getLongName() << " ][" #ifdef NO_OFFICIAL_RELEASE << CommandLineParser::LongSign << cmlHist.getLongName() << " ][" #endif << CommandLineParser::LongSign << cmlPrompt.getLongName() << " ][" << CommandLineParser::LongSign << cmlQuiet.getLongName() << "]\n\t\t\t[" << CommandLineParser::LongSign << cmlLogin.getLongName() << "|" << CommandLineParser::LongSign << cmlTestLogin.getLongName() << "|" << CommandLineParser::LongSign << cmlInteractive.getLongName() << "|" << CommandLineParser::LongSign << cmlExecute.getLongName() << " ]" << std::endl; std::cout << "Option description:" << std::endl; cmlInter.printHelp(); std::cout< "); break; case PROMPTRASC : strcpy(prompt,"rasc> "); break; case PROMPTFULL : sprintf(prompt,"%s:%s> ",userLogin.getUserName(),rasmgrHost); break; } return prompt; } const char* RascontrolConfig::getCommand() { return command; } void RascontrolConfig::printDebugInfo() { std::cout<<"Working modus:."; switch(workModus) { case WKMUNKNOWN : std::cout<<"unknown";break; case WKMINTERACTIV : std::cout<<"interactiv";break; case WKMBATCH : std::cout<<"batch";break; case WKMLOGIN : std::cout<<"login";break; } std::cout<