#include <switch_cpp.h>
Collaboration diagram for API:
Public Member Functions | |
| API (void) | |
| virtual | ~API () |
| const char * | execute (const char *command, const char *data=NULL) |
| const char * | executeString (const char *command) |
| char * | getTime (void) |
Protected Attributes | |
| char * | last_data |
| char | time_buf [64] |
Definition at line 104 of file switch_cpp.h.
| API::API | ( | void | ) |
Definition at line 185 of file switch_cpp.cpp.
References last_data.
00186 { 00187 last_data = NULL; 00188 }
| API::~API | ( | ) | [virtual] |
Definition at line 190 of file switch_cpp.cpp.
References last_data, and switch_safe_free.
00191 { 00192 switch_safe_free(last_data); 00193 }
| const char * API::execute | ( | const char * | command, | |
| const char * | data = NULL | |||
| ) |
Definition at line 196 of file switch_cpp.cpp.
References switch_stream_handle::data, switch_api_execute(), switch_safe_free, SWITCH_STANDARD_STREAM, and this_check.
00197 { 00198 switch_stream_handle_t stream = { 0 }; 00199 this_check(""); 00200 SWITCH_STANDARD_STREAM(stream); 00201 switch_api_execute(cmd, arg, NULL, &stream); 00202 switch_safe_free(last_data); 00203 last_data = (char *) stream.data; 00204 return last_data; 00205 }
| const char * API::executeString | ( | const char * | command | ) |
Definition at line 218 of file switch_cpp.cpp.
References switch_stream_handle::data, switch_api_execute(), switch_assert, switch_safe_free, SWITCH_STANDARD_STREAM, and this_check.
00219 { 00220 char *arg; 00221 switch_stream_handle_t stream = { 0 }; 00222 char *mycmd = strdup(cmd); 00223 00224 switch_assert(mycmd); 00225 00226 this_check(""); 00227 00228 if ((arg = strchr(mycmd, ' '))) { 00229 *arg++ = '\0'; 00230 } 00231 00232 switch_safe_free(last_data); 00233 00234 SWITCH_STANDARD_STREAM(stream); 00235 switch_api_execute(mycmd, arg, NULL, &stream); 00236 last_data = (char *) stream.data; 00237 switch_safe_free(mycmd); 00238 return last_data; 00239 }
| char * API::getTime | ( | void | ) |
Definition at line 209 of file switch_cpp.cpp.
References switch_micro_time_now(), and SWITCH_TIME_T_FMT.
00210 { 00211 switch_time_t now = switch_micro_time_now() / 1000; 00212 snprintf(time_buf, sizeof(time_buf), "%" SWITCH_TIME_T_FMT, now); 00213 return time_buf; 00214 }
char* API::last_data [protected] |
char API::time_buf[64] [protected] |
Definition at line 107 of file switch_cpp.h.
1.4.7