1 /*
2    BAREOS® - Backup Archiving REcovery Open Sourced
3 
4    Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
5    Copyright (C) 2011-2012 Planets Communications B.V.
6    Copyright (C) 2013-2020 Bareos GmbH & Co. KG
7 
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version three of the GNU Affero General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12 
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    Affero General Public License for more details.
17 
18    You should have received a copy of the GNU Affero General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22 */
23 
24 #ifndef BAREOS_LIB_BAREOS_RESOURCE_H_
25 #define BAREOS_LIB_BAREOS_RESOURCE_H_
26 
27 #include "include/bareos.h"
28 
29 class PoolMem;
30 class ConfigurationParser;
31 class OutputFormatterResource;
32 struct ResourceItem;
33 
34 #define MAX_RES_ITEMS 95 /* maximum resource items per BareosResource */
35 
36 class BareosResource {
37  public:
38   BareosResource* next_; /* Pointer to next resource of this type */
39   char* resource_name_;  /* Resource name */
40   char* description_;    /* Resource description */
41   uint32_t rcode_;       /* Resource id or type */
42   int32_t refcnt_;       /* Reference count for releasing */
43   std::string rcode_str_;
44   char item_present_[MAX_RES_ITEMS]; /* Set if item is present in conf file */
45   char inherit_content_[MAX_RES_ITEMS]; /* Set if item has inherited content */
46   bool internal_{false};
47 
48   BareosResource();
49   BareosResource(const BareosResource& other);
50   BareosResource& operator=(const BareosResource& rhs);
51 
52   virtual ~BareosResource() = default;
53   virtual bool PrintConfig(OutputFormatterResource& send,
54                            const ConfigurationParser& my_config,
55                            bool hide_sensitive_data = false,
56                            bool verbose = false);
57 
58   virtual bool Validate();
59   virtual void PrintResourceItem(ResourceItem& item,
60                                  const ConfigurationParser& my_config,
61                                  OutputFormatterResource& send,
62                                  bool hide_sensitive_data,
63                                  bool inherited,
64                                  bool verbose);
65 };
66 
67 const char* GetResourceName(void* resource);
68 
69 #endif /* BAREOS_LIB_BAREOS_RESOURCE_H_ */
70