9abbe3fd81c3f2e376c966a4d8d413dae8285b57
3 * $Id: class.h,v 1.2 1997/08/04 10:24:21 mdw Exp $
5 * Handling classes of things nicely
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of `become'
14 * `Become' is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * `Become' is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with `become'; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /*----- Revision history --------------------------------------------------*
32 * Revision 1.2 1997/08/04 10:24:21 mdw
33 * Sources placed under CVS control.
35 * Revision 1.1 1997/07/21 13:47:52 mdw
47 /*----- Required headers --------------------------------------------------*/
49 #include <sys/types.h>
50 #include <sys/socket.h>
51 #include <netinet/in.h>
52 #include <arpa/inet.h>
58 /*----- Data structures ---------------------------------------------------*/
60 /* --- Class types --- */
63 clType_user
= 1, /* Class of users */
64 clType_command
= 2, /* Class of command strings */
65 clType_host
= 4, /* Class of host names */
66 clType_all
= 7, /* All of the above (maintain me) */
67 clType__limit
/* First undefined class type */
70 /* --- Class block --- */
72 typedef struct classdef
{
73 unsigned type
; /* Type of this class */
74 unsigned ref
; /* Reference count */
75 sym_table
*t
; /* Symbol table for this class */
78 /*----- Global variables --------------------------------------------------*/
80 extern classdef
*class_all
; /* The match-everything class */
82 /*----- Functions provided ------------------------------------------------*/
84 /* --- @class_create@ --- *
86 * Arguments: @unsigned type@ = type of the class to create
87 * @sym_table *t@ = pointer to symbol table which stores info
89 * Returns: Pointer to a @classdef@ which maintains the class's info.
91 * Use: Creates a new class definition. The new definition has one
92 * reference attached to it (which is the one you get returned).
95 extern classdef
*class_create(unsigned /*type*/, sym_table */
*t*/
);
97 /* --- @class_inc@ --- *
99 * Arguments: @classdef *c@ = pointer to a class block
103 * Use: Adds a reference to the class definition.
106 extern void class_inc(classdef */
*c*/
);
108 /* --- @class_dec@ --- *
110 * Arguments: @classdef *c@ = pointer to a class block
114 * Use: Removes a reference to a class block.
117 extern void class_dec(classdef */
*c*/
);
119 /* --- @class_userMatch@ --- *
121 * Arguments: @classdef *c@ = pointer to a class block
122 * @int u@ = uid number to check against
124 * Returns: Zero if no match, nonzero if it matched.
126 * Use: Looks to see if a user is in a group.
129 extern int class_userMatch(classdef */
*c*/
, int /*u*/);
131 /* --- @class_commandMatch@ --- *
133 * Arguments: @classdef *c@ = pointer to a class block
134 * @const char *p@ = pointer to command string to match
136 * Returns: Zero for no match, nonzero if it matched.
138 * Use: Tries to match a string against the wildcard patterns in the
139 * given class. Note that this involves examining all the
140 * items, so it's not too quick. Then again, you don't have
141 * big command classes, do you...?
144 extern int class_commandMatch(classdef */
*c*/
, const char */
*p*/
);
146 /* --- @class_hostMatch@ --- *
148 * Arguments: @classdef *c@ = pointer to class block
149 * @struct in_addr addr@ = IP address to match
151 * Returns: Zero for no match, nonzero if it matched.
153 * Use: Tries to match an IP address against the patterns and masks
154 * in the given class.
157 extern int class_hostMatch(classdef */
*c*/
, struct in_addr
/*addr*/);
159 /* --- @class_dump@ --- *
161 * Arguments: @classdef *c@ = pointer to a class block
165 * Use: Dumps the contents of a class to a stream.
168 extern void class_dump(classdef */
*c*/
);
170 /*----- That's all, folks -------------------------------------------------*/