read_stats.c 453 B

123456789101112131415161718192021222324
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <grass/gis.h>
  4. #include <grass/glocale.h>
  5. int read_stats(FILE * fd, long *cat1, long *cat2, double *value)
  6. {
  7. char buf[1024];
  8. if (fgets(buf, sizeof(buf), fd) == NULL)
  9. return 0;
  10. if (sscanf(buf, "%ld %ld %lf", cat1, cat2, value) == 3) {
  11. G_debug(3, "base: %ld cover: %ld val: %lf", *cat1, *cat2, *value);
  12. return 1;
  13. }
  14. G_fatal_error(_("Reading r.stats output"));
  15. return -1;
  16. }