Transfer from CVS at SourceForge
[doldaconnect.git] / daemon / auth.h
1 /*
2  *  Dolda Connect - Modular multiuser Direct Connect-style client
3  *  Copyright (C) 2004 Fredrik Tolf (fredrik@dolda2000.com)
4  *  
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *  
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *  
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19 #ifndef _AUTH_H
20 #define _AUTH_H
21
22 #include <wchar.h>
23
24 #define AUTH_SUCCESS 0  /* Authentication successful and done */
25 #define AUTH_DENIED 1   /* Ultimately failed - reason in handle->text */
26 #define AUTH_PASS 2     /* Pass data - look in handle->prompt */
27 #define AUTH_ERR 3      /* An error occurred that */
28
29 #define AUTH_PR_AUTO 0
30 #define AUTH_PR_NOECHO 1
31 #define AUTH_PR_ECHO 2
32 #define AUTH_PR_INFO 3
33 #define AUTH_PR_ERROR 4
34
35 struct authhandle;
36
37 struct authmech
38 {
39     struct authmech *next;
40     int enabled;
41     wchar_t *name;
42     int (*inithandle)(struct authhandle *handle, char *username);
43     void (*release)(struct authhandle *handle);
44     int (*authenticate)(struct authhandle *handle, char *data);
45     int (*renewcred)(struct authhandle *handle);
46     int (*opensess)(struct authhandle *handle);
47     int (*closesess)(struct authhandle *handle);
48 };
49
50 struct authhandle
51 {
52     int refcount;
53     struct authmech *mech;
54     int prompt;
55     wchar_t *text;
56     void *mechdata;
57 };
58
59 int authenticate(struct authhandle *handle, char *data);
60 struct authhandle *initauth(wchar_t *mechname, char *username);
61 void authgethandle(struct authhandle *auth);
62 void authputhandle(struct authhandle *auth);
63 int authrenewcred(struct authhandle *handle);
64 int authopensess(struct authhandle *handle);
65 int authclosesess(struct authhandle *handle);
66 void regmech(struct authmech *mech);
67
68 extern struct authmech *mechs;
69
70 #endif