Commit 17083675 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Namespace changes

  added slap_ and ldbm_ to many structures
  added typedefs to many structures
  used typedefs
New main.c argument parsing with ldap url support (replacing -a address).
New sockaddr_in handling and support for multiple listeners.
parent 543aafd9
......@@ -38,7 +38,7 @@ access_allowed(
)
{
int rc;
struct acl *a;
AccessControl *a;
char *edn;
regmatch_t matches[MAXREMATCHES];
......@@ -93,7 +93,7 @@ access_allowed(
* acl_access_allowed().
*/
struct acl *
AccessControl *
acl_get_applicable(
Backend *be,
Operation *op,
......@@ -104,7 +104,7 @@ acl_get_applicable(
)
{
int i;
struct acl *a;
AccessControl *a;
char *edn;
Debug( LDAP_DEBUG_ACL, "\n=> acl_get: entry (%s) attr (%s)\n",
......@@ -200,7 +200,7 @@ acl_get_applicable(
int
acl_access_allowed(
struct acl *a,
AccessControl *a,
Backend *be,
Connection *conn,
Entry *e,
......@@ -212,7 +212,7 @@ acl_access_allowed(
)
{
int i;
struct access *b;
Access *b;
Attribute *at;
struct berval bv;
int default_access;
......@@ -398,7 +398,7 @@ acl_check_modlist(
)
{
int i;
struct acl *a;
AccessControl *a;
char *edn = e->e_ndn;
for ( ; mlist != NULL; mlist = mlist->ml_next ) {
......
......@@ -13,12 +13,12 @@
#include "slap.h"
static void split(char *line, int splitchar, char **left, char **right);
static void acl_append(struct acl **l, struct acl *a);
static void access_append(struct access **l, struct access *a);
static void acl_append(AccessControl **l, AccessControl *a);
static void access_append(Access **l, Access *a);
static void acl_usage(void);
#ifdef LDAP_DEBUG
static void print_acl(struct acl *a);
static void print_access(struct access *b);
static void print_acl(AccessControl *a);
static void print_access(Access *b);
#endif
static int
......@@ -88,8 +88,8 @@ parse_acl(
{
int i;
char *left, *right;
struct acl *a;
struct access *b;
AccessControl *a;
Access *b;
a = NULL;
for ( i = 1; i < argc; i++ ) {
......@@ -101,7 +101,7 @@ parse_acl(
fname, lineno );
acl_usage();
}
a = (struct acl *) ch_calloc( 1, sizeof(struct acl) );
a = (AccessControl *) ch_calloc( 1, sizeof(AccessControl) );
for ( ++i; i < argc; i++ ) {
if ( strcasecmp( argv[i], "by" ) == 0 ) {
i--;
......@@ -181,7 +181,7 @@ parse_acl(
* by clause consists of <who> and <access>
*/
b = (struct access *) ch_calloc( 1, sizeof(struct access) );
b = (Access *) ch_calloc( 1, sizeof(Access) );
if ( ++i == argc ) {
fprintf( stderr,
......@@ -400,7 +400,7 @@ split(
}
static void
access_append( struct access **l, struct access *a )
access_append( Access **l, Access *a )
{
for ( ; *l != NULL; l = &(*l)->a_next )
; /* NULL */
......@@ -409,7 +409,7 @@ access_append( struct access **l, struct access *a )
}
static void
acl_append( struct acl **l, struct acl *a )
acl_append( AccessControl **l, AccessControl *a )
{
for ( ; *l != NULL; l = &(*l)->acl_next )
; /* NULL */
......@@ -420,7 +420,7 @@ acl_append( struct acl **l, struct acl *a )
#ifdef LDAP_DEBUG
static void
print_access( struct access *b )
print_access( Access *b )
{
fprintf( stderr, "\tby" );
......@@ -451,10 +451,10 @@ print_access( struct access *b )
}
static void
print_acl( struct acl *a )
print_acl( AccessControl *a )
{
int i;
struct access *b;
Access *b;
if ( a == NULL ) {
fprintf( stderr, "NULL\n" );
......
......@@ -13,7 +13,7 @@
static int
ainfo_type_cmp(
char *type,
struct attrinfo *a
AttrInfo *a
)
{
return( strcasecmp( type, a->ai_type ) );
......@@ -21,8 +21,8 @@ ainfo_type_cmp(
static int
ainfo_cmp(
struct attrinfo *a,
struct attrinfo *b
AttrInfo *a,
AttrInfo *b
)
{
return( strcasecmp( a->ai_type, b->ai_type ) );
......@@ -37,8 +37,8 @@ ainfo_cmp(
static int
ainfo_dup(
struct attrinfo *a,
struct attrinfo *b
AttrInfo *a,
AttrInfo *b
)
{
/*
......@@ -62,13 +62,13 @@ attr_masks(
int *syntaxmask
)
{
struct attrinfo *a;
AttrInfo *a;
*indexmask = 0;
*syntaxmask = 0;
if ( (a = (struct attrinfo *) avl_find( li->li_attrs, type,
if ( (a = (AttrInfo *) avl_find( li->li_attrs, type,
(AVL_CMP) ainfo_type_cmp )) == NULL ) {
if ( (a = (struct attrinfo *) avl_find( li->li_attrs, "default",
if ( (a = (AttrInfo *) avl_find( li->li_attrs, "default",
(AVL_CMP) ainfo_type_cmp )) == NULL ) {
return;
}
......@@ -93,14 +93,14 @@ attr_index_config(
{
int i, j;
char **attrs, **indexes;
struct attrinfo *a;
AttrInfo *a;
attrs = str2charray( argv[0], "," );
if ( argc > 1 ) {
indexes = str2charray( argv[1], "," );
}
for ( i = 0; attrs[i] != NULL; i++ ) {
a = (struct attrinfo *) ch_malloc( sizeof(struct attrinfo) );
a = (AttrInfo *) ch_malloc( sizeof(AttrInfo) );
a->ai_type = ch_strdup( attrs[i] );
a->ai_syntaxmask = attr_syntax( a->ai_type );
if ( argc == 1 ) {
......
......@@ -69,7 +69,7 @@ typedef ID ID_BLOCK;
#define ID_BLOCK_INDIRECT(b) (ID_BLOCK_NIDS(b) == ID_BLOCK_INDIRECT_VALUE)
/* for the in-core cache of entries */
struct cache {
typedef struct ldbm_cache {
int c_maxsize;
int c_cursize;
Avlnode *c_dntree;
......@@ -77,13 +77,13 @@ struct cache {
Entry *c_lruhead; /* lru - add accessed entries here */
Entry *c_lrutail; /* lru - rem lru entries from here */
ldap_pvt_thread_mutex_t c_mutex;
};
} Cache;
#define CACHE_READ_LOCK 0
#define CACHE_WRITE_LOCK 1
/* for the cache of open index files */
struct dbcache {
typedef struct ldbm_dbcache {
int dbc_refcnt;
int dbc_maxids;
int dbc_maxindirect;
......@@ -91,10 +91,10 @@ struct dbcache {
long dbc_blksize;
char *dbc_name;
LDBM dbc_db;
};
} DBCache;
/* for the cache of attribute information (which are indexed, etc.) */
struct attrinfo {
typedef struct ldbm_attrinfo {
char *ai_type; /* type name (cn, sn, ...) */
int ai_indexmask; /* how the attr is indexed */
#define INDEX_PRESENCE 0x01
......@@ -110,7 +110,7 @@ struct attrinfo {
#define SYNTAX_BIN 0x04
... etc. ...
*/
};
} AttrInfo;
#define MAXDBCACHE 10
......@@ -130,11 +130,11 @@ struct ldbminfo {
ldap_pvt_thread_mutex_t li_nextid_mutex;
int li_mode;
char *li_directory;
struct cache li_cache;
Cache li_cache;
Avlnode *li_attrs;
int li_dbcachesize;
int li_dbcachewsync;
struct dbcache li_dbcache[MAXDBCACHE];
DBCache li_dbcache[MAXDBCACHE];
ldap_pvt_thread_mutex_t li_dbcache_mutex;
ldap_pvt_thread_cond_t li_dbcache_cv;
#ifdef HAVE_BERKELEY_DB2
......
......@@ -13,7 +13,7 @@
#include "back-ldbm.h"
/* LDBM backend specific entry info -- visible only to the cache */
struct ldbm_entry_info {
typedef struct ldbm_entry_info {
ldap_pvt_thread_rdwr_t lei_rdwr; /* reader/writer lock */
/*
......@@ -28,14 +28,14 @@ struct ldbm_entry_info {
#define CACHE_ENTRY_DELETED 3
int lei_refcnt; /* # threads ref'ing this entry */
struct entry *lei_lrunext; /* for cache lru list */
struct entry *lei_lruprev;
};
#define LEI(e) ((struct ldbm_entry_info *) ((e)->e_private))
Entry *lei_lrunext; /* for cache lru list */
Entry *lei_lruprev;
} EntryInfo;
#define LEI(e) ((EntryInfo *) ((e)->e_private))
static int cache_delete_entry_internal(struct cache *cache, Entry *e);
static int cache_delete_entry_internal(Cache *cache, Entry *e);
#ifdef LDAP_DEBUG
static void lru_print(struct cache *cache);
static void lru_print(Cache *cache);
#endif
static int
......@@ -120,7 +120,7 @@ cache_entry_private_destroy( Entry*e )
}
void
cache_return_entry_rw( struct cache *cache, Entry *e, int rw )
cache_return_entry_rw( Cache *cache, Entry *e, int rw )
{
ID id;
int refcnt;
......@@ -209,7 +209,7 @@ cache_return_entry_rw( struct cache *cache, Entry *e, int rw )
*/
int
cache_add_entry_rw(
struct cache *cache,
Cache *cache,
Entry *e,
int rw
)
......@@ -330,7 +330,7 @@ cache_add_entry_rw(
*/
int
cache_update_entry(
struct cache *cache,
Cache *cache,
Entry *e
)
{
......@@ -430,7 +430,7 @@ cache_update_entry(
ID
cache_find_entry_dn2id(
Backend *be,
struct cache *cache,
Cache *cache,
char *dn
)
{
......@@ -509,7 +509,7 @@ try_again:
Entry *
cache_find_entry_id(
struct cache *cache,
Cache *cache,
ID id,
int rw
)
......@@ -608,7 +608,7 @@ try_again:
*/
int
cache_delete_entry(
struct cache *cache,
Cache *cache,
Entry *e
)
{
......@@ -631,7 +631,7 @@ cache_delete_entry(
static int
cache_delete_entry_internal(
struct cache *cache,
Cache *cache,
Entry *e
)
{
......@@ -670,7 +670,7 @@ cache_delete_entry_internal(
#ifdef SLAP_CLEANUP
void
cache_release_all( struct cache *cache )
cache_release_all( Cache *cache )
{
Entry *e;
int rc;
......@@ -703,7 +703,7 @@ cache_release_all( struct cache *cache )
#ifdef LDAP_DEBUG
static void
lru_print( struct cache *cache )
lru_print( Cache *cache )
{
Entry *e;
......
......@@ -19,7 +19,7 @@
#include "slap.h"
#include "back-ldbm.h"
struct dbcache *
DBCache *
ldbm_cache_open(
Backend *be,
char *name,
......@@ -127,7 +127,7 @@ ldbm_cache_open(
}
void
ldbm_cache_close( Backend *be, struct dbcache *db )
ldbm_cache_close( Backend *be, DBCache *db )
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
......@@ -139,7 +139,7 @@ ldbm_cache_close( Backend *be, struct dbcache *db )
}
void
ldbm_cache_really_close( Backend *be, struct dbcache *db )
ldbm_cache_really_close( Backend *be, DBCache *db )
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
......@@ -188,7 +188,7 @@ ldbm_cache_flush_all( Backend *be )
Datum
ldbm_cache_fetch(
struct dbcache *db,
DBCache *db,
Datum key
)
{
......@@ -203,7 +203,7 @@ ldbm_cache_fetch(
int
ldbm_cache_store(
struct dbcache *db,
DBCache *db,
Datum key,
Datum data,
int flags
......@@ -236,7 +236,7 @@ ldbm_cache_store(
int
ldbm_cache_delete(
struct dbcache *db,
DBCache *db,
Datum key
)
{
......
......@@ -19,7 +19,7 @@ dn2id_add(
)
{
int rc, flags;
struct dbcache *db;
DBCache *db;
Datum key, data;
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
......@@ -62,7 +62,7 @@ dn2id(
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
struct dbcache *db;
DBCache *db;
ID id;
Datum key, data;
......@@ -116,7 +116,7 @@ dn2id_delete(
char *dn
)
{
struct dbcache *db;
DBCache *db;
Datum key;
int rc;
......
......@@ -17,7 +17,7 @@ id2children_add(
Entry *e
)
{
struct dbcache *db;
DBCache *db;
Datum key;
char buf[20];
......@@ -59,7 +59,7 @@ id2children_remove(
Entry *e
)
{
struct dbcache *db;
DBCache *db;
Datum key;
char buf[20];
......@@ -105,7 +105,7 @@ has_children(
Entry *p
)
{
struct dbcache *db;
DBCache *db;
Datum key;
int rc = 0;
ID_BLOCK *idl;
......
......@@ -18,7 +18,7 @@ int
id2entry_add( Backend *be, Entry *e )
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
struct dbcache *db;
DBCache *db;
Datum key, data;
int len, rc, flags;
......@@ -60,7 +60,7 @@ int
id2entry_delete( Backend *be, Entry *e )
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
struct dbcache *db;
DBCache *db;
Datum key;
int rc;
......@@ -104,7 +104,7 @@ Entry *
id2entry_rw( Backend *be, ID id, int rw )
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
struct dbcache *db;
DBCache *db;
Datum key, data;
Entry *e;
......
......@@ -61,7 +61,7 @@ idl_free( ID_BLOCK *idl )
static ID_BLOCK *
idl_fetch_one(
Backend *be,
struct dbcache *db,
DBCache *db,
Datum key
)
{
......@@ -97,7 +97,7 @@ idl_fetch_one(
ID_BLOCK *
idl_fetch(
Backend *be,
struct dbcache *db,
DBCache *db,
Datum key
)
{
......@@ -191,7 +191,7 @@ idl_fetch(
static int
idl_store(
Backend *be,
struct dbcache *db,
DBCache *db,
Datum key,
ID_BLOCK *idl
)
......@@ -277,7 +277,7 @@ idl_split_block(
static int
idl_change_first(
Backend *be,
struct dbcache *db,
DBCache *db,
Datum hkey, /* header block key */
ID_BLOCK *h, /* header block */
int pos, /* pos in h to update */
......@@ -321,7 +321,7 @@ idl_change_first(
int
idl_insert_key(
Backend *be,
struct dbcache *db,
DBCache *db,
Datum key,
ID id
)
......@@ -662,7 +662,7 @@ idl_insert( ID_BLOCK **idl, ID id, unsigned int maxids )
int
idl_delete_key (
Backend *be,
struct dbcache *db,
DBCache *db,
Datum key,
ID id
)
......
......@@ -11,13 +11,13 @@
#include "back-ldbm.h"
static int change_value(Backend *be,
struct dbcache *db,
DBCache *db,
char *type,
int indextype,
char *val,
ID id,
int
(*idl_func)(Backend *, struct dbcache *, Datum, ID));
(*idl_func)(Backend *, DBCache *, Datum, ID));
static int index2prefix(int indextype);
int
......@@ -116,7 +116,7 @@ index_read(
char *val
)
{
struct dbcache *db;
DBCache *db;
Datum key;
ID_BLOCK *idl;
int indexmask, syntax;
......@@ -188,12 +188,12 @@ index_read(
static int
change_value(
Backend *be,
struct dbcache *db,
DBCache *db,
char *type,
int indextype,
char *val,
ID id,
int (*idl_func)(Backend *, struct dbcache *, Datum, ID)
int (*idl_func)(Backend *, DBCache *, Datum, ID)
)
{
int rc;
......@@ -257,10 +257,10 @@ index_change_values(
char buf[SUBLEN + 1];
char vbuf[BUFSIZ];
char *bigbuf;
struct dbcache *db;
DBCache *db;
int (*idl_funct)(Backend *,
struct dbcache *,
DBCache *,
Datum, ID);
char *at_cn; /* Attribute canonical name */
int mode;
......
......@@ -39,31 +39,31 @@ void attr_index_destroy LDAP_P(( Avlnode *tree ));
* cache.c
*/
int cache_add_entry_rw LDAP_P(( struct cache *cache, Entry *e, int rw ));
int cache_update_entry LDAP_P(( struct cache *cache, Entry *e ));
void cache_return_entry_rw LDAP_P(( struct cache *cache, Entry *e, int rw ));
int cache_add_entry_rw LDAP_P(( Cache *cache, Entry *e, int rw ));
int cache_update_entry LDAP_P(( Cache *cache, Entry *e ));
void cache_return_entry_rw LDAP_P(( Cache *cache, Entry *e, int rw ));
#define cache_return_entry_r(c, e) cache_return_entry_rw((c), (e), 0)
#define cache_return_entry_w(c, e) cache_return_entry_rw((c), (e), 1)
ID cache_find_entry_dn2id LDAP_P(( Backend *be, struct cache *cache, char *dn ));
Entry * cache_find_entry_id LDAP_P(( struct cache *cache, ID id, int rw ));
int cache_delete_entry LDAP_P(( struct cache *cache, Entry *e ));
ID cache_find_entry_dn2id LDAP_P(( Backend *be, Cache *cache, char *dn ));
Entry * cache_find_entry_id LDAP_P(( Cache *cache, ID id, int rw ));
int cache_delete_entry LDAP_P(( Cache *cache, Entry *e ));
#ifdef SLAP_CLEANUP