freeswitch plugin: Re-added esl header files and libesl.a, also aadded -L. to Makefil...
[collectd.git] / src / esl_oop.h
1 /*
2  * Copyright (c) 2007, Anthony Minessale II
3  * All rights reserved.
4  * 
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * 
16  * * Neither the name of the original author; nor the names of any contributors
17  * may be used to endorse or promote products derived from this software
18  * without specific prior written permission.
19  * 
20  * 
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
25  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #ifndef _ESL_OOP_H_
35 #define _ESL_OOP_H_
36 #include <esl.h>
37 #ifdef __cplusplus
38 extern "C" { 
39 #endif
40
41 #define this_check(x) do { if (!this) { esl_log(ESL_LOG_ERROR, "object is not initalized\n"); return x;}} while(0)
42 #define this_check_void() do { if (!this) { esl_log(ESL_LOG_ERROR, "object is not initalized\n"); return;}} while(0)
43
44
45 class ESLevent {
46  private:
47         esl_event_header_t *hp;
48  public:
49         esl_event_t *event;
50         char *serialized_string;
51         int mine;
52
53         ESLevent(const char *type, const char *subclass_name = NULL);
54         ESLevent(esl_event_t *wrap_me, int free_me = 0);
55         ESLevent(ESLevent *me);
56         virtual ~ESLevent();
57         const char *serialize(const char *format = NULL);
58         bool setPriority(esl_priority_t priority = ESL_PRIORITY_NORMAL);
59         const char *getHeader(const char *header_name);
60         char *getBody(void);
61         const char *getType(void);
62         bool addBody(const char *value);
63         bool addHeader(const char *header_name, const char *value);
64         bool delHeader(const char *header_name);
65         const char *firstHeader(void);
66         const char *nextHeader(void);
67 };
68
69
70
71 class ESLconnection {
72  private:
73         esl_handle_t handle;
74         ESLevent *last_event_obj;
75  public:
76         ESLconnection(const char *host, const char *port, const char *password);
77         ESLconnection(int socket);
78         virtual ~ESLconnection();
79         int connected();
80         ESLevent *getInfo();
81         int send(const char *cmd);
82         ESLevent *sendRecv(const char *cmd);
83         ESLevent *api(const char *cmd, const char *arg = NULL);
84         ESLevent *bgapi(const char *cmd, const char *arg = NULL);
85         int sendEvent(ESLevent *send_me);
86         ESLevent *recvEvent();
87         ESLevent *recvEventTimed(int ms);
88         ESLevent *filter(const char *header, const char *value);
89         int events(const char *etype, const char *value);
90         int execute(const char *app, const char *arg = NULL, const char *uuid = NULL);
91         int executeAsync(const char *app, const char *arg = NULL, const char *uuid = NULL);
92         int setAsyncExecute(const char *val);
93         int setEventLock(const char *val);
94         int disconnect(void);
95 };
96
97 void eslSetLogLevel(int level);
98
99
100
101 #ifdef __cplusplus
102 }
103 #endif
104
105 #endif