/usr/include/wvstreams/wvconfemu.h is in libwvstreams-dev 4.6.1-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | /* -*- Mode: C++ -*-
* Worldvisions Weaver Software:
* Copyright (C) 1997-2004 Net Integration Technologies, Inc.
*
* Basic WvConf emulation layer for UniConf.
*/
#ifndef __WVCONFEMU_H
#define __WVCONFEMU_H
#include "uniconfroot.h"
#include "wvstringtable.h"
#include "wvsorter.h"
#define WvConf WvConfEmu
#define WvConfigSection WvConfigSectionEmu
#define WvConfigSectionList WvConfigSectionListEmu
#define WvConfigEntry WvConfigEntryEmu
#define WvConfigEntryList WvConfigEntryListEmu
class WvConfEmu;
class WvConfigEntryEmu;
class WvConfigSectionEmu;
class WvAuthDaemon;
class WvAuthDaemonSvc;
typedef WvConfEmu WvConfigSectionListEmu;
typedef WvConfigSectionEmu WvConfigEntryListEmu;
class WvConfigEntryEmu
{
public:
const WvString name;
WvString value;
WvConfigEntryEmu(WvStringParm _name, WvStringParm _value):
name(_name), value(_value)
{}
};
DeclareWvDict(WvConfigEntryEmu, WvString, name);
class WvConfigSectionEmu
{
private:
const UniConf uniconf;
WvConfigEntryEmuDict entries;
WvStringTable &values;
public:
const WvString name;
WvConfigSectionEmu(const UniConf& _uniconf, WvStringParm _name,
WvStringTable *_values):
uniconf(_uniconf), entries(42), values(*_values), name(_name)
{}
WvConfigEntryEmu *operator[] (WvStringParm s);
const char *get(WvStringParm entry, const char *def_val = NULL);
void set(WvStringParm entry, WvStringParm value);
void quick_set(WvStringParm entry, WvStringParm value);
bool isempty() const;
class Iter;
friend class Iter;
typedef WvSorter<WvConfigEntryEmu, WvConfigSectionEmu, Iter> Sorter;
};
DeclareWvDict(WvConfigSectionEmu, WvString, name);
class WvConfigSectionEmu::Iter
{
private:
WvConfigSectionEmu& sect;
UniConf::RecursiveIter iter;
WvLink link;
WvConfigEntryEmu* entry;
public:
Iter(WvConfigSectionEmu& _sect):
sect(_sect), iter(_sect.uniconf), link(NULL, false), entry(NULL)
{
assert(&_sect);
}
~Iter();
void rewind();
WvLink *next();
WvLink *cur();
WvConfigEntryEmu* ptr() const;
void* vptr() const;
WvIterStuff(WvConfigEntryEmu);
};
// parameters are: userdata, section, entry, oldval, newval
typedef wv::function<void(void*, WvStringParm, WvStringParm, WvStringParm, WvStringParm)> WvConfCallback;
class WvConfEmu
{
private:
struct CallbackInfo
{
WvConfCallback callback;
void* userdata;
WvString section;
WvString key;
void* cookie;
CallbackInfo(WvConfCallback _callback, void* _userdata,
WvStringParm _section, WvStringParm _key,
void* _cookie):
callback(_callback), userdata(_userdata), section(_section),
key(_key), cookie(_cookie)
{}
};
WvConfigSectionEmuDict sections;
bool hold;
bool dirty;
WvList<CallbackInfo> callbacks;
WvStringTable values;
void notify(const UniConf &_uni, const UniConfKey &_key);
public:
const UniConf uniconf;
WvConfEmu(const UniConf &_uniconf);
~WvConfEmu();
void zap();
bool isclean() const;
bool isok() const;
void load_file(WvStringParm filename);
void save(WvStringParm filename, int _create_mode = 0666);
void save();
void flush();
WvConfigSectionEmu *operator[] (WvStringParm sect);
void add_callback(WvConfCallback callback, void *userdata,
WvStringParm section, WvStringParm key, void *cookie);
void del_callback(WvStringParm section, WvStringParm key, void *cookie);
void add_setbool(bool *b, WvStringParm _section, WvStringParm _key);
void del_setbool(bool *b, WvStringParm _section, WvStringParm _key);
// The addname callback will add the key "ent" in "sect" to the "list"
// whenever "ent" changes. If ent is empty, add any key in the sect to
// the list when one is added/deleted/changed
void add_addname(WvStringList *list, WvStringParm sect, WvStringParm ent);
void del_addname(WvStringList *list, WvStringParm sect, WvStringParm ent);
WvString getraw(WvString wvconfstr, int &parse_error);
int getint(WvStringParm section, WvStringParm entry, int def_val);
const char *get(WvStringParm section, WvStringParm entry,
const char *def_val = NULL);
int fuzzy_getint(WvStringList §, WvStringParm entry,
int def_val);
const char *fuzzy_get(WvStringList §, WvStringParm entry,
const char *def_val = NULL);
void setraw(WvString wvconfstr, const char *&value, int &parse_error);
void setint(WvStringParm section, WvStringParm entry, int value);
void set(WvStringParm section, WvStringParm entry,
const char *value);
void maybesetint(WvStringParm section, WvStringParm entry,
int value);
void maybeset(WvStringParm section, WvStringParm entry,
const char *value);
void delete_section(WvStringParm section);
// Gets a user's password and decrypts it. This isn't defined in wvconf.cc.
WvString get_passwd(WvStringParm sect, WvStringParm user);
WvString get_passwd(WvStringParm user)
{ return get_passwd("Users", user); }
WvString get_passwd2(WvString pwenc);
// Check the password passed in. This isn't defined in wvconf.cc
// We use this function to check passwords since we may not know what
// the password actually is!
// If s is not null and has continue_select enabled, check_passwd will
// pause if the password is incorrect (the pause length depends on how
// many password failures have occurred recently).
bool check_passwd(WvStringParm sect, WvStringParm user,
WvStringParm passwd, WvStream *s);
bool check_passwd(WvStringParm user, WvStringParm passwd, WvStream *s)
{
return check_passwd("Users", user, passwd, s);
}
// Check if the user exists. This isn't defined in wvconf.cc
bool user_exists(WvStringParm sect, WvStringParm user);
bool user_exists(WvStringParm user)
{
return user_exists("Users", user);
}
// Encrypts and sets a user's password. This isn't defined in wvconf.cc.
void set_passwd(WvStringParm sect, WvStringParm user, WvStringParm passwd);
void set_passwd(WvStringParm user, WvStringParm passwd)
{ set_passwd("Users", user, passwd); }
WvString set_passwd2(WvStringParm passwd);
// Converts all passwords to unencrypted format. Not defined in wvconf.cc.
void convert_to_old_pw();
static int check_for_bool_string(const char *s);
class Iter;
friend class Iter;
private:
/* The following is an ugly hack, but since WvConf is being
* deprecated, we don't care.
*
* It seems that check_passwd() and user_exists() need to talk to a
* WvAuthDaemon. However, making them virtual functions would break since
* everyone else has to implement them. So we'll its pointer and accessors
* here.
*/
private:
WvAuthDaemon *wvauthd; // Authentication Daemon
public:
friend class WvAuthDaemonSvc;
};
class WvConfEmu::Iter
{
WvConfEmu& conf;
UniConf::Iter iter;
WvLink link;
public:
Iter(WvConfEmu& _conf):
conf(_conf), iter(conf.uniconf), link(NULL, false)
{}
void rewind();
WvLink *next();
WvConfigSectionEmu* ptr() const;
WvIterStuff(WvConfigSectionEmu);
};
#endif // __WVCONFEMU_H
|