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