Defines | |
| #define | CMD_BUFLEN 1024; |
Functions | |
| 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. | |
| char * | expand_alias (char *cmd, char *arg) |
| void | switch_console_printf (switch_text_channel_t channel, const char *file, const char *func, int line, const char *fmt,...) |
| switch_status_t | switch_console_set_alias (const char *string) |
| switch_status_t | switch_console_set_complete (const char *string) |
| void | switch_console_loop (void) |
| A simple comand loop that reads input from the terminal. | |
|
|
|
|
||||||||||||
|
00165 {
00166 char *errmsg = NULL;
00167 char *r = NULL;
00168 char *sql;
00169 char *exp = NULL;
00170 switch_core_db_t *db = switch_core_db_handle();
00171 int full = 0;
00172
00173 sql = switch_mprintf("select command from aliases where alias='%q'", cmd);
00174
00175 switch_core_db_exec(db, sql, alias_callback, &r, &errmsg);
00176
00177 if (errmsg) {
00178 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error [%s][%s]\n", sql, errmsg);
00179 free(errmsg);
00180 }
00181
00182 if (!r) {
00183 sql = switch_mprintf("select command from aliases where alias='%q %q'", cmd, arg);
00184
00185 switch_core_db_exec(db, sql, alias_callback, &r, &errmsg);
00186
00187 if (errmsg) {
00188 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error [%s][%s]\n", sql, errmsg);
00189 free(errmsg);
00190 }
00191 if (r) {
00192 full++;
00193 }
00194 }
00195
00196
00197 if (r) {
00198 if (arg && !full) {
00199 exp = switch_mprintf("%s %s", r, arg);
00200 free(r);
00201 } else {
00202 exp = r;
00203 }
00204 } else {
00205 exp = cmd;
00206 }
00207
00208 switch_core_db_close(db);
00209 return exp;
00210 }
|
Here is the call graph for this function:

|
|
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:

|
||||||||||||||||||||||||||||
|
00255 {
00256 char *data = NULL;
00257 int ret = 0;
00258 va_list ap;
00259 FILE *handle = switch_core_data_channel(channel);
00260 const char *filep = switch_cut_path(file);
00261 char date[80] = "";
00262 switch_size_t retsize;
00263 switch_time_exp_t tm;
00264 switch_event_t *event;
00265
00266 va_start(ap, fmt);
00267 ret = switch_vasprintf(&data, fmt, ap);
00268 va_end(ap);
00269
00270 if (ret == -1) {
00271 fprintf(stderr, "Memory Error\n");
00272 goto done;
00273 }
00274
00275 if (channel == SWITCH_CHANNEL_ID_LOG_CLEAN) {
00276 fprintf(handle, "%s", data);
00277 goto done;
00278 }
00279
00280 switch_time_exp_lt(&tm, switch_timestamp_now());
00281 switch_strftime(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
00282
00283 if (channel == SWITCH_CHANNEL_ID_LOG) {
00284 fprintf(handle, "[%d] %s %s:%d %s() %s", (int) getpid(), date, filep, line, func, data);
00285 goto done;
00286 }
00287
00288 if (channel == SWITCH_CHANNEL_ID_EVENT &&
00289 switch_event_running() == SWITCH_STATUS_SUCCESS &&
00290 switch_event_create(&event, SWITCH_EVENT_LOG) == SWITCH_STATUS_SUCCESS) {
00291
00292 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Data", "%s", data);
00293 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-File", "%s", filep);
00294 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Function", "%s", func);
00295 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Log-Line", "%d", line);
00296 switch_event_fire(&event);
00297 }
00298
00299 done:
00300 if (data) {
00301 free(data);
00302 }
00303 fflush(handle);
00304 }
|
Here is the call graph for this function:

|
|
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 }
|
1.3.9.1