Disk ARchive  2.5.1
Full featured and portable backup and archiving tool
user_group_bases.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21 
25 
26 #ifndef USER_GROUP_BASES_HPP
27 #define USER_GROUP_BASES_HPP
28 
29 #include "../my_config.h"
30 
31 #ifdef __DYNAMIC__
32 
33 extern "C"
34 {
35 #if MUTEX_WORKS
36 #if HAVE_PTHREAD_H
37 #include <pthread.h>
38 #endif
39 #endif
40 }
41 
42 #include <map>
43 #include <string>
44 #include "infinint.hpp"
45 
46 namespace libdar
47 {
48 
51 
52  class user_group_bases
53  {
54  public:
55  user_group_bases() : filled(false) {};
56 
58 
60  const std::string & get_username(const infinint & uid) const;
61 
62 
64 
66  const std::string & get_groupname(const infinint & gid) const;
67 
68 
69  private:
70  bool filled;
71  std::map<infinint, std::string> user_database;
72  std::map<infinint, std::string> group_database;
73 
74  void fill() const;
75 
76  static const std::string empty_string;
77 #if MUTEX_WORKS
78  // the system call used to read the password and group database are not re-entrant, the mutex
79  // must block all other thread while a given thread is reading the databases
80  // the best solution would have to let the user provide such a database object already filled
81  // but that would rely on it not to destroy this object while threads are using it
82  // for this reason, here the mutex is 'static'
83  static pthread_mutex_t lock_fill;
84 #endif
85  };
86 
87 
89 
90 } // end of namespace
91 
92 #endif
93 
94 #endif
switch module to limitint (32 ou 64 bits integers) or infinint
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47