]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/parse_conf.h
kes Correctly detect Ubuntu systems, and add ubuntu platform directory.
[bacula/bacula] / bacula / src / lib / parse_conf.h
index 181d55343d0a0adc51cb65fdc252c15338507aaf..6ce558666998154cbf9e49286e19b774449d3882 100644 (file)
@@ -1,25 +1,43 @@
 /*
- *   Version $Id$
- */
+   Bacula® - The Network Backup Solution
+
+   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.
+   This program is Free Software; you can redistribute it and/or
+   modify it under the terms of version two of the GNU General Public
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
+
+   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., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+   Bacula® is a registered trademark of John Walker.
+   The licensor of Bacula is the Free Software Foundation Europe
+   (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+   Switzerland, email:ftf@fsfeurope.org.
+*/
 /*
-   Copyright (C) 2000-2006 Kern Sibbald
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License
-   version 2 as amended with additional clauses defined in the
-   file LICENSE in the main source directory.
-
-   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 
-   the file LICENSE for additional details.
-
+ *
+ *     Kern Sibbald, January MM
+ *
+ *   Version $Id$
+ *
  */
 
 struct RES_ITEM;                    /* Declare forward referenced structure */
-struct RES;                         /* Declare forware 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
@@ -48,13 +66,14 @@ struct RES_ITEM {
 /* 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
  * record.
  */
-struct RES {
+class RES {
+public:
    RES *next;                         /* pointer to next resource of this type */
    char *name;                        /* resource name */
    char *desc;                        /* resource description */
@@ -75,6 +94,8 @@ struct RES_TABLE {
    int rcode;                         /* code if needed */
 };
 
+
+
 /* Common Resource definitions */
 
 #define MAX_RES_NAME_LENGTH MAX_NAME_LENGTH-1       /* maximum resource name length */
@@ -84,33 +105,69 @@ struct RES_TABLE {
 #define ITEM_NO_EQUALS   0x4          /* Don't scan = after name */
 
 /* Message Resource */
-struct MSGS {
+class MSGS {
+public:
    RES   hdr;
    char *mail_cmd;                    /* mail command */
    char *operator_cmd;                /* Operator command */
    DEST *dest_chain;                  /* chain of destinations */
    char send_msg[nbytes_for_bits(M_MAX+1)];  /* bit array of types */
-};
-
 
-/* Define the Union of all the above common
- * resource structure definitions.
- */
-union CURES {
-   MSGS  res_msgs;
-   RES hdr;
+   /* Methods */
+   char *name() const;
 };
 
+inline char *MSGS::name() const { return hdr.name; }
 
-/* Configuration routines */
+/* 
+ * Old C style configuration routines -- deprecated do not use.
+ */
 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 */
+   int m_err_type;                     /* the way to terminate on failure */
+   void *m_res_all;                    /* pointer to res_all buffer */
+   int m_res_all_size;                 /* length of buffer */
+   /* The below are not yet implemented */
+   int m_r_first;                      /* first daemon resource type */
+   int 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,
+      int err_type,
+      void *vres_all,
+      int res_all_size,
+      int r_first,
+      int 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, char *name);
+RES *GetResWithName(int rcode, const char *name);
 RES *GetNextRes(int rcode, RES *res);
 void b_LockRes(const char *file, int line);
 void b_UnlockRes(const char *file, int line);
@@ -130,7 +187,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);