my_cmd.h 2.2 KB

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