1/* shellutil.h */
2/* $OpenLDAP$ */
3/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 *
5 * Copyright 1998-2011 The OpenLDAP Foundation.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
10 * Public License.
11 *
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
15 */
16/* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
18 *
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
25 */
26/* ACKNOWLEDGEMENTS:
27 * This work was originally developed by the University of Michigan
28 * (as part of U-MICH LDAP).
29 */
30
31#ifndef SHELLUTIL_H
32#define SHELLUTIL_H
33
34#include <ldap_cdefs.h>
35
36LDAP_BEGIN_DECL
37
38#define MAXLINELEN	512
39
40#define STR_OP_SEARCH	"SEARCH"
41
42
43struct inputparams {
44    int		ip_type;
45#define IP_TYPE_SUFFIX		0x01
46#define IP_TYPE_BASE		0x02
47#define IP_TYPE_SCOPE		0x03
48#define IP_TYPE_ALIASDEREF	0x04
49#define IP_TYPE_SIZELIMIT	0x05
50#define IP_TYPE_TIMELIMIT	0x06
51#define IP_TYPE_FILTER		0x07
52#define IP_TYPE_ATTRSONLY	0x08
53#define IP_TYPE_ATTRS		0x09
54    char	*ip_tag;
55};
56
57
58struct ldsrchparms {
59    int		ldsp_scope;
60    int		ldsp_aliasderef;
61    int		ldsp_sizelimit;
62    int		ldsp_timelimit;
63    int		ldsp_attrsonly;
64    char	*ldsp_filter;
65    char	**ldsp_attrs;
66};
67
68
69struct ldop {
70    int		ldop_op;
71#define LDOP_SEARCH	0x01
72    char	**ldop_suffixes;
73    char	*ldop_dn;
74    union ldapop_params_u {
75		    struct ldsrchparms LDsrchparams;
76	  }	ldop_params;
77#define ldop_srch	ldop_params.LDsrchparams
78};
79
80
81struct ldattr {
82    char	*lda_name;
83    char	**lda_values;
84};
85
86
87struct ldentry {
88    char		*lde_dn;
89    struct ldattr	**lde_attrs;
90};
91
92
93#ifdef LDAP_DEBUG
94void	debug_printf(const char *, ...) LDAP_GCCATTR((format(printf, 1, 2)));
95#else /* LDAP_DEBUG */
96#define	debug_printf	(void) /* Ignore "arguments" */
97#endif /* LDAP_DEBUG */
98
99/*
100 * function prototypes
101 */
102void write_result( FILE *fp, int code, char *matched, char *info );
103void write_entry( struct ldop *op, struct ldentry *entry, FILE *ofp );
104int test_filter( struct ldop *op, struct ldentry *entry );
105void free_entry( struct ldentry *entry );
106int attr_requested( char *name, struct ldop *op );
107int parse_input( FILE *ifp, FILE *ofp, struct ldop *op );
108struct inputparams *find_input_tag( char **linep );
109void add_strval( char ***sp, char *val );
110char *ecalloc( unsigned nelem, unsigned elsize );
111void *erealloc( void *s, unsigned size );
112char *estrdup( char *s );
113extern void dump_ldop (struct ldop *op);
114
115
116/*
117 * global variables
118 */
119extern int	debugflg;
120extern char	*progname;
121
122LDAP_END_DECL
123#endif
124