rewind.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*!
  2. \file rewind.c
  3. \brief Vector library - rewind data
  4. Higher level functions for reading/writing/manipulating vectors.
  5. (C) 2001-2008 by the GRASS Development Team
  6. This program is free software under the
  7. GNU General Public License (>=v2).
  8. Read the file COPYING that comes with GRASS
  9. for details.
  10. \author Original author CERL, probably Dave Gerdes or Mike Higgins.
  11. Update to GRASS 5.7 Radim Blazek and David D. Gray.
  12. \date 2001
  13. */
  14. #include <grass/Vect.h>
  15. #include <grass/glocale.h>
  16. /* Rewind vector data file to cause reads to start at beginning */
  17. /* returns 0 on success, -1 on error */
  18. static int rew_dummy()
  19. {
  20. return -1;
  21. }
  22. #ifndef HAVE_OGR
  23. static int format()
  24. {
  25. G_fatal_error(_("Requested format is not compiled in this version"));
  26. return 0;
  27. }
  28. #endif
  29. static int (*Rewind_array[][3]) () = {
  30. {
  31. rew_dummy, V1_rewind_nat, V2_rewind_nat}
  32. #ifdef HAVE_OGR
  33. , {
  34. rew_dummy, V1_rewind_ogr, V2_rewind_ogr}
  35. #else
  36. , {
  37. rew_dummy, format, format}
  38. #endif
  39. };
  40. /*!
  41. \brief Rewind vector data file to cause reads to start at beginning
  42. \param Map vector map
  43. \return 0 on success
  44. \return -1 on error
  45. */
  46. int Vect_rewind(struct Map_info *Map)
  47. {
  48. if (!VECT_OPEN(Map))
  49. return -1;
  50. G_debug(1, "Vect_Rewind(): name = %s", Map->name);
  51. return (*Rewind_array[Map->format][Map->level]) (Map);
  52. }