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