xdrvalue.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <grass/dbmi.h>
  2. #include "macros.h"
  3. int db__send_value(dbValue * value, int Ctype)
  4. {
  5. DB_SEND_CHAR(value->isNull);
  6. if (value->isNull)
  7. return DB_OK;
  8. switch (Ctype) {
  9. case DB_C_TYPE_INT:
  10. DB_SEND_INT(value->i);
  11. break;
  12. case DB_C_TYPE_DOUBLE:
  13. DB_SEND_DOUBLE(value->d);
  14. break;
  15. case DB_C_TYPE_STRING:
  16. DB_SEND_STRING(&value->s);
  17. break;
  18. case DB_C_TYPE_DATETIME:
  19. DB_SEND_DATETIME(&value->t);
  20. break;
  21. default:
  22. db_error("send data: invalid C-type");
  23. return DB_FAILED;
  24. }
  25. return DB_OK;
  26. }
  27. int db__recv_value(dbValue * value, int Ctype)
  28. {
  29. DB_RECV_CHAR(&value->isNull);
  30. if (value->isNull)
  31. return DB_OK;
  32. switch (Ctype) {
  33. case DB_C_TYPE_INT:
  34. DB_RECV_INT(&value->i);
  35. break;
  36. case DB_C_TYPE_DOUBLE:
  37. DB_RECV_DOUBLE(&value->d);
  38. break;
  39. case DB_C_TYPE_STRING:
  40. DB_RECV_STRING(&value->s);
  41. break;
  42. case DB_C_TYPE_DATETIME:
  43. DB_RECV_DATETIME(&value->t);
  44. break;
  45. default:
  46. db_error("send data: invalid C-type");
  47. return DB_FAILED;
  48. }
  49. return DB_OK;
  50. }