API Class Reference

#include <switch_cpp.h>

Collaboration diagram for API:

[legend]

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]

Detailed Description

Definition at line 104 of file switch_cpp.h.


Constructor & Destructor Documentation

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 }


Member Function Documentation

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 }


Field Documentation

char* API::last_data [protected]

Definition at line 106 of file switch_cpp.h.

Referenced by API(), and ~API().

char API::time_buf[64] [protected]

Definition at line 107 of file switch_cpp.h.


The documentation for this class was generated from the following files:
Generated on Wed May 16 04:00:20 2012 for FreeSWITCH API Documentation by  doxygen 1.4.7