- better naming (rather use "client" prefixes)
authorJiří Škrábal <nykolas@ics.muni.cz>
Tue, 20 Sep 2005 14:12:23 +0000 (14:12 +0000)
committerJiří Škrábal <nykolas@ics.muni.cz>
Tue, 20 Sep 2005 14:12:23 +0000 (14:12 +0000)
org.glite.jp.client/Makefile
org.glite.jp.client/interface/jpcl_ctx_int.h [new file with mode: 0644]
org.glite.jp.client/interface/jpimp-ctx-int.h [deleted file]
org.glite.jp.client/interface/jpimporter.h
org.glite.jp.client/src/jpcl_ctx.c [moved from org.glite.jp.client/src/jpimp_ctx.c with 58% similarity]
org.glite.jp.client/src/jpimp_lib.c

index 7b9388e..1162f50 100644 (file)
@@ -22,6 +22,7 @@ CC=gcc
 
 -include Makefile.inc
 
+STAGETO=include/${globalprefix}/${jpprefix}
 
 VPATH=${top_srcdir}/src:${top_srcdir}/examples:${top_srcdir}/project:${stagedir}/interface:${top_srcdir}/build
 
@@ -43,7 +44,8 @@ LTCOMPILE:=libtool --mode=compile ${CC} ${CFLAGS}
 LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} 
 INSTALL:=libtool --mode=install install
 
-HDRS:=jpimporter.h
+STAGE_HDRS:=jpcl_ctx_int.h
+HDRS:=jp_client.h jpimporter.h
 
 LIBOBJS:=jpimp_ctx.o jpimp_lib.o
 
@@ -131,8 +133,14 @@ distbin:
        rm -rf tmpbuilddir
         
 install:
-       -mkdir -p ${PREFIX}/bin ${PREFIX}/etc ${PREFIX}/examples ${PREFIX}/etc/init.d
+       -mkdir -p ${PREFIX}/${STAGETO}
+       -mkdir -p ${PREFIX}/bin
        ${INSTALL} -m 755 ${daemon} ${PREFIX}/bin
+       ${INSTALL} -m 644 ${HDRS} ${PREFIX}/${STAGETO}
+       if [ x${DOSTAGE} = xyes ]; then \
+               cd ${top_srcdir}/interface && ${INSTALL} -m 644 ${FAKE_H} ${PREFIX}/${STAGETO} ; \
+       fi
+
 
 clean:
 
diff --git a/org.glite.jp.client/interface/jpcl_ctx_int.h b/org.glite.jp.client/interface/jpcl_ctx_int.h
new file mode 100644 (file)
index 0000000..dcf6038
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef __GLITE_JPCLIENT_CONTEXT_INT
+#define __GLITE_JPCLIENT_CONTEXT_INT
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct _glite_jpcl_context_t {
+       int             errCode;
+       char   *errDesc;
+
+       char   *jpps;
+       char   *lbmd_dir;
+};
+
+extern int glite_jpcl_SetError(glite_jpcl_context_t, int, const char *);
+extern int glite_jpcl_ResetError(glite_jpcl_context_t);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/org.glite.jp.client/interface/jpimp-ctx-int.h b/org.glite.jp.client/interface/jpimp-ctx-int.h
deleted file mode 100644 (file)
index 3412e39..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef __GLITE_JPIMPORTER_CONTEXT_INT
-#define __GLITE_JPIMPORTER_CONTEXT_INT
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct _glite_jpimp_context_t {
-       int             errCode;
-       char   *errDesc;
-
-       char   *jpps;
-       char   *lbmd_dir;
-};
-
-extern int glite_jpimp_SetError(glite_jpimp_context_t, int, const char *);
-extern int glite_jpimp_ResetError(glite_jpimp_context_t);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
index 7258bc6..93f7c72 100644 (file)
@@ -1,34 +1,15 @@
-#ifndef __GLITE_JPIMPORTER
-#define __GLITE_JPIMPORTER
+#ifndef __GLITE_JPIMPORTER__
+#define __GLITE_JPIMPORTER__
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-typedef struct _glite_jpimp_context_t *glite_jpimp_context_t;
-
-typedef enum _glite_jpimp_ctx_param_t {
-       GLITE_JPIMP_PARAM_JPPS,
-       GLITE_JPIMP_PARAM_LBMAILDIR
-} glite_jpimp_ctx_param_t;
-
-extern int glite_jpimp_InitContext(glite_jpimp_context_t *);
-extern void glite_jpimp_FreeContext(glite_jpimp_context_t);
-
-extern int glite_jpimp_SetParam(
-               glite_jpimp_context_t ctx,
-               int param, ... );
-
-extern int glite_jpimp_Error(
-               glite_jpimp_context_t ctx,
-               char **errt,
-               char **errd);
-
 extern int glite_jpimporter_upload_files(
-               glite_jpimp_context_t ctx,
-               char *jobid,
-               char *files,
-               char *user);
+               glite_jpcl_context_t ctx,
+               const char *jobid,
+               const char **files,
+               const char *proxy);
 
 #ifdef __cplusplus
 }
similarity index 58%
rename from org.glite.jp.client/src/jpimp_ctx.c
rename to org.glite.jp.client/src/jpcl_ctx.c
index ef030a9..48e4c06 100644 (file)
@@ -5,12 +5,12 @@
 #include <string.h>
 
 #include "jpimporter.h"
