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