Use consistent indentation and formatting style;

Fix a few typos; Fix long line.

svn path=/trunk/; revision=44902
This commit is contained in:
Bill Meier 2012-09-14 15:19:15 +00:00
parent ebda6f06b7
commit dd7a2708be

View file

@ -196,12 +196,13 @@ sip_init_hash(sipstat_t *sp)
{
gint *key = g_malloc (sizeof(gint));
sip_response_code_t *sc = g_malloc (sizeof(sip_response_code_t));
*key = vals_status_code[i].value;
sc->packets=0;
sc->packets = 0;
sc->response_code = *key;
sc->name=vals_status_code[i].strptr;
sc->widget=NULL;
sc->table=NULL;
sc->name = vals_status_code[i].strptr;
sc->widget = NULL;
sc->table = NULL;
sc->sp = sp;
g_hash_table_insert(sc->sp->hash_responses, key, sc);
}
@ -212,13 +213,13 @@ sip_init_hash(sipstat_t *sp)
/* Draw the entry for an individual request message */
static void
sip_draw_hash_requests(gchar *key _U_ , sip_request_method_t *data, gchar * unused _U_)
sip_draw_hash_requests(gchar *key _U_, sip_request_method_t *data, gchar *unused _U_)
{
gchar string_buff[SUM_STR_MAX];
g_assert(data!=NULL);
g_assert(data != NULL);
if (data->packets==0)
if (data->packets == 0)
{
return;
}
@ -226,12 +227,12 @@ sip_draw_hash_requests(gchar *key _U_ , sip_request_method_t *data, gchar * unus
/* Build string showing method and count */
g_snprintf(string_buff, sizeof(string_buff),
" %-11s : %3d packets", data->response, data->packets);
if (data->widget==NULL)
if (data->widget == NULL)
{
/* Create new label */
data->widget=gtk_label_new(string_buff);
data->widget = gtk_label_new(string_buff);
gtk_misc_set_alignment(GTK_MISC(data->widget), 0.0f, 0.5f);
gtk_box_pack_start(GTK_BOX(data->sp->request_box), data->widget,FALSE,FALSE, 0);
gtk_box_pack_start(GTK_BOX(data->sp->request_box), data->widget, FALSE, FALSE, 0);
gtk_widget_show(data->widget);
}
else
@ -247,22 +248,22 @@ sip_draw_hash_responses(gint * key _U_ , sip_response_code_t *data, gchar * unus
{
gchar string_buff[SUM_STR_MAX];
g_assert(data!=NULL);
g_assert(data != NULL);
if (data->packets==0)
if (data->packets == 0)
{
return;
}
/* Create an entry in the relevant box of the window */
if (data->widget==NULL)
if (data->widget == NULL)
{
guint x;
GtkWidget *tmp;
guint i = data->response_code;
/* Out of valid range - ignore */
if ((i<100)||(i>=700))
if ((i < 100) || (i >= 700))
{
return;
}
@ -317,7 +318,7 @@ sip_draw_hash_responses(gint * key _U_ , sip_response_code_t *data, gchar * unus
/* Show number of packets */
g_snprintf(string_buff, sizeof(string_buff), "%9d", data->packets);
data->widget=gtk_label_new(string_buff);
data->widget = gtk_label_new(string_buff);
/* Show this widget in the right place */
gtk_table_attach_defaults(GTK_TABLE(data->table), data->widget, 1, 2,x,x+1);
@ -377,7 +378,7 @@ sipstat_reset(void *psp)
static int
sipstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pri)
{
const sip_info_value_t *value=pri;
const sip_info_value_t *value = pri;
sipstat_t *sp = (sipstat_t *)psp;
/* Total number of packets, including continuation packets */
@ -421,37 +422,37 @@ sipstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const
/* Look up response code in hash table */
*key = value->response_code;
sc = g_hash_table_lookup(sp->hash_responses, key);
if (sc==NULL)
if (sc == NULL)
{
/* Non-standard status code ; we classify it as others
* in the relevant category
* (Informational,Success,Redirection,Client Error,Server Error,Global Failure)
*/
int i = value->response_code;
if ((i<100) || (i>=700))
if ((i < 100) || (i >= 700))
{
/* Forget about crazy values */
return 0;
}
else if (i<200)
{
*key=199; /* Hopefully, this status code will never be used */
*key = 199; /* Hopefully, this status code will never be used */
}
else if (i<300)
{
*key=299;
*key = 299;
}
else if (i<400)
{
*key=399;
*key = 399;
}
else if (i<500)
{
*key=499;
*key = 499;
}
else if (i<600)
else if (i < 600)
{
*key=599;
*key = 599;
}
else
{
@ -460,7 +461,7 @@ sipstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const
/* Now look up this fallback code to get its text description */
sc = g_hash_table_lookup(sp->hash_responses, key);
if (sc==NULL)
if (sc == NULL)
{
return 0;
}
@ -477,7 +478,7 @@ sipstat_packet(void *psp, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const
if (sc == NULL)
{
/* First of this type. Create structure and initialise */
sc=g_malloc(sizeof(sip_request_method_t));
sc = g_malloc(sizeof(sip_request_method_t));
sc->response = g_strdup(value->request_method);
sc->packets = 1;
sc->widget = NULL;
@ -506,7 +507,7 @@ static void
sipstat_draw(void *psp)
{
gchar string_buff[SUM_STR_MAX];
sipstat_t *sp=psp;
sipstat_t *sp = psp;
/* Set summary label */
g_snprintf(string_buff, sizeof(string_buff),
@ -524,24 +525,25 @@ sipstat_draw(void *psp)
/* Set resend count label */
g_snprintf(string_buff, sizeof(string_buff),
"Average setup time %d ms\n Min %d ms\n Max %d ms", sp->average_setup_time, sp->min_setup_time, sp->max_setup_time);
"Average setup time %d ms\n Min %d ms\n Max %d ms",
sp->average_setup_time, sp->min_setup_time, sp->max_setup_time);
gtk_label_set_text(GTK_LABEL(sp->average_setup_time_label), string_buff);
gtk_widget_show_all(sp->win);
}
/* since the gtk2 implementation of tap is multithreaded we must protect
/* Since the gtk2 implementation of tap is multithreaded we must protect
* remove_tap_listener() from modifying the list while draw_tap_listener()
* is running. the other protected block is in main.c
* is running. The other protected block is in main.c
*
* there should not be any other critical regions in gtk2
* There should not be any other critical regions in gtk2
*/
/* When window is destroyed, clean up */
static void
win_destroy_cb(GtkWindow *win _U_, gpointer data)
{
sipstat_t *sp=(sipstat_t *)data;
sipstat_t *sp = (sipstat_t *)data;
protect_thread_critical_region();
remove_tap_listener(sp);
@ -561,9 +563,9 @@ static void
gtk_sipstat_init(const char *optarg, void *userdata _U_)
{
sipstat_t *sp;
const char *filter = NULL;
const char *filter;
GString *error_string;
char *title = NULL;
char *title;
GtkWidget *main_vb, *separator,
*informational_fr, *success_fr, *redirection_fr,
*client_errors_fr, *server_errors_fr, *global_failures_fr,
@ -575,7 +577,7 @@ gtk_sipstat_init(const char *optarg, void *userdata _U_)
if (strncmp (optarg, "sip,stat,", 9) == 0)
{
/* Skip those characters from filter to display */
filter=optarg + 9;
filter = optarg + 9;
}
else
{
@ -629,14 +631,14 @@ gtk_sipstat_init(const char *optarg, void *userdata _U_)
gtk_container_add(GTK_CONTAINER(informational_fr), sp->informational_table);
/* Success table and frame */
success_fr = gtk_frame_new ("Success SIP 2xx");
success_fr = gtk_frame_new("Success SIP 2xx");
gtk_box_pack_start(GTK_BOX(main_vb), success_fr, TRUE, TRUE, 0);
sp->success_table = gtk_table_new(0, 2, FALSE);
gtk_container_add(GTK_CONTAINER(success_fr), sp->success_table);
/* Redirection table and frame */
redirection_fr = gtk_frame_new ("Redirection SIP 3xx");
redirection_fr = gtk_frame_new("Redirection SIP 3xx");
gtk_box_pack_start(GTK_BOX(main_vb), redirection_fr, TRUE, TRUE, 0);
sp->redirection_table = gtk_table_new(0, 2, FALSE);