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