]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/parse_conf.h
kes Apply Marco van Wieringen's set of patches, cleans up Migration/Copy
[bacula/bacula] / bacula / src / lib / parse_conf.h
index 470ac528184c3120a2eae3a30fbaa0b231eb165c..395dee19d19d84b3319757c5a79eb7281e545a65 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -20,7 +20,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Bacula® is a registered trademark of John Walker.
+   Bacula® is a registered trademark of Kern Sibbald.
    The licensor of Bacula is the Free Software Foundation Europe
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
@@ -37,6 +37,8 @@ struct RES_ITEM;                    /* Declare forward referenced structure */
 class RES;                         /* Declare forware referenced structure */
 typedef void (MSG_RES_HANDLER)(LEX *lc, RES_ITEM *item, int index, int pass);
 
+
+
 /* This is the structure that defines
  * the record types (items) permitted within each
  * resource. It is used to define the configuration
@@ -57,15 +59,15 @@ struct RES_ITEM {
       RES *resvalue;
       RES **presvalue;
    };
-   int  code;                         /* item code/additional info */
-   int  flags;                        /* flags: default, required, ... */
-   int  default_value;                /* default value */
+   int32_t  code;                     /* item code/additional info */
+   uint32_t  flags;                   /* flags: default, required, ... */
+   int32_t  default_value;            /* default value */
 };
 
 /* For storing name_addr items in res_items table */
 #define ITEM(x) {(char **)&res_all.x}
 
-#define MAX_RES_ITEMS 70              /* maximum resource items per RES */
+#define MAX_RES_ITEMS 80              /* maximum resource items per RES */
 
 /* This is the universal header that is
  * at the beginning of every resource
@@ -76,8 +78,8 @@ public:
    RES *next;                         /* pointer to next resource of this type */
    char *name;                        /* resource name */
    char *desc;                        /* resource description */
-   int   rcode;                       /* resource id or type */
-   int   refcnt;                      /* reference count for releasing */
+   uint32_t rcode;                    /* resource id or type */
+   int32_t  refcnt;                   /* reference count for releasing */
    char  item_present[MAX_RES_ITEMS]; /* set if item is present in conf file */
 };
 
@@ -90,9 +92,11 @@ public:
 struct RES_TABLE {
    const char *name;                  /* resource name */
    RES_ITEM *items;                   /* list of resource keywords */
-   int rcode;                         /* code if needed */
+   uint32_t rcode;                    /* code if needed */
 };
 
+
+
 /* Common Resource definitions */
 
 #define MAX_RES_NAME_LENGTH MAX_NAME_LENGTH-1       /* maximum resource name length */
@@ -116,22 +120,53 @@ public:
 
 inline char *MSGS::name() const { return hdr.name; }
 
-
-/* Define the Union of all the above common
- * resource structure definitions.
+/* 
+ * Old C style configuration routines -- deprecated do not use.
  */
-union CURES {
-   MSGS  res_msgs;
-   RES hdr;
-};
-
-
-/* Configuration routines */
-int   parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error = NULL, int err_type=M_ERROR_TERM);
+//int   parse_config(const char *cf, LEX_ERROR_HANDLER *scan_error = NULL, int err_type=M_ERROR_TERM);
 void    free_config_resources(void);
 RES   **save_config_resources(void);
 RES   **new_res_head();
 
+/*
+ * New C++ configuration routines
+ */
+
+class CONFIG {
+public:
+   const char *m_cf;                   /* config file */
+   LEX_ERROR_HANDLER *m_scan_error;    /* error handler if non-null */
+   int32_t m_err_type;                 /* the way to terminate on failure */
+   void *m_res_all;                    /* pointer to res_all buffer */
+   int32_t m_res_all_size;             /* length of buffer */
+
+   /* The below are not yet implemented */
+   int32_t m_r_first;                  /* first daemon resource type */
+   int32_t m_r_last;                   /* last daemon resource type */
+   RES_TABLE *m_resources;             /* pointer to table of permitted resources */      
+   RES **m_res_head;                   /* pointer to defined resources */
+   brwlock_t m_res_lock;               /* resource lock */
+
+   /* functions */
+   void init(
+      const char *cf,
+      LEX_ERROR_HANDLER *scan_error,
+      int32_t err_type,
+      void *vres_all,
+      int32_t res_all_size,
+      int32_t r_first,
+      int32_t r_last,
+      RES_TABLE *resources,
+      RES **res_head);
+
+   bool parse_config();
+   void free_resources();
+   RES **save_resources();
+   RES **new_res_head();
+};
+CONFIG *new_config_parser();
+
 
 /* Resource routines */
 RES *GetResWithName(int rcode, const char *name);
@@ -154,7 +189,9 @@ const char *res_to_str(int rcode);
 #endif
 
 
-
+/*
+ * Standard global parsers defined in parse_config.c
+ */
 void store_str(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_dir(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_password(LEX *lc, RES_ITEM *item, int index, int pass);
@@ -163,8 +200,8 @@ void store_strname(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_res(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_alist_res(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_alist_str(LEX *lc, RES_ITEM *item, int index, int pass);
-void store_int(LEX *lc, RES_ITEM *item, int index, int pass);
-void store_pint(LEX *lc, RES_ITEM *item, int index, int pass);
+void store_int32(LEX *lc, RES_ITEM *item, int index, int pass);
+void store_pint32(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_msgs(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_int64(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_bit(LEX *lc, RES_ITEM *item, int index, int pass);
@@ -173,3 +210,10 @@ void store_time(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_size(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_defs(LEX *lc, RES_ITEM *item, int index, int pass);
 void store_label(LEX *lc, RES_ITEM *item, int index, int pass);
+
+/* ***FIXME*** eliminate these globals */
+extern int32_t r_first;
+extern int32_t r_last;
+extern RES_TABLE resources[];
+extern RES **res_head;
+extern int32_t res_all_size;