rewind.c 1.3 KB

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