-static char *database_dir;
-
-static int make_database_dir(void)
-{
- int ret;
-
- if (!database_dir) {
- if (conf.afs_database_dir_given)
- database_dir = para_strdup(conf.afs_database_dir_arg);
- else {
- char *home = para_homedir();
- database_dir = make_message(
- "%s/.paraslash/afs_database", home);
- free(home);
- }
- }
- PARA_INFO_LOG("afs_database dir %s\n", database_dir);
- ret = para_mkdir(database_dir, 0777);
- if (ret >= 0 || ret == -E_EXIST)
- return 1;
- free(database_dir);
- database_dir = NULL;
- return ret;
-}
-
-static int open_afs_tables(void)
-{
- int ret = make_database_dir();
-
- if (ret < 0)
- return ret;
- ret = attribute_init(&afs_tables[TBLNUM_ATTRIBUTES], database_dir);
- if (ret < 0)
- return ret;
- ret = moods_init(&afs_tables[TBLNUM_MOODS], database_dir);
- if (ret < 0)
- goto moods_init_error;
- ret = playlists_init(&afs_tables[TBLNUM_PLAYLIST], database_dir);
- if (ret < 0)
- goto playlists_init_error;
- ret = lyrics_init(&afs_tables[TBLNUM_LYRICS], database_dir);
- if (ret < 0)
- goto lyrics_init_error;
- ret = images_init(&afs_tables[TBLNUM_IMAGES], database_dir);
- if (ret < 0)
- goto images_init_error;
- ret = score_init(&afs_tables[TBLNUM_SCORES], database_dir);
- if (ret < 0)
- goto score_init_error;
- ret = aft_init(&afs_tables[TBLNUM_AUDIO_FILES], database_dir);
- if (ret < 0)
- goto aft_init_error;
- return 1;
-
-aft_init_error:
- score_shutdown(OSL_MARK_CLEAN);
-score_init_error:
- images_shutdown(OSL_MARK_CLEAN);
-images_init_error:
- lyrics_shutdown(OSL_MARK_CLEAN);
-lyrics_init_error:
- playlists_shutdown(OSL_MARK_CLEAN);
-playlists_init_error:
- moods_shutdown(OSL_MARK_CLEAN);
-moods_init_error:
- attribute_shutdown(OSL_MARK_CLEAN);
- return ret;
-}
-
-__noreturn int afs_init(uint32_t cookie, int socket_fd)