- struct ldbminfo *li = (struct ldbminfo *) be->be_private;
- char buf[MAXPATHLEN];
- char buf2[20];
- FILE *fp;
- ID id;
-
- sprintf( buf, "%s/NEXTID", li->li_directory );
-
- pthread_mutex_lock( &li->li_nextid_mutex );
- /* first time in here since startup - try to read the nexid */
- if ( li->li_nextid == -1 ) {
- if ( (fp = fopen( buf, "r" )) == NULL ) {
- Debug( LDAP_DEBUG_ANY,
- "next_id %d: could not open \"%s\"\n",
- li->li_nextid, buf, 0 );
- li->li_nextid = 1;
- } else {
- if ( fgets( buf2, sizeof(buf2), fp ) != NULL ) {
- li->li_nextid = atol( buf2 );
- } else {
- Debug( LDAP_DEBUG_ANY,
- "next_id %d: could not fgets nextid from \"%s\"\n",
- li->li_nextid, buf2, 0 );
- li->li_nextid = 1;
- }
- fclose( fp );
- }
+ Datum key, data;
+ DBCache *db;
+
+ *idp = NOID;
+
+ if ( (db = ldbm_cache_open( be, "nextid", LDBM_SUFFIX, LDBM_WRCREAT ))
+ == NULL ) {
+#ifdef NEW_LOGGING
+ LDAP_LOG( BACK_LDBM, CRIT,
+ "next_id_read: could not open/create nextid%s\n", LDBM_SUFFIX, 0, 0 );
+#else
+ Debug( LDAP_DEBUG_ANY, "Could not open/create nextid" LDBM_SUFFIX "\n",
+ 0, 0, 0 );
+#endif
+
+ return( -1 );