 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
67 #define NUM_ACCOUNT_FIELDS 6
108 #define ACCOUNT_FILE "accounts"
138 LOG(
llevError,
"Unable to allocate an account_struct!\n");
167 LOG(
llevError,
"account_load_entries(): Called when accounts has been set.\n");
180 if (
buf[0] ==
'#')
continue;
187 ac->
last_login = strtoul(tmp[2], (
char**)NULL, 10);
193 if (
fields>4) ac->
created = strtoul(tmp[4], (
char**)NULL, 10);
204 for (cp = tmp[3]; *cp !=
'\0'; cp++) {
245 fprintf(fp,
":%u:\n", (uint32_t) ac->
created);
270 fprintf(fp,
"# IMPORTANT: Do not edit this file while the server is running. This file is\n"
271 "# only read when the server starts, and any changes will be overwritten when\n"
272 "# the server exits.\n");
273 fprintf(fp,
"# Format:\n");
274 fprintf(fp,
"# Account name:Password:Account last used:Characters (semicolon separated):created:expansion\n");
281 if (ac->num_characters || (ac->created > (
time(NULL) - 86400)))
299 if (!
strcasecmp(ac->name, account_name))
return ac->name;
323 ac->last_login =
time(NULL);
362 const char *cp = str;
365 if (!isalnum(*str))
return 1;
366 for (; *str !=
'\0'; ++str) {
367 if (!isprint(*str))
return 1;
378 if (isspace(*(str-1)))
return 1;
379 if ((str - cp) >
MAX_NAME)
return 2;
448 ac->character_names[ac->num_characters] =
strdup_local(player_name);
449 ac->num_characters++;
477 if (account_name == NULL)
486 for (i=0; i<ac->num_characters; i++) {
487 if (!strcmp(ac->character_names[i], player_name)) {
488 free(ac->character_names[i]);
492 ac->character_names[i] = ac->character_names[i+1];
497 ac->num_characters--;
522 if (!
strcasecmp(ac->name, account_name))
return ac->character_names;
534 for (
auto ch : chars) {
535 if (strcmp(ch->name,
name) == 0) {
555 for (
int i = 0; i < ac->num_characters; i++) {
559 lc->
name = ac->character_names[i];
584 for (i=0; i<ac->num_characters; i++) {
585 if (!strcmp(ac->character_names[i], charname)) {
628 const char *current_password,
const char *new_password) {
641 if (current_password != NULL && !
check_password(current_password, ac->password)) {
char ** account_get_players_for_account(const char *account_name)
Returns an array of strings for the characters on this account - the array is null terminated.
struct Settings settings
Global settings.
void account_logout(const char *account_name)
Remove 'account_name' from the list of logged in accounts.
Structure that holds account data.
static account_struct * account_alloc()
Allocate a new account_struct item.
@ llevError
Error, serious thing.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
int of_close(OutputFile *of)
Closes an output file.
FILE * of_open(OutputFile *of, const char *fname)
Opens an output file.
char const * newhash(char const *password)
linked_char * account_get_additional_chars(const char *account_name, const Account_Chars *chars, int *count)
Get a list of character names linked to the specified account which are not listed in chars.
void accounts_save(void)
Save all the account information.
time_t created
When character was created.
non standard information is not specified or uptime fields
non standard information is not specified or uptime this means how long since the executable has been started A particular host may have been running a server for quite a long time
void bufferreader_destroy(BufferReader *br)
Destroy a BufferReader.
const char * account_exists(const char *account_name)
Checks the existing accounts, and see if this account exists.
static int accounts_loaded
Whether the account information was loaded or not.
int num_characters
Number of characters on this account.
int account_remove_player(const char *account_name, const char *player_name)
Removes a player name from an account.
static std::vector< account_struct * > accounts
list of all accounts.
static int char_in_list(const char *name, const std::vector< Account_Char * > chars)
Check if a character name is in a list or not.
Plugin animator file specs[Config] name
std::vector< Account_Char * > chars
Characters of the account.
void accounts_clear(void)
This is used purely by the test harness - by clearing the accounts, it can then verify that the data ...
void account_password(char *buf, int len, socket_struct *ns)
Handles the account password change.
BufferReader * bufferreader_init_from_file(BufferReader *br, const char *filepath, const char *failureMessage, LogLevel failureLevel)
Initialize or create a BufferReader from a file path.
size_t split_string(char *str, char *array[], size_t array_size, char sep)
Splits a string delimited by passed in sep value into characters into an array of strings.
time_t last_login
Last time this account was logged in.
#define NUM_ACCOUNT_FIELDS
Number of fields in the accounts file.
struct linked_char * next
#define ACCOUNT_FILE
Name of the accounts file.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
#define MAX_BUF
Used for all kinds of things.
static void ensure_available_characters(account_struct *account, int count)
Ensure an account can handle at least the specified count of character names.
int allocated_characters
Number of allocated items in character_names.
static std::set< std::string > accounts_logged_in
Set of accounts names that are currently logged in.
int strcasecmp(const char *s1, const char *s2)
Structure handling character information for an account.
const char * account_get_account_for_char(const char *charname)
This looks at all the accounts and sees if charname is associated with any of them.
bool check_password(const char *typed, const char *crypted)
Hash a password and compare it to the stored version.
int account_is_logged_in(const char *name)
This checkes if an account is logged in.
char ** character_names
Character names associated with this account, +1 added to allow for NULL termination.
int account_change_password(const char *account_name, const char *current_password, const char *new_password)
Change an account password.
static void account_write_entry(FILE *fp, account_struct *ac)
This writes a single account entry to the given filepointer.
int account_link(const char *account_name, const char *player_name)
Adds a player name to an account.
int account_login(const char *account_name, const char *account_password)
Check if the given account exists, and whether the password is correct.
void accounts_load(void)
This loads all the account entries into memory.
int account_check_string(const char *str)
Checks a string to make sure it does not have any invalid characters.
int account_new(const char *account_name, const char *account_password)
Adds an account.
char * password
Password for this account.
char * bufferreader_next_line(BufferReader *br)
Return the next line in the buffer, as separated by a newline.
const char * localdir
Read/write data files.