my_cmd.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2001-2003 FhG Fokus
  3. * Copyright (C) 2006-2007 iptelorg GmbH
  4. *
  5. * This file is part of Kamailio, a free SIP server.
  6. *
  7. * Kamailio is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version
  11. *
  12. * Kamailio is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #ifndef _MY_CMD_H
  22. #define _MY_CMD_H 1
  23. #include "../../lib/srdb2/db_drv.h"
  24. #include "../../lib/srdb2/db_cmd.h"
  25. #include <mysql/mysql.h>
  26. #include <stdarg.h>
  27. typedef enum my_flags {
  28. /** Fetch all data from the server to the client at once */
  29. MY_FETCH_ALL = (1 << 0),
  30. } my_flags_t;
  31. struct my_cmd {
  32. db_drv_t gen;
  33. str sql_cmd; /**< Database command represented in SQL language */
  34. int next_flag;
  35. MYSQL_STMT* st; /**< MySQL pre-compiled statement handle */
  36. /** This is the sequential number of the last
  37. * connection reset last time the command was
  38. * uploaded to the server. If the reset number
  39. * in the corresponding my_con structure is higher
  40. * than the number in this variable then we need
  41. * to upload the command again, because the
  42. * the connection was reconnected meanwhile.
  43. */
  44. unsigned int last_reset;
  45. unsigned int flags; /**< Various flags, mainly used by setopt and getopt */
  46. };
  47. int my_cmd(db_cmd_t* cmd);
  48. int my_cmd_exec(db_res_t* res, db_cmd_t* cmd);
  49. int my_cmd_first(db_res_t* res);
  50. int my_cmd_next(db_res_t* res);
  51. int my_getopt(db_cmd_t* cmd, char* optname, va_list ap);
  52. int my_setopt(db_cmd_t* cmd, char* optname, va_list ap);
  53. #endif /* _MY_CMD_H */