*/
#include "includes.h"
+#include "system/filesys.h"
+#include "intl/lang_tdb.h"
+#include "util_tdb.h"
static TDB_CONTEXT *tdb;
/* load a msg file into the tdb */
-static BOOL load_msg(const char *msg_file)
+static bool load_msg(const char *msg_file)
{
char **lines;
int num_lines, i;
char *msgid, *msgstr;
TDB_DATA data;
- lines = file_lines_load(msg_file, &num_lines,0);
+ lines = file_lines_load(msg_file, &num_lines, 0, NULL);
if (!lines) {
return False;
}
if (tdb_lockall(tdb) != 0) {
- file_lines_free(lines);
+ TALLOC_FREE(lines);
return False;
}
/* wipe the db */
- tdb_traverse(tdb, tdb_traverse_delete_fn, NULL);
+ tdb_wipe_all(tdb);
msgid = NULL;
}
}
- file_lines_free(lines);
+ TALLOC_FREE(lines);
tdb_unlockall(tdb);
return True;
/* initialise the message translation subsystem. If the "lang" argument
is NULL then get the language from the normal environment variables */
-BOOL lang_tdb_init(const char *lang)
+bool lang_tdb_init(const char *lang)
{
char *path = NULL;
char *msg_path = NULL;
struct stat st;
static int initialised;
time_t loadtime;
- BOOL result = False;
+ bool result = False;
/* we only want to init once per process, unless given
an override */
if (!lang)
return True;
- asprintf(&msg_path, "%s.msg", lib_path((const char *)lang));
+ if (asprintf(&msg_path, "%s.msg",
+ data_path(talloc_tos(), (const char *)lang)) == -1) {
+ DEBUG(0, ("asprintf failed\n"));
+ goto done;
+ }
if (stat(msg_path, &st) != 0) {
/* the msg file isn't available */
DEBUG(10, ("lang_tdb_init: %s: %s\n", msg_path,
goto done;
}
- asprintf(&path, "%s%s.tdb", lock_path("lang_"), lang);
+ if (asprintf(&path, "%s%s.tdb", lock_path("lang_"), lang) == -1) {
+ DEBUG(0, ("asprintf failed\n"));
+ goto done;
+ }
DEBUG(10, ("lang_tdb_init: loading %s\n", path));
void lang_msg_free(const char *msgstr)
{
if (!tdb) return;
- free((void *)msgstr);
+ free(discard_const_p(void, msgstr));
}
/*