From 9482ad14a3a2b82a44e19edaa673e117a3d0acb7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20=C5=A0kr=C3=A1bal?= Date: Wed, 21 Sep 2005 13:54:27 +0000 Subject: [PATCH] - test utility for jpimporter library added --- org.glite.jp.client/Makefile | 11 +++- org.glite.jp.client/examples/jpps_upload_files.c | 73 ++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 org.glite.jp.client/examples/jpps_upload_files.c diff --git a/org.glite.jp.client/Makefile b/org.glite.jp.client/Makefile index 1162f50..1cefcde 100644 --- a/org.glite.jp.client/Makefile +++ b/org.glite.jp.client/Makefile @@ -47,7 +47,9 @@ INSTALL:=libtool --mode=install install STAGE_HDRS:=jpcl_ctx_int.h HDRS:=jp_client.h jpimporter.h -LIBOBJS:=jpimp_ctx.o jpimp_lib.o +LIBOBJS:=jpcl_ctx.o jpimp_lib.o + +EXAMPLES:=jpps_upload_files LIBTHROBJS:=${LIBOBJS:.o=.thr.o} LIBLOBJS:=${LIBOBJS:.o=.lo} @@ -78,12 +80,19 @@ default all: compile compile: ${daemon} ${LIB} +examples: ${EXAMPLES} + ${LIB}: ${LIBOBJS} ${LINK} ${version_info} -o $@ ${LIBLOBJS} -rpath ${glite_location}/lib ${LBMAILDIRLIB} ${daemon}: ${OBJS} ${LINK} -o $@ ${OBJS} ${LBMAILDIRLIB} ${GSOAPLIB} ${GLOBUS_LIBS} +${EXAMPLES}: ${LIB} +${EXAMPLES}: %: %.o + ${LINK} -o $@ $< ${LIB} -ltar ${LBMAILDIRLIB} + + JobProvenancePS.xh: %.xh: %.wsdl JobProvenanceTypes.wsdl typemap.dat cp ${stagedir}/interface/JobProvenanceTypes.wsdl . diff --git a/org.glite.jp.client/examples/jpps_upload_files.c b/org.glite.jp.client/examples/jpps_upload_files.c new file mode 100644 index 0000000..81a8d02 --- /dev/null +++ b/org.glite.jp.client/examples/jpps_upload_files.c @@ -0,0 +1,73 @@ +#include +#include +#include + +#include "jp_client.h" +#include "jpimporter.h" + +static char *myname; + +void usage(void) +{ + fprintf(stderr, + "Usage: %s [-h][-p user_proxy][-j jobid] files\n" + " -h show this help\n" + " -p path to the proxy filename\n" + " -j jobid string\n" + " -m location of the lb maildir structure\n" + " -s JP PS server address and port\n" + , myname); +} + +int main(int argc, char **argv) +{ + glite_jpcl_context_t ctx; + char **files, + *jobid, + *proxy, + *lbmd = NULL, + *jpps = NULL; + int i; + + + myname = strrchr(argv[0],'/'); + if ( myname ) myname++; else myname = argv[0]; + + if ( argc < 2 ) { usage(); return 1; } + for ( i = 1; i < argc; i++ ) { + if ( argv[i][0] != '-' ) break; + if ( argv[i][1] == 'j' ) jobid = argv[++i]; + else if ( argv[i][1] == 'p' ) proxy = argv[++i]; + else if ( argv[i][1] == 'm' ) lbmd = argv[++i]; + else if ( argv[i][1] == 's' ) jpps = argv[++i]; + else if ( argv[i][1] == 'h' || argv[i][1] == '?' ) {usage();return 0;} + else {usage();return 1;} + } + + if ( !(files = calloc(argc-i+1, sizeof(*files))) ) { + perror("calloc()"); + return 1; + } + for ( i = 0; i < argc; i++ ) files[i] = argv[i+1]; + + if ( glite_jpcl_InitContext(&ctx) ) { + perror("glite_jpcl_InitContext()"); + return 1; + } + + if ( lbmd ) glite_jpcl_SetParam(ctx, GLITE_JPCL_PARAM_LBMAILDIR, lbmd); + if ( jpps ) glite_jpcl_SetParam(ctx, GLITE_JPCL_PARAM_JPPS, jpps); + + if ( glite_jpimporter_upload_files(ctx, jobid, files, proxy) ) { + char *errt, *errd; + + glite_jpcl_Error(ctx, &errt, &errd); + printf("Error calling glite_jpimporter_upload_files()\n\t%s: %s\n", + errt, errd); + glite_jpcl_FreeContext(ctx); + return 1; + } + + glite_jpcl_FreeContext(ctx); + return 0; +} -- 1.8.2.3