{
int token, i;
- token = lex_get_token(lc);
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "expected an identifier or string, got: %s", lc->str);
- } else {
- /* Store the type both pass 1 and pass 2 */
- for (i=0; jobtypes[i].type_name; i++) {
- if (strcasecmp(lc->str, jobtypes[i].type_name) == 0) {
- ((JOB *)(item->value))->JobType = jobtypes[i].job_type;
- i = 0;
- break;
- }
- }
- if (i != 0) {
- scan_err1(lc, "Expected a Job Type keyword, got: %s", lc->str);
+ token = lex_get_token(lc, T_NAME);
+ /* Store the type both pass 1 and pass 2 */
+ for (i=0; jobtypes[i].type_name; i++) {
+ if (strcasecmp(lc->str, jobtypes[i].type_name) == 0) {
+ ((JOB *)(item->value))->JobType = jobtypes[i].job_type;
+ i = 0;
+ break;
}
}
+ if (i != 0) {
+ scan_err1(lc, "Expected a Job Type keyword, got: %s", lc->str);
+ }
scan_to_eol(lc);
set_bit(index, res_all.hdr.item_present);
}
{
int token, i;
- token = lex_get_token(lc);
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "expected an identifier or string, got: %s", lc->str);
- } else {
- /* Store the level pass 2 so that type is defined */
- for (i=0; joblevels[i].level_name; i++) {
- if (strcasecmp(lc->str, joblevels[i].level_name) == 0) {
- ((JOB *)(item->value))->level = joblevels[i].level;
- i = 0;
- break;
- }
- }
- if (i != 0) {
- scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
+ token = lex_get_token(lc, T_NAME);
+ /* Store the level pass 2 so that type is defined */
+ for (i=0; joblevels[i].level_name; i++) {
+ if (strcasecmp(lc->str, joblevels[i].level_name) == 0) {
+ ((JOB *)(item->value))->level = joblevels[i].level;
+ i = 0;
+ break;
}
}
+ if (i != 0) {
+ scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
+ }
scan_to_eol(lc);
set_bit(index, res_all.hdr.item_present);
}
((JOB *)(item->value))->JobType = item->code;
- while ((token = lex_get_token(lc)) != T_EOL) {
+ while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
int found;
if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
scan_err1(lc, "Expected a backup/verify keyword, got: %s", lc->str);
- } else {
- Dmsg1(190, "Got keyword: %s\n", lc->str);
- found = FALSE;
- for (i=0; BakVerFields[i].name; i++) {
- if (strcasecmp(lc->str, BakVerFields[i].name) == 0) {
- found = TRUE;
- if (lex_get_token(lc) != T_EQUALS) {
- scan_err1(lc, "Expected an equals, got: %s", lc->str);
- }
- token = lex_get_token(lc);
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
- }
- Dmsg1(190, "Got value: %s\n", lc->str);
- switch (BakVerFields[i].token) {
- case 'C':
- /* Find Client Resource */
- if (pass == 2) {
- res = GetResWithName(R_CLIENT, lc->str);
- if (res == NULL) {
- scan_err1(lc, "Could not find specified Client Resource: %s",
- lc->str);
- }
- res_all.res_job.client = (CLIENT *)res;
- }
- break;
- case 'F':
- /* Find FileSet Resource */
- if (pass == 2) {
- res = GetResWithName(R_FILESET, lc->str);
- if (res == NULL) {
- scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
- lc->str);
- }
- res_all.res_job.fs = (FILESET *)res;
+ }
+ Dmsg1(190, "Got keyword: %s\n", lc->str);
+ found = FALSE;
+ for (i=0; BakVerFields[i].name; i++) {
+ if (strcasecmp(lc->str, BakVerFields[i].name) == 0) {
+ found = TRUE;
+ if (lex_get_token(lc, T_ALL) != T_EQUALS) {
+ scan_err1(lc, "Expected an equals, got: %s", lc->str);
+ }
+ token = lex_get_token(lc, T_NAME);
+ Dmsg1(190, "Got value: %s\n", lc->str);
+ switch (BakVerFields[i].token) {
+ case 'C':
+ /* Find Client Resource */
+ if (pass == 2) {
+ res = GetResWithName(R_CLIENT, lc->str);
+ if (res == NULL) {
+ scan_err1(lc, "Could not find specified Client Resource: %s",
+ lc->str);
}
- break;
- case 'L':
- /* Get level */
- for (i=0; joblevels[i].level_name; i++) {
- if (joblevels[i].job_type == item->code &&
- strcasecmp(lc->str, joblevels[i].level_name) == 0) {
- ((JOB *)(item->value))->level = joblevels[i].level;
- i = 0;
- break;
- }
+ res_all.res_job.client = (CLIENT *)res;
+ }
+ break;
+ case 'F':
+ /* Find FileSet Resource */
+ if (pass == 2) {
+ res = GetResWithName(R_FILESET, lc->str);
+ if (res == NULL) {
+ scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
+ lc->str);
}
- if (i != 0) {
- scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
+ res_all.res_job.fs = (FILESET *)res;
+ }
+ break;
+ case 'L':
+ /* Get level */
+ for (i=0; joblevels[i].level_name; i++) {
+ if (joblevels[i].job_type == item->code &&
+ strcasecmp(lc->str, joblevels[i].level_name) == 0) {
+ ((JOB *)(item->value))->level = joblevels[i].level;
+ i = 0;
+ break;
}
- break;
- } /* end switch */
- break;
- } /* end if strcmp() */
- } /* end for */
- if (!found) {
- scan_err1(lc, "%s not a valid Backup/verify keyword", lc->str);
- }
+ }
+ if (i != 0) {
+ scan_err1(lc, "Expected a Job Level keyword, got: %s", lc->str);
+ }
+ break;
+ } /* end switch */
+ break;
+ } /* end if strcmp() */
+ } /* end for */
+ if (!found) {
+ scan_err1(lc, "%s not a valid Backup/verify keyword", lc->str);
}
} /* end while */
lc->options = options; /* reset original options */
Dmsg0(190, "Enter store_restore()\n");
((JOB *)(item->value))->JobType = item->code;
- while ((token = lex_get_token(lc)) != T_EOL) {
+ while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
int found;
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "Expected a Restore keyword, got: %s", lc->str);
- } else {
- found = FALSE;
- for (i=0; RestoreFields[i].name; i++) {
- Dmsg1(190, "Restore kw=%s\n", lc->str);
- if (strcasecmp(lc->str, RestoreFields[i].name) == 0) {
- found = TRUE;
- if (lex_get_token(lc) != T_EQUALS) {
- scan_err1(lc, "Expected an equals, got: %s", lc->str);
- }
- token = lex_get_token(lc);
- Dmsg1(190, "Restore value=%s\n", lc->str);
- switch (RestoreFields[i].token) {
- case 'C':
- /* Find Client Resource */
- if (pass == 2) {
- res = GetResWithName(R_CLIENT, lc->str);
- if (res == NULL) {
- scan_err1(lc, "Could not find specified Client Resource: %s",
- lc->str);
- }
- res_all.res_job.client = (CLIENT *)res;
- }
- break;
- case 'F':
- /* Find FileSet Resource */
- if (pass == 2) {
- res = GetResWithName(R_FILESET, lc->str);
- if (res == NULL) {
- scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
- lc->str);
- }
- res_all.res_job.fs = (FILESET *)res;
- }
- break;
- case 'J':
- /* JobId */
- if (token != T_NUMBER) {
- scan_err1(lc, "expected an integer number, got: %s", lc->str);
- }
- errno = 0;
- res_all.res_job.RestoreJobId = strtol(lc->str, NULL, 0);
- Dmsg1(190, "RestorJobId=%d\n", res_all.res_job.RestoreJobId);
- if (errno != 0) {
- scan_err1(lc, "expected an integer number, got: %s", lc->str);
- }
- break;
- case 'W':
- /* Where */
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "Expected a Restore root directory, got: %s", lc->str);
- }
- if (pass == 1) {
- res_all.res_job.RestoreWhere = bstrdup(lc->str);
- }
- break;
- case 'R':
- /* Replacement options */
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
+ if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
+ scan_err1(lc, "expected a name, got: %s", lc->str);
+ }
+ found = FALSE;
+ for (i=0; RestoreFields[i].name; i++) {
+ Dmsg1(190, "Restore kw=%s\n", lc->str);
+ if (strcasecmp(lc->str, RestoreFields[i].name) == 0) {
+ found = TRUE;
+ if (lex_get_token(lc, T_ALL) != T_EQUALS) {
+ scan_err1(lc, "Expected an equals, got: %s", lc->str);
+ }
+ token = lex_get_token(lc, T_ALL);
+ Dmsg1(190, "Restore value=%s\n", lc->str);
+ switch (RestoreFields[i].token) {
+ case 'C':
+ /* Find Client Resource */
+ if (pass == 2) {
+ res = GetResWithName(R_CLIENT, lc->str);
+ if (res == NULL) {
+ scan_err1(lc, "Could not find specified Client Resource: %s",
+ lc->str);
}
- /* Fix to scan Replacement options */
- for (i=0; ReplaceOptions[i].name; i++) {
- if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
- ((JOB *)(item->value))->RestoreOptions = ReplaceOptions[i].token;
- i = 0;
- break;
- }
+ res_all.res_job.client = (CLIENT *)res;
+ }
+ break;
+ case 'F':
+ /* Find FileSet Resource */
+ if (pass == 2) {
+ res = GetResWithName(R_FILESET, lc->str);
+ if (res == NULL) {
+ scan_err1(lc, "Could not find specified FileSet Resource: %s\n",
+ lc->str);
}
- if (i != 0) {
- scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
+ res_all.res_job.fs = (FILESET *)res;
+ }
+ break;
+ case 'J':
+ /* JobId */
+ if (token != T_NUMBER) {
+ scan_err1(lc, "expected an integer number, got: %s", lc->str);
+ }
+ errno = 0;
+ res_all.res_job.RestoreJobId = strtol(lc->str, NULL, 0);
+ Dmsg1(190, "RestorJobId=%d\n", res_all.res_job.RestoreJobId);
+ if (errno != 0) {
+ scan_err1(lc, "expected an integer number, got: %s", lc->str);
+ }
+ break;
+ case 'W':
+ /* Where */
+ if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
+ scan_err1(lc, "Expected a Restore root directory, got: %s", lc->str);
+ }
+ if (pass == 1) {
+ res_all.res_job.RestoreWhere = bstrdup(lc->str);
+ }
+ break;
+ case 'R':
+ /* Replacement options */
+ if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
+ scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
+ }
+ /* Fix to scan Replacement options */
+ for (i=0; ReplaceOptions[i].name; i++) {
+ if (strcasecmp(lc->str, ReplaceOptions[i].name) == 0) {
+ ((JOB *)(item->value))->RestoreOptions = ReplaceOptions[i].token;
+ i = 0;
+ break;
}
- break;
- } /* end switch */
- break;
- } /* end if strcmp() */
- } /* end for */
- if (!found) {
- scan_err1(lc, "%s not a valid Restore keyword", lc->str);
- }
+ }
+ if (i != 0) {
+ scan_err1(lc, "Expected a Restore replacement option, got: %s", lc->str);
+ }
+ break;
+ } /* end switch */
+ break;
+ } /* end if strcmp() */
+ } /* end for */
+ if (!found) {
+ scan_err1(lc, "%s not a valid Restore keyword", lc->str);
}
} /* end while */
lc->options = options; /* reset original options */
option[0] = 0; /* default option = none */
opts[0] = option[2] = 0; /* terminate options */
for (;;) {
- token = lex_get_token(lc); /* expect at least one option */
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "expected a FileSet option, got: %s", lc->str);
- }
+ token = lex_get_token(lc, T_NAME); /* expect at least one option */
if (keyword == FS_KW_VERIFY) { /* special case */
/* ***FIXME**** ensure these are in permitted set */
strcpy(option, "V"); /* indicate Verify */
if (lc->ch != ',') {
break; /* no, get out */
}
- token = lex_get_token(lc); /* yes, eat comma */
+ token = lex_get_token(lc, T_ALL); /* yes, eat comma */
}
return opts;
/* Get include options */
strcpy(inc_opts, "0"); /* set no options */
- while ((token=lex_get_token(lc)) != T_BOB) {
- if (token != T_STRING) {
- scan_err1(lc, "expected a FileSet option keyword, got: %s", lc->str);
- } else {
- keyword = FS_KW_NONE;
- for (i=0; FS_option_kw[i].name; i++) {
- if (strcasecmp(lc->str, FS_option_kw[i].name) == 0) {
- keyword = FS_option_kw[i].token;
- break;
- }
- }
- if (keyword == FS_KW_NONE) {
- scan_err1(lc, "Expected a FileSet keyword, got: %s", lc->str);
+ while ((token=lex_get_token(lc, T_ALL)) != T_BOB) {
+ keyword = FS_KW_NONE;
+ for (i=0; FS_option_kw[i].name; i++) {
+ if (strcasecmp(lc->str, FS_option_kw[i].name) == 0) {
+ keyword = FS_option_kw[i].token;
+ break;
}
}
+ if (keyword == FS_KW_NONE) {
+ scan_err1(lc, "Expected a FileSet keyword, got: %s", lc->str);
+ }
/* Option keyword should be following by = <option> */
- if ((token=lex_get_token(lc)) != T_EQUALS) {
+ if ((token=lex_get_token(lc, T_ALL)) != T_EQUALS) {
scan_err1(lc, "expected an = following keyword, got: %s", lc->str);
}
strcat(inc_opts, scan_fs_options(lc, keyword));
* a "0 " (zero) indicates no options,
* and fname is the file/directory name given
*/
- while ((token = lex_get_token(lc)) != T_EOB) {
+ while ((token = lex_get_token(lc, T_ALL)) != T_EOB) {
switch (token) {
case T_COMMA:
case T_EOL:
continue;
case T_IDENTIFIER:
- case T_STRING:
+ case T_UNQUOTED_STRING:
case T_QUOTED_STRING:
fname = (char *) malloc(lc->str_len + inc_opts_len + 1);
strcpy(fname, inc_opts);
}
}
} else { /* pass 2 */
- while (lex_get_token(lc) != T_EOB)
+ while (lex_get_token(lc, T_ALL) != T_EOB)
{}
}
scan_to_eol(lc);
/* scan for Job level "full", "incremental", ... */
for (found=TRUE; found; ) {
found = FALSE;
- token = lex_get_token(lc);
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
- }
+ token = lex_get_token(lc, T_NAME);
for (i=0; RunFields[i].name; i++) {
if (strcasecmp(lc->str, RunFields[i].name) == 0) {
found = TRUE;
- if (lex_get_token(lc) != T_EQUALS) {
+ if (lex_get_token(lc, T_ALL) != T_EQUALS) {
scan_err1(lc, "Expected an equals, got: %s", lc->str);
}
- token = lex_get_token(lc);
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "Expected a keyword name, got: %s", lc->str);
- }
+ token = lex_get_token(lc, T_NAME);
switch (RunFields[i].token) {
case 'L': /* level */
for (j=0; joblevels[j].level_name; j++) {
state = s_none;
set_defaults();
- for ( ; token != T_EOL; (token = lex_get_token(lc))) {
+ for ( ; token != T_EOL; (token = lex_get_token(lc, T_ALL))) {
int len, pm;
switch (token) {
case T_NUMBER:
scan_err0(lc, _("Day number out of range (1-31)"));
}
break;
- case T_STRING:
+ case T_NAME: /* this handles drop through from keyword */
+ case T_UNQUOTED_STRING:
if (strchr(lc->str, (int)'-')) {
state = s_range;
break;
case T_COMMA:
continue;
default:
- scan_err1(lc, _("Unexpected token: %s"), lc->str);
+ scan_err2(lc, _("Unexpected token: %d:%s"), token, lc->str);
break;
}
switch (state) {
makepath.c \
md5.c message.c mem_pool.c parse_conf.c \
queue.c rwlock.c save-cwd.c serial.c \
- signal.c smartall.c util.c watchdog.c workq.c
+ signal.c smartall.c tree.c util.c watchdog.c workq.c
# immortal.c filesys.c
makepath.o \
md5.o message.o mem_pool.o parse_conf.o \
queue.o rwlock.o save-cwd.o serial.o \
- signal.o smartall.o util.o watchdog.o workq.o
+ signal.o smartall.o tree.o util.o watchdog.o workq.o
# immortal.o filesys.o
{
int token;
Dmsg0(150, "start scan to eof\n");
- lc->expect = 0; /* clear expectations */
if (token != T_EOL) {
- while ((token = lex_get_token(lc)) != T_EOL) {
+ while ((token = lex_get_token(lc, T_ALL)) != T_EOL) {
}
}
Dmsg0(150, "done scan to eof\n");
lex_tok_to_str(int token)
{
switch(token) {
- case L_EOF: return "L_EOF";
- case L_EOL: return "L_EOL";
- case T_NONE: return "T_NONE";
- case T_NUMBER: return "T_NUMBER";
- case T_IPADDR: return "T_IPADDR";
- case T_IDENTIFIER: return "T_IDENTIFIER";
- case T_STRING: return "T_STRING";
- case T_QUOTED_STRING: return "T_QUOTED_STRING";
- case T_BOB: return "T_BOB";
- case T_EOB: return "T_EOB";
- case T_EQUALS: return "T_EQUALS";
- case T_ERROR: return "T_ERROR";
- case T_EOF: return "T_EOF";
- case T_COMMA: return "T_COMMA";
- case T_EOL: return "T_EOL";
- default: return "??????";
+ case L_EOF: return "L_EOF";
+ case L_EOL: return "L_EOL";
+ case T_NONE: return "T_NONE";
+ case T_NUMBER: return "T_NUMBER";
+ case T_IPADDR: return "T_IPADDR";
+ case T_IDENTIFIER: return "T_IDENTIFIER";
+ case T_UNQUOTED_STRING: return "T_UNQUOTED_STRING";
+ case T_QUOTED_STRING: return "T_QUOTED_STRING";
+ case T_BOB: return "T_BOB";
+ case T_EOB: return "T_EOB";
+ case T_EQUALS: return "T_EQUALS";
+ case T_ERROR: return "T_ERROR";
+ case T_EOF: return "T_EOF";
+ case T_COMMA: return "T_COMMA";
+ case T_EOL: return "T_EOL";
+ default: return "??????";
}
}
*
*/
int
-lex_get_token(LEX *lf)
+lex_get_token(LEX *lf, int expect)
{
int ch;
int token = T_NONE;
if (ch == '\n' || ch == L_EOL || ch == '=' || ch == '}' || ch == '{' ||
ch == ';' || ch == ',' || ch == '#' || (ISSPACE(ch)) ) {
lex_unget_char(lf);
- token = T_STRING;
+ token = T_UNQUOTED_STRING;
lf->state = lex_none;
break;
}
* expectations (e.g. 32 bit integer). If so, we do type checking
* and possible additional scanning (e.g. for range).
*/
- switch (lf->expect) {
+ switch (expect) {
case T_PINT32:
lf->pint32_val = scan_pint(lf, lf->str);
lf->pint32_val2 = lf->pint32_val;
break;
case T_NAME:
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
+ if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
scan_err1(lf, "expected a name: %s", lf->str);
} else if (lf->str_len > MAX_RES_NAME_LENGTH) {
scan_err3(lf, "name %s length %d too long, max is %d\n", lf->str,
token = T_NAME;
break;
+ case T_STRING:
+ if (token != T_IDENTIFIER && token != T_UNQUOTED_STRING && token != T_QUOTED_STRING) {
+ scan_err1(lf, "expected a name: %s", lf->str);
+ }
+ token = T_STRING;
+ break;
+
+
default:
break; /* no expectation given */
}
#define T_NUMBER 102
#define T_IPADDR 103
#define T_IDENTIFIER 104
-#define T_STRING 105
+#define T_UNQUOTED_STRING 105
#define T_QUOTED_STRING 106
#define T_BOB 108 /* begin block */
#define T_EOB 109 /* end of block */
#define T_PINT32_RANGE 115 /* positive integer range */
#define T_INT32 116 /* integer */
#define T_INT64 117 /* 64 bit integer */
-#define T_NAME 118 /* resource name */
+#define T_NAME 118 /* name max 128 chars */
+#define T_STRING 119 /* string */
+
+#define T_ALL 0 /* no expectations */
/* Lexical state */
enum lex_state {
typedef struct s_lex_context {
struct s_lex_context *next; /* pointer to next lexical context */
int options; /* scan options */
- int expect; /* types expected */
char *fname; /* filename */
FILE *fd; /* file descriptor */
char line[MAXSTRING]; /* input line */
#include "fnmatch.h"
#endif
#include "md5.h"
+#include "tree.h"
#include "protos.h"
dest[0] = 0;
/* Pick up comma separated list of destinations */
for ( ;; ) {
- token = lex_get_token(lc); /* scan destination */
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "expected a message destination, got: %s", lc->str);
- }
+ token = lex_get_token(lc, T_NAME); /* scan destination */
dest = (char *) check_pool_memory_size(dest, dest_len + lc->str_len + 2);
if (dest[0] != 0) {
strcat(dest, " "); /* separate multiple destinations with space */
strcat(dest, lc->str);
dest_len += lc->str_len;
Dmsg2(100, "store_msgs newdest=%s: dest=%s:\n", lc->str, dest);
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_ALL);
if (token == T_COMMA) {
continue; /* get another destination */
}
case MD_APPEND: /* append */
dest = get_pool_memory(PM_MESSAGE);
/* Pick up a single destination */
- token = lex_get_token(lc); /* scan destination */
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "expected a message destination, got: %s", lc->str);
- }
+ token = lex_get_token(lc, T_NAME); /* scan destination */
dest = check_pool_memory_size(dest, dest_len + lc->str_len + 2);
strcpy(dest, lc->str);
dest_len = lc->str_len;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_ALL);
Dmsg1(200, "store_msgs dest=%s:\n", dest);
if (token != T_EQUALS) {
scan_err1(lc, "expected an =, got: %s", lc->str);
char *str;
for (quit=0; !quit;) {
- token = lex_get_token(lc); /* expect at least one type */
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "expected a message type, got: %s", lc->str);
- }
+ token = lex_get_token(lc, T_NAME); /* expect at least one type */
found = FALSE;
if (lc->str[0] == '!') {
is_not = TRUE;
break;
}
Dmsg0(200, "call lex_get_token() to eat comma\n");
- token = lex_get_token(lc); /* eat comma */
+ token = lex_get_token(lc, T_ALL); /* eat comma */
}
Dmsg0(200, "Done scan_types()\n");
}
{
int token;
- lc->expect = T_NAME;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_NAME);
/* Store the name both pass 1 and pass 2 */
*(item->value) = bstrdup(lc->str);
scan_to_eol(lc);
{
int token;
- lc->expect = T_NAME;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_NAME);
/* Store the name */
if (pass == 1) {
*(item->value) = bstrdup(lc->str);
{
int token;
- token = lex_get_token(lc);
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "expected an identifier or string, got: %s", lc->str);
- } else {
- if (pass == 1) {
- *(item->value) = bstrdup(lc->str);
- }
+ token = lex_get_token(lc, T_STRING);
+ if (pass == 1) {
+ *(item->value) = bstrdup(lc->str);
}
scan_to_eol(lc);
set_bit(index, res_all.hdr.item_present);
{
int token;
- token = lex_get_token(lc);
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "expected an identifier or string, got: %s", lc->str);
- } else {
- if (pass == 1) {
- do_shell_expansion(lc->str);
- *(item->value) = bstrdup(lc->str);
- }
+ token = lex_get_token(lc, T_STRING);
+ if (pass == 1) {
+ do_shell_expansion(lc->str);
+ *(item->value) = bstrdup(lc->str);
}
scan_to_eol(lc);
set_bit(index, res_all.hdr.item_present);
char sig[100];
- token = lex_get_token(lc);
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "expected an identifier or string, got: %s\n", lc->str);
- } else {
- if (pass == 1) {
- MD5Init(&md5c);
- MD5Update(&md5c, (unsigned char *) (lc->str), lc->str_len);
- MD5Final(signature, &md5c);
- for (i = j = 0; i < sizeof(signature); i++) {
- sprintf(&sig[j], "%02x", signature[i]);
- j += 2;
- }
- *(item->value) = bstrdup(sig);
+ token = lex_get_token(lc, T_STRING);
+ if (pass == 1) {
+ MD5Init(&md5c);
+ MD5Update(&md5c, (unsigned char *) (lc->str), lc->str_len);
+ MD5Final(signature, &md5c);
+ for (i = j = 0; i < sizeof(signature); i++) {
+ sprintf(&sig[j], "%02x", signature[i]);
+ j += 2;
}
+ *(item->value) = bstrdup(sig);
}
scan_to_eol(lc);
set_bit(index, res_all.hdr.item_present);
int token;
RES *res;
- token = lex_get_token(lc);
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "expected a Resource name, got: %s", lc->str);
- }
+ token = lex_get_token(lc, T_NAME);
if (pass == 2) {
res = GetResWithName(item->code, lc->str);
if (res == NULL) {
{
int token;
- token = lex_get_token(lc);
- if (token != T_NUMBER || !is_a_number(lc->str)) {
- scan_err1(lc, "expected an integer number, got: %s", lc->str);
- } else {
- errno = 0;
- *(int *)(item->value) = (int)strtod(lc->str, NULL);
- if (errno != 0) {
- scan_err1(lc, "expected an integer number, got: %s", lc->str);
- }
- }
+ token = lex_get_token(lc, T_INT32);
+ *(int *)(item->value) = lc->int32_val;
scan_to_eol(lc);
set_bit(index, res_all.hdr.item_present);
}
{
int token;
- lc->expect = T_PINT32;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_PINT32);
*(int *)(item->value) = lc->pint32_val;
scan_to_eol(lc);
set_bit(index, res_all.hdr.item_present);
{
int token;
- lc->expect = T_INT64;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_INT64);
*(int64_t *)(item->value) = lc->int64_val;
scan_to_eol(lc);
set_bit(index, res_all.hdr.item_present);
#endif
Dmsg0(400, "Enter store_size\n");
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_ALL);
errno = 0;
switch (token) {
case T_NUMBER:
*(uint64_t *)(item->value) = value;
break;
case T_IDENTIFIER:
- case T_STRING:
+ case T_UNQUOTED_STRING:
/* Look for modifier */
ch = lc->str[lc->str_len - 1];
i = 0;
int token;
btime_t value;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_ALL);
errno = 0;
switch (token) {
case T_NUMBER:
*(btime_t *)(item->value) = value;
break;
case T_IDENTIFIER:
- case T_STRING:
+ case T_UNQUOTED_STRING:
if (!string_to_btime(lc->str, &value)) {
scan_err1(lc, "expected a time period, got: %s", lc->str);
}
{
int token;
- token = lex_get_token(lc);
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "expected an identifier or string, got: %s", lc->str);
- } else if (strcasecmp(lc->str, "yes") == 0) {
+ token = lex_get_token(lc, T_NAME);
+ if (strcasecmp(lc->str, "yes") == 0) {
*(int *)(item->value) |= item->code;
} else if (strcasecmp(lc->str, "no") == 0) {
*(int *)(item->value) &= ~(item->code);
for (pass=1; pass <= 2; pass++) {
Dmsg1(200, "parse_config pass %d\n", pass);
lc = lex_open_file(lc, cf);
- while ((token=lex_get_token(lc)) != T_EOF) {
+ while ((token=lex_get_token(lc, T_ALL)) != T_EOF) {
Dmsg1(150, "parse got token=%s\n", lex_tok_to_str(token));
switch (state) {
case p_none:
}
for (i=0; items[i].name; i++) {
if (strcasecmp(items[i].name, lc->str) == 0) {
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_ALL);
Dmsg1 (150, "in T_IDENT got token=%s\n", lex_tok_to_str(token));
if (token != T_EQUALS) {
scan_err1(lc, "expected an equals, got: %s", lc->str);
int lex_get_char (LEX *lf);
void lex_unget_char (LEX *lf);
char * lex_tok_to_str (int token);
-int lex_get_token (LEX *lf);
+int lex_get_token (LEX *lf, int expect);
/* makepath.c */
int make_path(
static char btpath[400];
pid_t pid;
- fprintf(stderr, "Kaboom! Got signal %d. Attempting traceback.\n", sig);
+ fprintf(stderr, "Kaboom! %s got signal %d. Attempting traceback.\n",
+ my_name, sig);
if (strlen(exepath) + 12 > (int)sizeof(btpath)) {
strcpy(btpath, "btraceback");
} else {
--- /dev/null
+/*
+ * Directory tree build/traverse routines
+ *
+ * Kern Sibbald, June MMII
+ *
+*/
+/*
+ Copyright (C) 2002 Kern Sibbald and John Walker
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ */
+
+
+#include "bacula.h"
+#include "findlib/find.h"
+#include "findlib/system.h"
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1000
+#endif
+
+TREE_NODE *new_tree_node(int type)
+{
+ TREE_NODE *node;
+ int size;
+
+ if (type == TN_ROOT) {
+ size = sizeof(TREE_ROOT);
+ } else {
+ size = sizeof(TREE_NODE);
+ }
+ node = (TREE_NODE *)malloc(size);
+ memset(node, 0, size);
+ node->type = type;
+ return node;
+}
+
+TREE_NODE *insert_tree_node(char *path, TREE_NODE *node, TREE_ROOT *root, TREE_NODE *parent)
+{
+ char *p, *fname;
+
+ Dmsg1(100, "insert_tree_node: %s\n", path);
+ p = strrchr(path, '/');
+ if (!p) {
+ Dmsg1(000, "No / found: %s\n", path);
+ exit(1);
+ }
+ *p = 0;
+ fname = p + 1;
+ if (!parent) {
+ parent = make_tree_path(path, root);
+ }
+ *p = '/';
+ append_tree_node(fname, node, root, parent);
+ Dmsg1(100, "insert_tree_node: parent=%s\n", parent->fname);
+ return parent;
+}
+
+TREE_NODE *make_tree_path(char *path, TREE_ROOT *root)
+{
+ TREE_NODE *parent, *sibling;
+ char *fname, *p;
+
+ Dmsg1(100, "make_tree_path: %s\n", path);
+ if (!*path) {
+ Dmsg0(100, "make_tree_path: parent=*root*\n");
+ return (TREE_NODE *)root;
+ }
+ p = strrchr(path, '/');
+ if (!p) {
+ Dmsg1(000, "No / found: %s\n", path);
+ exit(1);
+ }
+ *p = 0;
+ fname = p + 1;
+ /* Find parent */
+ parent = make_tree_path(path, root);
+ *p = '/';
+ /* Is it already a sibling? */
+ for (sibling=parent->sibling; sibling; sibling=sibling->sibling) {
+ if (strcmp(sibling->fname, fname) == 0) {
+ Dmsg1(100, "make_tree_path: found parent=%s\n", parent->fname);
+ return parent;
+ }
+ }
+ /* Must add */
+ sibling = new_tree_node(TN_NEWDIR);
+ append_tree_node(fname, sibling, root, parent);
+ parent = sibling;
+ Dmsg1(100, "make_tree_path: add parent=%s\n", parent->fname);
+ return parent;
+}
+
+/*
+ * Append sibling to parent's child chain
+ */
+void append_tree_node(char *fname, TREE_NODE *node, TREE_ROOT *root, TREE_NODE *parent)
+{
+ TREE_NODE *child;
+
+ Dmsg1(100, "append_tree_node: %s\n", fname);
+ node->fname = bstrdup(fname);
+ node->parent = parent;
+ if (!parent->child) {
+ parent->child = node;
+ goto item_link;
+ }
+ for (child=parent->child; child->sibling; child=child->sibling)
+ { }
+ child->sibling = node;
+
+item_link:
+ if (!root->first) {
+ root->first = node;
+ root->last = node;
+ } else {
+ root->last->next = node;
+ root->last = node;
+ }
+ return;
+}
+
+TREE_NODE *first_tree_node(TREE_ROOT *root)
+{
+ return root->first;
+}
+
+TREE_NODE *next_tree_node(TREE_NODE *node)
+{
+ return node->next;
+}
+
+
+void print_tree(char *path, TREE_NODE *tree)
+{
+ char buf[MAXPATHLEN];
+ char *termchr;
+
+ if (!tree) {
+ return;
+ }
+ switch (tree->type) {
+ case TN_DIR:
+ case TN_NEWDIR:
+ termchr = "/";
+ break;
+ case TN_ROOT:
+ case TN_FILE:
+ default:
+ termchr = "";
+ break;
+ }
+ Dmsg3(-1, "%s/%s%s\n", path, tree->fname, termchr);
+ switch (tree->type) {
+ case TN_FILE:
+ break;
+ case TN_DIR:
+ sprintf(buf, "%s/%s", path, tree->fname);
+ print_tree(buf, tree->child);
+ break;
+ case TN_ROOT:
+ print_tree(path, tree->child);
+ break;
+ case TN_NEWDIR:
+ sprintf(buf, "%s/%s", path, tree->fname);
+ print_tree(buf, tree->child);
+ break;
+ default:
+ Dmsg1(000, "Unknown node type %d\n", tree->type);
+ }
+ print_tree(path, tree->sibling);
+ return;
+}
+
+void free_tree(TREE_NODE *node)
+{
+ if (!node) {
+ return;
+ }
+ switch (node->type) {
+ case TN_FILE:
+ break;
+ case TN_DIR:
+ case TN_ROOT:
+ case TN_NEWDIR:
+ free_tree(node->child);
+ break;
+ default:
+ Dmsg1(000, "Unknown node type %d\n", node->type);
+ break;
+ }
+ free_tree(node->sibling);
+ free(node->fname);
+ free(node);
+ return;
+}
+
+int tree_getpath(TREE_NODE *node, char *buf, int buf_size)
+{
+ if (!node) {
+ buf[0] = 0;
+ return 1;
+ }
+ tree_getpath(node->parent, buf, buf_size);
+ strcat(buf, node->fname);
+ if (node->type != TN_FILE) {
+ strcat(buf, "/");
+ }
+ return 1;
+}
+
+/*
+ * Change to specified directory
+ */
+TREE_NODE *tree_cwd(char *path, TREE_ROOT *root, TREE_NODE *node)
+{
+ if (strcmp(path, ".") == 0) {
+ return node;
+ }
+ if (strcmp(path, "..") == 0) {
+ if (node->parent) {
+ return node->parent;
+ } else {
+ return node;
+ }
+ }
+ if (path[0] == '/') {
+ Dmsg0(100, "Doing absolute lookup.\n");
+ return tree_relcwd(path+1, root, (TREE_NODE *)root);
+ }
+ Dmsg0(100, "Doing relative lookup.\n");
+ return tree_relcwd(path, root, node);
+}
+
+
+TREE_NODE *tree_relcwd(char *path, TREE_ROOT *root, TREE_NODE *node)
+{
+ char *p;
+ int len;
+ TREE_NODE *cd;
+
+ if (*path == 0) {
+ return node;
+ }
+ p = strchr(path, '/');
+ if (p) {
+ len = p - path;
+ }
+ for (cd=node->child; cd; cd=cd->sibling) {
+ if (strncmp(cd->fname, path, len) == 0) {
+ Dmsg1(100, "tree_relcwd: found cd=%s\n", cd->fname);
+ break;
+ }
+ }
+ if (!cd || cd->type == TN_FILE) {
+ Dmsg1(100, "tree_relcwd: failed %s is a file.\n", cd->fname);
+ return NULL;
+ }
+ if (!p) {
+ Dmsg0(100, "tree_relcwd: no more to lookup. found.\n");
+ return cd;
+ }
+ Dmsg2(100, "recurse tree_relcwd with path=%s, cd=%s\n", p+1, cd->fname);
+ return tree_relcwd(p+1, root, cd);
+}
+
+
+
+#ifdef BUILD_TEST_PROGRAM
+
+void FillDirectoryTree(char *path, TREE_ROOT *root, TREE_NODE *parent);
+
+static uint32_t FileIndex = 0;
+/*
+ * Simple test program for tree routines
+ */
+int main(int argc, char *argv[])
+{
+ TREE_ROOT *root;
+ TREE_NODE *node;
+ char buf[MAXPATHLEN];
+
+ root = (TREE_ROOT *)new_tree_node(TN_ROOT);
+ root->fname = bstrdup("");
+
+ FillDirectoryTree("/home/kern/bacula/k", root, NULL);
+
+ for (node = first_tree_node(root); node; node=next_tree_node(node)) {
+ tree_getpath(node, buf, sizeof(buf));
+ Dmsg2(100, "%d: %s\n", node->FileIndex, buf);
+ }
+
+ node = (TREE_NODE *)root;
+ Dmsg0(000, "doing cd /home/kern/bacula/k/techlogs\n");
+ node = tree_cwd("/home/kern/bacula/k/techlogs", root, node);
+ if (node) {
+ tree_getpath(node, buf, sizeof(buf));
+ Dmsg2(100, "findex=%d: cwd=%s\n", node->FileIndex, buf);
+ }
+
+ Dmsg0(000, "doing cd /home/kern/bacula/k/src/testprogs\n");
+ node = tree_cwd("/home/kern/bacula/k/src/testprogs", root, node);
+ if (node) {
+ tree_getpath(node, buf, sizeof(buf));
+ Dmsg2(100, "findex=%d: cwd=%s\n", node->FileIndex, buf);
+ } else {
+ Dmsg0(100, "testprogs not found.\n");
+ }
+
+ free_tree((TREE_NODE *)root);
+
+ return 0;
+}
+
+void FillDirectoryTree(char *path, TREE_ROOT *root, TREE_NODE *parent)
+{
+ TREE_NODE *newparent = NULL;
+ TREE_NODE *node;
+ struct stat statbuf;
+ DIR *dp;
+ struct dirent *dir;
+ char pathbuf[MAXPATHLEN];
+ char file[MAXPATHLEN];
+ int type;
+ int i;
+
+ Dmsg1(100, "FillDirectoryTree: %s\n", path);
+ dp = opendir(path);
+ if (!dp) {
+ return;
+ }
+ while ((dir = readdir(dp))) {
+ if (strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0) {
+ continue;
+ }
+ strcpy(file, dir->d_name);
+ snprintf(pathbuf, MAXPATHLEN-1, "%s/%s", path, file);
+ if (lstat(pathbuf, &statbuf) < 0) {
+ printf("lstat() failed. ERR=%s\n", strerror(errno));
+ continue;
+ }
+// printf("got file=%s, pathbuf=%s\n", file, pathbuf);
+ type = TN_FILE;
+ if (S_ISLNK(statbuf.st_mode))
+ type = TN_FILE; /* link */
+ else if (S_ISREG(statbuf.st_mode))
+ type = TN_FILE;
+ else if (S_ISDIR(statbuf.st_mode)) {
+ type = TN_DIR;
+ } else if (S_ISCHR(statbuf.st_mode))
+ type = TN_FILE; /* char dev */
+ else if (S_ISBLK(statbuf.st_mode))
+ type = TN_FILE; /* block dev */
+ else if (S_ISFIFO(statbuf.st_mode))
+ type = TN_FILE; /* fifo */
+ else if (S_ISSOCK(statbuf.st_mode))
+ type = TN_FILE; /* sock */
+ else {
+ type = TN_FILE;
+ printf("Unknown file type: 0x%x\n", statbuf.st_mode);
+ }
+
+ Dmsg2(100, "Doing: %d %s\n", type, pathbuf);
+ node = new_tree_node(type);
+ node->FileIndex = ++FileIndex;
+ parent = insert_tree_node(pathbuf, node, root, parent);
+ if (S_ISDIR(statbuf.st_mode) && !S_ISLNK(statbuf.st_mode)) {
+ Dmsg2(100, "calling fill. pathbuf=%s, file=%s\n", pathbuf, file);
+ FillDirectoryTree(pathbuf, root, node);
+ }
+ }
+ closedir(dp);
+}
+#endif
--- /dev/null
+/*
+ * Directory tree build/traverse routines
+ *
+ * Kern Sibbald, June MMII
+ *
+*/
+/*
+ Copyright (C) 2002 Kern Sibbald and John Walker
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA.
+
+ */
+
+struct s_tree_node {
+ char *fname; /* file name */
+ uint32_t FileIndex; /* file index */
+ int type; /* node type */
+ struct s_tree_node *parent;
+ struct s_tree_node *sibling;
+ struct s_tree_node *child;
+ struct s_tree_node *next; /* next hash of FileIndex */
+};
+typedef struct s_tree_node TREE_NODE;
+
+struct s_tree_root {
+ char *fname; /* file name */
+ uint32_t FileIndex; /* file index */
+ int type; /* node type */
+ struct s_tree_node *parent;
+ struct s_tree_node *sibling;
+ struct s_tree_node *child;
+ struct s_tree_node *next; /* next hash of FileIndex */
+
+ /* The above ^^^ must be identical to a TREE_NODE structure */
+ struct s_tree_node *first; /* first entry in the tree */
+ struct s_tree_node *last; /* last entry in tree */
+};
+typedef struct s_tree_root TREE_ROOT;
+
+/* type values */
+#define TN_ROOT 1 /* root node */
+#define TN_NEWDIR 2 /* created directory to fill path */
+#define TN_DIR 3 /* directory entry */
+#define TN_FILE 4 /* file entry */
+
+TREE_NODE *new_tree_node(int type);
+TREE_NODE *insert_tree_node(char *path, TREE_NODE *node, TREE_ROOT *root, TREE_NODE *parent);
+TREE_NODE *make_tree_path(char *path, TREE_ROOT *root);
+TREE_NODE *first_tree_node(TREE_ROOT *root);
+TREE_NODE *next_tree_node(TREE_NODE *node);
+TREE_NODE *tree_cwd(char *path, TREE_ROOT *root, TREE_NODE *node);
+TREE_NODE *tree_relcwd(char *path, TREE_ROOT *root, TREE_NODE *node);
+void append_tree_node(char *fname, TREE_NODE *node, TREE_ROOT *root, TREE_NODE *parent);
+void print_tree(char *path, TREE_NODE *root);
+void free_tree(TREE_NODE *node);
+int tree_getpath(TREE_NODE *node, char *buf, int buf_size);
+
int found;
} BSR_SESSID;
+typedef struct s_bsr_sesstime {
+ struct s_bsr_sesstime *next;
+ uint32_t sesstime;
+ int found;
+} BSR_SESSTIME;
+
typedef struct s_bsr_volfile {
struct s_bsr_volfile *next;
uint32_t sfile; /* start file */
int found;
} BSR_VOLFILE;
-
-typedef struct s_bsr_sesstime {
- struct s_bsr_sesstime *next;
- uint32_t sesstime;
- int found;
-} BSR_SESSTIME;
-
typedef struct s_bsr_findex {
struct s_bsr_findex *next;
int32_t findex; /* start file index */
struct s_bsr *next; /* pointer to next one */
int done; /* set when everything found */
char *VolumeName;
- BSR_CLIENT *client;
- BSR_JOB *job;
- BSR_SESSID *sessid;
+ BSR_VOLFILE *volfile;
BSR_SESSTIME *sesstime;
- BSR_FINDEX *FileIndex;
+ BSR_SESSID *sessid;
BSR_JOBID *JobId;
+ BSR_JOB *job;
+ BSR_CLIENT *client;
+ BSR_FINDEX *FileIndex;
BSR_JOBTYPE *JobType;
BSR_JOBLEVEL *JobLevel;
- BSR_VOLFILE *volfile;
FF_PKT *ff; /* include/exclude */
} BSR;
/* Forward references */
static int match_sesstime(BSR_SESSTIME *sesstime, DEV_RECORD *rec);
static int match_sessid(BSR_SESSID *sessid, DEV_RECORD *rec);
-static int match_client(BSR_CLIENT *client, SESSION_LABEL *sesrec);
-static int match_job(BSR_JOB *job, SESSION_LABEL *sesrec);
-static int match_job_type(BSR_JOBTYPE *job_type, SESSION_LABEL *sesrec);
-static int match_job_level(BSR_JOBLEVEL *job_level, SESSION_LABEL *sesrec);
-static int match_jobid(BSR_JOBID *jobid, SESSION_LABEL *sesrec);
-static int match_file_index(BSR_FINDEX *findex, DEV_RECORD *rec);
-static int match_one_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sesrec);
+static int match_client(BSR_CLIENT *client, SESSION_LABEL *sessrec);
+static int match_job(BSR_JOB *job, SESSION_LABEL *sessrec);
+static int match_job_type(BSR_JOBTYPE *job_type, SESSION_LABEL *sessrec);
+static int match_job_level(BSR_JOBLEVEL *job_level, SESSION_LABEL *sessrec);
+static int match_jobid(BSR_JOBID *jobid, SESSION_LABEL *sessrec);
+static int match_findex(BSR_FINDEX *findex, DEV_RECORD *rec);
+static int match_volfile(BSR_VOLFILE *volfile, DEV_RECORD *rec);
+static int match_one_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec);
/*********************************************************************
*
* Match Bootstrap records
*
*/
-int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sesrec)
+int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec)
{
if (!bsr) {
return 0;
}
- if (match_one_bsr(bsr, rec, volrec, sesrec)) {
+ if (match_one_bsr(bsr, rec, volrec, sessrec)) {
return 1;
}
- return match_bsr(bsr->next, rec, volrec, sesrec);
+ return match_bsr(bsr->next, rec, volrec, sessrec);
}
-static int match_one_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sesrec)
+static int match_one_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec)
{
if (strcmp(bsr->VolumeName, volrec->VolName) != 0) {
return 0;
}
- if (!match_client(bsr->client, sesrec)) {
+ if (!match_volfile(bsr->volfile, rec)) {
+ return 0;
+ }
+ if (!match_sesstime(bsr->sesstime, rec)) {
return 0;
}
if (!match_sessid(bsr->sessid, rec)) {
return 0;
}
- if (!match_sesstime(bsr->sesstime, rec)) {
+ if (!match_jobid(bsr->JobId, sessrec)) {
return 0;
}
- if (!match_job(bsr->job, sesrec)) {
+ if (!match_job(bsr->job, sessrec)) {
return 0;
}
- if (!match_file_index(bsr->FileIndex, rec)) {
+ if (!match_client(bsr->client, sessrec)) {
return 0;
}
- if (!match_job_type(bsr->JobType, sesrec)) {
+ if (!match_findex(bsr->FileIndex, rec)) {
return 0;
}
- if (!match_job_level(bsr->JobLevel, sesrec)) {
+ if (!match_job_type(bsr->JobType, sessrec)) {
return 0;
}
- if (!match_jobid(bsr->JobId, sesrec)) {
+ if (!match_job_level(bsr->JobLevel, sessrec)) {
return 0;
}
return 1;
}
-static int match_client(BSR_CLIENT *client, SESSION_LABEL *sesrec)
+static int match_client(BSR_CLIENT *client, SESSION_LABEL *sessrec)
{
if (!client) {
return 1; /* no specification matches all */
}
- if (strcmp(client->ClientName, sesrec->ClientName) == 0) {
+ if (strcmp(client->ClientName, sessrec->ClientName) == 0) {
return 1;
}
if (client->next) {
- return match_client(client->next, sesrec);
+ return match_client(client->next, sessrec);
}
return 0;
}
-static int match_job(BSR_JOB *job, SESSION_LABEL *sesrec)
+static int match_job(BSR_JOB *job, SESSION_LABEL *sessrec)
{
if (!job) {
return 1; /* no specification matches all */
}
- if (strcmp(job->Job, sesrec->Job) == 0) {
+ if (strcmp(job->Job, sessrec->Job) == 0) {
job->found++;
return 1;
}
if (job->next) {
- return match_job(job->next, sesrec);
+ return match_job(job->next, sessrec);
}
return 0;
}
-static int match_job_type(BSR_JOBTYPE *job_type, SESSION_LABEL *sesrec)
+static int match_job_type(BSR_JOBTYPE *job_type, SESSION_LABEL *sessrec)
{
if (!job_type) {
return 1; /* no specification matches all */
}
- if (job_type->JobType == sesrec->JobType) {
+ if (job_type->JobType == sessrec->JobType) {
return 1;
}
if (job_type->next) {
- return match_job_type(job_type->next, sesrec);
+ return match_job_type(job_type->next, sessrec);
}
return 0;
}
-static int match_job_level(BSR_JOBLEVEL *job_level, SESSION_LABEL *sesrec)
+static int match_job_level(BSR_JOBLEVEL *job_level, SESSION_LABEL *sessrec)
{
if (!job_level) {
return 1; /* no specification matches all */
}
- if (job_level->JobLevel == sesrec->JobLevel) {
+ if (job_level->JobLevel == sessrec->JobLevel) {
return 1;
}
if (job_level->next) {
- return match_job_level(job_level->next, sesrec);
+ return match_job_level(job_level->next, sessrec);
}
return 0;
}
-static int match_jobid(BSR_JOBID *jobid, SESSION_LABEL *sesrec)
+static int match_jobid(BSR_JOBID *jobid, SESSION_LABEL *sessrec)
{
if (!jobid) {
return 1; /* no specification matches all */
}
- if (jobid->JobId == sesrec->JobId) {
+ if (jobid->JobId >= sessrec->JobId && jobid->JobId2 <= sessrec->JobId) {
jobid->found++;
return 1;
}
if (jobid->next) {
- return match_jobid(jobid->next, sesrec);
+ return match_jobid(jobid->next, sessrec);
+ }
+ return 0;
+}
+
+
+static int match_volfile(BSR_VOLFILE *volfile, DEV_RECORD *rec)
+{
+ if (!volfile) {
+ return 1; /* no specification matches all */
+ }
+ if (volfile->sfile >= rec->File && volfile->efile <= rec->File) {
+ volfile->found++;
+ return 1;
+ }
+ if (volfile->next) {
+ return match_volfile(volfile->next, rec);
}
return 0;
}
-static int match_file_index(BSR_FINDEX *findex, DEV_RECORD *rec)
+static int match_findex(BSR_FINDEX *findex, DEV_RECORD *rec)
{
if (!findex) {
return 1; /* no specification matches all */
return 1;
}
if (findex->next) {
- return match_file_index(findex->next, rec);
+ return match_findex(findex->next, rec);
}
return 0;
}
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA.
*/
static BSR *store_jobid(LEX *lc, BSR *bsr);
static BSR *store_jobtype(LEX *lc, BSR *bsr);
static BSR *store_joblevel(LEX *lc, BSR *bsr);
-static BSR *store_file_index(LEX *lc, BSR *bsr);
+static BSR *store_findex(LEX *lc, BSR *bsr);
static BSR *store_sessid(LEX *lc, BSR *bsr);
static BSR *store_volfile(LEX *lc, BSR *bsr);
static BSR *store_sesstime(LEX *lc, BSR *bsr);
{"client", store_client},
{"job", store_job},
{"jobid", store_jobid},
- {"fileindex", store_file_index},
+ {"fileindex", store_findex},
{"jobtype", store_jobtype},
{"joblevel", store_joblevel},
{"volsessionid", store_sessid},
Dmsg0(200, "Enter parse_bsf()\n");
lc = lex_open_file(lc, cf);
- while ((token=lex_get_token(lc)) != T_EOF) {
+ while ((token=lex_get_token(lc, T_ALL)) != T_EOF) {
Dmsg1(150, "parse got token=%s\n", lex_tok_to_str(token));
if (token == T_EOL) {
continue;
}
- if (token != T_IDENTIFIER) {
- scan_err1(lc, "Expected a keyword identifier, got: %s", lc->str);
- }
for (i=0; items[i].name; i++) {
if (strcasecmp(items[i].name, lc->str) == 0) {
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_ALL);
Dmsg1 (150, "in T_IDENT got token=%s\n", lex_tok_to_str(token));
if (token != T_EQUALS) {
scan_err1(lc, "expected an equals, got: %s", lc->str);
{
int token;
- token = lex_get_token(lc);
- if (token != T_IDENTIFIER && token != T_STRING && token != T_QUOTED_STRING) {
- scan_err1(lc, "expected an identifier or string, got: %s", lc->str);
- } else if (lc->str_len > MAX_RES_NAME_LENGTH) {
- scan_err3(lc, "name %s length %d too long, max is %d\n", lc->str,
- lc->str_len, MAX_RES_NAME_LENGTH);
- } else {
- if (bsr->VolumeName) {
- bsr->next = new_bsr();
- bsr = bsr->next;
- }
- bsr->VolumeName = bstrdup(lc->str);
+ token = lex_get_token(lc, T_NAME);
+ if (bsr->VolumeName) {
+ bsr->next = new_bsr();
+ bsr = bsr->next;
}
+ bsr->VolumeName = bstrdup(lc->str);
scan_to_eol(lc);
return bsr;
}
BSR_CLIENT *client;
for (;;) {
- lc->expect = T_NAME;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_NAME);
client = (BSR_CLIENT *)malloc(sizeof(BSR_CLIENT));
memset(client, 0, sizeof(BSR_CLIENT));
client->ClientName = bstrdup(lc->str);
bsr->client = client;
} else {
BSR_CLIENT *bc = bsr->client;
- for ( ;; ) {
- if (bc->next) {
- bc = bc->next;
- } else {
- bc->next = client;
- break;
- }
- }
+ for ( ;bc->next; bc=bc->next)
+ { }
+ bc->next = client;
}
- lc->expect = 0;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
break;
}
}
-// scan_to_eol(lc);
return bsr;
}
int token;
BSR_JOB *job;
- lc->expect = T_NAME;
- token = lex_get_token(lc);
- job = (BSR_JOB *)malloc(sizeof(BSR_JOB));
- memset(job, 0, sizeof(BSR_JOB));
- job->Job = bstrdup(lc->str);
- /* Add it to the end of the client chain */
- if (!bsr->job) {
- bsr->job = job;
- } else {
- /* Add to end of chain */
- BSR_JOB *bc = bsr->job;
- for ( ;bc->next; bc=bc->next)
- { }
- bc->next = job;
+ for (;;) {
+ token = lex_get_token(lc, T_NAME);
+ job = (BSR_JOB *)malloc(sizeof(BSR_JOB));
+ memset(job, 0, sizeof(BSR_JOB));
+ job->Job = bstrdup(lc->str);
+ /* Add it to the end of the client chain */
+ if (!bsr->job) {
+ bsr->job = job;
+ } else {
+ /* Add to end of chain */
+ BSR_JOB *bc = bsr->job;
+ for ( ;bc->next; bc=bc->next)
+ { }
+ bc->next = job;
+ }
+ token = lex_get_token(lc, T_ALL);
+ if (token != T_COMMA) {
+ break;
+ }
}
- scan_to_eol(lc);
return bsr;
}
-static BSR *store_file_index(LEX *lc, BSR *bsr)
+static BSR *store_findex(LEX *lc, BSR *bsr)
{
int token;
BSR_FINDEX *findex;
for (;;) {
- lc->expect = T_PINT32_RANGE;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_PINT32_RANGE);
findex = (BSR_FINDEX *)malloc(sizeof(BSR_FINDEX));
memset(findex, 0, sizeof(BSR_FINDEX));
findex->findex = lc->pint32_val;
/* Add to end of chain */
BSR_FINDEX *bs = bsr->FileIndex;
for ( ;bs->next; bs=bs->next)
- { }
+ { }
bs->next = findex;
}
- lc->expect = 0;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
break;
}
}
-// scan_to_eol(lc);
return bsr;
}
BSR_JOBID *jobid;
for (;;) {
- lc->expect = T_PINT32_RANGE;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_PINT32_RANGE);
jobid = (BSR_JOBID *)malloc(sizeof(BSR_JOBID));
memset(jobid, 0, sizeof(BSR_JOBID));
jobid->JobId = lc->pint32_val;
/* Add to end of chain */
BSR_JOBID *bs = bsr->JobId;
for ( ;bs->next; bs=bs->next)
- { }
+ { }
bs->next = jobid;
}
- lc->expect = 0;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
break;
}
}
-// scan_to_eol(lc);
return bsr;
}
BSR_VOLFILE *volfile;
for (;;) {
- lc->expect = T_PINT32_RANGE;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_PINT32_RANGE);
volfile = (BSR_VOLFILE *)malloc(sizeof(BSR_VOLFILE));
memset(volfile, 0, sizeof(BSR_VOLFILE));
volfile->sfile = lc->pint32_val;
/* Add to end of chain */
BSR_VOLFILE *bs = bsr->volfile;
for ( ;bs->next; bs=bs->next)
- { }
+ { }
bs->next = volfile;
}
- lc->expect = 0;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
break;
}
}
-// scan_to_eol(lc);
return bsr;
}
BSR_SESSID *sid;
for (;;) {
- lc->expect = T_PINT32_RANGE;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_PINT32_RANGE);
sid = (BSR_SESSID *)malloc(sizeof(BSR_SESSID));
memset(sid, 0, sizeof(BSR_SESSID));
sid->sessid = lc->pint32_val;
/* Add to end of chain */
BSR_SESSID *bs = bsr->sessid;
for ( ;bs->next; bs=bs->next)
- { }
+ { }
bs->next = sid;
}
- lc->expect = 0;
- token = lex_get_token(lc);
+ token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
break;
}
}
-// scan_to_eol(lc);
return bsr;
}
int token;
BSR_SESSTIME *stime;
- lc->expect = T_PINT32;
- token = lex_get_token(lc);
- stime = (BSR_SESSTIME *)malloc(sizeof(BSR_SESSTIME));
- memset(stime, 0, sizeof(BSR_SESSTIME));
- stime->sesstime = lc->pint32_val;
- /* Add it to the end of the chain */
- if (!bsr->sesstime) {
- bsr->sesstime = stime;
- } else {
- /* Add to end of chain */
- BSR_SESSTIME *bs = bsr->sesstime;
- for ( ;bs->next; bs=bs->next)
- { }
- bs->next = stime;
+ for (;;) {
+ token = lex_get_token(lc, T_PINT32);
+ stime = (BSR_SESSTIME *)malloc(sizeof(BSR_SESSTIME));
+ memset(stime, 0, sizeof(BSR_SESSTIME));
+ stime->sesstime = lc->pint32_val;
+ /* Add it to the end of the chain */
+ if (!bsr->sesstime) {
+ bsr->sesstime = stime;
+ } else {
+ /* Add to end of chain */
+ BSR_SESSTIME *bs = bsr->sesstime;
+ for ( ;bs->next; bs=bs->next)
+ { }
+ bs->next = stime;
+ }
+ token = lex_get_token(lc, T_ALL);
+ if (token != T_COMMA) {
+ break;
+ }
}
- scan_to_eol(lc);
return bsr;
}
void dump_volfile(BSR_VOLFILE *volfile)
{
- if (!volfile) {
- return;
+ if (volfile) {
+ Dmsg2(-1, "VolFile : %u-%u\n", volfile->sfile, volfile->efile);
+ dump_volfile(volfile->next);
}
- Dmsg2(-1,
-"VolFile : %u-%u\n", volfile->sfile, volfile->efile);
- dump_volfile(volfile->next);
}
void dump_findex(BSR_FINDEX *FileIndex)
{
- if (!FileIndex) {
- return;
- }
- if (FileIndex->findex == FileIndex->findex2) {
- Dmsg1(-1, "FileIndex : %u\n", FileIndex->findex);
- } else {
- Dmsg2(-1, "FileIndex : %u-%u\n", FileIndex->findex, FileIndex->findex2);
+ if (FileIndex) {
+ if (FileIndex->findex == FileIndex->findex2) {
+ Dmsg1(-1, "FileIndex : %u\n", FileIndex->findex);
+ } else {
+ Dmsg2(-1, "FileIndex : %u-%u\n", FileIndex->findex, FileIndex->findex2);
+ }
+ dump_findex(FileIndex->next);
}
- dump_findex(FileIndex->next);
}
void dump_jobid(BSR_JOBID *jobid)
{
- if (!jobid) {
- return;
- }
- if (jobid->JobId == jobid->JobId2) {
- Dmsg1(-1, "JobId : %u\n", jobid->JobId);
- } else {
- Dmsg2(-1, "JobId : %u-%u\n", jobid->JobId, jobid->JobId2);
+ if (jobid) {
+ if (jobid->JobId == jobid->JobId2) {
+ Dmsg1(-1, "JobId : %u\n", jobid->JobId);
+ } else {
+ Dmsg2(-1, "JobId : %u-%u\n", jobid->JobId, jobid->JobId2);
+ }
+ dump_jobid(jobid->next);
}
- dump_jobid(jobid->next);
}
void dump_sessid(BSR_SESSID *sessid)
{
- if (!sessid) {
- return;
- }
- if (sessid->sessid == sessid->sessid2) {
- Dmsg1(-1, "SessId : %u\n", sessid->sessid);
- } else {
- Dmsg2(-1, "SessId : %u-%u\n", sessid->sessid, sessid->sessid2);
+ if (sessid) {
+ if (sessid->sessid == sessid->sessid2) {
+ Dmsg1(-1, "SessId : %u\n", sessid->sessid);
+ } else {
+ Dmsg2(-1, "SessId : %u-%u\n", sessid->sessid, sessid->sessid2);
+ }
+ dump_sessid(sessid->next);
}
- dump_sessid(sessid->next);
}
void dump_client(BSR_CLIENT *client)
{
- if (!client) {
- return;
+ if (client) {
+ Dmsg1(-1, "Client : %s\n", client->ClientName);
+ dump_client(client->next);
}
- Dmsg1(-1, "Client : %s\n", client->ClientName);
- dump_client(client->next);
}
void dump_job(BSR_JOB *job)
{
- if (!job) {
- return;
+ if (job) {
+ Dmsg1(-1, "Job : %s\n", job->Job);
+ dump_job(job->next);
}
- Dmsg1(-1, "Job : %s\n", job->Job);
- dump_job(job->next);
}
void dump_sesstime(BSR_SESSTIME *sesstime)
{
- if (!sesstime) {
- return;
+ if (sesstime) {
+ Dmsg1(-1, "SessTime : %u\n", sesstime->sesstime);
+ dump_sesstime(sesstime->next);
}
- Dmsg1(-1, "SessTime : %u\n", sesstime->sesstime);
- dump_sesstime(sesstime->next);
}
static void free_bsr_item(BSR *bsr)
{
- if (!bsr) {
- return;
+ if (bsr) {
+ free_bsr_item(bsr->next);
+ free(bsr);
}
- free_bsr_item(bsr->next);
- free(bsr);
}
void free_bsr(BSR *bsr)
free_bsr_item((BSR *)bsr->sessid);
free_bsr_item((BSR *)bsr->sesstime);
free_bsr_item((BSR *)bsr->volfile);
+ free_bsr_item((BSR *)bsr->JobId);
+ free_bsr_item((BSR *)bsr->job);
+ free_bsr_item((BSR *)bsr->FileIndex);
+ free_bsr_item((BSR *)bsr->JobType);
+ free_bsr_item((BSR *)bsr->JobLevel);
if (bsr->VolumeName) {
free(bsr->VolumeName);
}
Dmsg4(90, "read_record FI=%s SessId=%d Strm=%s len=%d\n",
FI_to_ascii(record->FileIndex), record->VolSessionId,
stream_to_ascii(record->Stream), record->data_len);
+ record->File = dev->file;
+ record->Block = dev->block_num;
return 1;
}
*/
typedef struct s_dev_rec {
int sync; /* synchronous */
- uint32_t File; /* File number, returned if sync set */
- uint32_t Block; /* Block number, returned if sync set */
+ /* File and Block are always returned on reading records, but
+ * only returned on writing if sync is set (obviously).
+ */
+ uint32_t File; /* File number */
+ uint32_t Block; /* Block number */
uint32_t VolSessionId; /* sequential id within this session */
uint32_t VolSessionTime; /* session start time */
int32_t FileIndex; /* sequential file number */
/* */
#define VERSION "1.22"
#define VSTRING "1"
-#define DATE "19 June 2002"
-#define LSMDATE "19Jun02"
+#define DATE "20 June 2002"
+#define LSMDATE "20Jun02"
/* Debug flags */
#define DEBUG 1