Author: Bleep <tomh@inxpress.net>
[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 #ifndef INCLUDED_config_h
27 #include "config.h"
28 #endif
29
30 struct Client;
31
32 struct AuthRequest {
33   struct AuthRequest* next;      /* linked list node ptr */
34   struct AuthRequest* prev;      /* linked list node ptr */
35   struct Client*      client;    /* pointer to client struct for request */
36   unsigned int        flags;     /* current state of request */
37   int                 fd;        /* file descriptor for auth queries */
38   int                 index;     /* select / poll index */
39   time_t              timeout;   /* time when query expires */
40 };
41
42 /*
43  * flag values for AuthRequest
44  * NAMESPACE: AM_xxx - Authentication Module
45  */
46 #define AM_AUTH_CONNECTING   0x01
47 #define AM_AUTH_PENDING      0x02
48 #define AM_DNS_PENDING       0x04
49
50 #define SetDNSPending(x)     ((x)->flags |= AM_DNS_PENDING)
51 #define ClearDNSPending(x)   ((x)->flags &= ~AM_DNS_PENDING)
52 #define IsDNSPending(x)      ((x)->flags &  AM_DNS_PENDING)
53
54 #define SetAuthConnect(x)    ((x)->flags |= AM_AUTH_CONNECTING)
55 #define ClearAuthConnect(x)  ((x)->flags &= ~AM_AUTH_CONNECTING)
56 #define IsAuthConnect(x)     ((x)->flags &  AM_AUTH_CONNECTING)
57
58 #define SetAuthPending(x)    ((x)->flags |= AM_AUTH_PENDING)
59 #define ClearAuthPending(x)  ((x)->flags &= AM_AUTH_PENDING)
60 #define IsAuthPending(x)     ((x)->flags &  AM_AUTH_PENDING)
61
62 #define ClearAuth(x)         ((x)->flags &= ~(AM_AUTH_PENDING | AM_AUTH_CONNECTING))
63 #define IsDoingAuth(x)       ((x)->flags &  (AM_AUTH_PENDING | AM_AUTH_CONNECTING))
64
65
66 extern struct AuthRequest* AuthPollList; /* GLOBAL - auth queries pending io */
67
68 extern void start_auth(struct Client *);
69 extern void timeout_auth_queries(time_t now);
70 extern void read_auth_reply(struct AuthRequest* req);
71 extern void send_auth_query(struct AuthRequest* req);
72 extern void remove_auth_request(struct AuthRequest *req);
73
74 #endif /* INCLUDED_s_auth_h */
75