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