new: seperate ctx init and new functions
This commit is contained in:
parent
d2d6679060
commit
61ab7f66ac
@ -55,7 +55,8 @@ typedef bool (*lm_ctx_check_callback_t)(
|
|||||||
/* ###############
|
/* ###############
|
||||||
## ctx stuff ##
|
## ctx stuff ##
|
||||||
############### */
|
############### */
|
||||||
bool lm_ctx_init(lm_ctx_t *ctx, char *root_dir, char *temp_dir, char *data_dir);
|
bool lm_ctx_init(lm_ctx_t *ctx);
|
||||||
|
bool lm_ctx_new(lm_ctx_t *ctx, char *root_dir, char *temp_dir, char *data_dir);
|
||||||
void lm_ctx_free(lm_ctx_t *ctx);
|
void lm_ctx_free(lm_ctx_t *ctx);
|
||||||
|
|
||||||
/* ####################
|
/* ####################
|
||||||
|
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2024-08-04 13:06+0300\n"
|
"POT-Creation-Date: 2024-08-04 15:24+0300\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
bool __lm_ctx_init_checkdir(char *path){
|
bool __lm_ctx_init_checkdir(char *path){
|
||||||
if(!mkdir_ifnot(path)){
|
if(!mkdir_ifnot(path)){
|
||||||
@ -28,17 +29,33 @@ bool __lm_ctx_init_checkdir(char *path){
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lm_ctx_init(lm_ctx_t *ctx, char *root_dir, char *temp_dir, char *data_dir) {
|
bool lm_ctx_init(lm_ctx_t *ctx) {
|
||||||
|
if(NULL == ctx){
|
||||||
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
textdomain("libmp");
|
textdomain("libmp");
|
||||||
|
|
||||||
char *suberr = NULL;
|
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
bzero(ctx, sizeof(lm_ctx_t));
|
bzero(ctx, sizeof(lm_ctx_t));
|
||||||
ctx->version = LM_VERSION;
|
ctx->version = LM_VERSION;
|
||||||
lm_error_clear();
|
lm_error_clear();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool lm_ctx_new(lm_ctx_t *ctx, char *root_dir, char *temp_dir, char *data_dir) {
|
||||||
|
if(NULL == ctx){
|
||||||
|
lm_error_set(LM_ERR_ArgNULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *suberr = NULL;
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
|
lm_ctx_init(ctx);
|
||||||
|
|
||||||
if(root_dir != NULL && !__lm_ctx_init_checkdir(root_dir)){
|
if(root_dir != NULL && !__lm_ctx_init_checkdir(root_dir)){
|
||||||
suberr = lm_strerror_dup();
|
suberr = lm_strerror_dup();
|
||||||
pdebug(__func__, "check failed for specified root directory: %s", lm_strerror());
|
pdebug(__func__, "check failed for specified root directory: %s", lm_strerror());
|
||||||
@ -83,7 +100,7 @@ void lm_ctx_free(lm_ctx_t *ctx) {
|
|||||||
|
|
||||||
if(NULL != ctx->db)
|
if(NULL != ctx->db)
|
||||||
lm_database_free(ctx->db);
|
lm_database_free(ctx->db);
|
||||||
|
|
||||||
lm_error_clear();
|
lm_error_clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user