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