]> git.sur5r.net Git - openldap/blob - clients/ud/ud.h
Merge in all devel changes since 2.0-alpha2.
[openldap] / clients / ud / ud.h
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted only
7  * as authorized by the OpenLDAP Public License.  A copy of this
8  * license is available at http://www.OpenLDAP.org/license.html or
9  * in file LICENSE in the top-level directory of the distribution.
10  */
11 /*
12  * Copyright (c) 1991, 1992, 1993 
13  * Regents of the University of Michigan.  All rights reserved.
14  *
15  * Redistribution and use in source and binary forms are permitted
16  * provided that this notice is preserved and that due credit is given
17  * to the University of Michigan at Ann Arbor. The name of the University
18  * may not be used to endorse or promote products derived from this
19  * software without specific prior written permission. This software
20  * is provided ``as is'' without express or implied warranty.
21  */
22
23 #define MAX_VALUES      1000
24
25 /*****************************************************************************
26  **
27  **             Limits which ud imposes.  Also subject to change.
28  **
29  *****************************************************************************/
30  
31 /*
32  *  Names are parsed somewhat like 'awk' parses them.  This is the
33  *  maximum number of components we store away.
34  *
35  *  The isnamesepartor() macro should return TRUE if x is equal to one of the
36  *  characters that delimits name fields.  The ignorechar() macro should
37  *  return TRUE if it is equal to a character that should be ignored when
38  *  parsing names.
39  */
40 #define MAX_NAME_COMPS          8
41 #define isnamesepartor(x)       (isspace((unsigned char) (x)))
42 #define isignorechar(x)         (((x) == '.') || ((x) == '_'))
43
44 /*
45  *  Quite often a search will turn up more than one match.  When it does we
46  *  print out a list of the matches, and ask the user to select the one that
47  *  s/he wants.  This defines how many we will save and show.
48  */
49 #define MAX_NUM_NAMES           128
50
51 /*
52  *  When a user displays a group, we will automatically print out this many
53  *  members and subscribers.  If the number is greater than this, we will
54  *  prompt the user before printing them.
55  */
56 #define TOO_MANY_TO_PRINT       16
57
58 /*
59  *  This is the default size of a tty if we can't figure out the actual size.
60  */
61 #define DEFAULT_TTY_HEIGHT      24
62 #define DEFAULT_TTY_WIDTH       80
63
64 /*
65  *  The number of attributes we know about must be less than this number.
66  *  Don't add lots of attributes to the list in globals.c without checking
67  *  this number too.
68  */
69 #define MAX_ATTRS       64
70
71 /*****************************************************************************
72  **
73  **             No user servicable parts beyond this point.
74  **
75  *****************************************************************************/
76
77 /*
78  *  Generic buffer sizes.
79  */
80 #define SMALL_BUF_SIZE           16
81 #define MED_BUF_SIZE            128
82 #define LARGE_BUF_SIZE          512
83
84 /*
85  *  Used to specify the operation in x_group().
86  */
87 #define G_JOIN          0
88 #define G_RESIGN        1
89
90 /*
91  *  Authentication method we will be using.
92  */
93 #ifdef HAVE_KERBEROS
94 #define UD_AUTH_METHOD          LDAP_AUTH_KRBV4
95 #else
96 #define UD_AUTH_METHOD          LDAP_AUTH_SIMPLE
97 #endif
98
99 /*
100  *  TRUE and FALSE - just in case we need them.
101  */
102 #ifndef TRUE
103 #define TRUE  1
104 #define FALSE 0
105 #endif
106
107 /*
108  *  Bound status.
109  */
110 #define UD_NOT_BOUND    0       /* bound only as the default defined above */
111 #define UD_BOUND        1       /* bound as an actual Directory entity */
112
113 /* 
114  *  Debug masks.
115  */
116 #define D_TRACE         0x0001
117 #define D_FIND          0x0002
118 #define D_GROUPS        0x0004
119 #define D_MODIFY        0x0008
120 #define D_PARSE         0x0010
121 #define D_PRINT         0x0020
122 #define D_AUTHENTICAT   0x0040
123 #define D_INITIALIZE    0x0080
124
125 /*
126  *  Used in the flags field of an attribute structure.
127  */
128 #define ATTR_FLAG_NONE          0x0000
129 #define ATTR_FLAG_PERSON        0x0001
130 #define ATTR_FLAG_GROUP         0x0002
131 #define ATTR_FLAG_PERSON_MOD    0x0010
132 #define ATTR_FLAG_GROUP_MOD     0x0020
133 #define ATTR_FLAG_MAY_EDIT      0x0040
134 #define ATTR_FLAG_SEARCH        0x0100
135 #define ATTR_FLAG_READ          0x0200
136 #define ATTR_FLAG_IS_A_DATE     0x0800
137 #define ATTR_FLAG_IS_A_DN       0x1000
138 #define ATTR_FLAG_IS_A_URL      0x2000
139 #define ATTR_FLAG_IS_A_BOOL     0x4000
140 #define ATTR_FLAG_IS_MULTILINE  0x8000
141
142 LDAP_BEGIN_DECL
143
144 /*
145  *  These are the structures we use when parsing an answer we get from the LDAP
146  *  server.
147  */
148 struct attribute {
149         char *quipu_name;
150         char *output_string;
151         void (*mod_func) LDAP_P(( char *who, int attr_idx ));
152         unsigned short flags;
153         int number_of_values;
154         char **values;
155 };
156
157 struct entry {
158         char may_join;
159         int  subscriber_count;
160         char *DN;
161         char *name;
162         struct attribute attrs[MAX_ATTRS];
163 };
164
165
166
167 /*
168  * Variables
169  */
170
171 /* in globals.c: */
172 extern struct attribute attrlist[];/* complete list of attrs */
173 /* in main.c: */
174 extern char copyright[];
175 extern char *default_bind_object;
176 extern char *bound_dn;
177 extern char *group_base;
178 extern char *search_base;       /* search base */
179 extern int lpp;
180 extern int verbose;             /* verbose mode flag */
181 extern int col_size;
182 extern int bind_status;
183 extern LDAP *ld;                /* our ldap descriptor */
184 extern LDAPFiltDesc *lfdp;      /* LDAP filter descriptor */
185 #ifdef DEBUG
186 extern int debug;               /* debug flag */
187 #endif
188 /* in print.c: */
189 extern struct entry Entry;
190 extern int      dmsize[];
191 /* in version.c: */
192 extern char Version[];
193
194
195 /*
196  * Functions
197  */
198
199 /* in auth.c: */
200 int  auth       LDAP_P(( char *who, int implicit ));
201 #if defined(HAVE_KERBEROS) && defined(_AC_KRB_H)
202 int  krbgetpass LDAP_P(( char *u, char *in, char *re, char *pw, C_Block key ));
203 void destroy_tickets LDAP_P(( void ));
204 #endif
205
206 /* in edit.c: */
207 void edit       LDAP_P(( char *who ));
208
209 /* in find.c: */
210 int  vrfy       LDAP_P(( char *dn ));
211 LDAPMessage *find       LDAP_P(( char *who, int quiet ));
212 int  pick_one   LDAP_P(( int i ));
213 void print_list LDAP_P(( LDAPMessage *list, char **names, int *matches ));
214 int  find_all_subscribers       LDAP_P(( char **sub, char *group ));
215 char *fetch_boolean_value       LDAP_P(( char *who, struct attribute attr ));
216
217 /* in globals.c: */
218
219 /* in group.c: */
220 void add_group  LDAP_P(( char *name ));
221 void remove_group       LDAP_P(( char *name ));
222 void x_group    LDAP_P(( int action, char *name ));
223 void bulk_load  LDAP_P(( char *group ));
224 void purge_group        LDAP_P(( char *group ));
225 void tidy_up    LDAP_P(( void ));
226 void mod_addrDN LDAP_P(( char *group, int offset ));
227 int  my_ldap_modify_s   LDAP_P(( LDAP *ldap, char *group, LDAPMod **mods ));
228 void list_groups        LDAP_P(( char *who ));
229 void list_memberships   LDAP_P(( char *who ));
230
231 /* in help.c: */
232 void print_help LDAP_P(( char *s ));
233
234 /* in main.c: */
235 #ifdef DEBUG
236 #endif
237
238 void do_commands        LDAP_P(( void )) LDAP_GCCATTR((noreturn));
239 void status     LDAP_P(( void ));
240 void change_base        LDAP_P(( int type, char **base, char *s ));
241 void initialize_client  LDAP_P(( void ));
242 RETSIGTYPE  attn        LDAP_P(( int sig ));
243 #if !defined(NO_TERMCAP) && defined(TIOCGWINSZ)
244 RETSIGTYPE  chwinsz     LDAP_P(( int sig ));
245 #endif
246
247 /* in mod.c: */
248 void modify     LDAP_P(( char *who ));
249 void change_field       LDAP_P(( char *who, int attr_idx ));
250 char *get_value LDAP_P(( char *id, char *prompt ));
251 void set_boolean        LDAP_P(( char *who, int attr_idx ));
252 #ifdef UOFM
253 void set_updates        LDAP_P(( char *who, int dummy ));
254 #endif
255 void print_mod_list     LDAP_P(( int group ));
256 int  perform_action     LDAP_P(( char *choice, char *dn, int group ));
257 void mod_perror LDAP_P(( LDAP *ld ));
258
259 /* in print.c: */
260 void parse_answer       LDAP_P(( LDAPMessage *s ));
261 void add_value  LDAP_P(( struct attribute *attr, LDAPMessage *ep, char *ap ));
262 void print_an_entry     LDAP_P(( void ));
263 void print_values       LDAP_P(( struct attribute A ));
264 void print_DN   LDAP_P(( struct attribute A ));
265 void clear_entry        LDAP_P(( void ));
266 int  attr_to_index      LDAP_P(( char *s ));
267 void initialize_attribute_strings       LDAP_P(( void ));
268 void print_URL  LDAP_P(( struct attribute A ));
269 void print_one_URL      LDAP_P(( char *s, int l_lead, char *tag, int u_lead ));
270
271 /* in string_to_key.c: */
272 #if defined(HAVE_KERBEROS) && !defined(openbsd) && defined(_AC_KRB_H)
273 #if defined(HAVE_AFS_KERBEROS) || !defined(HAVE_KERBEROS_V)
274 void  des_string_to_key LDAP_P(( char *str, des_cblock *key ));
275 #endif
276 #if defined(HAVE_AFS_KERBEROS)
277 void ka_StringToKey LDAP_P(( char *str, char *cell, des_cblock *key ));
278 #endif
279 #endif
280
281 /* in util.c: */
282 void printbase  LDAP_P(( char *lead, char *s ));
283 void fetch_buffer       LDAP_P(( char *buffer, int length, FILE *where ));
284 void fatal      LDAP_P(( char *s )) LDAP_GCCATTR((noreturn));
285 int  isgroup    LDAP_P(( void ));
286 void format     LDAP_P(( char *str, int width, int lead ));
287 void format2    LDAP_P(( char *s, char *ft, char *t, int fi, int i, int w ));
288 char *strip_ignore_chars        LDAP_P(( char *cp ));
289 char *code_to_str       LDAP_P(( int i ));
290 char *friendly_name     LDAP_P(( char *s ));
291 #ifdef UOFM
292 int  isauniqname        LDAP_P(( char *s ));
293 #endif
294 int  isadn      LDAP_P(( char *s ));
295 char *my_ldap_dn2ufn    LDAP_P(( char *s ));
296 int  isaurl     LDAP_P(( char *s ));
297 int  isadate    LDAP_P(( char *s ));
298 void *Malloc    LDAP_P(( unsigned int size ));
299 void Free       LDAP_P(( void *ptr ));
300 char *nextstr   LDAP_P(( char *s ));
301 void free_mod_struct    LDAP_P(( LDAPMod *modp ));
302 void StrFreeDup LDAP_P(( char **ptr, char *new_value ));
303 int  confirm_action     LDAP_P(( char *msg ));
304
305 LDAP_END_DECL