char **lines;
int num_lines, i;
char *msgid, *msgstr;
- TDB_DATA data;
+ TDB_DATA key, data;
lines = file_lines_load(msg_file, &num_lines,0);
}
all_string_sub(msgid, "\\n", "\n", 0);
all_string_sub(msgstr, "\\n", "\n", 0);
- data = string_term_tdb_data(msgstr);
- tdb_store_bystring(tdb, msgid, data, 0);
+ key.dptr = msgid;
+ key.dsize = strlen(msgid)+1;
+ data.dptr = msgstr;
+ data.dsize = strlen(msgstr)+1;
+ tdb_store(tdb, key, data, 0);
msgid = NULL;
}
}
*/
const char *lang_msg(const char *msgid)
{
- TDB_DATA data;
+ TDB_DATA key, data;
const char *p;
char *q, *msgid_quoted;
int count;
*q = 0;
- data = tdb_fetch_bystring(tdb, msgid_quoted);
+ key.dptr = (char *)msgid_quoted;
+ key.dsize = strlen(msgid_quoted)+1;
+
+ data = tdb_fetch(tdb, key);
free(msgid_quoted);
free((void *)msgstr);
}
+
+/*
+ when the _() translation macro is used there is no obvious place to free
+ the resulting string and there is no easy way to give a static pointer.
+ All we can do is rotate between some static buffers and hope a single d_printf()
+ doesn't have more calls to _() than the number of buffers
+*/
+const char *lang_msg_rotate(const char *msgid)
+{
+#define NUM_LANG_BUFS 16
+ char *msgstr;
+ static pstring bufs[NUM_LANG_BUFS];
+ static int next;
+
+ msgstr = (char *)lang_msg(msgid);
+ if (!msgstr) return msgid;
+
+ pstrcpy(bufs[next], msgstr);
+ msgstr = bufs[next];
+
+ next = (next+1) % NUM_LANG_BUFS;
+
+ return msgstr;
+}
+
+
/*
return the current language - needed for language file mappings
*/