static char OKRunBeforeNow[] = "2000 OK RunBeforeNow\n";
/* Forward referenced functions */
+static bool send_list_item(JCR *jcr, const char *code, char *item, BSOCK *fd);
/* External functions */
extern DIRRES *director;
char ed1[50];
stime = str_to_utime(jcr->stime);
- bnet_fsend(fd, levelcmd, NT_("since_utime "), edit_uint64(stime, ed1), 0);
+ fd->fsend(levelcmd, NT_("since_utime "), edit_uint64(stime, ed1), 0);
while (bget_dirmsg(fd) >= 0) { /* allow him to poll us to sync clocks */
Jmsg(jcr, M_INFO, 0, "%s\n", fd->msg);
}
*/
switch (jcr->JobLevel) {
case L_BASE:
- bnet_fsend(fd, levelcmd, "base", " ", 0);
+ fd->fsend(levelcmd, "base", " ", 0);
break;
/* L_NONE is the console, sending something off to the FD */
case L_NONE:
case L_FULL:
- bnet_fsend(fd, levelcmd, "full", " ", 0);
+ fd->fsend(levelcmd, "full", " ", 0);
break;
case L_DIFFERENTIAL:
- bnet_fsend(fd, levelcmd, "differential", " ", 0);
+ fd->fsend(levelcmd, "differential", " ", 0);
send_since_time(jcr);
break;
case L_INCREMENTAL:
- bnet_fsend(fd, levelcmd, "incremental", " ", 0);
+ fd->fsend(levelcmd, "incremental", " ", 0);
send_since_time(jcr);
break;
case L_SINCE:
num = fileset->num_excludes;
}
for (int i=0; i<num; i++) {
- BPIPE *bpipe;
- FILE *ffd;
- char buf[2000];
- char *p;
- int optlen, stat;
+ char *item;
INCEXE *ie;
int j, k;
if (include) {
ie = fileset->include_items[i];
- bnet_fsend(fd, "I\n");
+ fd->fsend("I\n");
} else {
ie = fileset->exclude_items[i];
- bnet_fsend(fd, "E\n");
+ fd->fsend("E\n");
}
for (j=0; j<ie->num_opts; j++) {
FOPTS *fo = ie->opts_list[j];
- bnet_fsend(fd, "O %s\n", fo->opts);
+ fd->fsend("O %s\n", fo->opts);
bool enhanced_wild = false;
for (k=0; fo->opts[k]!='\0'; k++) {
}
for (k=0; k<fo->regex.size(); k++) {
- bnet_fsend(fd, "R %s\n", fo->regex.get(k));
+ fd->fsend("R %s\n", fo->regex.get(k));
}
for (k=0; k<fo->regexdir.size(); k++) {
- bnet_fsend(fd, "RD %s\n", fo->regexdir.get(k));
+ fd->fsend("RD %s\n", fo->regexdir.get(k));
}
for (k=0; k<fo->regexfile.size(); k++) {
- bnet_fsend(fd, "RF %s\n", fo->regexfile.get(k));
+ fd->fsend("RF %s\n", fo->regexfile.get(k));
}
for (k=0; k<fo->wild.size(); k++) {
- bnet_fsend(fd, "W %s\n", fo->wild.get(k));
+ fd->fsend("W %s\n", fo->wild.get(k));
}
for (k=0; k<fo->wilddir.size(); k++) {
- bnet_fsend(fd, "WD %s\n", fo->wilddir.get(k));
+ fd->fsend("WD %s\n", fo->wilddir.get(k));
}
for (k=0; k<fo->wildfile.size(); k++) {
- bnet_fsend(fd, "WF %s\n", fo->wildfile.get(k));
+ fd->fsend("WF %s\n", fo->wildfile.get(k));
}
for (k=0; k<fo->wildbase.size(); k++) {
- bnet_fsend(fd, "W%c %s\n", enhanced_wild ? 'B' : 'F', fo->wildbase.get(k));
+ fd->fsend("W%c %s\n", enhanced_wild ? 'B' : 'F', fo->wildbase.get(k));
}
for (k=0; k<fo->base.size(); k++) {
- bnet_fsend(fd, "B %s\n", fo->base.get(k));
+ fd->fsend("B %s\n", fo->base.get(k));
}
for (k=0; k<fo->fstype.size(); k++) {
- bnet_fsend(fd, "X %s\n", fo->fstype.get(k));
+ fd->fsend("X %s\n", fo->fstype.get(k));
}
for (k=0; k<fo->drivetype.size(); k++) {
- bnet_fsend(fd, "XD %s\n", fo->drivetype.get(k));
+ fd->fsend("XD %s\n", fo->drivetype.get(k));
+ }
+ if (fo->plugin) {
+ fd->fsend("G %s\n", fo->plugin);
}
if (fo->reader) {
- bnet_fsend(fd, "D %s\n", fo->reader);
+ fd->fsend("D %s\n", fo->reader);
}
if (fo->writer) {
- bnet_fsend(fd, "T %s\n", fo->writer);
+ fd->fsend("T %s\n", fo->writer);
}
- bnet_fsend(fd, "N\n");
+ fd->fsend("N\n");
}
for (j=0; j<ie->name_list.size(); j++) {
- p = (char *)ie->name_list.get(j);
- switch (*p) {
- case '|':
- p++; /* skip over the | */
- fd->msg = edit_job_codes(jcr, fd->msg, p, "");
- bpipe = open_bpipe(fd->msg, 0, "r");
- if (!bpipe) {
- berrno be;
- Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
- p, be.bstrerror());
- goto bail_out;
- }
- bstrncpy(buf, "F ", sizeof(buf));
- Dmsg1(500, "Opts=%s\n", buf);
- optlen = strlen(buf);
- while (fgets(buf+optlen, sizeof(buf)-optlen, bpipe->rfd)) {
- fd->msglen = Mmsg(fd->msg, "%s", buf);
- Dmsg2(500, "Inc/exc len=%d: %s", fd->msglen, fd->msg);
- if (!bnet_send(fd)) {
- Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
- goto bail_out;
- }
- }
- if ((stat=close_bpipe(bpipe)) != 0) {
- berrno be;
- Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. ERR=%s\n"),
- p, be.bstrerror(stat));
- goto bail_out;
- }
- break;
- case '<':
- p++; /* skip over < */
- if ((ffd = fopen(p, "rb")) == NULL) {
- berrno be;
- Jmsg(jcr, M_FATAL, 0, _("Cannot open included file: %s. ERR=%s\n"),
- p, be.bstrerror());
- goto bail_out;
- }
- bstrncpy(buf, "F ", sizeof(buf));
- Dmsg1(500, "Opts=%s\n", buf);
- optlen = strlen(buf);
- while (fgets(buf+optlen, sizeof(buf)-optlen, ffd)) {
- fd->msglen = Mmsg(fd->msg, "%s", buf);
- if (!bnet_send(fd)) {
- Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
- goto bail_out;
- }
- }
- fclose(ffd);
- break;
- case '\\':
- p++; /* skip over \ */
- /* Note, fall through wanted */
- default:
- pm_strcpy(fd->msg, "F ");
- fd->msglen = pm_strcat(fd->msg, p);
- Dmsg1(500, "Inc/Exc name=%s\n", fd->msg);
- if (!bnet_send(fd)) {
- Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
- goto bail_out;
- }
- break;
+ item = (char *)ie->name_list.get(j);
+ if (!send_list_item(jcr, "F ", item, fd)) {
+ goto bail_out;
}
}
- bnet_fsend(fd, "N\n");
+ fd->fsend("N\n");
+ for (j=0; j<ie->plugin_list.size(); j++) {
+ item = (char *)ie->plugin_list.get(j);
+ if (!send_list_item(jcr, "P ", item, fd)) {
+ goto bail_out;
+ }
+ }
+ fd->fsend("N\n");
}
if (!include) { /* If we just did excludes */
break; /* all done */
include = false; /* Now do excludes */
}
- bnet_sig(fd, BNET_EOD); /* end of data */
+ fd->signal(BNET_EOD); /* end of data */
if (!response(jcr, fd, OKinc, "Include", DISPLAY_ERROR)) {
goto bail_out;
}
}
+static bool send_list_item(JCR *jcr, const char *code, char *item, BSOCK *fd)
+{
+ BPIPE *bpipe;
+ FILE *ffd;
+ char buf[2000];
+ int optlen, stat;
+ char *p = item;
+
+ switch (*p) {
+ case '|':
+ p++; /* skip over the | */
+ fd->msg = edit_job_codes(jcr, fd->msg, p, "");
+ bpipe = open_bpipe(fd->msg, 0, "r");
+ if (!bpipe) {
+ berrno be;
+ Jmsg(jcr, M_FATAL, 0, _("Cannot run program: %s. ERR=%s\n"),
+ p, be.bstrerror());
+ return false;
+ }
+ bstrncpy(buf, code, sizeof(buf));
+ Dmsg1(500, "code=%s\n", buf);
+ optlen = strlen(buf);
+ while (fgets(buf+optlen, sizeof(buf)-optlen, bpipe->rfd)) {
+ fd->msglen = Mmsg(fd->msg, "%s", buf);
+ Dmsg2(500, "Inc/exc len=%d: %s", fd->msglen, fd->msg);
+ if (!bnet_send(fd)) {
+ Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
+ return false;
+ }
+ }
+ if ((stat=close_bpipe(bpipe)) != 0) {
+ berrno be;
+ Jmsg(jcr, M_FATAL, 0, _("Error running program: %s. ERR=%s\n"),
+ p, be.bstrerror(stat));
+ return false;
+ }
+ break;
+ case '<':
+ p++; /* skip over < */
+ if ((ffd = fopen(p, "rb")) == NULL) {
+ berrno be;
+ Jmsg(jcr, M_FATAL, 0, _("Cannot open included file: %s. ERR=%s\n"),
+ p, be.bstrerror());
+ return false;
+ }
+ bstrncpy(buf, code, sizeof(buf));
+ Dmsg1(500, "code=%s\n", buf);
+ optlen = strlen(buf);
+ while (fgets(buf+optlen, sizeof(buf)-optlen, ffd)) {
+ fd->msglen = Mmsg(fd->msg, "%s", buf);
+ if (!bnet_send(fd)) {
+ Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
+ return false;
+ }
+ }
+ fclose(ffd);
+ break;
+ case '\\':
+ p++; /* skip over \ */
+ /* Note, fall through wanted */
+ default:
+ pm_strcpy(fd->msg, code);
+ fd->msglen = pm_strcat(fd->msg, p);
+ Dmsg1(500, "Inc/Exc name=%s\n", fd->msg);
+ if (!fd->send()) {
+ Jmsg(jcr, M_FATAL, 0, _(">filed: write error on socket\n"));
+ return false;
+ }
+ break;
+ }
+ return true;
+}
+
/*
* Send include list to File daemon
static void store_drivetype(LEX *lc, RES_ITEM *item, int index, int pass);
static void store_opts(LEX *lc, RES_ITEM *item, int index, int pass);
static void store_fname(LEX *lc, RES_ITEM *item, int index, int pass);
+static void store_plugin_name(LEX *lc, RES_ITEM *item, int index, int pass);
static void options_res(LEX *lc, RES_ITEM *item, int index, int pass);
static void store_base(LEX *lc, RES_ITEM *item, int index, int pass);
+static void store_plugin(LEX *lc, RES_ITEM *item, int index, int pass);
static void store_reader(LEX *lc, RES_ITEM *item, int index, int pass);
static void store_writer(LEX *lc, RES_ITEM *item, int index, int pass);
static void setup_current_opts(void);
*/
static RES_ITEM newinc_items[] = {
{"file", store_fname, {0}, 0, 0, 0},
+ {"plugin", store_plugin_name, {0}, 0, 0, 0},
{"options", options_res, {0}, 0, 0, 0},
{NULL, NULL, {0}, 0, 0, 0}
};
{"wildfile", store_wild, {0}, 2, 0, 0},
{"exclude", store_opts, {0}, 0, 0, 0},
{"aclsupport", store_opts, {0}, 0, 0, 0},
+ {"plugin", store_plugin, {0}, 0, 0, 0},
{"reader", store_reader, {0}, 0, 0, 0},
{"writer", store_writer, {0}, 0, 0, 0},
{"ignorecase", store_opts, {0}, 0, 0, 0},
scan_to_eol(lc);
}
+/* Store reader info */
+static void store_plugin(LEX *lc, RES_ITEM *item, int index, int pass)
+{
+ int token;
+
+ token = lex_get_token(lc, T_NAME);
+ if (pass == 1) {
+ /*
+ * Pickup plugin command
+ */
+ res_incexe.current_opts->plugin = bstrdup(lc->str);
+ }
+ scan_to_eol(lc);
+}
+
+
/* Store reader info */
static void store_reader(LEX *lc, RES_ITEM *item, int index, int pass)
{
scan_to_eol(lc);
}
+/*
+ * Store Filename info. Note, for minor efficiency reasons, we
+ * always increase the name buffer by 10 items because we expect
+ * to add more entries.
+ */
+static void store_plugin_name(LEX *lc, RES_ITEM *item, int index, int pass)
+{
+ int token;
+ INCEXE *incexe;
+
+ token = lex_get_token(lc, T_SKIP_EOL);
+ if (pass == 1) {
+ /* Pickup Filename string
+ */
+ switch (token) {
+ case T_IDENTIFIER:
+ case T_UNQUOTED_STRING:
+ if (strchr(lc->str, '\\')) {
+ scan_err1(lc, _("Backslash found. Use forward slashes or quote the string.: %s\n"), lc->str);
+ /* NOT REACHED */
+ }
+ case T_QUOTED_STRING:
+ if (res_all.res_fs.have_MD5) {
+ MD5Update(&res_all.res_fs.md5c, (unsigned char *)lc->str, lc->str_len);
+ }
+ incexe = &res_incexe;
+ if (incexe->plugin_list.size() == 0) {
+ incexe->plugin_list.init(10, true);
+ }
+ incexe->plugin_list.append(bstrdup(lc->str));
+ Dmsg1(900, "Add to plugin_list %s\n", lc->str);
+ break;
+ default:
+ scan_err1(lc, _("Expected a filename, got: %s"), lc->str);
+ }
+ }
+ scan_to_eol(lc);
+}
+
+
/*
* Come here when Options seen in Include/Exclude
}
incexe->opts_list.destroy();
incexe->name_list.destroy();
+ incexe->plugin_list.destroy();
}
fileset->include_list.destroy();
}
incexe->opts_list.destroy();
incexe->name_list.destroy();
+ incexe->plugin_list.destroy();
}
fileset->exclude_list.destroy();
free(fileset);
* Add fname to include/exclude fileset list. First check for
* | and < and if necessary perform command.
*/
-static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *fileset)
+static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *fileset,
+ bool is_file)
{
char *p;
BPIPE *bpipe;
free_pool_memory(fn);
while (fgets(buf, sizeof(buf), bpipe->rfd)) {
strip_trailing_junk(buf);
- fileset->incexe->name_list.append(new_dlistString(buf));
+ if (is_file) {
+ fileset->incexe->name_list.append(new_dlistString(buf));
+ } else {
+ fileset->incexe->plugin_list.append(new_dlistString(buf));
+ }
}
if ((stat=close_bpipe(bpipe)) != 0) {
berrno be;
while (fgets(buf, sizeof(buf), ffd)) {
strip_trailing_junk(buf);
Dmsg1(100, "%s\n", buf);
- fileset->incexe->name_list.append(new_dlistString(buf));
+ if (is_file) {
+ fileset->incexe->name_list.append(new_dlistString(buf));
+ } else {
+ fileset->incexe->plugin_list.append(new_dlistString(buf));
+ }
}
fclose(ffd);
break;
default:
- fileset->incexe->name_list.append(new_dlistString(fname));
+ if (is_file) {
+ fileset->incexe->name_list.append(new_dlistString(fname));
+ } else {
+ fileset->incexe->plugin_list.append(new_dlistString(fname));
+ }
break;
}
}
memset(fileset->incexe, 0, sizeof(findINCEXE));
fileset->incexe->opts_list.init(1, true);
fileset->incexe->name_list.init(); /* for dlist; was 1,true for alist */
+ fileset->incexe->plugin_list.init();
fileset->include_list.append(fileset->incexe);
break;
case 'E':
memset(fileset->incexe, 0, sizeof(findINCEXE));
fileset->incexe->opts_list.init(1, true);
fileset->incexe->name_list.init();
+ fileset->incexe->plugin_list.init();
fileset->exclude_list.append(fileset->incexe);
break;
case 'N':
state = state_none;
break;
case 'F':
- /* File item to either include/include list */
+ /* File item to include or exclude list */
+ state = state_include;
+ add_file_to_fileset(jcr, item, fileset, true);
+ break;
+ case 'P':
+ /* Plugin item to include list */
state = state_include;
- add_file_to_fileset(jcr, item, fileset);
+ add_file_to_fileset(jcr, item, fileset, false);
break;
case 'R':
current_opts = start_options(ff);
foreach_dlist(node, &incexe->name_list) {
Dmsg1(400, "F %s\n", node->c_str());
}
+ foreach_dlist(node, &incexe->plugin_list) {
+ Dmsg1(400, "P %s\n", node->c_str());
+ }
}
for (i=0; i<fileset->exclude_list.size(); i++) {
findINCEXE *incexe = (findINCEXE *)fileset->exclude_list.get(i);
foreach_dlist(node, incexe->name_list) {
Dmsg1(400, "F %s\n", node->c_str());
}
+ foreach_dlist(node, &incexe->plugin_list) {
+ Dmsg1(400, "P %s\n", node->c_str());
+ }
}
#endif
return ff->fileset->state != state_error;