Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

switch_console.h File Reference


Detailed Description

Simple Console.

This module implements a basic console i/o and by basic I mean, um yeah, basic Right now the primary function of this portion of the program is to keep it from exiting.


Defines

#define SWITCH_CMD_CHUNK_LEN   1024
#define SWITCH_STANDARD_STREAM(s)

Functions

void switch_console_loop (void)
 A simple comand loop that reads input from the terminal.
void switch_console_printf (switch_text_channel_t channel, const char *file, const char *func, int line, const char *fmt,...) PRINTF_FUNCTION(5
 A method akin to printf that allows you to redirect output to a specific console "channel".
 SWITCH_DECLARE_NONSTD (switch_status_t) switch_console_stream_raw_write(switch_stream_handle_t *handle
 the actual hangup hook called back by freeswitch core which in turn gets the session and calls the appropriate instance method to complete the callback.
const char PRINTF_FUNCTION (2, 3)

Variables

uint8_t * data
uint8_t switch_size_t datalen
const char * fmt


Define Documentation

#define SWITCH_CMD_CHUNK_LEN   1024
 

#define SWITCH_STANDARD_STREAM  ) 
 

Value:

memset(&s, 0, sizeof(s)); s.data = malloc(SWITCH_CMD_CHUNK_LEN); \
        switch_assert(s.data);                                                                                          \
        memset(s.data, 0, SWITCH_CMD_CHUNK_LEN);                                                        \
        s.end = s.data;                                                                                                         \
        s.data_size = SWITCH_CMD_CHUNK_LEN;                                                                     \
        s.write_function = switch_console_stream_write;                                         \
        s.raw_write_function = switch_console_stream_raw_write;                         \
        s.alloc_len = SWITCH_CMD_CHUNK_LEN;                                                                     \
        s.alloc_chunk = SWITCH_CMD_CHUNK_LEN


Function Documentation

const char PRINTF_FUNCTION ,
 

void switch_console_loop void   ) 
 

A simple comand loop that reads input from the terminal.

00779 {
00780 
00781         char cmd[2048];
00782         int32_t activity = 1;
00783         switch_size_t x = 0;
00784 
00785         gethostname(hostname, sizeof(hostname));
00786 
00787         while (running) {
00788                 int32_t arg;
00789 #ifndef _MSC_VER
00790                 fd_set rfds, efds;
00791                 struct timeval tv = { 0, 20000 };
00792 #endif
00793 
00794                 switch_core_session_ctl(SCSC_CHECK_RUNNING, &arg);
00795                 if (!arg) {
00796                         break;
00797                 }
00798 
00799                 if (activity) {
00800                         switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "\nfreeswitch@%s> ", hostname);
00801                 }
00802 #ifdef _MSC_VER
00803                 activity = WaitForSingleObject(GetStdHandle(STD_INPUT_HANDLE), 20);
00804 
00805                 if (activity == 102) {
00806                         fflush(stdout);
00807                         continue;
00808                 }
00809 #else
00810                 FD_ZERO(&rfds);
00811                 FD_ZERO(&efds);
00812                 FD_SET(fileno(stdin), &rfds);
00813                 FD_SET(fileno(stdin), &efds);
00814                 if ((activity = select(fileno(stdin) + 1, &rfds, NULL, &efds, &tv)) < 0) {
00815                         break;
00816                 }
00817 
00818                 if (activity == 0) {
00819                         fflush(stdout);
00820                         continue;
00821                 }
00822 #endif
00823                 memset(&cmd, 0, sizeof(cmd));
00824                 for (x = 0; x < (sizeof(cmd) - 1); x++) {
00825                         int c = getchar();
00826                         if (c < 0) {
00827                                 int y = read(fileno(stdin), cmd, sizeof(cmd) - 1);
00828                                 cmd[y - 1] = '\0';
00829                                 break;
00830                         }
00831 
00832                         cmd[x] = (char) c;
00833 
00834                         if (cmd[x] == '\n') {
00835                                 cmd[x] = '\0';
00836                                 break;
00837                         }
00838                 }
00839 
00840                 if (cmd[0]) {
00841                         running = switch_console_process(cmd, 0);
00842                 }
00843         }
00844 }

Here is the call graph for this function:

void switch_console_printf switch_text_channel_t  channel,
const char *  file,
const char *  func,
int  line,
const char *  fmt,
  ...
 

A method akin to printf that allows you to redirect output to a specific console "channel".

SWITCH_DECLARE_NONSTD switch_status_t   ) 
 

the actual hangup hook called back by freeswitch core which in turn gets the session and calls the appropriate instance method to complete the callback.

00089 {
00090         switch_size_t nwrite;
00091         FILE *out = switch_core_get_console();
00092 
00093         if (out) {
00094                 nwrite = fwrite(data, datalen, 1, out);
00095                 if (nwrite != datalen) {
00096                         return SWITCH_STATUS_FALSE;
00097                 }
00098                 return SWITCH_STATUS_SUCCESS;
00099         }
00100 
00101         return SWITCH_STATUS_FALSE;
00102 }

Here is the call graph for this function:


Variable Documentation

uint8_t* data
 

uint8_t switch_size_t datalen
 

const char* fmt
 


Generated on Mon May 26 22:06:51 2008 for FreeSWITCH by  doxygen 1.3.9.1