3 * Nonblocking RFC931 client
5 * (c) 1999 Mark Wooding
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
12 * mLib is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * mLib is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
35 /*----- Header files ------------------------------------------------------*/
37 #include <sys/types.h>
38 #include <sys/socket.h>
39 #include <netinet/in.h>
40 #include <arpa/inet.h>
54 /*----- Data structures ---------------------------------------------------*/
56 /* --- Parsed response from ident server --- */
58 typedef struct ident_reply
{
59 unsigned short sport
, dport
; /* Source and destination ports */
60 unsigned type
; /* Type of reply from server */
63 char *os
; /* Operating system name */
64 char *user
; /* User name */
66 char *error
; /* Error message from server */
70 /* --- Response type codes --- */
78 /* --- Request structure --- */
80 typedef struct ident_request
{
81 struct sockaddr_in local
, remote
;
83 void (*func
)(ident_reply */
*i*/
, void */
*p*/
);
96 /*----- Functions provided ------------------------------------------------*/
98 /* --- @ident_abort@ --- *
100 * Arguments: @ident_request *rq@ = pointer to request block
104 * Use: Cancels an ident request in progress.
107 extern void ident_abort(ident_request */
*rq*/
);
111 * Arguments: @ident_request *rq@ = pointer to request block
112 * @sel_state *s@ = I/O multiplexor
113 * @const struct sockaddr_in *local, *remote@ = addresses
114 * @void (*func)(ident_reply *i, void *p)@ = handler function
115 * @void *p@ = argument for handler
119 * Use: Initializes an ident request.
122 extern void ident(ident_request */
*rq*/
, sel_state */
*s*/
,
123 const struct sockaddr_in */
*local*/
,
124 const struct sockaddr_in */
*remote*/
,
125 void (*/
*func*/
)(ident_reply */
*i*/
, void */
*p*/
),
128 /* --- @ident_socket@ --- *
130 * Arguments: @ident_request *rq@ = pointer to request block
131 * @sel_state *s@ = I/O multiplexor
132 * @int sk@ = connected socket file descriptor
133 * @void (*func)(ident_reply *i, void *p)@ = handler function
134 * @void *p@ = argument for handler
138 * Use: An alternative interface to @ident@. Initializes an ident
139 * request from a connected socket, rather than from an explicit
140 * address. This will call @getsockname@ and @getpeername@ to
141 * find out what the socket is actually connected to, which adds
142 * convenience but wastes time.
145 extern void ident_socket(ident_request */
*rq*/
, sel_state */
*s*/
, int /*sk*/,
146 void (*/
*func*/
)(ident_reply */
*i*/
, void */
*p*/
),
149 /*----- That's all, folks -------------------------------------------------*/