/* This file is part of Bolixo. Bolixo 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. Bolixo 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 Bolixo. If not, see . */ /* Command line tool to control bod */ #include #include #include #include #include #include #include #include "bolixo.m" using namespace std; #include "proto/bod_control.protoch" int main (int argc, char *argv[]) { glocal int ret = -1; glocal const char *control = "/var/run/bod.sock"; glocal.ret = (argc,argv,"bolixo"); setproginfo ("bod-control",VERSION ,MSG_U(I_BOD_CONTROL,"Command line tool to control bod\n" "\n" "\tdebug 0/1\n" "\tdebugfile filename\n" "\terase_session session\n" "\thelptest\n" "\thelp_connect host port message\n" "\tinstrument 0|1\n" "\tkeepmsgs days\n" "\tnodelogin hosturl\n" "\tnodelogout hosturl session\n" "\tpublishemail nickname email\n" "\tquit\n" "\tstatus\n")); setarg ('p',"control",MSG_U(I_BOD_SOCK,"Unix socket to reach bod"),glocal.control,false); glocal int ret = -1; CONNECT_INFO con; con.port = glocal.control; if (strcmp(argv[0],"status")==0 && argc==1){ (con); for (auto x:lines) printf ("%s\n",x); if (lines.size() > 0) glocal.ret = 0; }else if (strcmp(argv[0],"helptest")==0 && argc==1){ (con,true,true); for (auto x:lines) printf ("%s\n",x); if (lines.size() > 0) glocal.ret = 0; }else if (strcmp(argv[0],"quit")==0){ (con); if (!internal_error) glocal.ret = 0; }else if (strcmp(argv[0],"publishemail")==0 && argc==3){ (con,argv[1],argv[2]); if (success){ glocal.ret = 0; }else{ tlmp_error ("publishemail: %s\n",msg); } }else if (strcmp(argv[0],"debug")==0 && argc==2){ (con,atoi(argv[1])); if (!internal_error) glocal.ret = 0; }else if (strcmp(argv[0],"debugfile")==0 && argc==2){ (con,argv[1]); if (!internal_error) glocal.ret = 0; }else if (strcmp(argv[0],"help_connect")==0 && argc==4){ (con,argv[1],argv[2],argv[3]); for (auto l:lines){ printf ("%s\n",l); } }else if (strcmp(argv[0],"nodelogin")==0 && argc==2){ (con,argv[1]); if (!success){ tlmp_error ("internal_error=%d success=%d msg=%s\n",internal_error,success,msg); }else{ printf ("%s\n",session); } }else if (strcmp(argv[0],"nodelogout")==0 && argc==3){ (con,argv[1],argv[2]); if (!success){ tlmp_error ("internal_error=%d success=%d\n",internal_error,success); } }else if (strcmp(argv[0],"instrument")==0 && argc==2){ (con,atoi(argv[1])); }else if (strcmp(argv[0],"keepmsgs")==0 && argc==2){ (con,atoi(argv[1])); }else if (strcmp(argv[0],"erase_session")==0 && argc==2){ (con,argv[1]); }else{ tlmp_error (MSG_R(E_IVLDCOMMAND),argv[0]); usage(); } return glocal.ret; return glocal.ret; }