Home | History | Annotate | Line # | Download | only in tools
      1 /*	$NetBSD: common.h,v 1.4 2025/09/05 21:16:13 christos Exp $	*/
      2 
      3 /* common.h - common definitions for the ldap client tools */
      4 /* $OpenLDAP$ */
      5 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
      6  *
      7  * Copyright 1998-2024 The OpenLDAP Foundation.
      8  * All rights reserved.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted only as authorized by the OpenLDAP
     12  * Public License.
     13  *
     14  * A copy of this license is available in the file LICENSE in the
     15  * top-level directory of the distribution or, alternatively, at
     16  * <http://www.OpenLDAP.org/license.html>.
     17  */
     18 /* ACKNOWLEDGEMENTS:
     19  * This file was initially created by Hallvard B. Furuseth based (in
     20  * part) upon argument parsing code for individual tools located in
     21  * this directory.
     22  */
     23 
     24 #ifndef _CLIENT_TOOLS_COMMON_H_
     25 #define _CLIENT_TOOLS_COMMON_H_
     26 
     27 LDAP_BEGIN_DECL
     28 
     29 typedef enum tool_type_t {
     30 	TOOL_SEARCH	= 0x01U,
     31 	TOOL_COMPARE	= 0x02U,
     32 	TOOL_ADD	= 0x04U,
     33 	TOOL_DELETE	= 0x08U,
     34 	TOOL_MODIFY	= 0x10U,
     35 	TOOL_MODRDN	= 0x20U,
     36 
     37 	TOOL_EXOP	= 0x40U,
     38 
     39 	TOOL_WHOAMI	= TOOL_EXOP | 0x100U,
     40 	TOOL_PASSWD	= TOOL_EXOP | 0x200U,
     41 	TOOL_VC		= TOOL_EXOP | 0x400U,
     42 
     43 	TOOL_WRITE	= (TOOL_ADD|TOOL_DELETE|TOOL_MODIFY|TOOL_MODRDN),
     44 	TOOL_READ	= (TOOL_SEARCH|TOOL_COMPARE),
     45 
     46 	TOOL_ALL	= 0xFFU
     47 } tool_type_t;
     48 
     49 
     50 /* input-related vars */
     51 
     52 /* misc. parameters */
     53 extern tool_type_t	tool_type;
     54 extern int		contoper;
     55 extern int		debug;
     56 extern char		*infile;
     57 extern int		dont;
     58 extern int		referrals;
     59 extern int		verbose;
     60 extern int		ldif;
     61 extern ber_len_t	ldif_wrap;
     62 extern char		*prog;
     63 
     64 /* connection */
     65 extern char		*ldapuri;
     66 extern int		use_tls;
     67 extern int		protocol;
     68 extern int		version;
     69 
     70 /* authc/authz */
     71 extern int		authmethod;
     72 extern char		*binddn;
     73 extern int		want_bindpw;
     74 extern struct berval	passwd;
     75 extern char		*pw_file;
     76 #ifdef HAVE_CYRUS_SASL
     77 extern unsigned		sasl_flags;
     78 extern char		*sasl_realm;
     79 extern char		*sasl_authc_id;
     80 extern char		*sasl_authz_id;
     81 extern char		*sasl_mech;
     82 extern char		*sasl_secprops;
     83 #endif
     84 
     85 /* controls */
     86 extern char		*assertion;
     87 extern char		*authzid;
     88 extern int		manageDIT;
     89 extern int		manageDSAit;
     90 extern int		noop;
     91 extern int		ppolicy;
     92 extern int		preread, postread;
     93 extern ber_int_t	pr_morePagedResults;
     94 extern struct berval	pr_cookie;
     95 #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR
     96 extern int		chaining;
     97 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
     98 extern ber_int_t	vlvPos;
     99 extern ber_int_t	vlvCount;
    100 extern struct berval	*vlvContext;
    101 
    102 /* features */
    103 extern int		backlog;
    104 
    105 /* options */
    106 extern struct timeval	nettimeout;
    107 
    108 /* Defined in common.c, set in main() */
    109 extern const char	__Version[];
    110 
    111 /* Defined in main program */
    112 extern const char	options[];
    113 
    114 void usage LDAP_P(( void )) LDAP_GCCATTR((noreturn));
    115 int handle_private_option LDAP_P(( int i ));
    116 
    117 /* Defined in common.c */
    118 void tool_init LDAP_P(( tool_type_t type ));
    119 void tool_common_usage LDAP_P(( void ));
    120 void tool_args LDAP_P(( int, char ** ));
    121 LDAP *tool_conn_setup LDAP_P(( int dont, void (*private_setup)( LDAP * ) ));
    122 void tool_bind LDAP_P(( LDAP * ));
    123 void tool_unbind LDAP_P(( LDAP * ));
    124 void tool_destroy LDAP_P(( void ));
    125 void tool_exit LDAP_P(( LDAP *ld, int status )) LDAP_GCCATTR((noreturn));
    126 void tool_server_controls LDAP_P(( LDAP *, LDAPControl *, int ));
    127 int tool_check_abandon LDAP_P(( LDAP *ld, int msgid ));
    128 void tool_perror LDAP_P((
    129 	const char *func,
    130 	int err,
    131 	const char *extra,
    132 	const char *matched,
    133 	const char *info,
    134 	char **refs ));
    135 void tool_print_ctrls LDAP_P(( LDAP *ld, LDAPControl **ctrls ));
    136 int tool_write_ldif LDAP_P(( int type, char *name, char *value, ber_len_t vallen ));
    137 int tool_is_oid LDAP_P(( const char *s ));
    138 
    139 
    140 LDAP_END_DECL
    141 
    142 #endif /* _CLIENT_TOOLS_COMMON_H_ */
    143