summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2005-11-29 16:26:36 (GMT)
committer jaromil <jaromil@949728d9-16ea-0310-a75c-cbdf8430a4b8>2005-11-29 16:26:36 (GMT)
commit3157004b1390f73caf79e0d15bbd750cb36307e7 (patch)
tree14b35f75268f6d6671aa678671d6cf1e65056abd
parent03f4a8b1cf5a826055feb4f08801dba63c8f71b4 (diff)
some more fixes for the remote controller
git-svn-id: svn://dyne.org/montevideo/ivysync@50 949728d9-16ea-0310-a75c-cbdf8430a4b8
-rw-r--r--Makefile29
-rw-r--r--ivysync-remote.cpp71
2 files changed, 59 insertions, 41 deletions
diff --git a/Makefile b/Makefile
index fb5446c..db29f31 100644
--- a/Makefile
+++ b/Makefile
@@ -5,33 +5,36 @@
# $Id: Makefile 60 2004-11-12 15:40:18Z jaromil $
-CC = gcc
CPP = g++
LINKER = ld
-# debugging flags:
-CPPFLAGS = -I. -Ixmlrpc++ -Wall -ggdb -pg `pkg-config --cflags gtk+-2.0`
+GTKFLAGS = `pkg-config --cflags gtk+-2.0`
+GTKLIBS = `pkg-config --libs gtk+-2.0`
+# debugging flags:
+CPPFLAGS = -I. -Ixmlrpc++ -Wall -ggdb -pg $(GTKFLAGS)
# optimized flags:
-#CPPFLAGS = -I. -Ixmlrpc++ -Wall -O2 -fomit-frame-pointer -ffast-math -march=pentium3 \
- `pkg-config --cflags gtk+-2.0`
+#CPPFLAGS = -I. -Ixmlrpc++ -Wall -O2 -fomit-frame-pointer -ffast-math
+
+
+
+
+LIBS = xmlrpc++/libxmlrpc++.a -lpthread -lssl
-LIBS = xmlrpc++/libxmlrpc++.a -lpthread -lssl `pkg-config --libs gtk+-2.0`
+IVYSYNC_OBJ = decoder.o thread.o utils.o cmdline.o gui.o xmlrpc.o
-OBJ = decoder.o thread.o utils.o cmdline.o gui.o xmlrpc.o
+IVYSYNC_REMOTE_OBJ = ivysync-remote.o utils.o
all: xmlrpc ivysync ivysync-remote
xmlrpc:
cd xmlrpc++ && $(MAKE)
-ivysync: $(OBJ)
- $(CPP) $(CPPFLAGS) -o ivysync $(OBJ) $(LIBS)
+ivysync: $(IVYSYNC_OBJ)
+ $(CPP) $(CPPFLAGS) -o ivysync $(IVYSYNC_OBJ) $(LIBS) $(GTKLIBS)
-ivysync-remote: ivysync-remote.o
- $(CPP) -Ixmlrpc++ -Wall -ggdb -pg \
- -o ivysync-remote ivysync-remote.o \
- xmlrpc++/libxmlrpc++ -lssl
+ivysync-remote: $(IVYSYNC_REMOTE_OBJ)
+ $(CPP) $(CPPFLAGS) -o ivysync-remote $(IVYSYNC_REMOTE_OBJ) $(LIBS)
#make clean
clean:
diff --git a/ivysync-remote.cpp b/ivysync-remote.cpp
index 40a17da..00905b4 100644
--- a/ivysync-remote.cpp
+++ b/ivysync-remote.cpp
@@ -30,71 +30,77 @@
#include <utils.h>
using namespace XmlRpc;
-
+using namespace std;
char *help =
"Usage: ivysync-remote [-s server:port] command [arguments]\n"
" -h --help show this help\n"
" -D --debug print verbos debugging messages\n"
-" -s --server server:port address to connect (default localhost:264)\n"
+" -s --server server address to connect (default localhost)\n"
+" -p --port server port to connect (default 264)\n"
" -i --inspect inspect methods available on host\n";
-char *short_options = "-hD:s:i";
+char *short_options = "-hD:s:p:i";
const struct option long_options[] = {
{ "help", no_argument, NULL, 'h'},
{ "debug", required_argument, NULL, 'D'},
{ "server", required_argument, NULL, 's'},
+ { "port", required_argument, NULL, 'p'},
{ "inspect", no_argument, NULL, 'i'},
{0, 0, 0, 0}
};
-bool introspect = false;
+bool inspect = false;
char server[512];
int port;
-
+char uri[256];
int cmdline(int argc, char **argv) {
int res;
int c;
-
+
N("IvySync 0.3 / (c)2004-2005 Denis Rojo <jaromil@dyne.org>");
-
+
strcpy(server,"localhost");
port = 264;
-
+
do {
res = getopt_long(argc, argv, short_options, long_options, NULL);
-
+
switch(res) {
-
+
case 'h':
fprintf(stderr,"%s",help);
exit(1);
break;
-
+
case 'i':
- introspect = true;
+ inspect = true;
break;
-
+
case 's':
- c = sscanf(optarg,"%s:%d",server,&port);
- if(c != 2) {
+ c = sscanf(optarg,"%s",server);
+ if(c != 1) {
E("error parsing server option: %s",optarg);
- E("malformed syntax, please specify hostname:port");
+ E("malformed syntax, please specify hostname");
exit(0);
}
break;
+
+ case 'p':
+ port = atoi(optarg);
+ break;
case 'D':
set_debug( atoi(optarg) );
break;
default: break;
-
+
}
-
+
} while(res > 0);
return res;
@@ -104,24 +110,33 @@ int cmdline(int argc, char **argv) {
int main(int argc, char* argv[]) {
set_debug(1);
-
+
cmdline(argc, argv);
+ N("connecting to %s:%u",server,port);
+
XmlRpcValue params;
XmlRpcValue result;
- XmlRpc::setVerbosity(5);
- XmlRpcClient c(server, port);
+ // XmlRpc::setVerbosity(5);
+ sprintf(uri,"/RPC2");
+ XmlRpcClient c((const char*)server, (int)port, (const char*)uri, true );
+
if(inspect) {
- if( c.execute("system.listMethods", params, result) )
- A("inspecting methods on %s:%i", server, port);
- fprintf(stderr,"%s\n",result);
- } else
+
+ A("inspecting methods on %s:%i", server, port);
+ c.execute("system.listMethods", params, result);
+
+ if( c.isFault() ) {
E("error calling system.listMethods on %s:%i", server, port);
- exit(1);
- }
+ exit(1);
+ }
+
+ cout << "\nMethods:\n" << result << "\n\n";
+ }
+
N("TODO");
exit(1);
-
+
}