- test utility for jpimporter library added
authorJiří Škrábal <nykolas@ics.muni.cz>
Wed, 21 Sep 2005 13:54:27 +0000 (13:54 +0000)
committerJiří Škrábal <nykolas@ics.muni.cz>
Wed, 21 Sep 2005 13:54:27 +0000 (13:54 +0000)
org.glite.jp.client/Makefile
org.glite.jp.client/examples/jpps_upload_files.c [new file with mode: 0644]

index 1162f50..1cefcde 100644 (file)
@@ -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 (file)
index 0000000..81a8d02
--- /dev/null
@@ -0,0 +1,73 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#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 <file>          path to the proxy filename\n"
+                       "    -j <jobid>         jobid string\n"
+                       "    -m <dir>           location of the lb maildir structure\n"
+                       "    -s <addr:port>     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;
+}