0b03355e93d13d82f978c5a3ec631e4028e917c6
[ircu2.10.12-pk.git] / include / s_auth.h
1 /************************************************************************
2  *   IRC - Internet Relay Chat, include/s_auth.h
3  *
4  *   This program is free software; you can redistribute it and/or modify
5  *   it under the terms of the GNU General Public License as published by
6  *   the Free Software Foundation; either version 1, or (at your option)
7  *   any later version.
8  *
9  *   This program is distributed in the hope that it will be useful,
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *   GNU General Public License for more details.
13  *
14  *   You should have received a copy of the GNU General Public License
15  *   along with this program; if not, write to the Free Software
16  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  *
18  *   $Id$
19  */
20 #ifndef INCLUDED_s_auth_h
21 #define INCLUDED_s_auth_h
22 #ifndef INCLUDED_sys_types_h
23 #include <sys/types.h>
24 #define INCLUDED_sys_types_h
25 #endif
26
27 struct Client;
28
29 struct AuthRequest {
30   struct AuthRequest* next;      /* linked list node ptr */
31   struct AuthRequest* prev;      /* linked list node ptr */
32   struct Client*      client;    /* pointer to client struct for request */
33   unsigned int        flags;     /* current state of request */
34   int                 fd;        /* file descriptor for auth queries */
35   int                 index;     /* select / poll index */
36   time_t              timeout;   /* time when query expires */
37 };
38
39 /*
40  * flag values for AuthRequest
41  * NAMESPACE: AM_xxx - Authentication Module
42  */
43 #define AM_AUTH_CONNECTING   0x01
44 #define AM_AUTH_PENDING      0x02
45 #define AM_DNS_PENDING       0x04
46
47 #define SetDNSPending(x)     ((x)->flags |= AM_DNS_PENDING)
48 #define ClearDNSPending(x)   ((x)->flags &= ~AM_DNS_PENDING)
49 #define IsDNSPending(x)      ((x)->flags &  AM_DNS_PENDING)
50
51 #define SetAuthConnect(x)    ((x)->flags |= AM_AUTH_CONNECTING)
52 #define ClearAuthConnect(x)  ((x)->flags &= ~AM_AUTH_CONNECTING)
53 #define IsAuthConnect(x)     ((x)->flags &  AM_AUTH_CONNECTING)
54
55 #define SetAuthPending(x)    ((x)->flags |= AM_AUTH_PENDING)
56 #define ClearAuthPending(x)  ((x)->flags &= AM_AUTH_PENDING)
57 #define IsAuthPending(x)     ((x)->flags &  AM_AUTH_PENDING)
58
59 #define ClearAuth(x)         ((x)->flags &= ~(AM_AUTH_PENDING | AM_AUTH_CONNECTING))
60 #define IsDoingAuth(x)       ((x)->flags &  (AM_AUTH_PENDING | AM_AUTH_CONNECTING))
61
62
63 extern struct AuthRequest* AuthPollList; /* GLOBAL - auth queries pending io */
64
65 extern void start_auth(struct Client *);
66 extern void timeout_auth_queries(time_t now);
67 extern void read_auth_reply(struct AuthRequest* req);
68 extern void send_auth_query(struct AuthRequest* req);
69 extern void remove_auth_request(struct AuthRequest *req);
70
71 #endif /* INCLUDED_s_auth_h */
72