18 #include <sys/types.h>
24 static int list_element(FILE *,
const char *,
const char *,
const char *,
25 int (*)(
const char *,
const char *,
const char *));
53 int (*lister) (
const char *,
const char *,
const char *))
61 if (desc == 0 || *desc == 0)
68 fprintf(more,
"----------------------------------------------\n");
75 if (mapset == 0 || *mapset == 0)
77 count += list_element(more,
element, desc, mapset, lister);
79 count += list_element(more,
element, desc, mapset, lister);
82 if (mapset == 0 || *mapset == 0)
83 fprintf(more,
_(
"no %s files available in current mapset\n"),
86 fprintf(more,
_(
"no %s files available in mapset <%s>\n"),
89 fprintf(more,
"----------------------------------------------\n");
97 static int list_element(FILE *out,
const char *
element,
const char *desc,
const char *mapset,
98 int (*lister)(
const char *,
const char *,
const char *))
108 if (strcmp(mapset,
".") == 0)
119 if (access(
path, 0) != 0) {
132 fprintf(out,
_(
"%s files available in mapset <%s>:\n"), desc, mapset);
138 lister(
name, mapset, title);
140 fprintf(out,
"\n%-18s %-.60s\n",
name, title);
145 for (i = 0; i <
count; i++) {
148 lister(
list[i], mapset, title);
149 fprintf(out,
"%-18s %-.60s\n",
list[i], title);
157 for (i = 0; i <
count; i++)
207 buf = (
char *)
G_malloc(strlen(gisbase) + strlen(location)
208 + strlen(mapset) + strlen(el) + 4);
210 sprintf(buf,
"%s/%s/%s/%s", gisbase, location, mapset, el);
222 if (dp->d_name[0] ==
'.')
232 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_free_list(char **list)
Free list.
void G_list_element(const char *element, const char *desc, const char *mapset, int(*lister)(const char *, const char *, const char *))
General purpose list function.