tmp = (ID_BLOCK **) ch_malloc( (i + 1) * sizeof(ID_BLOCK *) );
/* read in all the blocks */
- kstr = (char *) ch_malloc( key.dsize + 20 );
+ kstr = (char *) ch_malloc( key.dsize + CONT_SIZE );
nids = 0;
for ( i = 0; !ID_BLOCK_NOID(idl, i); i++ ) {
ldbm_datum_init( data );
- sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, ID_BLOCK_ID(idl, i) );
+#ifndef CONT_POSTFIX
+ sprintf( kstr, "%c%s%ld", CONT_PREFIX,
+ key.dptr, ID_BLOCK_ID(idl, i) );
+#else
+ sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+ ID_BLOCK_ID(idl, i), key.dptr );
+#endif
data.dptr = kstr;
data.dsize = strlen( kstr ) + 1;
}
/* write block with new key */
- sprintf( bkey.dptr, "%c%s%ld", CONT_PREFIX, hkey.dptr, ID_BLOCK_ID(b, 0) );
+#ifdef CONT_POSTFIX
+ sprintf( bkey.dptr, "%c%s%ld", CONT_PREFIX,
+ hkey.dptr, ID_BLOCK_ID(b, 0) );
+#else
+ sprintf( bkey.dptr, "%c%ld%s", CONT_PREFIX,
+ ID_BLOCK_ID(b, 0), hkey.dptr );
+#endif
bkey.dsize = strlen( bkey.dptr ) + 1;
if ( (rc = idl_store( be, db, bkey, b )) != 0 ) {
Debug( LDAP_DEBUG_ANY,
rc = idl_store( be, db, key, idl );
/* store the first id block */
- kstr = (char *) ch_malloc( key.dsize + 20 );
- sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
- ID_BLOCK_ID(tmp, 0) );
+ kstr = (char *) ch_malloc( key.dsize + CONT_SIZE );
+#ifdef CONT_POSTFIX
+ sprintf( kstr, "%c%s%ld", CONT_PREFIX,
+ key.dptr, ID_BLOCK_ID(tmp, 0) );
+#else
+ sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+ ID_BLOCK_ID(tmp, 0), key.dptr );
+#endif
k2.dptr = kstr;
k2.dsize = strlen( kstr ) + 1;
rc = idl_store( be, db, k2, tmp );
/* store the second id block */
- sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
- ID_BLOCK_ID(tmp2, 0) );
+#ifdef CONT_POSTFIX
+ sprintf( kstr, "%c%s%ld", CONT_PREFIX,
+ key.dptr, ID_BLOCK_ID(tmp2, 0) );
+#else
+ sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+ ID_BLOCK_ID(tmp2, 0), key.dptr );
+#endif
k2.dptr = kstr;
k2.dsize = strlen( kstr ) + 1;
rc = idl_store( be, db, k2, tmp2 );
}
/* get the block */
- kstr = (char *) ch_malloc( key.dsize + 20 );
- sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, ID_BLOCK_ID(idl, i) );
+ kstr = (char *) ch_malloc( key.dsize + CONT_SIZE );
+#ifdef CONT_POSTFIX
+ sprintf( kstr, "%c%s%ld", CONT_PREFIX,
+ key.dptr, ID_BLOCK_ID(idl, i) );
+#else
+ sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+ ID_BLOCK_ID(idl, i), key.dptr );
+#endif
k2.dptr = kstr;
k2.dsize = strlen( kstr ) + 1;
if ( (tmp = idl_fetch_one( be, db, k2 )) == NULL ) {
/* is there a next block? */
if ( !first && !ID_BLOCK_NOID(idl, i + 1) ) {
/* read it in */
- sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
- ID_BLOCK_ID(idl, i + 1) );
+#ifdef CONT_POSTFIX
+ sprintf( kstr, "%c%s%ld", CONT_PREFIX,
+ key.dptr, ID_BLOCK_ID(idl, i + 1) );
+#else
+ sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+ ID_BLOCK_ID(idl, i + 1), key.dptr );
+#endif
k2.dptr = kstr;
k2.dsize = strlen( kstr ) + 1;
if ( (tmp2 = idl_fetch_one( be, db, k2 )) == NULL ) {
/* delete all indirect blocks */
for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ ) {
- sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
- ID_BLOCK_ID(idl, j) );
+#ifdef CONT_POSTFIX
+ sprintf( kstr, "%c%s%ld", CONT_PREFIX,
+ key.dptr, ID_BLOCK_ID(idl, j) );
+#else
+ sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+ ID_BLOCK_ID(idl, j), key.dptr );
+#endif
k2.dptr = kstr;
k2.dsize = strlen( kstr ) + 1;
rc = idl_store( be, db, key, tmp );
/* store the first id block */
- sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
- ID_BLOCK_ID(tmp2, 0) );
+#ifdef CONT_POSTFIX
+ sprintf( kstr, "%c%s%ld", CONT_PREFIX,
+ key.dptr, ID_BLOCK_ID(tmp2, 0) );
+#else
+ sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+ ID_BLOCK_ID(tmp2, 0), key.dptr );
+#endif
k2.dptr = kstr;
k2.dsize = strlen( kstr ) + 1;
rc = idl_store( be, db, k2, tmp2 );
/* store the second id block */
- sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr,
- ID_BLOCK_ID(tmp3, 0) );
+#ifdef CONT_POSTFIX
+ sprintf( kstr, "%c%s%ld", CONT_PREFIX,
+ key.dptr, ID_BLOCK_ID(tmp3, 0) );
+#else
+ sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+ ID_BLOCK_ID(tmp3, 0), key.dptr );
+#endif
k2.dptr = kstr;
k2.dsize = strlen( kstr ) + 1;
rc = idl_store( be, db, k2, tmp3 );
int
idl_insert( ID_BLOCK **idl, ID id, unsigned int maxids )
{
- unsigned int i, j;
+ unsigned int i;
if ( ID_BLOCK_ALLIDS( *idl ) ) {
return( 2 ); /* already there */
*/
for ( nids = 0; !ID_BLOCK_NOID(idl, nids); nids++ )
; /* NULL */
- kstr = (char *) ch_malloc( key.dsize + 20 );
+ kstr = (char *) ch_malloc( key.dsize + CONT_SIZE );
for ( j = 0; !ID_BLOCK_NOID(idl, j); j++ )
{
ldbm_datum_init( data );
- sprintf( kstr, "%c%s%ld", CONT_PREFIX, key.dptr, ID_BLOCK_ID(idl, j) );
+#ifdef CONT_POSTFIX
+ sprintf( kstr, "%c%s%ld", CONT_PREFIX,
+ key.dptr, ID_BLOCK_ID(idl, j) );
+#else
+ sprintf( kstr, "%c%ld%s", CONT_PREFIX,
+ ID_BLOCK_ID(idl, j), key.dptr );
+#endif
data.dptr = kstr;
data.dsize = strlen( kstr ) + 1;