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