]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/runscript_with_multiple_command_v2.patch
ebl Use old LStat fields for deleted files (more simple)
[bacula/bacula] / bacula / patches / testing / runscript_with_multiple_command_v2.patch
1 Index: src/dird/dird_conf.c
2 ===================================================================
3 --- src/dird/dird_conf.c        (rĂ©vision 6192)
4 +++ src/dird/dird_conf.c        (copie de travail)
5 @@ -1678,6 +1678,8 @@
6  
7  /* We build RunScripts items here */
8  static RUNSCRIPT res_runscript;
9 +static alist *res_runscript_cmd;
10 +static alist *res_runscript_type;
11  
12  /* Store a runscript->when in a bit field */
13  static void store_runscript_when(LEX *lc, RES_ITEM *item, int index, int pass)
14 @@ -1731,7 +1733,10 @@
15     lex_get_token(lc, T_STRING);
16  
17     if (pass == 2) {
18 -      ((RUNSCRIPT*)item->value)->set_command(lc->str, item->code);
19 +      POOLMEM *c = get_pool_memory(PM_FNAME);
20 +      pm_strcpy(c, lc->str);
21 +      res_runscript_cmd->prepend(c);
22 +      res_runscript_type->prepend((void*) item->code);
23     }
24     scan_to_eol(lc);
25  }
26 @@ -1833,7 +1838,8 @@
27   */
28  static void store_runscript(LEX *lc, RES_ITEM *item, int index, int pass)
29  {
30 -   int token, i;
31 +   char *c;
32 +   int token, i, t;
33     alist **runscripts = (alist **)(item->value) ;
34  
35     Dmsg1(200, "store_runscript: begin store_runscript pass=%i\n", pass);
36 @@ -1846,6 +1852,11 @@
37        scan_err1(lc, _("Expecting open brace. Got %s"), lc->str);
38     }
39     
40 +   if (pass == 2) {
41 +      res_runscript_cmd = New(alist(10, not_owned_by_alist));
42 +      res_runscript_type = New(alist(10, not_owned_by_alist));
43 +   }
44 +
45     while ((token = lex_get_token(lc, T_SKIP_EOL)) != T_EOF) {
46        if (token == T_EOB) {
47          break;
48 @@ -1873,26 +1884,26 @@
49     }
50  
51     if (pass == 2) {
52 -      if (res_runscript.command == NULL) {
53 -         scan_err2(lc, _("%s item is required in %s resource, but not found.\n"),
54 -                   "command", "runscript");
55 -      }
56 -
57        /* run on client by default */
58        if (res_runscript.target == NULL) {
59           res_runscript.set_target("%c");
60        }
61 -
62 -      RUNSCRIPT *script = new_runscript();
63 -      memcpy(script, &res_runscript, sizeof(RUNSCRIPT));
64 -      script->set_job_code_callback(job_code_callback_filesetname);
65 -      
66        if (*runscripts == NULL) {
67 -        *runscripts = New(alist(10, not_owned_by_alist));
68 +         *runscripts = New(alist(10, not_owned_by_alist));
69        }
70 -      
71 -      (*runscripts)->append(script);
72 -      script->debug();
73 +      while ((c=(char*)res_runscript_cmd->pop()) != NULL) {
74 +         t = (int) res_runscript_type->pop();
75 +         RUNSCRIPT *script = new_runscript();
76 +         memcpy(script, &res_runscript, sizeof(RUNSCRIPT));
77 +         script->set_job_code_callback(job_code_callback_filesetname);
78 +         script->command = c;
79 +         script->cmd_type = t;
80 +
81 +         (*runscripts)->append(script);
82 +         script->debug();
83 +      }
84 +      delete res_runscript_type;
85 +      delete res_runscript_cmd;
86     }
87  
88     scan_to_eol(lc);