23 static char *dbmscap_files[] = {
"/etc/dbmscap",
26 "/usr/local/lib/dbmscap",
27 "/usr/local/dbmi/lib/dbmscap",
33 static char *dbmscap_filename(
int err_flag)
38 file = getenv(
"DBMSCAP");
42 for (i = 0; (
file = dbmscap_files[i]); i++) {
43 if (access(
file, 0) == 0)
49 return ((
char *)
NULL);
59 return dbmscap_filename(1);
70 return (dbmscap_filename(0) !=
NULL);
125 fd = fopen(
file,
"r");
138 for (line = 1; fgets(buf,
sizeof buf, fd); line++) {
139 if (sscanf(buf,
"%1s", comment) != 1 || *comment ==
'#')
141 if (sscanf(buf,
"%[^:]:%[^:]:%[^:\n]",
name, startup, comment) == 3)
142 add_entry(&
list,
name, startup, comment);
143 else if (sscanf(buf,
"%[^:]:%[^:\n]",
name, startup) == 2)
144 add_entry(&
list,
name, startup,
"");
146 fprintf(stderr,
"%s: line %d: invalid entry\n",
file, line);
147 fprintf(stderr,
"%d:%s\n", line, buf);
161 sprintf(dirpath,
"%s\\driver\\db\\",
G_gisbase());
167 G_debug(2,
"dbDbmscap(): opendir [%s]", dirpath);
168 dir = opendir(dirpath);
176 while ((ent = readdir(dir))) {
179 if ((strcmp(ent->d_name,
".") == 0) || (strcmp(ent->d_name,
"..") == 0))
184 if (strstr(ent->d_name,
".manifest"))
193 strlen(ent->d_name) + 1);
194 sprintf(dirpath,
"%s\\driver\\db\\%s",
G_gisbase(), ent->d_name);
199 add_entry(&
list,
name, dirpath,
"");
239 while (tail && tail->
next && cmp_entry(tail->
next, cur) < 0)
243 if (tail && cmp_entry(tail, cur) < 0) {
266 for (cur =
list; cur; cur = next) {
void db_copy_dbmscap_entry(dbDbmscap *dst, dbDbmscap *src)
Copy dbmscap entry.
void db_free_dbmscap(dbDbmscap *list)
Free dbmscap.
const char * db_dbmscap_filename(void)
Get dbmscap file name.
int db_has_dbms(void)
Check dbms.
dbDbmscap * db_read_dbmscap(void)
Read dbmscap.
void db_free(void *)
Free allocated memory.
void db_error(const char *)
Report error message.
void db_syserror(const char *)
Report system error.
void * db_malloc(int)
Allocate memory.
void G_free(void *)
Free allocated memory.
char * G_str_replace(const char *, const char *, const char *)
Replace all occurrences of old_str in buffer with new_str.
int G_asprintf(char **, const char *,...) __attribute__((format(printf
const char * G_gisbase(void)
Get full path name of the top level module directory.
int G_debug(int, const char *,...) __attribute__((format(printf
char * G_convert_dirseps_to_host(char *)
Converts directory separator characters in a string to the native host separator character (/ on Unix...