]> git.sur5r.net Git - openldap/blob - servers/slapd/shell-backends/shellutil.h
7f51500d35844ba2b28415dc60502a4d5e8ee05f
[openldap] / servers / slapd / shell-backends / shellutil.h
1 /*
2  shellutil.h
3
4  Copyright (c) 1995 Regents of the University of Michigan.
5  All rights reserved.
6
7  Redistribution and use in source and binary forms are permitted
8  provided that this notice is preserved and that due credit is given
9  to the University of Michigan at Ann Arbor. The name of the University
10  may not be used to endorse or promote products derived from this
11  software without specific prior written permission. This software
12  is provided ``as is'' without express or implied warranty.
13 */
14
15 #ifndef SHELLUTIL_H
16 #define SHELLUTIL_H
17
18 #include <ldap_cdefs.h>
19
20 LDAP_BEGIN_DECL
21
22 #define MAXLINELEN      512
23
24 #define STR_OP_SEARCH   "SEARCH"
25
26
27 struct inputparams {
28     int         ip_type;
29 #define IP_TYPE_SUFFIX          0x01
30 #define IP_TYPE_BASE            0x02
31 #define IP_TYPE_SCOPE           0x03
32 #define IP_TYPE_ALIASDEREF      0x04
33 #define IP_TYPE_SIZELIMIT       0x05
34 #define IP_TYPE_TIMELIMIT       0x06
35 #define IP_TYPE_FILTER          0x07
36 #define IP_TYPE_ATTRSONLY       0x08
37 #define IP_TYPE_ATTRS           0x09
38     char        *ip_tag;
39 };
40
41
42 struct ldsrchparms {
43     int         ldsp_scope;
44     int         ldsp_aliasderef;
45     int         ldsp_sizelimit;
46     int         ldsp_timelimit;
47     int         ldsp_attrsonly;
48     char        *ldsp_filter;
49     char        **ldsp_attrs;
50 };
51
52
53 struct ldop { 
54     int         ldop_op;
55 #define LDOP_SEARCH     0x01
56     char        **ldop_suffixes;
57     char        *ldop_dn;
58     union {
59                     struct ldsrchparms LDsrchparams;
60           }     ldop_params;
61 #define ldop_srch       ldop_params.LDsrchparams
62 };
63
64
65 struct ldattr {
66     char        *lda_name;
67     char        **lda_values;
68 };
69
70
71 struct ldentry {
72     char                *lde_dn;
73     struct ldattr       **lde_attrs;
74 };
75
76
77 #ifdef LDAP_DEBUG
78 void debug_printf LDAP_P((char *, ...));
79 #else /* LDAP_DEBUG */
80 #define debug_printf()
81 #endif /* LDAP_DEBUG */
82
83 /*
84  * function prototypes
85  */
86 void write_result( FILE *fp, int code, char *matched, char *info );
87 void write_entry( struct ldop *op, struct ldentry *entry, FILE *ofp );
88 int test_filter( struct ldop *op, struct ldentry *entry );
89 void free_entry( struct ldentry *entry );
90 int attr_requested( char *name, struct ldop *op );
91 int parse_input( FILE *ifp, FILE *ofp, struct ldop *op );
92 struct inputparams *find_input_tag( char **linep );
93 void add_strval( char ***sp, char *val );
94 char *ecalloc( unsigned nelem, unsigned elsize );
95 void *erealloc( void *s, unsigned size );
96 char *estrdup( char *s );
97 extern void dump_ldop (struct ldop *op);
98
99
100 /*
101  * global variables
102  */
103 extern int      debugflg;
104 extern char     *progname;
105
106 LDAP_END_DECL
107 #endif