xdrprocedure.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*!
  2. \file lib/db/dbmi_base/xdrprocedure.c
  3. \brief DBMI Library (base) - external data representation (procedure)
  4. (C) 1999-2009, 2011 by the GRASS Development Team
  5. This program is free software under the GNU General Public License
  6. (>=v2). Read the file COPYING that comes with GRASS for details.
  7. \author Joel Jones (CERL/UIUC), Radim Blazek, Brad Douglas, Markus Neteler
  8. \author Doxygenized by Martin Landa <landa.martin gmail.com> (2011)
  9. */
  10. #include "xdr.h"
  11. #include "macros.h"
  12. /*!
  13. \brief ? (client only)
  14. \param procnum
  15. \return
  16. */
  17. int db__start_procedure_call(int procnum)
  18. {
  19. int reply;
  20. DB_SEND_INT(procnum);
  21. DB_RECV_INT(&reply);
  22. if (reply != procnum) {
  23. if (reply == 0) {
  24. db_noproc_error(procnum);
  25. }
  26. else {
  27. db_protocol_error();
  28. }
  29. return DB_PROTOCOL_ERR;
  30. }
  31. return DB_OK;
  32. }
  33. /*!
  34. \brief ? (driver only)
  35. \param n
  36. \return DB_OK ok
  37. \return DB_EOF eof from client
  38. */
  39. int db__recv_procnum(int *n)
  40. {
  41. int stat = DB_OK;
  42. if (!db__recv(n, sizeof(*n)))
  43. stat = DB_EOF;
  44. return stat;
  45. }
  46. /*!
  47. \brief ?
  48. \param n
  49. \return
  50. */
  51. int db__send_procedure_ok(int n)
  52. {
  53. return db__send_int(n);
  54. }
  55. /*!
  56. \brief ?
  57. \param n
  58. \return
  59. */
  60. int db__send_procedure_not_implemented(int n)
  61. {
  62. return db__send_int(n ? 0 : -1);
  63. }