loc_info.c 655 B

1234567891011121314151617181920212223
  1. #include <grass/imagery.h>
  2. #include <string.h>
  3. #include <grass/gis.h>
  4. /* makes a three part title with location, mapset info */
  5. char *I_location_info(const char *middle)
  6. {
  7. char left[80];
  8. char right[80];
  9. char *buf;
  10. int len, buf_len;
  11. G_snprintf(left, 80, "LOCATION: %s", G_location());
  12. G_snprintf(right, 80, "MAPSET: %s", G_mapset());
  13. len = 79 - strlen(left) - strlen(middle) - strlen(right);
  14. buf_len = len + strlen(left) + strlen(middle) + strlen(right);
  15. buf = (char*)G_calloc(buf_len, sizeof(char));
  16. G_snprintf(buf, buf_len, "%s%*s%s%*s%s",
  17. left, len / 2, "", middle, len / 2, "", right);
  18. return buf;
  19. }