PLUGIN_LIBS:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour}\
        ${classadslib} -lstdc++ ${expatlib} -lexpat\
 
-PLUGIN_LOBJS:= lb_plugin.lo jobstat_supp.lo process_event.lo lbs_db_supp.lo
+PLUGIN_LOBJS:= lb_plugin.lo jobstat_supp.lo process_event.lo lbs_db_supp.lo process_event_pbs.lo
 
 BKSERVER_BASE_OBJS:= \
-       bkserverd.o il_lbproxy.o get_events.o index.o jobstat.o jobstat_supp.o process_event.o \
+       bkserverd.o il_lbproxy.o get_events.o index.o jobstat.o jobstat_supp.o process_event.o process_event_pbs.o \
        seqcode.o write2rgma.o lbs_db.o lbs_db_supp.o lb_html.o lb_http.o lb_proto.o lb_xml_parse.o \
        lb_xml_parse_V21.o \
        lock.o openserver.o query.o userjobs.o db_store.o request.o store.o \
 endif
 
 INDEX_OBJS:= index.o index_parse.o jobstat_supp.o lbs_db.o lbs_db_supp.o openserver.o \
-       jobstat.o process_event.o query.o lock.o get_events.o write2rgma.o index_lex.o \
+       jobstat.o process_event.o process_event_pbs.o query.o lock.o get_events.o write2rgma.o index_lex.o \
        lb_authz.o store.o bkindex.o stats.o\
        request.o db_store.o srv_purge.o notif_match.o il_lbproxy.o dump.o lb_xml_parse.o il_notification.o lb_proto.o server_state.o lb_xml_parse_V21.o lb_html.o notification.o seqcode.o userjobs.o load.o
 
 HDRS=index.h lb_authz.h lbs_db.h store.h
 
 LIB_OBJS_BK:= \
-       il_lbproxy.o get_events.o index.o jobstat.o jobstat_supp.o process_event.o \
+       il_lbproxy.o get_events.o index.o jobstat.o jobstat_supp.o process_event.o process_event_pbs.o \
        seqcode.o lbs_db.o lbs_db_supp.o lb_html.o lb_http.o lb_proto.o lb_xml_parse.o \
        lb_xml_parse_V21.o \
        lock.o openserver.o query.o userjobs.o db_store.o request.o store.o \
 
 int component_seqcode(const char *a, edg_wll_Source index);
 char * set_component_seqcode(char *s,edg_wll_Source index,int val);
 int processEvent(intJobStat *, edg_wll_Event *, int, int, char **);
+int processEvent_PBS(intJobStat *, edg_wll_Event *, int, int, char **);
 
 int add_stringlist(char ***, const char *);
 int edg_wll_compare_seq(const char *, const char *);
 
 
 static int compare_pevents_by_seq(const void *a, const void *b)
 {
-        const edg_wll_Event **e = (edg_wll_Event **) a;
-        const edg_wll_Event **f = (edg_wll_Event **) b;
+        const edg_wll_Event **e = (const edg_wll_Event **) a;
+        const edg_wll_Event **f = (const edg_wll_Event **) b;
        return compare_events_by_seq(*e,*f);
 }
 
 void init_intJobStat(intJobStat *p)
 {
        memset(p, 0, sizeof(intJobStat));
-       p->pub.jobtype = EDG_WLL_STAT_SIMPLE;
+       p->pub.jobtype = -1 /* why? EDG_WLL_STAT_SIMPLE */;
        p->pub.children_hist = (int*) calloc(1+EDG_WLL_NUMBER_OF_STATCODES, sizeof(int));
        p->pub.children_hist[0] = EDG_WLL_NUMBER_OF_STATCODES;
        p->pub.stateEnterTimes = (int*) calloc(1+EDG_WLL_NUMBER_OF_STATCODES, sizeof(int));
 
 #define UNUSED_VAR
 #endif
 
+static int processEvent_glite(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring);
+
+int processEvent(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring)
+{
+       if (js->pub.jobtype == -1 && e->type == EDG_WLL_EVENT_REGJOB)
+               switch (e->regJob.jobtype) {
+                       case EDG_WLL_REGJOB_SIMPLE:
+                               js->pub.jobtype = EDG_WLL_STAT_SIMPLE;
+                               break;
+                       case EDG_WLL_REGJOB_DAG: 
+                       case EDG_WLL_REGJOB_PARTITIONABLE:
+                       case EDG_WLL_REGJOB_PARTITIONED:
+                               js->pub.jobtype = EDG_WLL_STAT_DAG;
+                               break;
+                       case EDG_WLL_REGJOB_COLLECTION:
+                               js->pub.jobtype = EDG_WLL_STAT_COLLECTION;
+                               break;
+                       case EDG_WLL_REGJOB_PBS:
+                               js->pub.jobtype = EDG_WLL_STAT_PBS;
+                               break;
+                       default:
+                               asprintf(errstring,"unknown job type %d in registration",e->regJob.jobtype);
+                               return RET_FAIL;
+       }
+
+       switch (js->pub.jobtype) {
+               case EDG_WLL_STAT_SIMPLE:
+               case EDG_WLL_STAT_DAG:
+               case EDG_WLL_STAT_COLLECTION:
+                       return processEvent_glite(js,e,ev_seq,strict,errstring);
+               case EDG_WLL_STAT_PBS: 
+                       return processEvent_PBS(js,e,ev_seq,strict,errstring);
+               default: 
+                       asprintf(errstring,"undefined job type %d",js->pub.jobtype);
+                       return RET_FAIL;
+       }
+}
+
 #define rep(a,b) { free(a); a = (b == NULL) ? NULL : strdup(b); }
 
 static void free_stringlist(char ***lptr)
 #define LRMS_STATE(state) ((state) == EDG_WLL_JOB_RUNNING || (state) == EDG_WLL_JOB_DONE)
 #define PARSABLE_SEQCODE(code) (component_seqcode((code),0) >= 0)
 
-int processEvent(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring)
+static int processEvent_glite(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring)
 {
        edg_wll_JobStatCode     old_state = js->pub.state;
        enum edg_wll_StatDone_code      old_done_code = js->pub.done_code;
 
--- /dev/null
+#ident "$Header$"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+#include <syslog.h>
+
+#include "glite/lb/producer.h"
+#include "glite/lb/context-int.h"
+
+#include "jobstat.h"
+#include "lock.h"
+
+/* TBD: share in whole logging or workload */
+#ifdef __GNUC__
+#define UNUSED_VAR __attribute__((unused))
+#else
+#define UNUSED_VAR
+#endif
+
+int processEvent_PBS(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring)
+{
+       fputs("processEvent_PBS()",stderr);
+
+       if (! js->pub.location) js->pub.location = strdup("this is PBS");
+       return RET_OK;
+}
+