-#include "jpimp-ctx-int.h"
+#include "jpcl_ctx_int.h"
 
 
-int glite_jpimp_InitContext(glite_jpimp_context_t *ctx)
+int glite_jpcl_InitContext(glite_jpcl_context_t *ctx)
 {
-       glite_jpimp_context_t out = (glite_jpimp_context_t) malloc(sizeof(*out));
+       glite_jpcl_context_t out = (glite_jpcl_context_t) malloc(sizeof(*out));
        if (!out) return ENOMEM;
        memset(out, 0, sizeof(*out));
        assert(out->errDesc == NULL);
@@ -19,50 +19,44 @@ int glite_jpimp_InitContext(glite_jpimp_context_t *ctx)
        return 0;
 }
 
-void glite_jpimp_FreeContext(glite_jpimp_context_t ctx)
+void glite_jpcl_FreeContext(glite_jpcl_context_t ctx)
 {
        free(ctx->jpps);
        free(ctx->lbmd_dir);
 }
 
-int glite_jpimp_SetParam(glite_jpimp_context_t ctx, int param, ...)
+int glite_jpcl_SetParam(glite_jpcl_context_t ctx, int param, ...)
 {
        va_list ap;
 
        va_start(ap, param);
        switch ( param ) {
-       case GLITE_JPIMP_PARAM_JPPS:
+       case GLITE_JPCL_PARAM_JPPS:
                if ( ctx->jpps ) free(ctx->jpps);
                ctx->jpps = va_arg(ap, char *);
                ctx->jpps = strdup(ctx->jpps);
                break;
-       case GLITE_JPIMP_PARAM_LBMAILDIR:
+       case GLITE_JPCL_PARAM_LBMAILDIR:
                if ( ctx->lbmd_dir ) free(ctx->lbmd_dir);
                ctx->lbmd_dir = strdup(va_arg(ap, char *));
                break;
        default:
-               return glite_jpimp_SetError(ctx, EINVAL, "unknown parameter");
+               return glite_jpcl_SetError(ctx, EINVAL, "unknown parameter");
        }
 
        return 0;
 }
 
-int glite_jpimp_Error(
-       glite_jpimp_context_t   ctx,
-       char                              **errt,
-       char                              **errd)
+int glite_jpcl_Error( glite_jpcl_context_t ctx, char **errt, char **errd)
 {
        if ( errt ) *errt = strdup(strerror(ctx->errCode));
        if ( errd ) *errd = (ctx->errDesc)? strdup(ctx->errDesc): NULL;
        return ctx->errCode;
 }
 
-int glite_jpimp_SetError(
-       glite_jpimp_context_t   ctx,
-       int                                     code,
-       const char                 *desc)
+int glite_jpcl_SetError(glite_jpcl_context_t ctx, int code, const char *desc)
 {
-       glite_jpimp_ResetError(ctx);
+       glite_jpcl_ResetError(ctx);
     if ( code ) {
                ctx->errCode = code;
                if ( desc ) ctx->errDesc = (char *) strdup(desc);
@@ -71,8 +65,7 @@ int glite_jpimp_SetError(
        return ctx->errCode;
 }
 
-int glite_jpimp_ResetError(
-       glite_jpimp_context_t ctx)
+int glite_jpcl_ResetError(glite_jpcl_context_t ctx)
 {
        if ( ctx->errDesc ) free(ctx->errDesc);
        ctx->errDesc = NULL;
index 999b470..7b0f2bb 100644 (file)
@@ -1,22 +1,58 @@
-#include "lb_maildir"
+#include <time.h>
+#include <errno.h>
+
+#include "glite/lb/lb_maildir.h"
+
+#include "jp_client.h"
 #include "jpimporter.h"
-#include "jpimp-ctx-int.h"
+#include "jpcl_ctx_int.h"
 
 int glite_jpimporter_upload_files(
-       glite_jpimp_context_t   ctx,
-       char                               *jobid,
-       char                               *files,
-       char                               *userdn)
+       glite_jpcl_context_t    ctx,
+       const char                         *jobid,
+       const char                        **files,
+       const char                         *proxy)
 {
+       char       *msg,
+                          *file;
+
+       if ( !files || !files[0] ) {
+               glite_jpcl_SetError(ctx, EINVAL, "No files given");
+               return -1;
+       }
+       if ( !jobid ) {
+               glite_jpcl_SetError(ctx, EINVAL, "No jobid given");
+               return -1;
+       }
+       /* TODO: get the user proxy if it is not specified and
+        * find the file of its location.
+        */
+
        if ( edg_wll_MaildirInit(ctx->lbmd_dir) ) {
                char *aux;
-               asprintf(aux, "Can't initialize maildir structure - %s", lbm_errdesc);
-               glite_jpimp_SetError(ctx, errno, aux);
+               asprintf(aux, "edg_wll_MaildirInit(): %s", lbm_errdesc);
+               glite_jpcl_SetError(ctx, errno, aux);
                free(aux);
                return -1;
        }
 
-       edg_wll_MaildirStoreMsg(const char *, const char *, const char *);
+       /* TODO: Pack all the files into one tar file */
+       file = files[0];
+
+       if ( ctx->jpps )
+               asprintf(msg, "jobid\t%s\nfile\t%s\nproxy\t%sjpps\t%s",
+                               jobid, file, proxy, ctx->jpps);
+       else
+               asprintf(msg, "jobid\t%s\nfile\t%s\nproxy\t%s",
+                               jobid, file, proxy);
+
+       if ( edg_wll_MaildirStoreMsg(ctx->lbmd_dir, "localhost", msg) ) {
+               char *aux;
+               asprintf(aux, "edg_wll_MaildirStoreMsg(): %s", lbm_errdesc);
+               glite_jpcl_SetError(ctx, errno, aux);
+               free(aux);
+               return -1;
+       }
 
        return 0;
 }