rpc.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* $Id$
  2. *
  3. * SER Remote Procedure Call Interface
  4. *
  5. * Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27. */
  28. #ifndef _RPC_H
  29. #define _RPC_H
  30. /*
  31. * TODO: Add the possibility to add printf-like formatted string to fault
  32. */
  33. enum rpc_flags {
  34. RET_ARRAY = (1 << 0),
  35. RET_VALUE = (1 << 1)
  36. };
  37. /* Send the result to the caller */
  38. typedef int (*rpc_send_f)(void* ctx); /* Send the reply to the client */
  39. typedef void (*rpc_fault_f)(void* ctx, int code, char* fmt, ...); /* Signal a failure to the client */
  40. typedef int (*rpc_add_f)(void* ctx, char* fmt, ...); /* Add a new piece of data to the result */
  41. typedef int (*rpc_scan_f)(void* ctx, char* fmt, ...); /* Retrieve request parameters */
  42. typedef int (*rpc_printf_f)(void* ctx, char* fmt, ...); /* Add printf-like formated data to the result set */
  43. typedef int (*rpc_struct_add_f)(void* ctx, char* fmt, ...); /* Create a new structure */
  44. typedef int (*rpc_struct_scan_f)(void* ctx, char* fmt, ...); /* Scan attributes of a structure */
  45. typedef int (*rpc_struct_printf_f)(void* ctx, char* name, char* fmt, ...); /* Struct version of rpc_printf */
  46. /*
  47. * RPC context, this is what RPC functions get as a parameter and use
  48. * it to obtain the value of the parameters of the call and reference
  49. * to the result structure that will be returned to the caller
  50. */
  51. typedef struct rpc {
  52. rpc_fault_f fault;
  53. rpc_send_f send;
  54. rpc_add_f add;
  55. rpc_scan_f scan;
  56. rpc_printf_f printf;
  57. rpc_struct_add_f struct_add;
  58. rpc_struct_scan_f struct_scan;
  59. rpc_struct_printf_f struct_printf;
  60. } rpc_t;
  61. /*
  62. * RPC Function Prototype
  63. */
  64. typedef void (*rpc_function_t)(rpc_t* rpc, void* ctx);
  65. /*
  66. * Remote Procedure Call Export
  67. */
  68. typedef struct rpc_export {
  69. const char* name; /* Name of the RPC function (null terminated) */
  70. rpc_function_t function; /* Pointer to the function */
  71. const char** doc_str; /* Documentation strings, method signature and description */
  72. unsigned int flags; /* Various flags, reserved for future use */
  73. } rpc_export_t;
  74. #endif /* _RPC_H */