changed render levels for labels/place names
[navit-package] / src / data / poi_geodownload / libmdb / options.c
1 /* MDB Tools - A library for reading MS Access database file
2  * Copyright (C) 2004 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <stdio.h>
21 #include <string.h>
22 #include <stdarg.h>
23 #include <stdlib.h>
24
25 #include <mdbtools.h>
26
27 #ifdef DMALLOC
28 #include "dmalloc.h"
29 #endif
30
31 #define DEBUG 1
32
33 static unsigned long opts;
34 static int optset;
35
36 static void load_options();
37
38 void
39 mdb_debug(int klass, char *fmt, ...)
40 {
41 #ifdef DEBUG
42         va_list ap;
43
44         if (!optset) load_options();
45         if (klass & opts) {     
46         va_start(ap, fmt);
47         vfprintf (stdout,fmt, ap);
48         va_end(ap);
49         fprintf(stdout,"\n");
50         }
51 #endif
52 }
53
54 static void
55 load_options()
56 {
57         char *opt;
58         char *s;
59
60     if (!optset && (s=getenv("MDBOPTS"))) {
61                 opt = strtok(s, ":");
62                 do {
63                 if (!strcmp(opt, "use_index")) opts |= MDB_USE_INDEX;
64                 if (!strcmp(opt, "debug_like")) opts |= MDB_DEBUG_LIKE;
65                 if (!strcmp(opt, "debug_write")) opts |= MDB_DEBUG_WRITE;
66                 if (!strcmp(opt, "debug_usage")) opts |= MDB_DEBUG_USAGE;
67                 if (!strcmp(opt, "debug_ole")) opts |= MDB_DEBUG_OLE;
68                 if (!strcmp(opt, "debug_row")) opts |= MDB_DEBUG_ROW;
69                 if (!strcmp(opt, "debug_all")) {
70                                 opts |= MDB_DEBUG_LIKE;
71                                 opts |= MDB_DEBUG_WRITE;
72                                 opts |= MDB_DEBUG_USAGE;
73                                 opts |= MDB_DEBUG_OLE;
74                                 opts |= MDB_DEBUG_ROW;
75                         }
76                         opt = strtok(NULL,":");
77                 } while (opt);
78     }
79         optset = 1;
80 }
81 int
82 mdb_get_option(unsigned long optnum)
83 {
84         if (!optset) load_options();
85         return ((opts & optnum) > 0);
86 }