-
Notifications
You must be signed in to change notification settings - Fork 6
/
profiles.h
202 lines (172 loc) · 7.66 KB
/
profiles.h
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
/***************************************************************************
profiles.h - profiles support include
-------------------
begin : Wed Mar 14 2001
copyright : (C) 2001 by Alexander Bilichenko
email : [email protected]
***************************************************************************/
#ifndef PROFILES_H_INCLUDED
#define PROFILES_H_INCLUDED
#include "basetypes.h"
#include "hashindex.h"
/* database length parameters */
#define PROFILES_MAX_PASSWORD_LENGTH 33
#define PROFILES_MAX_ICQ_LEN 16
#define PROFILES_MAX_ALT_DISPLAY_NAME 90
#define PROFILES_FAV_THREADS_COUNT 20 //4*20 = 80 bytes real size
#define PROFILES_MAX_USERNAME_LENGTH 30
#define PROFILES_MAX_SIGNATURE_LENGTH 255
#define PROFILES_FULL_USERINFO_MAX_NAME 255
#define PROFILES_FULL_USERINFO_MAX_EMAIL 255
#define PROFILES_FULL_USERINFO_MAX_HOMEPAGE 70
#define PROFILES_FULL_USERINFO_MAX_SELECTEDUSR 185
#define PROFILES_MIN_PASSWORD_LENGTH 3
/* bit mask for user flags */
#define PROFILES_FLAG_HAVE_PICTURE 0x0001u
#define PROFILES_FLAG_HAVE_SIGNATURE 0x0002u
#define PROFILES_FLAG_INVISIBLE 0x0004u
#define PROFILES_FLAG_VISIBLE_EMAIL 0x0008u
#define PROFILES_FLAG_NOT_ACTIVATED 0x0010u
#define PROFILES_FLAG_VIEW_SETTINGS 0x0020u
#define PROFILES_FLAG_DISABLED 0x0040u
#define PROFILES_FLAG_PERSMSGDISABLED 0x0080u
#define PROFILES_FLAG_PERSMSGTOEMAIL 0x0100u
#define PROFILES_FLAG_ALWAYS_EMAIL_ACKN 0x0200u
#define PROFILES_FLAG_ALT_DISPLAY_NAME 0x0400u
#define PROFILES_FLAG_APPLY_CONF_LOGIN 0x0800u
/* profile function error codes */
#define PROFILE_RETURN_ALLOK 0
#define PROFILE_RETURN_ALREADY_EXIST 1
#define PROFILE_RETURN_DB_ERROR 3
#define PROFILE_RETURN_INVALID_FORMAT 4
#define PROFILE_RETURN_INVALID_LOGIN 5
#define PROFILE_RETURN_INVALID_PASSWORD 6
#define PROFILE_RETURN_PASSWORD_SHORT 7
#define PROFILE_RETURN_UNKNOWN_ERROR 9
#define PROFILE_LOGIN_MIN_LENGTH 3
#define PROFILE_NO_NEXT_INDEX 0xFFFFFFFF
#define PROFILE_WASTED_FINFO_SIZE sizeof(SProfile_FullUserInfo) - sizeof(char*)
#define PROFILE_PERSONAL_MESSAGE_LENGTH 385
struct SPersonalMessage {
DWORD Prev;
DWORD PosterPrev;
char NameFrom[PROFILES_MAX_USERNAME_LENGTH];
DWORD UIdFrom;
char NameTo[PROFILES_MAX_USERNAME_LENGTH];
DWORD UIdTo;
time_t Date;
char Msg[PROFILE_PERSONAL_MESSAGE_LENGTH];
};
static_assert(sizeof(SPersonalMessage) == 472, "sizeof(SPersonalMessage) must be 472 (0x1D8)");
#pragma pack(push, 1)
struct SViewSettings
{
WORD dsm;
DWORD topics;
WORD tv;
WORD tc;
unsigned char ss:3;
unsigned char lsel:2;
unsigned char tt:4;
signed char tz:5;
unsigned char resrvd:2;
};
static_assert(sizeof(SViewSettings) == 12, "sizeof(SViewSettings) must be 12 (0xC)");
/* Full user information */
struct SProfile_FullUserInfo {
char FullName[PROFILES_FULL_USERINFO_MAX_NAME];
char Email[PROFILES_FULL_USERINFO_MAX_EMAIL];
char HomePage[PROFILES_FULL_USERINFO_MAX_HOMEPAGE];
char SelectedUsers[PROFILES_FULL_USERINFO_MAX_SELECTEDUSR];
char Signature[PROFILES_MAX_SIGNATURE_LENGTH];
time_t CreateDate;
// Here you can define additional parameters
// do not modify following 2 lines
DWORD size;
char *AboutUser;
~SProfile_FullUserInfo() {
free(this->AboutUser);
this->AboutUser = NULL;
}
};
static_assert(sizeof(SProfile_FullUserInfo) == 1032, "sizeof(SProfile_FullUserInfo) must be 1032 (0x408)");
/* Structure which keep information about user in profiles database */
struct SProfile_UserInfo {
/* Username, password */
char username[PROFILES_MAX_USERNAME_LENGTH];
char password[PROFILES_MAX_PASSWORD_LENGTH];
/* view settings */
SViewSettings vs;
char icqnumber[PROFILES_MAX_ICQ_LEN];
char altdisplayname[PROFILES_MAX_ALT_DISPLAY_NAME];
DWORD favs[PROFILES_FAV_THREADS_COUNT];
// count of refresh of this board
DWORD RefreshCount;
// recieved persmsg read count
WORD readpersmescnt;
// received persmsg current count
WORD persmescnt;
// posted persmsg count
WORD postedmescnt;
// personal message index (or 0xFFFFFFFF if does not exist)
DWORD persmsg;
// posted personal message index (or 0xFFFFFFFF)
DWORD postedpersmsg;
// user status
BYTE Status;
// Ip of last login
DWORD lastIP;
// This field is not used now.
// security level for message header
BYTE secheader;
BYTE align1[3];
// unique user identifier
DWORD UniqID;
// flags for user (ex: have picture... etc.)
DWORD Flags;
// This field is not used now.
// security level of user (for message body)
BYTE secur;
BYTE align2[3];
// right for user
DWORD right;
// number of posts to conference
DWORD postcount;
time_t LoginDate;
// index in profile bodies file of structure with common user information
DWORD FullInfo_ID;
};
static_assert(sizeof(SProfile_UserInfo) == 316, "sizeof(SProfile_UserInfo) must be 316 (0x13C)");
#pragma pack(pop)
class CProfiles {
protected:
WCFILE *Fp_i, // profiles index file
*Fp_b; // profiles body file
int ReadFullInfo(DWORD idx, SProfile_FullUserInfo *FI);
int WriteFullInfo(DWORD *idx, SProfile_FullUserInfo *FI);
int DeleteFullInfo(DWORD idx);
int GetSpaceforUInfo(DWORD *idx);
int WriteUInfo(DWORD idx, const SProfile_UserInfo *FI);
int DeleteUInfo(DWORD idx);
int ReadUInfo(DWORD idx, SProfile_UserInfo *FI);
public:
static bool IsLoginValid(const char *s);
int AddNewUser(SProfile_UserInfo *newprf, SProfile_FullUserInfo *FullUI, DWORD *ui_index);
int ModifyUser(SProfile_UserInfo *newprf, SProfile_FullUserInfo *FullUI, DWORD *ui_index);
int DeleteUser(const char *name);
int GetUserByName(const char *name, SProfile_UserInfo *ui, SProfile_FullUserInfo *Fui, DWORD *ui_index);
// personal messages
int PostPersonalMessage(const char *username, DWORD userindex, const char *message, const char *from, DWORD userindexfrom);
int ReadPersonalMessages(const char *username, DWORD userindex,
SPersonalMessage **tomessages, DWORD *tocount, SPersonalMessage **frommessages, DWORD *fromcount);
int ReadPersonalMessagesByDate(const char *username, DWORD userindex,
SPersonalMessage **tomessages, time_t todate, SPersonalMessage **frommessages, time_t fromdate);
int GenerateUserList(char ***buf, DWORD *cnt);
int GetUsersCount(DWORD *uc);
int GetUInfo(DWORD idx, SProfile_UserInfo *FI);
int SetUInfo(DWORD idx, const SProfile_UserInfo *FI);
int GetFullInfo(DWORD idx, SProfile_FullUserInfo *FI);
int CheckandAddFavsList(DWORD userindex, DWORD msgindex, int doadd);
int DelFavsList(DWORD userindex, DWORD msgindex);
};
#endif