19 #include "../../clib/cfgelem.h" 20 #include "../../clib/cfgfile.h" 21 #include "../../clib/clib.h" 22 #include "../../clib/logfacility.h" 23 #include "../../clib/passert.h" 24 #include "../../clib/streamsaver.h" 25 #include "../../clib/timer.h" 26 #include "../../plib/systemstate.h" 27 #include "../globals/state.h" 28 #include "../globals/uvars.h" 29 #include "../polsig.h" 38 unsigned int naccounts = 0;
39 static int num_until_dot = 1000;
51 while ( cf.
read( elem ) )
53 if ( --num_until_dot == 0 )
76 const char* accountstxtfile_c = accountstxtfile.c_str();
77 const char* accountsbakfile_c = accountsbakfile.c_str();
78 const char* accountsndtfile_c = accountsndtfile.c_str();
80 unlink( accountsbakfile_c );
81 unlink( accountsndtfile_c );
85 std::ofstream ofs( accountsndtfile_c, std::ios::trunc | std::ios::out );
99 rename( accountstxtfile_c, accountsbakfile_c );
100 rename( accountsndtfile_c, accountstxtfile_c );
103 stat( accountstxtfile_c, &newst );
116 elem.
add_prop(
"password", password );
118 elem.
add_prop(
"enabled", ( (
unsigned int)( enabled ? 1 : 0 ) ) );
119 auto acct =
new Account( elem );
133 if ( oldacct !=
nullptr )
138 elem.
add_prop(
"name", newacctname );
140 auto acct =
new Account( elem );
155 if ( stricmp( account->name(), acctname ) == 0 )
157 return account.get();
168 Account* account = ( *itr ).get();
169 if ( stricmp( account->
name(), acctname ) == 0 )
191 if ( existing !=
nullptr )
210 stat( accountsfile.c_str(), &newst );
212 ( newst.st_mtime < time(
nullptr ) - 10 ) )
221 while ( cf.
read( elem ) )
235 INFO_PRINT <<
"Error reading accounts.txt!\n";
std::string remove_string(const char *propname)
Account * create_new_account(const std::string &acctname, const std::string &password, bool enabled)
void readfrom(Clib::ConfigElem &elem)
std::string world_data_path
Account * duplicate_account(const std::string &oldacctname, const std::string &newacctname)
void write_account_data()
#define THREAD_CHECKPOINT(thread, check)
void force_backtrace(bool complete)
void reload_account_data(void)
void add_prop(std::string propname, std::string propval)
const char * name() const
void reread_account(Clib::ConfigElem &elem)
void write_account_data_task(void)
int delete_account(const char *acctname)
struct stat accounts_txt_stat
void writeto(Clib::StreamWriter &sw) const
bool read(ConfigElem &elem)
Account * find_account(const char *acctname)