summaryrefslogtreecommitdiffstats
path: root/servers/slapd/shell-backends/shellutil.h
blob: a359aa20a0965181ffb2818e35846a31d0b672cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* shellutil.h */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
 *
 * Copyright 1998-2021 The OpenLDAP Foundation.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted only as authorized by the OpenLDAP
 * Public License.
 *
 * A copy of this license is available in the file LICENSE in the
 * top-level directory of the distribution or, alternatively, at
 * <http://www.OpenLDAP.org/license.html>.
 */
/* Portions Copyright (c) 1995 Regents of the University of Michigan.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms are permitted
 * provided that this notice is preserved and that due credit is given
 * to the University of Michigan at Ann Arbor. The name of the University
 * may not be used to endorse or promote products derived from this
 * software without specific prior written permission. This software
 * is provided ``as is'' without express or implied warranty.
 */
/* ACKNOWLEDGEMENTS:
 * This work was originally developed by the University of Michigan
 * (as part of U-MICH LDAP).
 */

#ifndef SHELLUTIL_H
#define SHELLUTIL_H

#include <ldap_cdefs.h>

LDAP_BEGIN_DECL

#define MAXLINELEN	512

#define STR_OP_SEARCH	"SEARCH"


struct inputparams {
    int		ip_type;
#define IP_TYPE_SUFFIX		0x01
#define IP_TYPE_BASE		0x02
#define IP_TYPE_SCOPE		0x03
#define IP_TYPE_ALIASDEREF	0x04
#define IP_TYPE_SIZELIMIT	0x05
#define IP_TYPE_TIMELIMIT	0x06
#define IP_TYPE_FILTER		0x07
#define IP_TYPE_ATTRSONLY	0x08
#define IP_TYPE_ATTRS		0x09
    char	*ip_tag;
};


struct ldsrchparms {
    int		ldsp_scope;
    int		ldsp_aliasderef;
    int		ldsp_sizelimit;
    int		ldsp_timelimit;
    int		ldsp_attrsonly;
    char	*ldsp_filter;
    char	**ldsp_attrs;
};


struct ldop { 
    int		ldop_op;
#define LDOP_SEARCH	0x01
    char	**ldop_suffixes;
    char	*ldop_dn;
    union ldapop_params_u {
		    struct ldsrchparms LDsrchparams;
	  }	ldop_params;
#define ldop_srch	ldop_params.LDsrchparams
};


struct ldattr {
    char	*lda_name;
    char	**lda_values;
};


struct ldentry {
    char		*lde_dn;
    struct ldattr	**lde_attrs;
};


#ifdef LDAP_DEBUG
void	debug_printf(const char *, ...) LDAP_GCCATTR((format(printf, 1, 2)));
#else /* LDAP_DEBUG */
#define	debug_printf	(void) /* Ignore "arguments" */
#endif /* LDAP_DEBUG */

/*
 * function prototypes
 */
void write_result( FILE *fp, int code, char *matched, char *info );
void write_entry( struct ldop *op, struct ldentry *entry, FILE *ofp );
int test_filter( struct ldop *op, struct ldentry *entry );
void free_entry( struct ldentry *entry );
int attr_requested( char *name, struct ldop *op );
int parse_input( FILE *ifp, FILE *ofp, struct ldop *op );
struct inputparams *find_input_tag( char **linep );
void add_strval( char ***sp, char *val );
char *ecalloc( unsigned nelem, unsigned elsize );
void *erealloc( void *s, unsigned size );
char *estrdup( char *s );
extern void dump_ldop (struct ldop *op);


/*
 * global variables
 */
extern int	debugflg;
extern char	*progname;

LDAP_END_DECL
#endif