ld_cmd.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * $Id$
  3. *
  4. * LDAP Database Driver for SER
  5. *
  6. * Copyright (C) 2008 iptelorg GmbH
  7. *
  8. * This file is part of SER, a free SIP server.
  9. *
  10. * SER is free software; you can redistribute it and/or modify it under the
  11. * terms of the GNU General Public License as published by the Free Software
  12. * Foundation; either version 2 of the License, or (at your option) any later
  13. * version.
  14. *
  15. * SER is distributed in the hope that it will be useful, but WITHOUT ANY
  16. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  17. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  18. * details.
  19. *
  20. * You should have received a copy of the GNU General Public License along
  21. * with this program; if not, write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  23. */
  24. #ifndef _LD_CMD_H
  25. #define _LD_CMD_H
  26. /** \addtogroup ldap
  27. * @{
  28. */
  29. /** \file
  30. * Declaration of ld_cmd data structure that contains LDAP specific data
  31. * stored in db_cmd structures and related functions.
  32. */
  33. #include "../../lib/srdb2/db_drv.h"
  34. #include "../../lib/srdb2/db_cmd.h"
  35. #include "../../lib/srdb2/db_res.h"
  36. #include "../../str.h"
  37. #include <stdarg.h>
  38. #include <sys/time.h>
  39. /** Extension structure of db_cmd adding LDAP specific data.
  40. * This data structure extends the generic data structure db_cmd in the
  41. * database API with data specific to the ldap driver.
  42. */
  43. struct ld_cmd {
  44. db_drv_t gen; /**< Generic part of the data structure (must be first */
  45. char* base; /**< Search base of the command */
  46. int scope; /**< Scope of the search */
  47. str filter; /**< To be added to the search filter */
  48. char** result; /**< An array with result attribute names for ldap_search */
  49. int sizelimit; /**< retrieve at most sizelimit entries for a search */
  50. struct timeval timelimit; /**< wait at most timelimit seconds for a search to complete */
  51. int chase_references; /**< dereference option for LDAP library */
  52. int chase_referrals; /**< follow referrals option for LDAP library */
  53. };
  54. /** Creates a new ld_cmd data structure.
  55. * This function allocates and initializes memory for a new ld_cmd data
  56. * structure. The data structure is then attached to the generic db_cmd
  57. * structure in cmd parameter.
  58. * @param cmd A generic db_cmd structure to which the newly created ld_cmd
  59. * structure will be attached.
  60. */
  61. int ld_cmd(db_cmd_t* cmd);
  62. /** The main execution function in ldap SER driver.
  63. * This is the main execution function in this driver. It is executed whenever
  64. * a SER module calls db_exec and the target database of the commands is
  65. * ldap.
  66. * @param res A pointer to (optional) result structure if the command returns
  67. * a result.
  68. * @retval 0 if executed successfully
  69. * @retval A negative number if the database server failed to execute command
  70. * @retval A positive number if there was an error on client side (SER)
  71. */
  72. int ld_cmd_exec(db_res_t* res, db_cmd_t* cmd);
  73. int ld_cmd_first(db_res_t* res);
  74. int ld_cmd_next(db_res_t* res);
  75. int ld_cmd_setopt(db_cmd_t* cmd, char* optname, va_list ap);
  76. /** @} */
  77. #endif /* _LD_CMD_H */