| 1 | /* |
| 2 | * Copyright (C) 1998,1999 Ross Combs ([email protected]) |
| 3 | * Copyright (C) 2000,2001 Marco Ziech ([email protected]) |
| 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 | #ifndef INCLUDED_ACCOUNT_TYPES |
| 20 | #define INCLUDED_ACCOUNT_TYPES |
| 21 | |
| 22 | #ifndef JUST_NEED_TYPES |
| 23 | #define JUST_NEED_TYPES |
| 24 | #include "common/list.h" |
| 25 | #include "common/elist.h" |
| 26 | #include "team.h" |
| 27 | #include "attrgroup.h" |
| 28 | #undef JUST_NEED_TYPES |
| 29 | #else |
| 30 | #include "common/list.h" |
| 31 | #include "common/elist.h" |
| 32 | #include "team.h" |
| 33 | #include "attrgroup.h" |
| 34 | #endif |
| 35 | |
| 36 | #define ACCOUNT_FLAG_NONE 0 |
| 37 | #define ACCOUNT_FLAG_FLOADED 1 /* friends list loaded */ |
| 38 | |
| 39 | namespace pvpgn |
| 40 | { |
| 41 | |
| 42 | namespace bnetd |
| 43 | { |
| 44 | |
| 45 | struct connection; |
| 46 | struct _clanmember; |
| 47 | struct clan; |
| 48 | |
| 49 | typedef struct account_struct |
| 50 | #ifdef ACCOUNT_INTERNAL_ACCESS |
| 51 | { |
| 52 | t_attrgroup * attrgroup; |
| 53 | char * name; /* profiling proved 99% of getstrattr its from get_name */ |
| 54 | unsigned int namehash; /* cached from attrs */ |
| 55 | unsigned int uid; /* cached from attrs */ |
| 56 | unsigned int flags; |
| 57 | struct connection * conn; |
| 58 | struct _clanmember * clanmember; |
| 59 | t_list * friends; |
| 60 | t_list * teams; |
| 61 | } |
| 62 | #endif |
| 63 | t_account; |
| 64 | |
| 65 | } |
| 66 | |
| 67 | } |
| 68 | |
| 69 | #endif |
| 70 | |
| 71 | /*****/ |
| 72 | #ifndef JUST_NEED_TYPES |
| 73 | #ifndef INCLUDED_ACCOUNT_PROTOS |
| 74 | #define INCLUDED_ACCOUNT_PROTOS |
| 75 | |
| 76 | #define JUST_NEED_TYPES |
| 77 | #include "common/hashtable.h" |
| 78 | #include "connection.h" |
| 79 | #undef JUST_NEED_TYPES |
| 80 | |
| 81 | namespace pvpgn |
| 82 | { |
| 83 | |
| 84 | namespace bnetd |
| 85 | { |
| 86 | |
| 87 | extern unsigned int maxuserid; |
| 88 | |
| 89 | extern int accountlist_reload(void); |
| 90 | extern int account_check_name(char const * name); |
| 91 | #define account_get_uid(A) account_get_uid_real(A,__FILE__,__LINE__) |
| 92 | extern unsigned int account_get_uid_real(t_account const * account, char const * fn, unsigned int ln); |
| 93 | extern int account_match(t_account * account, char const * username); |
| 94 | extern int account_save(t_account *account, unsigned flags); |
| 95 | extern char const * account_get_strattr_real(t_account * account, char const * key, char const * fn, unsigned int ln); |
| 96 | #define account_get_strattr(A,K) account_get_strattr_real(A,K,__FILE__,__LINE__) |
| 97 | extern int account_set_strattr(t_account * account, char const * key, char const * val); |
| 98 | |
| 99 | extern int accountlist_create(void); |
| 100 | extern int accountlist_destroy(void); |
| 101 | extern t_hashtable * accountlist(void); |
| 102 | extern t_hashtable * accountlist_uid(void); |
| 103 | extern int accountlist_load_all(int flag); |
| 104 | extern unsigned int accountlist_get_length(void); |
| 105 | extern int accountlist_save(unsigned flags); |
| 106 | extern int accountlist_flush(unsigned flags); |
| 107 | extern t_account * accountlist_find_account(char const * username); |
| 108 | extern t_account * accountlist_find_account_by_uid(unsigned int uid); |
| 109 | extern char const *accountlist_find_vague_account(t_account * account, char const *vague_username); |
| 110 | extern int accountlist_allow_add(void); |
| 111 | extern t_account * accountlist_create_account(const char *username, const char *passhash1); |
| 112 | |
| 113 | /* names and passwords */ |
| 114 | extern char const * account_get_name_real(t_account * account, char const * fn, unsigned int ln); |
| 115 | # define account_get_name(A) account_get_name_real(A,__FILE__,__LINE__) |
| 116 | |
| 117 | |
| 118 | extern int account_check_mutual(t_account * account, int myuserid); |
| 119 | extern t_list * account_get_friends(t_account * account); |
| 120 | |
| 121 | extern int account_set_clanmember(t_account * account, _clanmember * clanmember); |
| 122 | extern _clanmember * account_get_clanmember(t_account * account); |
| 123 | extern _clanmember * account_get_clanmember_forced(t_account * account); |
| 124 | extern clan * account_get_clan(t_account * account); |
| 125 | extern clan * account_get_creating_clan(t_account * account); |
| 126 | |
| 127 | extern int account_set_conn(t_account * account, t_connection * conn); |
| 128 | extern t_connection * account_get_conn(t_account * account); |
| 129 | |
| 130 | extern void account_add_team(t_account * account, t_team * team); |
| 131 | extern t_team * account_find_team_by_accounts(t_account * account, t_account **accounts, t_clienttag clienttag); |
| 132 | extern t_team * account_find_team_by_teamid(t_account * account, unsigned int teamid); |
| 133 | extern t_list * account_get_teams(t_account * account); |
| 134 | |
| 135 | } |
| 136 | |
| 137 | } |
| 138 | |
| 139 | #endif |
| 140 | #endif |