extract attributes from file
authorAleš Křenek <ljocha@ics.muni.cz>
Thu, 7 Jul 2005 15:05:09 +0000 (15:05 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Thu, 7 Jul 2005 15:05:09 +0000 (15:05 +0000)
org.glite.jp.primary/src/feed.c
org.glite.jp.primary/src/is_client.c
org.glite.jp.primary/src/is_client.h [new file with mode: 0644]

index 5d39565..ba9e2e1 100644 (file)
@@ -11,7 +11,7 @@
 #include "feed.h"
 #include "file_plugin.h"
 #include "builtin_plugins.h"
-
+#include "is_client.h"
 
 /* 
  * seconds before feed expires: should be 
@@ -190,9 +190,21 @@ int glite_jpps_match_file(
        int     pi;
        void    *bh = NULL;
        int     ret;
+       struct  jpfeed  *f = ctx->feeds;
+
+       int     nvals = 0,j,i,attrs[GLITE_JP_ATTR__LAST];
+       glite_jp_attrtype_t     attrl[GLITE_JP_ATTR__LAST];
+       glite_jp_attrval_t      *vals = NULL,*oneval;
 
        fprintf(stderr,"%s: %s %s %s\n",__FUNCTION__,job,class,name);
 
+       memset(attrs,0,sizeof attrs);
+       
+       for (;f;f=f->next) for (i=0; f->attrs[i].type; i++) attrs[i] = 1;
+       j = 0;
+       for (i=1; i<GLITE_JP_ATTR__LAST; i++) if (attrs[i]) attrl[j++] = i;
+       attrl[j] = GLITE_JP_ATTR_UNDEF;
+
        switch (glite_jpps_fplug_lookup(ctx,class,&pd)) {
                case ENOENT: return 0;  /* XXX: shall we complain? */
                case 0: break;
@@ -215,6 +227,7 @@ int glite_jpps_match_file(
                                continue;
                        }
 
+#if 0 /* not needed anymore -- owner is known from registration */
                        /* XXX: does not belong here but I'd like to avoid opening the file twice */
                        if (!strcmp(class,GLITE_JP_FILETYPE_LB)) {
                                glite_jp_attr_t         owner = { GLITE_JP_ATTR_OWNER, NULL };
@@ -232,14 +245,36 @@ int glite_jpps_match_file(
                                        default: /* TODO: complain */; break;
                                }
                        }
+#endif
 
                        /* TODO: extract attributes for the feeds */
-
+                       for (i=0; attrl[i]; i++) 
+                               if (!pd[pi]->ops.attr(pd[pi]->fpctx,ph,attrl[i],&oneval)) {
+                               /* XXX: ignore error */
+                                       for (j=0; oneval[j].attr; j++);
+                                       vals = realloc(vals,(nvals+j+1) * sizeof *vals);
+                                       memcpy(vals+nvals,oneval,(j+1) * sizeof *vals);
+                                       nvals += j;
+                               }
 
                        pd[pi]->ops.close(pd[pi]->fpctx,ph);
                }
        }
 
+       for (f = ctx->feeds; f; f=f->next) {
+               glite_jp_attrval_t      * fattr = malloc((nvals+1) * sizeof *fattr);
+               int     attri[GLITE_JP_ATTR__LAST];
+
+               memset(attri,0,sizeof attri);
+               for (i=0; f->attrs[i].attr; i++) attri[f->attrs[i].attr] = 1;
+
+               j = 0;
+               for (i=0; i<nvals; i++) if (attri[vals[i].attr]) memcpy(fattr+j++,vals+i,sizeof *fattr);
+               memset(fattr+j,0,sizeof *fattr);
+
+               glite_jp_single_feed(ctx,f->destination,job,fattr);
+       }
+
        if (bh) glite_jppsbe_close_file(ctx,bh);
        free(pd);
 
index 8a747ef..237fb4c 100644 (file)
@@ -8,6 +8,7 @@
 #include "glite/jp/types.h"
 
 #include "feed.h"
+#include "is_client.h"
 /* FIXME
 #include "jpis_H.h"
 #include "jpis_.nsmap"
@@ -17,7 +18,7 @@ int glite_jpps_single_feed(
                glite_jp_context_t ctx,
                const char *destination,
                const char *job,
-               const glite_jp_attrval_t attrs[]
+               glite_jp_attrval_t const * const attrs[]
 )
 {
        /* TODO: really call JP Index server (via interlogger) */
diff --git a/org.glite.jp.primary/src/is_client.h b/org.glite.jp.primary/src/is_client.h
new file mode 100644 (file)
index 0000000..a15d998
--- /dev/null
@@ -0,0 +1 @@
+int glite_jpps_single_feed(glite_jp_context_t,const char *,const char *,glite_jp_attrval_t const *);