CLASSADPLUGIN_LOBJS:= classad_plugin.lo
-
GLOBUS_CFLAGS:=-I${globus_prefix}/include/${nothrflavour}
DEBUG:=-g -O0 -DDEBUG
plugins:=glite-jp-ftpdauth.la glite-jp-classad.la glite-jp-sandbox.la
HDRS_I=file_plugin.h
-HDRS_S=builtin_plugins.h backend.h feed.h
+HDRS_S=builtin_plugins.h backend.h feed.h utils.h
SRCS:= bones_server.c soap_ops.c \
- new_ftp_backend.c mysql.c file_plugin.c \
- feed.c authz.c attrs.c\
+ new_ftp_backend.c mysql.c file_plugin.c utils.c\
+ feed.c authz.c attrs.c \
tags.c\
is_client.c \
soap_switch.c
\retval ENOSYS this attribute is not defined by this type of file
\retval ENOENT no value is present
*/
- int (*attr)(void *fpctx,void *handle,const char *ns, const char *attr,glite_jp_attrval_t **attrval);
+ int (*attr)(void *fpctx,void *handle, const char *attr,glite_jp_attrval_t **attrval);
/** File type specific operation.
\param[in] fpctx Plugin context.
} *known_namespaces;
-static char* get_namespace(const char* attr){
- char* namespace = strdup(attr);
- char* colon = strrchr(namespace, ':');
- if (colon)
- namespace[strrchr(namespace, ':') - namespace] = 0;
- else
- namespace[0] = 0;
- return namespace;
-}
-
static void scan_namespaces(glite_jp_context_t ctx)
{
int i,j,k;
return nout+nin;
}
-void process_files(glite_jp_context_t ctx, const char *job, glite_jp_attrval_t** out, int* nout, const char* attr, const glite_jpps_fplug_data_t* plugin, const char* class, const char* uri, const char *ns){
+void process_files(glite_jp_context_t ctx, const char *job, glite_jp_attrval_t** out, int* nout, const char* attr, const glite_jpps_fplug_data_t* plugin, const char* class, const char* uri){
void *ph, *beh;
char** names = NULL;
int nnames = glite_jppsbe_get_names(ctx, job, class, &names);
if (!plugin->ops.open(plugin->fpctx,beh,uri,&ph)) {
glite_jp_attrval_t* myattr;
// XXX: ignore errors
- if (!plugin->ops.attr(plugin->fpctx,ph,ns,attr,&myattr)) {
+ if (!plugin->ops.attr(plugin->fpctx,ph,attr,&myattr)) {
int k;
for (k=0; myattr[k].name; k++) {
myattr[k].origin = GLITE_JP_ATTR_ORIG_FILE;
nout++;
for (j = 0; known_namespaces[j].namespace; j++) {
void* ph;
- char* attr_namespace = get_namespace(other[i]);
+ char* attr_namespace = glite_jpps_get_namespace(other[i]);
if (strcmp(attr_namespace, known_namespaces[j].namespace) == 0){
for (k = 0; known_namespaces[j].plugins[k]; k++)
for (l = 0; known_namespaces[j].plugins[k]->classes[l]; l++)
process_files(ctx, job, &out, &nout, other[i], known_namespaces[j].plugins[k]
, known_namespaces[j].plugins[k]->classes[l]
- , known_namespaces[j].plugins[k]->uris[l]
- , known_namespaces[j].namespace);
+ , known_namespaces[j].plugins[k]->uris[l]);
break;
}
free(attr_namespace);
int glite_jpps_get_attrs(glite_jp_context_t,const char *,char **,int,glite_jp_attrval_t **);
+
time_t timestamp;
} classad_handle;
-static int classad_query(void *fpctx, void *handle, const char *ns, const char *attr, glite_jp_attrval_t **attrval);
+static int classad_query(void *fpctx, void *handle, const char *attr, glite_jp_attrval_t **attrval);
static int classad_open(void *fpctx, void *bhandle, const char *uri, void **handle);
static int classad_open_str(void *fpctx, const char *str, const char *uri, const char *ns, void **handle);
static int classad_close(void *fpctx, void *handle);
}
-static int classad_query(void *fpctx,void *handle, const char* ns, const char *attr,glite_jp_attrval_t **attrval) {
+static int classad_query(void *fpctx,void *handle, const char *attr,glite_jp_attrval_t **attrval) {
glite_jp_context_t ctx = (glite_jp_context_t) fpctx;
glite_jp_error_t err;
glite_jp_attrval_t *av = NULL;
}
for (i=0; attrs[i]; i++)
- if (!pd[pi]->ops.attr(pd[pi]->fpctx,ph,"",attrs[i],&oneval)) {
+ if (!pd[pi]->ops.attr(pd[pi]->fpctx,ph,attrs[i],&oneval)) {
/* XXX: ignore error */
for (j=0; oneval[j].name; j++);
vals = realloc(vals,(nvals+j+1) * sizeof *vals);
//static int sandbox_append(void *,void *,int,...);
static int sandbox_open(void *,void *,const char *uri,void **);
static int sandbox_close(void *,void *);
-static int sandbox_attr(void *,void *,const char*,const char *,glite_jp_attrval_t **);
+static int sandbox_attr(void *,void *,const char *,glite_jp_attrval_t **);
static int sandbox_filecom(void *,void *);
int init(glite_jp_context_t ctx, glite_jpps_fplug_data_t *data)
}
-static int sandbox_attr(void *fpctx,void *handle,const char *ns,const char *attr,glite_jp_attrval_t **attrval)
+static int sandbox_attr(void *fpctx,void *handle,const char *attr,glite_jp_attrval_t **attrval)
{
glite_jp_error_t err;
glite_jp_context_t ctx = fpctx;
--- /dev/null
+#include <getopt.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <assert.h>
+#include <limits.h>
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "glite/jp/types.h"
+#include "glite/jp/context.h"
+#include "glite/jp/strmd5.h"
+#include "glite/jp/known_attr.h"
+#include "glite/jp/attr.h"
+#include "glite/jp/escape.h"
+
+#include "feed.h"
+#include "tags.h"
+#include "db.h"
+
+#include "utils.h"
+#include "backend.h"
+
+/*
+ * realloc the line to double size if needed
+ *
+ * \return 0 if failed, did nothing
+ * \return 1 if success
+ */
+int check_realloc_line(char **line, size_t *maxlen, size_t len) {
+ void *tmp;
+
+ if (len > *maxlen) {
+ *maxlen <<= 1;
+ tmp = realloc(*line, *maxlen);
+ if (!tmp) return 0;
+ *line = tmp;
+ }
+
+ return 1;
+}
+
+/*
+ * read next line from stream
+ *
+ * \return error code
+ */
+int glite_jppsbe_readline(
+ glite_jp_context_t ctx,
+ void *handle,
+ rl_buffer_t *buffer,
+ char **line
+)
+{
+ size_t maxlen, len, i;
+ ssize_t nbytes;
+ int retval, z, end;
+
+ maxlen = BUFSIZ;
+ i = 0;
+ len = 0;
+ *line = malloc(maxlen);
+ end = 0;
+
+ do {
+ /* read next portion */
+ if (buffer->pos >= buffer->size) {
+ buffer->pos = 0;
+ buffer->size = 0;
+ if ((retval = glite_jppsbe_pread(ctx, handle, buffer->buf, BUFSIZ, buffer->offset, &nbytes)) == 0) {
+ if (nbytes < 0) {
+ retval = EINVAL;
+ goto fail;
+ } else {
+ if (nbytes) {
+ buffer->size = (size_t)nbytes;
+ buffer->offset += nbytes;
+ } else end = 1;
+ }
+ } else goto fail;
+ }
+
+ /* we have buffer->size - buffer->pos bytes */
+ i = buffer->pos;
+ do {
+ if (i >= buffer->size) z = '\0';
+ else {
+ z = buffer->buf[i];
+ if (z == '\n') z = '\0';
+ }
+ len++;
+
+ if (!check_realloc_line(line, &maxlen, len)) {
+ retval = ENOMEM;
+ goto fail;
+ }
+ (*line)[len - 1] = z;
+ i++;
+ } while (z && i < buffer->size);
+ buffer->pos = i;
+ } while (len && (*line)[len - 1] != '\0');
+
+ if ((!len || !(*line)[0]) && end) {
+ free(*line);
+ *line = NULL;
+ }
+
+ return 0;
+
+fail:
+ free(*line);
+ *line = NULL;
+ return retval;
+}
+
+char* glite_jpps_get_namespace(const char* attr){
+ char* namespace = strdup(attr);
+ char* colon = strrchr(namespace, ':');
+ if (colon)
+ namespace[strrchr(namespace, ':') - namespace] = 0;
+ else
+ namespace[0] = 0;
+ return namespace;
+}
+
--- /dev/null
+#ifndef __GLITE_JP_UTILS
+#define __GLITE_JP_UTILS
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "feed.h"
+
+typedef struct _rl_buffer_t {
+ char *buf;
+ size_t pos, size;
+ off_t offset;
+} rl_buffer_t;
+
+int glite_jppsbe_readline(
+ glite_jp_context_t ctx,
+ void *handle,
+ rl_buffer_t *buffer,
+ char **line
+);
+
+char* glite_jpps_get_namespace(
+ const char* attr
+);
+
+#endif
+