1 #define MODULE_API_REVISION 2
2 
3 struct rtpp_cfg_stable;
4 struct rtpp_module_priv;
5 struct rtpp_acct;
6 
7 #if !defined(MODULE_IF_CODE)
8 #include <sys/types.h>
9 #include "rtpp_types.h"
10 #endif
11 
12 DEFINE_METHOD(rtpp_cfg_stable, rtpp_module_ctor, struct rtpp_module_priv *);
13 DEFINE_METHOD(rtpp_module_priv, rtpp_module_dtor, void);
14 DEFINE_METHOD(rtpp_module_priv, rtpp_module_on_session_end, void,
15   struct rtpp_acct *);
16 
17 #include <stdarg.h>
18 
19 DEFINE_RAW_METHOD(rtpp_module_malloc, void *, size_t,  void *, const char *,
20   int, const char *);
21 DEFINE_RAW_METHOD(rtpp_module_zmalloc, void *, size_t,  void *, const char *,
22   int, const char *);
23 DEFINE_RAW_METHOD(rtpp_module_free, void, void *, void *, const char *, int,
24   const char *);
25 DEFINE_RAW_METHOD(rtpp_module_realloc, void *, void *, size_t,   void *,
26   const char *, int, const char *);
27 DEFINE_RAW_METHOD(rtpp_module_strdup, char *, const char *,  void *,
28   const char *, int, const char *);
29 DEFINE_RAW_METHOD(rtpp_module_asprintf, int, char **, const char *,
30    void *, const char *, int, const char *, ...);
31 DEFINE_RAW_METHOD(rtpp_module_vasprintf, int, char **, const char *,
32    void *, const char *, int, const char *, va_list);
33 
34 #if !defined(MODULE_IF_CODE)
35 #define mod_malloc(n) rtpp_module._malloc((n), rtpp_module.memdeb_p, \
36   __FILE__, __LINE__, __func__)
37 #define mod_zmalloc(n) rtpp_module._zmalloc((n), rtpp_module.memdeb_p, \
38   __FILE__, __LINE__, __func__)
39 #define mod_free(p) rtpp_module._free((p), rtpp_module.memdeb_p, \
40   __FILE__, __LINE__, __func__)
41 #define mod_realloc(p,n) rtpp_module._realloc((p), (n), rtpp_module.memdeb_p, \
42   __FILE__, __LINE__, __func__)
43 #define mod_strdup(p) rtpp_module._strdup((p), rtpp_module.memdeb_p, \
44   __FILE__, __LINE__, __func__)
45 #define mod_asprintf(pp, fmt, args...) rtpp_module._asprintf((pp), (fmt), \
46   rtpp_module.memdeb_p, __FILE__, __LINE__, __func__, ## args)
47 #define mod_vasprintf(pp, fmt, vl) rtpp_module._vasprintf((pp), (fmt), \
48   rtpp_module.memdeb_p, __FILE__, __LINE__, __func__, (vl))
49 #endif
50 
51 struct api_version {
52     int rev;
53     size_t mi_size;
54 };
55 
56 struct api_on_sess_end {
57    int rev;
58    size_t argsize;
59    rtpp_module_on_session_end_t func;
60 };
61 
62 struct rtpp_minfo {
63     /* Upper half, filled by the module */
64     struct api_version ver;
65     const char *name;
66     const char *author;
67     const char *copyright;
68     const char *maintainer;
69     rtpp_module_ctor_t ctor;
70     rtpp_module_dtor_t dtor;
71     struct api_on_sess_end on_session_end;
72     /* Lower half, filled by the core */
73     rtpp_module_malloc_t _malloc;
74     rtpp_module_zmalloc_t _zmalloc;
75     rtpp_module_free_t _free;
76     rtpp_module_realloc_t _realloc;
77     rtpp_module_strdup_t _strdup;
78     rtpp_module_asprintf_t _asprintf;
79     rtpp_module_vasprintf_t _vasprintf;
80     void *memdeb_p;
81 };
82 
83 #define MI_VER_INIT() {.rev = MODULE_API_REVISION, .mi_size = sizeof(rtpp_module)}
84 #define MI_VER_CHCK(sptr) ((sptr)->ver.rev == MODULE_API_REVISION && \
85   (sptr)->ver.mi_size == sizeof(struct rtpp_minfo))
86