4 This file is part of avahi.
6 avahi is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
11 avahi is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with avahi; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
28 #include <avahi-common/malloc.h>
32 static GDBM_FILE gdbm_file = NULL;
33 static char *buffer = NULL;
35 static int init(void) {
40 if (!(gdbm_file = gdbm_open((char*) DATABASE_FILE, 0, GDBM_READER, 0, NULL)))
46 const char* stdb_lookup(const char *name) {
56 if ((loc = setlocale(LC_MESSAGES, NULL))) {
59 snprintf(k, sizeof(k), "%s[%s]", name, loc);
61 key.dsize = strlen(k);
62 data = gdbm_fetch(gdbm_file, key);
66 snprintf(l, sizeof(l), "%s", loc);
68 if ((e = strchr(l, '@'))) {
70 snprintf(k, sizeof(k), "%s[%s]", name, l);
72 key.dsize = strlen(k);
73 data = gdbm_fetch(gdbm_file, key);
77 if ((e = strchr(l, '_'))) {
79 snprintf(k, sizeof(k), "%s[%s]", name, l);
81 key.dsize = strlen(k);
82 data = gdbm_fetch(gdbm_file, key);
89 key.dptr = (char*) name;
90 key.dsize = strlen(name);
91 data = gdbm_fetch(gdbm_file, key);
98 buffer = avahi_strndup(data.dptr, data.dsize);
108 void stdb_shutdown(void) {
110 gdbm_close(gdbm_file);