Go to the documentation of this file.
62 #define NUM_ACCOUNT_FIELDS 6
104 #define ACCOUNT_FILE "accounts"
134 LOG(
llevError,
"Unable to allocate an account_struct!\n");
137 ac->last_login = time(NULL);
138 ac->created =
ac->last_login;
164 LOG(
llevError,
"account_load_entries(): Called when accounts has been set.\n");
177 if (
buf[0] ==
'#')
continue;
184 ac->last_login = strtoul(
tmp[2], (
char**)NULL, 10);
190 if (fields>4)
ac->created = strtoul(
tmp[4], (
char**)NULL, 10);
192 ac->created =
ac->last_login;
200 ac->num_characters=1;
201 for (cp =
tmp[3]; *cp !=
'\0'; cp++) {
202 if (*cp ==
';')
ac->num_characters++;
210 for (i=0; i<
ac->num_characters; i++) {
243 fprintf(fp,
"%s:%s:%u:",
ac->name,
ac->password, (uint32_t)
ac->last_login);
244 for (i=0; i<
ac->num_characters; i++) {
246 fprintf(fp,
";%s",
ac->character_names[i]);
248 fprintf(fp,
"%s",
ac->character_names[i]);
250 fprintf(fp,
":%u:\n", (uint32_t)
ac->created);
276 fprintf(fp,
"# IMPORTANT: Do not edit this file while the server is running. This file is\n"
277 "# only read when the server starts, and any changes will be overwritten when\n"
278 "# the server exits.\n");
279 fprintf(fp,
"# Format:\n");
280 fprintf(fp,
"# Account name:Password:Account last used:Characters (semicolon separated):created:expansion\n");
287 if (
ac->num_characters || (
ac->created > (time(NULL) - 86400)))
333 ac->last_login = time(NULL);
364 const char *cp =
str;
367 if (!isalnum(*
str))
return 1;
368 for (; *
str !=
'\0'; ++
str) {
369 if (!isprint(*
str))
return 1;
380 if (isspace(*(
str-1)))
return 1;
453 if (
ac == NULL)
return 1;
457 ac->num_characters++;
483 if (account_name == NULL)
489 if (
ac == NULL)
return 1;
495 for (i=0; i<
ac->num_characters; i++) {
496 if (!strcmp(
ac->character_names[i], player_name)) {
497 free(
ac->character_names[i]);
501 ac->character_names[i] =
ac->character_names[i+1];
506 ac->num_characters--;
530 if (!
strcasecmp(
ac->name, account_name))
return ac->character_names;
543 if (strcmp(chars->
name,
name) == 0) {
565 for (
int i = 0; i <
ac->num_characters; i++) {
569 lc->
name =
ac->character_names[i];
595 for (i=0; i<
ac->num_characters; i++) {
596 if (!strcmp(
ac->character_names[i],
charname)) {
686 const char *current_password,
const char *new_password) {
709 if (current_password != NULL && !
check_password(current_password,
ac->password)) {
const char * account_get_account_for_char(const char *charname)
void accounts_clear(void)
static void ensure_available_characters(account_struct *account, int count)
socket_struct * init_sockets
char const * newhash(char const *password)
BufferReader * bufferreader_init_from_file(BufferReader *br, const char *filepath, const char *failureMessage, LogLevel failureLevel)
#define NUM_ACCOUNT_FIELDS
int account_link(const char *account_name, const char *player_name)
char * bufferreader_next_line(BufferReader *br)
player * account_get_logged_in_player(const char *name)
struct account_struct * next
const char * account_exists(const char *account_name)
void account_password(char *buf, int len, socket_struct *ns)
static account_struct * account_alloc()
int of_close(OutputFile *of)
void fatal(enum fatal_error err)
int account_login(const char *account_name, const char *account_password)
EXTERN player * first_player
struct linked_char * next
linked_char * account_get_additional_chars(const char *account_name, const Account_Chars *chars, int *count)
struct account_char_struct * next
int account_remove_player(const char *account_name, const char *player_name)
socket_struct * account_get_logged_in_init_socket(const char *name)
size_t split_string(char *str, char *array[], size_t array_size, char sep)
static int accounts_loaded
char ** account_get_players_for_account(const char *account_name)
int account_change_password(const char *account_name, const char *current_password, const char *new_password)
void LOG(LogLevel logLevel, const char *format,...)
struct account_struct account_struct
FILE * of_open(OutputFile *of, const char *fname)
void bufferreader_destroy(BufferReader *br)
int account_new(const char *account_name, const char *account_password)
int strcasecmp(const char *s1, const char *s2)
int account_is_logged_in(const char *name)
int account_check_string(const char *str)
bool check_password(const char *typed, const char *crypted)
static int char_in_list(const char *name, const Account_Char *chars)
static void account_write_entry(FILE *fp, account_struct *ac)
static account_struct * accounts