*/
#include "includes.h"
+#include "system/filesys.h"
+#include "intl/lang_tdb.h"
+#include "util_tdb.h"
+#include "lib/util/util_paths.h"
static TDB_CONTEXT *tdb;
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;
struct stat st;
static int initialised;
time_t loadtime;
- bool result = False;
+ bool result = false;
+ char *dpath = NULL;
+ char *lpath = NULL;
/* we only want to init once per process, unless given
an override */
if (!lang)
return True;
- if (asprintf(&msg_path, "%s.msg",
- data_path((const char *)lang)) == -1) {
+ dpath = data_path(talloc_tos(), (const char *)lang);
+ if (dpath == NULL) {
+ goto done;
+ }
+
+ if (asprintf(&msg_path, "%s.msg", dpath) == -1) {
DEBUG(0, ("asprintf failed\n"));
goto done;
}
strerror(errno)));
goto done;
}
-
- if (asprintf(&path, "%s%s.tdb", lock_path("lang_"), lang) == -1) {
+
+ lpath = lock_path("lang_");
+ if (lpath == NULL) {
+ goto done;
+ }
+
+ if (asprintf(&path, "%s%s.tdb", lpath, lang) == -1) {
DEBUG(0, ("asprintf failed\n"));
goto done;
}
done:
SAFE_FREE(msg_path);
SAFE_FREE(path);
+ TALLOC_FREE(lpath);
+ TALLOC_FREE(dpath);
return result;
}
void lang_msg_free(const char *msgstr)
{
if (!tdb) return;
- free((void *)msgstr);
+ free(discard_const_p(void, msgstr));
}
/*