summaryrefslogtreecommitdiffstats
path: root/c/src/libnetworking/rtems_webserver/um.h
blob: bdef4906fe7d59bce9812c12ee81dbc18e55e588 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
 *	um.h -- GoAhead User Management public header
 *
 *	Copyright (c) GoAhead Software Inc., 1992-2000. All Rights Reserved.
 *
 *	See the file "license.txt" for information on usage and redistribution
 *
 * $Id$
 */

#ifndef _h_UM
#define _h_UM 1

/******************************** Description *********************************/

/*
 *	GoAhead User Management header. This defines the User Management
 *	public APIs.  Include this header for files that contain access to
 *	user inquiry or management.
 */

/********************************* Includes ***********************************/

#ifndef UEMF
	#include	"basic/basic.h"
	#include	"emf/emf.h"
#else
	#include	"uemf.h"
#endif

/********************************** Defines ***********************************/

/*
 *	Error Return Flags
 */
#define UM_OK				0
#define UM_ERR_GENERAL		-1
#define UM_ERR_NOT_FOUND	-2
#define UM_ERR_PROTECTED	-3
#define UM_ERR_DUPLICATE	-4
#define UM_ERR_IN_USE		-5
#define UM_ERR_BAD_NAME		-6
#define UM_ERR_BAD_PASSWORD -7

/*
 *	Privilege Masks
 */
#define PRIV_NONE	0x00
#define PRIV_READ	0x01
#define PRIV_WRITE	0x02
#define PRIV_ADMIN	0x04

/*
 *	User classes
 */
typedef short bool_t;

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

typedef enum {
	AM_NONE = 0,
	AM_FULL,
	AM_BASIC,
	AM_DIGEST,
	AM_INVALID
} accessMeth_t;

/********************************** Prototypes ********************************/

/*
 *	umOpen() must be called before accessing User Management functions
 */
extern int				umOpen();

/*
 *	umClose() should be called before shutdown to free memory
 */
extern void				umClose();

/*
 *	umCommit() persists the user management database
 */
extern int				umCommit(char_t *filename);

/*
 *	umRestore() loads the user management database
 */
extern int				umRestore(char_t *filename);

/*
 *	umUser functions use a user ID for a key
 */
extern int				umAddUser(char_t *user, char_t *password,
							char_t *group, bool_t protect, bool_t disabled);

extern int				umDeleteUser(char_t *user);

extern char_t			*umGetFirstUser();
extern char_t			*umGetNextUser(char_t *lastUser);

extern bool_t			umUserExists(char_t *user);

extern char_t			*umGetUserPassword(char_t *user);
extern int				umSetUserPassword(char_t *user, char_t *password);

extern char_t			*umGetUserGroup(char_t *user);
extern int				umSetUserGroup(char_t *user, char_t *password);

extern bool_t			umGetUserEnabled(char_t *user);
extern int				umSetUserEnabled(char_t *user, bool_t enabled);

extern bool_t			umGetUserProtected(char_t *user);
extern int				umSetUserProtected(char_t *user, bool_t protect);

/*
 *	umGroup functions use a group name for a key
 */
extern int				umAddGroup(char_t *group, short privilege,
							accessMeth_t am, bool_t protect, bool_t disabled);

extern int				umDeleteGroup(char_t *group);

extern char_t 			*umGetFirstGroup();
extern char_t			*umGetNextGroup(char_t *lastUser);

extern bool_t			umGroupExists(char_t *group);
extern bool_t			umGetGroupInUse(char_t *group);

extern accessMeth_t		umGetGroupAccessMethod(char_t *group);
extern int				umSetGroupAccessMethod(char_t *group, accessMeth_t am);

extern bool_t			umGetGroupEnabled(char_t *group);
extern int				umSetGroupEnabled(char_t *group, bool_t enabled);

extern short			umGetGroupPrivilege(char_t *group);
extern int				umSetGroupPrivilege(char_t *group, short privileges);

extern bool_t			umGetGroupProtected(char_t *group);
extern int				umSetGroupProtected(char_t *group, bool_t protect);

/*
 *	umAccessLimit functions use a URL as a key
 */
extern int			umAddAccessLimit(char_t *url, accessMeth_t am,
						short secure, char_t *group);

extern int			umDeleteAccessLimit(char_t *url);

extern char_t		*umGetFirstAccessLimit();
extern char_t		*umGetNextAccessLimit(char_t *lastUser);

/*
 *	Returns the name of an ancestor access limit if
 */
extern char_t		*umGetAccessLimit(char_t *url);

extern bool_t		umAccessLimitExists(char_t *url);

extern accessMeth_t	umGetAccessLimitMethod(char_t *url);
extern int			umSetAccessLimitMethod(char_t *url, accessMeth_t am);

extern short		umGetAccessLimitSecure(char_t *url);
extern int			umSetAccessLimitSecure(char_t *url, short secure);

extern char_t		*umGetAccessLimitGroup(char_t *url);
extern int			umSetAccessLimitGroup(char_t *url, char_t *group);

/*
 *	Convenience Functions
 */

extern accessMeth_t	umGetAccessMethodForURL(char_t *url);
extern bool_t		umUserCanAccessURL(char_t *user, char_t *url);

#endif /* _h_UM */

/******************************************************************************/