Updated the CtdlUserGoto() API call to also return the oldest and newest message...
[citadel.git] / citadel / user_ops.h
1 #ifndef __USER_OPS_H__
2 #define __USER_OPS_H__
3
4 #include <ctype.h>
5 #include <syslog.h>
6
7 int hash (char *str);
8 /* getuser is deprecated, use CtdlGetUser instead */
9 int getuser (struct ctdluser *, char *) __attribute__ ((deprecated));
10 /* lgetuser is deprecated, use CtdlGetUserLock instead */
11 int lgetuser (struct ctdluser *, char *) __attribute__ ((deprecated));
12 /* putuser is deprecated, use CtdlPutUser instead */
13 void putuser (struct ctdluser *) __attribute__ ((deprecated));
14 /* lputuser is deprecated, use CtdlPutUserLock instead */
15 void lputuser (struct ctdluser *) __attribute__ ((deprecated));
16 int is_aide (void);
17 int is_room_aide (void);
18 int CtdlCheckInternetMailPermission(struct ctdluser *who);
19 /* getuserbynumber is deprecated, use CtdlGetUserByNumber instead */
20 int getuserbynumber (struct ctdluser *usbuf, long int number) __attribute__ ((deprecated));
21 void rebuild_usersbynumber(void);
22 void session_startup (void);
23 void logged_in_response(void);
24 int purge_user (char *pname);
25 int create_user (const char *newusername, long len, int become_user);
26 void do_login(void);
27 int CtdlInvtKick(char *iuser, int op);
28 void ForEachUser(void (*CallBack)(struct ctdluser *EachUser, void *out_data),
29         void *in_data);
30 void ListThisUser(struct ctdluser *usbuf, void *data);
31 int NewMailCount(void);
32 int InitialMailCheck(void);
33 void put_visit(visit *newvisit);
34 /* MailboxName is deprecated us CtdlMailboxName instead */
35 void MailboxName(char *buf, size_t n, const struct ctdluser *who,
36                  const char *prefix) __attribute__ ((deprecated));
37 int GenerateRelationshipIndex(  char *IndexBuf,
38                                 long RoomID,
39                                 long RoomGen,
40                                 long UserID);
41 int CtdlAssociateSystemUser(char *screenname, char *loginname);
42
43
44
45
46 void CtdlSetPassword(char *new_pw);
47
48 int CtdlForgetThisRoom(void);
49
50 void cmd_newu (char *cmdbuf);
51 void start_chkpwd_daemon(void);
52
53
54 #define RENAMEUSER_OK                   0       /* Operation succeeded */
55 #define RENAMEUSER_LOGGED_IN            1       /* Cannot rename a user who is currently logged in */
56 #define RENAMEUSER_NOT_FOUND            2       /* The old user name does not exist */
57 #define RENAMEUSER_ALREADY_EXISTS       3       /* An account with the desired new name already exists */
58
59 int rename_user(char *oldname, char *newname);
60
61 ///#ifndef CTDL_INLINE_USR
62 ////#define CTDL_INLINE_USR static INLINE
63 ///#endif
64
65 ///CTDL_INLINE_USR 
66 static INLINE long cutuserkey(char *username) { 
67         long len;
68         len = strlen(username);
69         if (len >= USERNAME_SIZE)
70         {
71                 syslog(LOG_INFO, "Username too long: %s", username);
72                 cit_backtrace ();
73                 len = USERNAME_SIZE - 1; 
74                 username[len]='\0';
75         }
76         return len;
77 }
78
79 /*
80  * makeuserkey() - convert a username into the format used as a database key
81  *               (it's just the username converted into lower case)
82  */
83 ///CTDL_INLINE_USR 
84 static INLINE void makeuserkey(char *key, const char *username, long len) {
85         int i;
86
87         if (len >= USERNAME_SIZE)
88         {
89                 syslog(LOG_INFO, "Username too long: %s", username);
90                 cit_backtrace ();
91                 len = USERNAME_SIZE - 1; 
92         }
93         for (i=0; i<=len; ++i) {
94                 key[i] = tolower(username[i]);
95         }
96 }
97
98
99 int internal_create_user (const char *username, long len, struct ctdluser *usbuf, uid_t uid);
100
101 #endif