GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
loc_info.c
Go to the documentation of this file.
1 #include <grass/imagery.h>
2 #include <string.h>
3 #include <grass/gis.h>
4 
5 /* makes a three part title with location, mapset info */
6 char *I_location_info(const char *middle)
7 {
8  char left[80];
9  char right[80];
10  char *buf;
11  int len, buf_len;
12 
13  G_snprintf(left, 80, "LOCATION: %s", G_location());
14  G_snprintf(right, 80, "MAPSET: %s", G_mapset());
15  len = 79 - strlen(left) - strlen(middle) - strlen(right);
16  buf_len = len + strlen(left) + strlen(middle) + strlen(right);
17  buf = (char*)G_calloc(buf_len, sizeof(char));
18  G_snprintf(buf, buf_len, "%s%*s%s%*s%s",
19  left, len / 2, "", middle, len / 2, "", right);
20 
21  return buf;
22 }
#define G_calloc(m, n)
Definition: defs/gis.h:113
const char * G_location(void)
Get current location name.
Definition: location.c:32
char * I_location_info(const char *middle)
Definition: loc_info.c:6
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
int G_snprintf(char *, size_t, const char *,...) __attribute__((format(printf