entry.h revision 5e45752a44935a6b2445ae1c763867d868fa3fbb
/*
*
* Copyright 1998 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* structs for storing and updating entries
*/
#if !defined(_ENTRY_H_) && !defined(_PROTO_SLAP)
#define _ENTRY_H_
#ifndef _SLDAPD_H_
/*
* represents an attribute (type + values + syntax + oid)
*/
typedef struct attr {
char *a_type;
int a_syntax;
} Attribute;
/*
* the attr_syntax() routine returns one of these values
* telling what kind of syntax an attribute supports.
*
* NOTE: The syntax may not be available in libentry unless you have
* read the slapd.conf config file.
*/
/* These next two are used by libentry. They are overloaded into a_syntax
* because there's no extra room and we didn't want to enlarge the structure
* because of the performance hit.
*/
#define DEFAULT_SYNTAX SYNTAX_CIS
typedef struct asyntaxinfo {
char **asi_names;
char *asi_oid;
int asi_options;
char *asi_default_oc;
int asi_maxlen;
int asi_syntax;
/*
* the id used in the indexes to refer to an entry
*/
typedef unsigned int ID;
#define NOID ((unsigned int)-1)
/*
* represents an entry in core
*/
typedef struct entry {
char *e_dn; /* DN of this entry */
char e_state; /* only ENTRY_FOUND is used below */
int e_refcnt; /* # threads ref'ing this entry */
} Entry;
/* This next #define is used by libentry. It is overloaded into e_state.
* if they are not found (for example on a remote replica).
*/
#define ENTRY_FOUND 0x80
#endif _SLDAPD_H_
/* entry.c */
/* output_ldif takes a modlist structure and prints out ldif. Since there are 3 ways
* you can use a modlist structure, you need to tell this routine what you're doing.
* The three choices are:
* LDAP_MODIFY_ENTRY
* LDAP_ADD_ENTRY
* LDAP_DELETE_ENTRY
* ldif suitable for feeding to ldapmodify will be produced.
*/
/* op arg to output_ldif() */
#define LDAP_MODIFY_ENTRY 1
#define LDAP_ADD_ENTRY 2
#define LDAP_DELETE_ENTRY 3
/* Checks that base exist. If not, create it.
* ld - ldap context, you must supply it because it's used in ldap_search
* out - file to output ldif to. If supplied, ldif will be printed here,
* if not supplied, ldap_mod will be called for you (using ld).
*
* returns number of entries created if all is ok, -1 if an error occured.
*
* mutex locks: if you are outputting to out from other threads, you need
* to lock output_mutex. output_ldif locks this mutex before outputting.
*/
/* Add an entry to ldap. You supply an Entry struct. Will either add entry
* to ldap or output ldif to an open file (stdout for example).
*
* ld - ldap context. Must be valid if you want entry_add to add entries to ldap
* for you.
* out - open file where to send ldif output. One of ld or out should be valid.
* new_entry is an Entry which you want added to ldap
*
* returns number of entries created or -1 if an error occured in ldap_add()
*/
/* Compares two entries and issue changes to make old look like new.
*
* ld - ldap context. Must be valid if you want entry_update to add entries to ldap
* for you.
* out - open file where to send ldif output. One of ld or out should be valid.
* new_entry is an Entry which you want old_entry to look like
*
* returns number of entries modified or -1 if an error occured in ldap_modify()
*/
/* Deletes an entry.
* ld - ldap context. Must be valid if you want delete_entry to call ldap
* for you.
* out - open file where to send ldif output. One of ld or out should be valid.
* ldap_entry is an Entry which you want to delete
*
* returns number of entries deleted or -1 if an error occured in ldap_modify()
* usually one, but for future it might delete more than one.
*/
/* attr.c */
int attr_merge_fast(
Entry *e,
char *type,
int nvals,
int naddvals,
int *maxvals,
Attribute ***a
);
int attr_merge(
Entry *e,
char *type,
);
Attribute *a,
char *type,
int ignoreOpt
);
int attr_delete(
char *type
);
int attr_syntax( char *type );
int attr_syntax_by_oid( char *oid );
void attr_syntax_config(
char *fname,
int lineno,
int argc,
char **argv
);
char * attr_normalize( char *s );
char * alias_normalize( char *s );
int type_list_compare(
char **a,
char *s
);
char * get_type_from_list(char **a, char *s);
char * attr_syntax2oid(int aSyntax);
/* value.c */
int value_add_fast(
int nvals,
int naddvals,
int *maxvals
);
int value_delete(
struct berval *v,
int syntax,
int normalize
);
int value_add_one(
struct berval *v,
int syntax,
int normalize
);
int value_add(
);
void value_normalize(
char *s,
int syntax
);
int value_cmp(
int syntax,
int normalize /* 1 => arg 1; 2 => arg 2; 3 => both */
);
int value_ncmp(
int syntax,
int len,
int normalize
);
int value_find(
struct berval *v,
int syntax,
int normalize
);
/* dn.c */
char *dn_normalize( char *dn );
char *dn_normalize_case( char *dn );
#endif _ENTRY_H_