r_labels.c 855 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <string.h>
  2. #include <grass/gis.h>
  3. #include "labels.h"
  4. #include "local_proto.h"
  5. #define KEY(x) (strcmp(key,x)==0)
  6. static char *help[] = {
  7. "font fontname",
  8. ""
  9. };
  10. int read_labels(char *name, char *mapset)
  11. {
  12. char fullname[GNAME_MAX + 2 * GMAPSET_MAX + 4];
  13. char buf[1024];
  14. char *key, *data;
  15. sprintf(fullname, "%s in %s", name, mapset);
  16. if (labels.count >= MAXLABELS) {
  17. error(fullname, "", "no more label files allowed");
  18. return 0;
  19. }
  20. labels.name[labels.count] = G_store(name);
  21. labels.mapset[labels.count] = G_store(mapset);
  22. while (input(2, buf, help)) {
  23. if (!key_data(buf, &key, &data))
  24. continue;
  25. if (KEY("font")) {
  26. get_font(data);
  27. labels.font[labels.count] = G_store(data);
  28. continue;
  29. }
  30. error(key, "", "illegal request (labels)");
  31. }
  32. labels.count++;
  33. return 1;
  34. }