From anthm@freeswitch.org Wed Jul 19 23:55:08 2006 From: Freeswitch SVN To: freeswitch-trunk@lists.freeswitch.org Subject: [Freeswitch-trunk] [commit] r2011 - in freeswitch/trunk/src: . mod/applications/mod_commands Date: Wed, 19 Jul 2006 23:55:07 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============9165581635226175032==" --===============9165581635226175032== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Author: anthm Date: Wed Jul 19 23:55:07 2006 New Revision: 2011 Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c freeswitch/trunk/src/switch_channel.c freeswitch/trunk/src/switch_core.c Log: enhance the show command Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (origin= al) +++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Wed Jul= 19 23:55:07 2006 @@ -186,15 +186,46 @@ =20 struct holder { switch_stream_handle_t *stream; + char *http; uint32_t count; }; =20 - - static int show_callback(void *pArg, int argc, char **argv, char **columnNam= es){ struct holder *holder =3D (struct holder *) pArg; + int x; =20 - holder->stream->write_function(holder->stream, "%s|%s\n", argv[0], argv[1] = ? argv[1] : "NULL"); + + if (holder->count =3D=3D 0) { + if (holder->http) { + holder->stream->write_function(holder->stream, "\n"); + } + + for(x =3D 0; x < argc; x++) { + if (holder->http) { + holder->stream->write_function(holder->stream, ""); + holder->stream->write_function(holder->stream, "%s%s", columnName= s[x], x =3D=3D (argc - 1) ? "\n" : ""); + } else { + holder->stream->write_function(holder->stream, "%s%s", columnNames[x], x= =3D=3D (argc - 1) ? "\n" : ","); + } + } + }=20 + + if (holder->http) { + holder->stream->write_function(holder->stream, "", holder= ->count % 2 =3D=3D 0 ? "eeeeee" : "ffffff"); + } + + for(x =3D 0; x < argc; x++) { + if (holder->http) { + holder->stream->write_function(holder->stream, ""); + holder->stream->write_function(holder->stream, "%s%s", argv[x], x =3D=3D = (argc - 1) ? "\n" : ""); + } else { + holder->stream->write_function(holder->stream, "%s%s", argv[x], x =3D=3D = (argc - 1) ? "\n" : ","); + } + } +=09 + + + holder->count++; return 0; } @@ -204,8 +235,12 @@ char sql[1024]; char *errmsg; switch_core_db_t *db =3D switch_core_db_handle(); - struct holder holder; -=09 + struct holder holder =3D {0}; + + if (stream->event) { + holder.http =3D switch_event_get_header(stream->event, "http-host"); + }=20 + if (!cmd) { sprintf (sql, "select * from interfaces"); } @@ -231,14 +266,23 @@ holder.stream =3D stream; holder.count =3D 0; =20 + if (holder.http) { + holder.stream->write_function(holder.stream, "\n"); + } + switch_core_db_exec(db, sql, show_callback, &holder, &errmsg); =20 + if (holder.http) { + holder.stream->write_function(holder.stream, "
"); + } + + if (errmsg) { stream->write_function(stream, "SQL ERR [%s]\n",errmsg); switch_core_db_free(errmsg); errmsg =3D NULL; } else { - stream->write_function(stream, "%u total.\n", holder.count); + stream->write_function(stream, "\n%u total.\n", holder.count); } =20 switch_core_db_close(db); Modified: freeswitch/trunk/src/switch_channel.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- freeswitch/trunk/src/switch_channel.c (original) +++ freeswitch/trunk/src/switch_channel.c Wed Jul 19 23:55:07 2006 @@ -593,6 +593,7 @@ { switch_caller_profile_t *caller_profile, *originator_caller_profile, *origi= natee_caller_profile; switch_hash_index_t *hi; + switch_codec_t *codec; void *val; const void *var; char state_num[25]; @@ -606,7 +607,16 @@ switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State-Number",= (char *) state_num); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", switch_= channel_get_name(channel)); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_cor= e_session_get_uuid(channel->session)); - +=09 + if ((codec =3D switch_core_session_get_read_codec(channel->session))) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Na= me", codec->implementation->iananame); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Read-Codec-Ra= te", "%u", codec->implementation->samples_per_second); + } +=09 + if ((codec =3D switch_core_session_get_write_codec(channel->session))) { + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Write-Codec-N= ame", codec->implementation->iananame); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Write-Codec-R= ate", "%u", codec->implementation->samples_per_second); + } =20 /* Index Caller's Profile */ if (caller_profile) { Modified: freeswitch/trunk/src/switch_core.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- freeswitch/trunk/src/switch_core.c (original) +++ freeswitch/trunk/src/switch_core.c Wed Jul 19 23:55:07 2006 @@ -2821,9 +2821,13 @@ ); break; case SWITCH_EVENT_CHANNEL_EXECUTE: - sql =3D switch_core_db_mprintf("update channels set application=3D'%q',app= lication_data=3D'%q' where uuid=3D'%q'", + sql =3D switch_core_db_mprintf("update channels set application=3D'%q',app= lication_data=3D'%q', read_codec=3D'%q',read_rate=3D'%q',write_codec=3D'%q',w= rite_rate=3D'%q' where uuid=3D'%q'", switch_event_get_header(event, "application"), switch_event_get_header(event, "application-data"), + switch_event_get_header(event, "channel-read-codec-name"), + switch_event_get_header(event, "channel-read-codec-rate"), + switch_event_get_header(event, "channel-write-codec-name"), + switch_event_get_header(event, "channel-write-codec-rate"), switch_event_get_header(event, "unique-id") ); break; @@ -3018,7 +3022,11 @@ " ip_addr VARCHAR(255),\n" " dest VARCHAR(255),\n" " application VARCHAR(255),\n" - " application_data VARCHAR(255)\n" + " application_data VARCHAR(255),\n" + " read_codec VARCHAR(255),\n" + " read_rate VARCHAR(255),\n" + " write_codec VARCHAR(255),\n" + " write_rate VARCHAR(255)\n" ");\n"; char create_calls_sql[] =3D "CREATE TABLE calls (\n" --===============9165581635226175032==--