Fixed HTTP-client query-string handling bug.
[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 #include "net.h"
25
26 #define AUTH_SUCCESS 0  /* Authentication successful and done */
27 #define AUTH_DENIED 1   /* Ultimately failed - reason in handle->text */
28 #define AUTH_PASS 2     /* Pass data - look in handle->prompt */
29 #define AUTH_ERR 3      /* An error occurred that */
30
31 #define AUTH_PR_AUTO 0
32 #define AUTH_PR_NOECHO 1
33 #define AUTH_PR_ECHO 2
34 #define AUTH_PR_INFO 3
35 #define AUTH_PR_ERROR 4
36
37 struct authhandle;
38
39 struct authmech
40 {
41     struct authmech *next;
42     int enabled;
43     wchar_t *name;
44     int (*inithandle)(struct authhandle *handle, char *username);
45     void (*release)(struct authhandle *handle);
46     int (*authenticate)(struct authhandle *handle, struct socket *sk, char *data);
47     int (*renewcred)(struct authhandle *handle);
48     int (*opensess)(struct authhandle *handle);
49     int (*closesess)(struct authhandle *handle);
50     int (*available)(struct socket *sk);
51 };
52
53 struct authhandle
54 {
55     int refcount;
56     struct authmech *mech;
57     int prompt;
58     wchar_t *text;
59     void *mechdata;
60 };
61
62 int authenticate(struct authhandle *handle, struct socket *sk, char *data);
63 struct authhandle *initauth(wchar_t *mechname, char *username);
64 void authgethandle(struct authhandle *auth);
65 void authputhandle(struct authhandle *auth);
66 int authrenewcred(struct authhandle *handle);
67 int authopensess(struct authhandle *handle);
68 int authclosesess(struct authhandle *handle);
69 void regmech(struct authmech *mech);
70 int authavailable(struct authmech *mech, struct socket *sk);
71
72 extern struct authmech *mechs;
73
74 #endif