18 #include <sys/types.h>
24 static int list_element(FILE *,
const char *,
const char *,
const char *,
25 int (*)(
const char *,
const char *,
char *));
52 int (*lister)(
const char *,
const char *,
char *))
60 if (desc == 0 || *desc == 0)
67 fprintf(more,
"----------------------------------------------\n");
74 if (mapset == 0 || *mapset == 0)
76 count += list_element(more,
element, desc, mapset, lister);
78 count += list_element(more,
element, desc, mapset, lister);
81 if (mapset == 0 || *mapset == 0)
82 fprintf(more,
_(
"no %s files available in current mapset\n"), desc);
84 fprintf(more,
_(
"no %s files available in mapset <%s>\n"), desc,
87 fprintf(more,
"----------------------------------------------\n");
95 static int list_element(FILE *out,
const char *
element,
const char *desc,
97 int (*lister)(
const char *,
const char *,
char *))
107 if (strcmp(mapset,
".") == 0)
117 if (access(
path, 0) != 0) {
130 fprintf(out,
_(
"%s files available in mapset <%s>:\n"), desc, mapset);
136 lister(
name, mapset, title);
138 fprintf(out,
"\n%-18s %-.60s\n",
name, title);
143 for (i = 0; i <
count; i++) {
146 lister(
list[i], mapset, title);
147 fprintf(out,
"%-18s %-.60s\n",
list[i], title);
155 for (i = 0; i <
count; i++)
204 buf = (
char *)
G_malloc(strlen(gisbase) + strlen(location) + strlen(mapset) +
207 sprintf(buf,
"%s/%s/%s/%s", gisbase, location, mapset, el);
218 while ((dp = readdir(dirp)) !=
NULL) {
219 if (dp->d_name[0] ==
'.')
228 while ((dp = readdir(dirp)) !=
NULL) {
229 if (dp->d_name[0] ==
'.')
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
FILE * G_open_pager(struct Popen *)
char * G_file_name(char *, const char *, const char *, const char *)
Builds full path names to GIS data files.
const char * G_get_mapset_name(int)
Get name of the n'th mapset from the current mapset search path.
void G_close_pager(struct Popen *)
const char * G_mapset(void)
Get current mapset name.
void G_ls_format(char **, int, int, FILE *)
Prints a listing of items to a stream, in prettified column format.
char ** G_ls2(const char *, int *)
Stores a sorted directory listing in an array.
char ** G_list(int element, const char *gisbase, const char *location, const char *mapset)
List specified type of elements. Application must release the allocated memory.
void G_list_element(const char *element, const char *desc, const char *mapset, int(*lister)(const char *, const char *, char *))
General purpose list function.
void G_free_list(char **list)
Free list.