SWITCH_DECLARE(switch_status_t) switch_console_execute(char *xcmd, int rec, switch_stream_handle_t *istream) { char *arg = NULL, *alias = NULL; char *delim = ";;"; int argc; char *argv[128]; int x; char *dup = strdup(xcmd); char *cmd; switch_status_t status = SWITCH_STATUS_FALSE; if (rec > 100) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Too much recursion!\n"); goto end; } if (!strncasecmp(xcmd, "alias", 5)) { argc = 1; argv[0] = xcmd; } else { argc = switch_separate_string_string(dup, delim, argv, 128); } for (x = 0; x < argc; x++) { cmd = argv[x]; if ((arg = strchr(cmd, '\r')) != 0 || (arg = strchr(cmd, '\n')) != 0) { *arg = '\0'; arg = NULL; } if ((arg = strchr(cmd, ' ')) != 0) { *arg++ = '\0'; } if ((alias = switch_console_expand_alias(cmd, arg)) && alias != cmd) { istream->write_function(istream, "\nExpand Alias [%s]->[%s]\n\n", cmd, alias); status = switch_console_execute(alias, ++rec, istream); free(alias); continue; } status = switch_api_execute(cmd, arg, NULL, istream); } end: switch_safe_free(dup); return status; }
bool WSClientParser::ParseFirstLine(char* line) { bool bFlag = false; // Get Param char* p = line; char* delim = " "; char decodeUrl[HTTP_URL_MAX_PATH] = {0}; char *array[HTTP_URL_FIRSTLINE_PARAM_MAX_COUNT]; if( switch_separate_string_string(p, delim, array, HTTP_URL_FIRSTLINE_PARAM_MAX_COUNT) >= HTTP_URL_FIRSTLINE_PARAM_COUNT ) { Arithmetic ac; ac.decode_url(array[1], strlen(array[1]), decodeUrl); switch_log_printf( SWITCH_CHANNEL_UUID_LOG(this->uuid), SWITCH_LOG_INFO, "WSClientParser::ParseFirstLine( " "this : %p, " "decodeUrl : '%s' " ") \n", this, decodeUrl ); if( strlen(decodeUrl) > 0 ) { // p = decodeUrl; p = switch_core_strdup(mpPool, decodeUrl); delim = "/"; if( *p == *delim ) { p++; } char *array2[HTTP_URL_PATH_PARAM_MAX_COUNT]; if( switch_separate_string_string(p, delim, array2, HTTP_URL_PATH_PARAM_MAX_COUNT) >= HTTP_URL_PATH_PARAM_COUNT ) { mpUser = switch_core_strdup(mpPool, array2[0]); mpDomain = switch_core_strdup(mpPool, array2[1]); mpDestNumber = switch_core_strdup(mpPool, array2[2]); // 暂时不做PHP验证 mpSite = switch_core_strdup(mpPool, array2[3]); mpCustom = switch_core_strdup(mpPool, array2[4]); // mpSite = switch_core_strdup(mpPool, ""); // mpCustom = switch_core_strdup(mpPool, ""); switch_log_printf( SWITCH_CHANNEL_UUID_LOG(this->uuid), SWITCH_LOG_INFO, "WSClientParser::ParseFirstLine( " "this : %p, " "user : '******', " "domain : '%s', " "destnumber : '%s', " "site : '%s', " "custom : '%s' " ") \n", this, mpUser, mpDomain, mpDestNumber, mpSite, mpCustom ); bFlag = true; } } } if( !bFlag ) { switch_log_printf( SWITCH_CHANNEL_UUID_LOG(this->uuid), SWITCH_LOG_ERROR, "WSClientParser::ParseFirstLine( " "[Fail], " "this : %p, " "decodeUrl : '%s' " ") \n", this, decodeUrl ); } return bFlag; }