23 static char *dbmscap_files[] = {
27 "/usr/local/lib/dbmscap",
28 "/usr/local/dbmi/lib/dbmscap",
35 static char *dbmscap_filename(
int err_flag)
44 for (i = 0; (file = dbmscap_files[i]); i++) {
45 if (access(file, 0) == 0)
51 return ((
char *)
NULL);
61 return dbmscap_filename(1);
72 return (dbmscap_filename(0) !=
NULL);
127 fd = fopen(file,
"r");
140 for (line = 1; fgets(buf,
sizeof buf, fd); line++) {
141 if (sscanf(buf,
"%1s", comment) != 1 || *comment ==
'#')
143 if (sscanf(buf,
"%[^:]:%[^:]:%[^:\n]",
name, startup, comment) == 3)
144 add_entry(&list,
name, startup, comment);
145 else if (sscanf(buf,
"%[^:]:%[^:\n]",
name, startup) == 2)
146 add_entry(&list,
name, startup,
"");
148 fprintf(stderr,
"%s: line %d: invalid entry\n", file, line);
149 fprintf(stderr,
"%d:%s\n", line, buf);
163 sprintf(dirpath,
"%s\\driver\\db\\",
G_gisbase());
169 G_debug(2,
"dbDbmscap(): opendir [%s]", dirpath);
181 if ((strcmp(ent->d_name,
".") == 0)
182 || (strcmp(ent->d_name,
"..") == 0))
187 if (strstr(ent->d_name,
".manifest"))
195 dirpath =
G_malloc(strlen(
"\\driver\\db\\")
196 + strlen(
G_gisbase()) + strlen(ent->d_name) + 1);
197 sprintf(dirpath,
"%s\\driver\\db\\%s",
G_gisbase(), ent->d_name);
202 add_entry(&list, name, dirpath,
"");
216 static void add_entry(
dbDbmscap **
list,
char *
name,
char *startup,
char *comment)
237 while (tail && tail->
next && cmp_entry(tail->
next,cur)<0)
241 if (tail && cmp_entry(tail,cur)<0) {
263 for (cur = list; cur; cur = next) {
dbDbmscap * db_read_dbmscap(void)
Read dbmscap.
void G_free(void *)
Free allocated memory.
void db_free(void *)
Free allocated memory.
void db_syserror(const char *)
Report system error.
char * G_str_replace(const char *, const char *, const char *)
Replace all occurrences of old_str in buffer with new_str.
const char * db_dbmscap_filename(void)
Get dbmscap file name.
void db_copy_dbmscap_entry(dbDbmscap *dst, dbDbmscap *src)
Copy dbmscap entry.
void db_error(const char *)
Report error message.
const char * G_gisbase(void)
Get full path name of the top level module directory.
void db_free_dbmscap(dbDbmscap *list)
Free dbmscap.
void * db_malloc(int)
Allocate memory.
int G_asprintf(char **, 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...
int db_has_dbms(void)
Check dbms.
int G_debug(int, const char *,...) __attribute__((format(printf