From c9b9640d4cabdaa7e3b5f843e42ebc48e70a2713 Mon Sep 17 00:00:00 2001 From: David Huggins-Daines Date: Fri, 16 Sep 2022 17:24:24 -0400 Subject: [PATCH] Minimal exports needed for Windows DLL build --- src/bin_mdef.h | 5 +++++ src/dict.h | 2 ++ src/fe/yin.h | 7 +++++++ src/lm/fsg_model.h | 10 ++++++++++ src/lm/jsgf.h | 6 ++++++ src/util/ckd_alloc.h | 10 +++++++++- src/util/cmd_ln.h | 4 ++++ src/util/filename.h | 2 ++ src/util/pio.h | 5 +++++ src/util/strfuncs.h | 5 +++++ 10 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/bin_mdef.h b/src/bin_mdef.h index a6b8bf961..7bcb15313 100644 --- a/src/bin_mdef.h +++ b/src/bin_mdef.h @@ -53,6 +53,7 @@ extern "C" { #endif #include +#include #include "util/mmio.h" #include "mdef.h" @@ -166,21 +167,25 @@ struct bin_mdef_s { /** * Read a binary mdef from a file. */ +POCKETSPHINX_EXPORT bin_mdef_t *bin_mdef_read(ps_config_t *config, const char *filename); /** * Read a text mdef from a file (creating an in-memory binary mdef). */ +POCKETSPHINX_EXPORT bin_mdef_t *bin_mdef_read_text(ps_config_t *config, const char *filename); /** * Write a binary mdef to a file. */ +POCKETSPHINX_EXPORT int bin_mdef_write(bin_mdef_t *m, const char *filename); /** * Write a binary mdef to a text file. */ +POCKETSPHINX_EXPORT int bin_mdef_write_text(bin_mdef_t *m, const char *filename); /** diff --git a/src/dict.h b/src/dict.h index 090f4e9ac..2f13b656f 100644 --- a/src/dict.h +++ b/src/dict.h @@ -112,6 +112,7 @@ dict_t *dict_init(ps_config_t *config, /**< Configuration (-dict, -fdict, -dictc int dict_write(dict_t *dict, char const *filename, char const *format); /** Return word id for given word string if present. Otherwise return BAD_S3WID */ +POCKETSPHINX_EXPORT s3wid_t dict_wordid(dict_t *d, const char *word); /** @@ -125,6 +126,7 @@ int dict_filler_word(dict_t *d, /**< The dictionary structure */ /** * Test if w is a "real" word, i.e. neither a filler word nor START/FINISH. */ +POCKETSPHINX_EXPORT int dict_real_word(dict_t *d, /**< The dictionary structure */ s3wid_t w /**< The word ID */ ); diff --git a/src/fe/yin.h b/src/fe/yin.h index 8a8365b5d..9a296d8bf 100644 --- a/src/fe/yin.h +++ b/src/fe/yin.h @@ -50,6 +50,7 @@ extern "C" { #endif #include +#include /** * Frame-based moving-window pitch estimator. @@ -59,22 +60,26 @@ typedef struct yin_s yin_t; /** * Initialize moving-window pitch estimation. */ +POCKETSPHINX_EXPORT yin_t *yin_init(int frame_size, float search_threshold, float search_range, int smooth_window); /** * Free a moving-window pitch estimator. */ +POCKETSPHINX_EXPORT void yin_free(yin_t *pe); /** * Start processing an utterance. */ +POCKETSPHINX_EXPORT void yin_start(yin_t *pe); /** * Mark the end of an utterance. */ +POCKETSPHINX_EXPORT void yin_end(yin_t *pe); /** @@ -84,6 +89,7 @@ void yin_end(yin_t *pe); * @param frame Frame of frame_size (see * yin_init()) samples of audio data. */ +POCKETSPHINX_EXPORT void yin_write(yin_t *pe, int16 const *frame); /** @@ -99,6 +105,7 @@ void yin_write(yin_t *pe, int16 const *frame); * @return Non-zero if enough data was avaliable to return a pitch * estimate, zero otherwise. */ +POCKETSPHINX_EXPORT int yin_read(yin_t *pe, uint16 *out_period, uint16 *out_bestdiff); #ifdef __cplusplus diff --git a/src/lm/fsg_model.h b/src/lm/fsg_model.h index b50dfe492..0bbcd411f 100644 --- a/src/lm/fsg_model.h +++ b/src/lm/fsg_model.h @@ -52,6 +52,8 @@ #include #include +#include + #include "util/glist.h" #include "util/bitvec.h" #include "util/hash_table.h" @@ -190,6 +192,7 @@ fsg_model_t *fsg_model_init(char const *name, logmath_t *lmath, * Return value: a new fsg_model_t structure if the file is successfully * read, NULL otherwise. */ +POCKETSPHINX_EXPORT fsg_model_t *fsg_model_readfile(const char *file, logmath_t *lmath, float32 lw); /** @@ -255,6 +258,7 @@ int32 fsg_model_tag_trans_add(fsg_model_t * fsg, int32 from, int32 to, * @param nulls List of null transitions, or NULL to find them automatically. * @return Updated list of null transitions. */ +POCKETSPHINX_EXPORT glist_t fsg_model_null_trans_closure(fsg_model_t * fsg, glist_t nulls); /** @@ -304,31 +308,37 @@ int fsg_model_add_alt(fsg_model_t * fsg, char const *baseword, /** * Write FSG to a file. */ +POCKETSPHINX_EXPORT void fsg_model_write(fsg_model_t *fsg, FILE *fp); /** * Write FSG to a file. */ +POCKETSPHINX_EXPORT void fsg_model_writefile(fsg_model_t *fsg, char const *file); /** * Write FSG to a file in AT&T FSM format. */ +POCKETSPHINX_EXPORT void fsg_model_write_fsm(fsg_model_t *fsg, FILE *fp); /** * Write FSG to a file in AT&T FSM format. */ +POCKETSPHINX_EXPORT void fsg_model_writefile_fsm(fsg_model_t *fsg, char const *file); /** * Write FSG symbol table to a file (for AT&T FSM) */ +POCKETSPHINX_EXPORT void fsg_model_write_symtab(fsg_model_t *fsg, FILE *file); /** * Write FSG symbol table to a file (for AT&T FSM) */ +POCKETSPHINX_EXPORT void fsg_model_writefile_symtab(fsg_model_t *fsg, char const *file); #ifdef __cplusplus diff --git a/src/lm/jsgf.h b/src/lm/jsgf.h index 0d4a7ea93..448cfdde3 100644 --- a/src/lm/jsgf.h +++ b/src/lm/jsgf.h @@ -48,6 +48,7 @@ /* Not much here anymore! */ #include +#include #ifdef __cplusplus extern "C" { @@ -65,6 +66,11 @@ extern "C" { */ jsgf_t *jsgf_grammar_new(jsgf_t *parent); +POCKETSPHINX_EXPORT +fsg_model_t *jsgf_build_fsg_raw(jsgf_t * grammar, jsgf_rule_t * rule, + logmath_t * lmath, float32 lw); + + #ifdef __cplusplus } #endif diff --git a/src/util/ckd_alloc.h b/src/util/ckd_alloc.h index 4785ed742..2f5effd02 100644 --- a/src/util/ckd_alloc.h +++ b/src/util/ckd_alloc.h @@ -90,6 +90,8 @@ #include #include +#include + /** \file ckd_alloc.h *\brief Sphinx's memory allocation/deallocation routines. @@ -136,13 +138,15 @@ void ckd_fail(char *format, ...); * message if any error occurs, with any other behaviour determined by * ckd_set_jump(), above. */ - +POCKETSPHINX_EXPORT void *__ckd_calloc__(size_t n_elem, size_t elem_size, const char *caller_file, int caller_line); +POCKETSPHINX_EXPORT void *__ckd_malloc__(size_t size, const char *caller_file, int caller_line); +POCKETSPHINX_EXPORT void *__ckd_realloc__(void *ptr, size_t new_size, const char *caller_file, int caller_line); @@ -150,6 +154,7 @@ void *__ckd_realloc__(void *ptr, size_t new_size, * Like strdup, except that if an error occurs it prints a diagnostic message and * exits. If origin in NULL the function also returns NULL. */ +POCKETSPHINX_EXPORT char *__ckd_salloc__(const char *origstr, const char *caller_file, int caller_line); @@ -157,6 +162,7 @@ char *__ckd_salloc__(const char *origstr, * Allocate a 2-D array and return ptr to it (ie, ptr to vector of ptrs). * The data area is allocated in one block so it can also be treated as a 1-D array. */ +POCKETSPHINX_EXPORT void *__ckd_calloc_2d__(size_t d1, size_t d2, /* In: #elements in the 2 dimensions */ size_t elemsize, /* In: Size (#bytes) of each element */ const char *caller_file, int caller_line); /* In */ @@ -205,11 +211,13 @@ void *__ckd_alloc_2d_ptr(size_t d1, /** * Test and free a 1-D array */ +POCKETSPHINX_EXPORT void ckd_free(void *ptr); /** * Free a 2-D array (ptr) previously allocated by ckd_calloc_2d */ +POCKETSPHINX_EXPORT void ckd_free_2d(void *ptr); /** diff --git a/src/util/cmd_ln.h b/src/util/cmd_ln.h index 13f2c3612..4d7381848 100644 --- a/src/util/cmd_ln.h +++ b/src/util/cmd_ln.h @@ -62,6 +62,7 @@ #include #include +#include #include "util/hash_table.h" @@ -193,6 +194,7 @@ int cmd_ln_free_r(cmd_ln_t *cmdln); * @return A cmd_ln_t containing the results of command line parsing, * or NULL on failure. **/ +POCKETSPHINX_EXPORT cmd_ln_t *cmd_ln_parse_r(cmd_ln_t *inout_cmdln, /**< In/Out: Previous command-line to update, or NULL to create a new one. */ arg_t const *defn, /**< In: Array of argument name definitions */ @@ -211,6 +213,7 @@ cmd_ln_t *cmd_ln_parse_r(cmd_ln_t *inout_cmdln, /**< In/Out: Previous command-li * * @return A cmd_ln_t containing the results of command line parsing, or NULL on failure. */ +POCKETSPHINX_EXPORT cmd_ln_t *cmd_ln_parse_file_r(cmd_ln_t *inout_cmdln, /**< In/Out: Previous command-line to update, or NULL to create a new one. */ arg_t const *defn, /**< In: Array of argument name definitions*/ @@ -256,6 +259,7 @@ void cmd_ln_set_str_extra_r(cmd_ln_t *cmdln, char const *name, char const *str); * @param cmdln command-line object * @param defn array of argument name definitions. */ +POCKETSPHINX_EXPORT void cmd_ln_log_help_r (cmd_ln_t *cmdln, const arg_t *defn); /** diff --git a/src/util/filename.h b/src/util/filename.h index b1aec059c..e06ecdafa 100644 --- a/src/util/filename.h +++ b/src/util/filename.h @@ -62,6 +62,7 @@ #define _LIBUTIL_FILENAME_H_ #include +#include /**\file filename.h *\brief File names related operation @@ -83,6 +84,7 @@ const char *path2basename(const char *path); * Strip off filename from the given path and copy the directory name into dir * Caller must have allocated dir (hint: it's always shorter than path). */ +POCKETSPHINX_EXPORT void path2dirname(const char *path, char *dir); diff --git a/src/util/pio.h b/src/util/pio.h index f440ee5f7..2eb23acf7 100644 --- a/src/util/pio.h +++ b/src/util/pio.h @@ -88,6 +88,7 @@ #endif #include +#include /** \file pio.h * \brief file IO related operations. @@ -161,6 +162,7 @@ int32 fread_retry(void *pointer, int32 size, int32 num_items, FILE *stream); * @param out_len Output: if not NULL, length of the string read. * @return allocated string containing the line, or NULL on error or EOF. */ +POCKETSPHINX_EXPORT char *fread_line(FILE *stream, size_t *out_len); /** @@ -178,6 +180,7 @@ typedef struct lineiter_t { /** * Start reading lines from a file. */ +POCKETSPHINX_EXPORT lineiter_t *lineiter_start(FILE *fh); /** @@ -188,6 +191,7 @@ lineiter_t *lineiter_start_clean(FILE *fh); /** * Move to the next line in the file. */ +POCKETSPHINX_EXPORT lineiter_t *lineiter_next(lineiter_t *li); /** @@ -277,6 +281,7 @@ int32 stat_mtime (const char *file); * * @return 0 on success, <0 on failure. */ +POCKETSPHINX_EXPORT int build_directory(const char *path); #ifdef __cplusplus diff --git a/src/util/strfuncs.h b/src/util/strfuncs.h index 57116c60b..a05b0e4ee 100644 --- a/src/util/strfuncs.h +++ b/src/util/strfuncs.h @@ -45,6 +45,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -58,6 +59,7 @@ extern "C" { * Concatenate a NULL-terminated argument list of strings, returning a * newly allocated string. **/ +POCKETSPHINX_EXPORT char *string_join(const char *base, ...); /** @@ -75,6 +77,7 @@ enum string_edge_e { * @param string string to trim, contents will be modified. * @param which one of STRING_START, STRING_END, or STRING_BOTH. */ +POCKETSPHINX_EXPORT char *string_trim(char *string, enum string_edge_e which); /** @@ -84,6 +87,7 @@ char *string_trim(char *string, enum string_edge_e which); * locale in a threaded program is extremely uncool, therefore we need * this since we pass floats as strings in 1000 different places. */ +POCKETSPHINX_EXPORT double atof_c(char const *str); /* FIXME: Both of these string splitting functions basically suck. I @@ -96,6 +100,7 @@ double atof_c(char const *str); * every word in the line. * Return value: No. of words found; -1 if no. of words in line exceeds n_wptr. */ +POCKETSPHINX_EXPORT int32 str2words (char *line, /**< In/Out: line to be parsed. This string will be modified! (NUL characters inserted at word