Skip to content

Commit

Permalink
Move to yyjson and isolate audio index parser
Browse files Browse the repository at this point in the history
  • Loading branch information
btrkeks committed May 31, 2024
1 parent 3d79ce4 commit b4eb8b9
Show file tree
Hide file tree
Showing 10 changed files with 393 additions and 1,702 deletions.
17 changes: 17 additions & 0 deletions include/ajt_audio_index_parser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef AUDIO_INDEX_PARSER_H
#define AUDIO_INDEX_PARSER_H

#include "util.h"

typedef struct {
s8 origin;
s8 hira_reading;
s8 pitch_number;
s8 pitch_pattern;
} fileinfo;

void parse_audio_index_from_file(s8 curdir, const char *index_filepath,
void (*foreach_headword)(void *, s8, s8), void *userdata_hw,
void (*foreach_file)(void *, s8, fileinfo), void *userdata_f);

#endif //AUDIO_INDEX_PARSER_H
34 changes: 18 additions & 16 deletions include/database.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
#include "util.h"
#include <lmdb.h>
#ifndef DATABASE_H
#define DATABASE_H

#include <stdbool.h>
#include "util.h"
#include "ajt_audio_index_parser.h"

typedef struct {
stringbuilder_s lastval;
MDB_env *env;
MDB_dbi dbi1;
MDB_dbi dbi2;
MDB_txn *txn;
bool readonly;
} database;
typedef struct database_s database;

database opendb(const char *path, bool readonly);
void closedb(database);
database *jdb_open(char *path, bool readonly);
void jdb_close(database *);
/*
* Add to database, allowing duplicates if they are added directly after another
*/
void addtodb1(database db, s8 key, s8 val);
void addtodb2(database db, s8 key, s8 val);
void jdb_add_headword_with_file(database *db, s8 headword, s8 filepath);
void jdb_add_file_with_fileinfo(database *db, s8 filepath, fileinfo fi);

s8 *jdb_get_files(database *db, s8 key);
fileinfo jdb_get_fileinfo(database *db, s8 fullpath);

i32 jdb_check_exists(s8 dbpath);

DEFINE_DROP_FUNC(database *, jdb_close)

s8 *getfiles(database db, s8 key);
s8 getfromdb2(database db, s8 key);
#endif // DATABASE_H
2 changes: 1 addition & 1 deletion include/jppron.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "util.h"

void jppron(s8 word, s8 reading, char *audiopth);
void jppron(s8 word, s8 reading, char *audio_folders_path);
126 changes: 0 additions & 126 deletions include/pdjson.h

This file was deleted.

134 changes: 0 additions & 134 deletions src/database.c

This file was deleted.

Loading

0 comments on commit b4eb8b9

Please sign in to comment.