DIRCONFOBJS = ../dird/dird_conf.o ../dird/run_conf.o ../dird/inc_conf.o ../dird/ua_acl.o
-NODIRTOOLS = bsmtp
-DIRTOOLS = bsmtp dbcheck drivetype fstype testfind testls bregex bwild bbatch bregtest bvfs_test
+NODIRTOOLS = bsmtp bjoblist
+DIRTOOLS = bsmtp dbcheck drivetype fstype testfind testls bregex bwild bbatch bregtest bvfs_test bjoblist
TOOLS = $(@DIR_TOOLS@)
INSNODIRTOOLS = bsmtp
$(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -L../lib -L../findlib -o $@ joblist.o ../lib/unittests.o -lbac -lbacfind $(DLIB) $(LIBS) $(GETTEXT_LIBS) $(OPENSSL_LIBS)
$(LIBTOOL_INSTALL) $(INSTALL_PROGRAM) $@ $(DESTDIR)$(sbindir)/
+bjoblist: bjoblist.o
+ $(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -L../lib -L../findlib -o $@ bjoblist.o -lbac -lbacfind $(DLIB) $(LIBS) $(GETTEXT_LIBS)
+
bsock_meeting_test: bsock_meeting_test.o ../lib/unittests.o
$(LIBTOOL_LINK) $(CXX) $(LDFLAGS) -L../lib -o $@ bsock_meeting_test.o ../lib/unittests.o -lbac $(DLIB) $(LIBS) $(GETTEXT_LIBS) $(OPENSSL_LIBS)
*/
#include "bacula.h"
+#include "filed/fd_plugins.h"
+#include "findlib/bfile.h"
+
+static const char *working="./";
+
+#define USE_JOB_LIST
+#define UNITTESTS
+#define MAX_PATH 512
+
+#include "plugins/fd/fd_common.h"
+
+void *start_heap;
int main(int argc, char *argv[]) {
int opt;
+ POOL_MEM tmp;
+ alist tmp_list(10, owned_by_alist); // define magick number
+ BFILE *file;
+
+ char *dat_file = NULL;
+ char *key = NULL;
+ char *prev_job = NULL;
+ char *curr_job = NULL;
+ char level;
+ char *data = NULL;
+ char *search_query = NULL;
+ bool is_store = false;
- while ((opt = getopt(argc, argv, "wdkpjlDmh")) != -1) {
+ // Array holding all command line args for easy for loop free memory
+
+ // Parsing of command line arguments
+ while ((opt = getopt(argc, argv, "w:d:f:k:p:j:l:D:sSh")) != -1) {
switch(opt) {
case 'w': // Working dir
- printf("w\n");
+ working_directory = optarg;
break;
- case 'd': // datfile
- printf("d\n");
+
+ case 'f': // datfile
+ dat_file = optarg;
+
break;
case 'k': // key (hostname + volume name)
- printf("w\n");
+ key = optarg;
break;
case 'p': // previous job
- printf("p\n");
+ prev_job = optarg;
break;
case 'j': // current job
- printf("j\n");
+ curr_job = optarg;
break;
case 'l': // level
- printf("l\n");
+ level = optarg[0];
break;
case 'D': // Data
- printf("D\n");
+ // TODO is no data put curr job instead
+ data = optarg;
break;
- case 'm': // mode {store, search}
- printf("m\n");
+ case 's': // Store
+ is_store = true;
+ break;
+
+ case 'S': // Search
+ is_store = false;
break;
case 'h': // help default is help as well
printf("bjoblist: joblist command line tool : store/search jobs and find deletable ones\n"
"USAGE: bjoblist [OPTIONS]\n"
"Options-styles: -option\n\n"
- "\t-w\tWoking directory\n"
+ "\t-w\tWorking directory\n"
"\t-d\tDat file with job hierarchy info\n"
"\t-k\tKey (hostname + volume name)\n"
"\t-p\tPrevious job\n"
"\t-j\tCurrent job\n"
"\t-l\tLevel {(f)ull, (d)ifferential, (i)ncremental}\n"
"\t-D\tData XXX-XXX-XXX-XXX-XXX\n"
- "\t-m\tMode {store, search}\n"
+ "\t-s\tStore-mode\n"
+ "\t-S\tSearch-mode\n"
"\t-h\t display this text\n\n");
}
}
+
+ joblist job_history(NULL, key, curr_job, prev_job, level); // context can be null
+ job_history.set_base(dat_file);
+
+ int ret1 = 0;
+ if (is_store) {
+ ret1 = job_history.store_job(data);
+ job_history.prune_jobs(NULL, NULL, &tmp_list);
+
+ char *buf;
+
+ printf("ret1 %d\n", ret1);
+
+ foreach_alist(buf, &tmp_list) {
+ printf("%s\n", buf);
+ }
+ } else {
+ job_history.find_job(curr_job, tmp.handle());
+ printf("Search out %s\n", curr_job);
+ }
+
+
+ return 1;
}
+