add missing braces to unbreak the build
[obnox/wireshark/wip.git] / gtk / service_response_time_table.c
1 /* service_response_time_table.c
2  * service_response_time_table   2003 Ronnie Sahlberg
3  * Helper routines common to all service response time statistics
4  * tap.
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  * 
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  * 
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  * 
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <string.h>
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <math.h>
35 #include <gtk/gtk.h>
36 #include "compat_macros.h"
37 #include "epan/packet_info.h"
38 #include "service_response_time_table.h"
39 #include "image/clist_ascend.xpm"
40 #include "image/clist_descend.xpm"
41 #include "simple_dialog.h"
42 #include "globals.h"
43 #include "gtk/find_dlg.h"
44 #include "color.h"
45 #include "gtk/color_dlg.h"
46 #include "main.h"
47 #include "gui_utils.h"
48 #include "gtkglobals.h"
49
50
51 #define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
52
53
54 typedef struct column_arrows {
55         GtkWidget *table;
56         GtkWidget *ascend_pm;
57         GtkWidget *descend_pm;
58 } column_arrows;
59
60
61 static void
62 srt_click_column_cb(GtkCList *clist, gint column, gpointer data)
63 {
64         column_arrows *col_arrows = (column_arrows *) data;
65         int i;
66
67         gtk_clist_freeze(clist);
68
69         for (i = 0; i < 6; i++) {
70                 gtk_widget_hide(col_arrows[i].ascend_pm);
71                 gtk_widget_hide(col_arrows[i].descend_pm);
72         }
73
74         if (column == clist->sort_column) {
75                 if (clist->sort_type == GTK_SORT_ASCENDING) {
76                         clist->sort_type = GTK_SORT_DESCENDING;
77                         gtk_widget_show(col_arrows[column].descend_pm);
78                 } else {
79                         clist->sort_type = GTK_SORT_ASCENDING;
80                         gtk_widget_show(col_arrows[column].ascend_pm);
81                 }
82         } else {
83                 /* Columns 2-5   Count, Min, Max, Avg are sorted in descending
84                         order by default.
85                    Columns 0 and 1 sort by ascending order by default
86                 */
87                 if(column>=2){
88                         clist->sort_type = GTK_SORT_DESCENDING;
89                         gtk_widget_show(col_arrows[column].descend_pm);
90                 } else {
91                         clist->sort_type = GTK_SORT_ASCENDING;
92                         gtk_widget_show(col_arrows[column].ascend_pm);
93                 }
94                 gtk_clist_set_sort_column(clist, column);
95         }
96         gtk_clist_thaw(clist);
97
98         gtk_clist_sort(clist);
99 }
100
101 static gint
102 srt_sort_column(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
103 {
104         char *text1 = NULL;
105         char *text2 = NULL;
106         int i1, i2;
107         float f1,f2;
108
109         const GtkCListRow *row1 = ptr1;
110         const GtkCListRow *row2 = ptr2;
111
112         text1 = GTK_CELL_TEXT (row1->cell[clist->sort_column])->text;
113         text2 = GTK_CELL_TEXT (row2->cell[clist->sort_column])->text;
114
115         switch(clist->sort_column){
116         case 1:
117                 return strcmp (text1, text2);
118         case 0:
119         case 2:
120                 i1=atoi(text1);
121                 i2=atoi(text2);
122                 return i1-i2;
123         case 3:
124         case 4:
125         case 5:
126                 sscanf(text1,"%f",&f1);
127                 sscanf(text2,"%f",&f2);
128                 if(fabs(f1-f2)<0.000005)
129                         return 0;
130                 if(f1>f2)
131                         return 1;
132                 return -1;
133         }
134         g_assert_not_reached();
135         return 0;
136 }
137
138
139
140 /* Filter actions */
141 #define ACTION_MATCH            0
142 #define ACTION_PREPARE          1
143 #define ACTION_FIND_FRAME       2
144 #define ACTION_FIND_NEXT        3
145 #define ACTION_FIND_PREVIOUS    4
146 #define ACTION_COLORIZE         5
147
148 /* Action type - says what to do with the filter */
149 #define ACTYPE_SELECTED         0
150 #define ACTYPE_NOT_SELECTED     1
151 #define ACTYPE_AND_SELECTED     2
152 #define ACTYPE_OR_SELECTED      3
153 #define ACTYPE_AND_NOT_SELECTED 4
154 #define ACTYPE_OR_NOT_SELECTED  5
155
156 /* Encoded callback arguments */
157 #define CALLBACK_MATCH(type)            ((ACTION_MATCH<<8) | (type))
158 #define CALLBACK_PREPARE(type)          ((ACTION_PREPARE<<8) | (type))
159 #define CALLBACK_FIND_FRAME(type)       ((ACTION_FIND_FRAME<<8) | (type))
160 #define CALLBACK_FIND_NEXT(type)        ((ACTION_FIND_NEXT<<8) | (type))
161 #define CALLBACK_FIND_PREVIOUS(type)    ((ACTION_FIND_PREVIOUS<<8) | (type))
162 #define CALLBACK_COLORIZE(type)         ((ACTION_COLORIZE<<8) | (type))
163
164 /* Extract components of callback argument */
165 #define FILTER_ACTION(cb_arg)           (((cb_arg)>>8) & 0xff)
166 #define FILTER_ACTYPE(cb_arg)           ((cb_arg) & 0xff)
167
168 static void
169 srt_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint callback_action)
170 {
171         int action, type, selection;
172         srt_stat_table *rst = (srt_stat_table *)callback_data;
173         char *str = NULL;
174         const char *current_filter;
175
176
177         if(rst->filter_string==NULL){
178                 return;
179         }
180
181         action = FILTER_ACTION(callback_action);
182         type = FILTER_ACTYPE(callback_action);
183
184         selection=GPOINTER_TO_INT(g_list_nth_data(GTK_CLIST(rst->table)->selection, 0));
185         if(selection>=(int)rst->num_procs){
186                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "No procedure selected");
187                 return;
188         }
189         /* translate it back from row index to index in procedures array */
190         selection=GPOINTER_TO_INT(gtk_clist_get_row_data(rst->table, selection));
191
192         current_filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
193
194         switch(type){
195         case ACTYPE_SELECTED:
196                 str = g_strdup_printf("%s==%d", rst->filter_string, selection);
197                 break;
198         case ACTYPE_NOT_SELECTED:
199                 str = g_strdup_printf("!(%s==%d)", rst->filter_string,
200                                       selection);
201                 break;
202         case ACTYPE_AND_SELECTED:
203                 if ((!current_filter) || (0 == strlen(current_filter)))
204                         str = g_strdup_printf("%s==%d", rst->filter_string, selection);
205                 else
206                         str = g_strdup_printf("(%s) && (%s==%d)", current_filter,
207                                               rst->filter_string, selection);
208                 break;
209         case ACTYPE_OR_SELECTED:
210                 if ((!current_filter) || (0 == strlen(current_filter)))
211                         str = g_strdup_printf("%s==%d", rst->filter_string, selection);
212                 else
213                         str = g_strdup_printf("(%s) || (%s==%d)", current_filter,
214                                               rst->filter_string, selection);
215                 break;
216         case ACTYPE_AND_NOT_SELECTED:
217                 if ((!current_filter) || (0 == strlen(current_filter)))
218                         str = g_strdup_printf("!(%s==%d)", rst->filter_string, selection);
219                 else
220                         str = g_strdup_printf("(%s) && !(%s==%d)", current_filter,
221                                               rst->filter_string, selection);
222                 break;
223         case ACTYPE_OR_NOT_SELECTED:
224                 if ((!current_filter) || (0 == strlen(current_filter)))
225                         str = g_strdup_printf("!(%s==%d)", rst->filter_string, selection);
226                 else
227                         str = g_strdup_printf("(%s) || !(%s==%d)", current_filter,
228                                               rst->filter_string, selection);
229                 break;
230         }
231
232         gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), str);
233
234         switch(action){
235         case ACTION_MATCH:
236                 main_filter_packets(&cfile, str, FALSE);
237                 break;
238         case ACTION_PREPARE:
239                 /* do nothing */
240                 break;
241         case ACTION_FIND_FRAME:
242                 find_frame_with_filter(str);
243                 break;
244         case ACTION_FIND_NEXT:
245                 find_previous_next_frame_with_filter(str, FALSE);
246                 break;
247         case ACTION_FIND_PREVIOUS:
248                 find_previous_next_frame_with_filter(str, TRUE);
249                 break;
250         case ACTION_COLORIZE:
251                 color_display_with_filter(str);
252                 break;
253         }
254
255         g_free(str);
256 }
257
258 static gint
259 srt_show_popup_menu_cb(void *widg _U_, GdkEvent *event, srt_stat_table *rst)
260 {
261         GdkEventButton *bevent = (GdkEventButton *)event;
262
263         if(event->type==GDK_BUTTON_PRESS && bevent->button==3){
264                 gtk_menu_popup(GTK_MENU(rst->menu), NULL, NULL, NULL, NULL, 
265                         bevent->button, bevent->time);
266         }
267
268         return FALSE;
269 }
270
271 static GtkItemFactoryEntry srt_list_menu_items[] =
272 {
273         /* Match */
274         {"/Apply as Filter", NULL, NULL, 0, "<Branch>", NULL,},
275         {"/Apply as Filter/Selected", NULL,
276                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_MATCH(ACTYPE_SELECTED), NULL, NULL,},
277         {"/Apply as Filter/... not Selected", NULL,
278                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_MATCH(ACTYPE_NOT_SELECTED), NULL, NULL,},
279         {"/Apply as Filter/.. and Selected", NULL,
280                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_MATCH(ACTYPE_AND_SELECTED), NULL, NULL,},
281         {"/Apply as Filter/... or Selected", NULL,
282                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_MATCH(ACTYPE_OR_SELECTED), NULL, NULL,},
283         {"/Apply as Filter/... and not Selected", NULL,
284                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_MATCH(ACTYPE_AND_NOT_SELECTED), NULL, NULL,},
285         {"/Apply as Filter/... or not Selected", NULL,
286                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_MATCH(ACTYPE_OR_NOT_SELECTED), NULL, NULL,},
287
288         /* Prepare */
289         {"/Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL,},
290         {"/Prepare a Filter/Selected", NULL,
291                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_PREPARE(ACTYPE_SELECTED), NULL, NULL,},
292         {"/Prepare a Filter/Not Selected", NULL,
293                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_PREPARE(ACTYPE_NOT_SELECTED), NULL, NULL,},
294         {"/Prepare a Filter/... and Selected", NULL,
295                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_PREPARE(ACTYPE_AND_SELECTED), NULL, NULL,},
296         {"/Prepare a Filter/... or Selected", NULL,
297                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_PREPARE(ACTYPE_OR_SELECTED), NULL, NULL,},
298         {"/Prepare a Filter/... and not Selected", NULL,
299                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_PREPARE(ACTYPE_AND_NOT_SELECTED), NULL, NULL,},
300         {"/Prepare a Filter/... or not Selected", NULL,
301                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_PREPARE(ACTYPE_OR_NOT_SELECTED), NULL, NULL,},
302
303         /* Find Frame */
304         {"/Find Frame", NULL, NULL, 0, "<Branch>", NULL,},
305         {"/Find Frame/Find Frame", NULL, NULL, 0, "<Branch>", NULL,},
306         {"/Find Frame/Find Frame/Selected", NULL,
307                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_FIND_FRAME(ACTYPE_SELECTED), NULL, NULL,},
308         {"/Find Frame/Find Frame/Not Selected", NULL,
309                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_FIND_FRAME(ACTYPE_NOT_SELECTED), NULL, NULL,},
310         /* Find Next */
311         {"/Find Frame/Find Next", NULL, NULL, 0, "<Branch>", NULL,},
312         {"/Find Frame/Find Next/Selected", NULL,
313                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_FIND_NEXT(ACTYPE_SELECTED), NULL, NULL,},
314         {"/Find Frame/Find Next/Not Selected", NULL,
315                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_FIND_NEXT(ACTYPE_NOT_SELECTED), NULL, NULL,},
316
317         /* Find Previous */
318         {"/Find Frame/Find Previous", NULL, NULL, 0, "<Branch>", NULL,},
319         {"/Find Frame/Find Previous/Selected", NULL,
320                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_FIND_PREVIOUS(ACTYPE_SELECTED), NULL, NULL,},
321         {"/Find Frame/Find Previous/Not Selected", NULL,
322                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_FIND_PREVIOUS(ACTYPE_NOT_SELECTED), NULL, NULL,},
323
324         /* Colorize Procedure */
325         {"/Colorize Procedure", NULL, NULL, 0, "<Branch>", NULL,},
326         {"/Colorize Procedure/Selected", NULL,
327                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_COLORIZE(ACTYPE_SELECTED), NULL, NULL,},
328         {"/Colorize Procedure/Not Selected", NULL,
329                 GTK_MENU_FUNC(srt_select_filter_cb), CALLBACK_COLORIZE(ACTYPE_NOT_SELECTED), NULL, NULL,}
330
331 };
332
333 static void
334 srt_create_popup_menu(srt_stat_table *rst)
335 {
336         GtkItemFactory *item_factory;
337
338         item_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
339
340         gtk_item_factory_create_items_ac(item_factory, sizeof(srt_list_menu_items)/sizeof(srt_list_menu_items[0]), srt_list_menu_items, rst, 2);
341
342         rst->menu = gtk_item_factory_get_widget(item_factory, "<main>");
343         SIGNAL_CONNECT(rst->table, "button_press_event", srt_show_popup_menu_cb, rst);
344 }
345
346
347 void
348 init_srt_table(srt_stat_table *rst, int num_procs, GtkWidget *vbox, const char *filter_string)
349 {
350         int i, j;
351         column_arrows *col_arrows;
352         GdkBitmap *ascend_bm, *descend_bm;
353         GdkPixmap *ascend_pm, *descend_pm;
354         GtkStyle *win_style;
355         GtkWidget *column_lb;
356         const char *default_titles[] = { "Index", "Procedure", "Calls", "Min SRT", "Max SRT", "Avg SRT" };
357
358
359         if(filter_string){
360                 rst->filter_string=g_strdup(filter_string);
361         } else {
362                 rst->filter_string=NULL;
363         }
364         rst->scrolled_window=scrolled_window_new(NULL, NULL);
365         gtk_box_pack_start(GTK_BOX(vbox), rst->scrolled_window, TRUE, TRUE, 0);
366
367         rst->table=(GtkCList *)gtk_clist_new(6);
368
369         gtk_widget_show(GTK_WIDGET(rst->table));
370         gtk_widget_show(rst->scrolled_window);
371
372         col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) * 6);
373         win_style = gtk_widget_get_style(rst->scrolled_window);
374         ascend_pm = gdk_pixmap_create_from_xpm_d(rst->scrolled_window->window,
375                         &ascend_bm,
376                         &win_style->bg[GTK_STATE_NORMAL],
377                         (gchar **)clist_ascend_xpm);
378         descend_pm = gdk_pixmap_create_from_xpm_d(rst->scrolled_window->window,
379                         &descend_bm,
380                         &win_style->bg[GTK_STATE_NORMAL],
381                         (gchar **)clist_descend_xpm);
382         for (i = 0; i < 6; i++) {
383                 col_arrows[i].table = gtk_table_new(2, 2, FALSE);
384                 gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
385                 column_lb = gtk_label_new(default_titles[i]);
386                 gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
387                 gtk_widget_show(column_lb);
388
389                 col_arrows[i].ascend_pm = gtk_pixmap_new(ascend_pm, ascend_bm);
390                 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
391                 col_arrows[i].descend_pm = gtk_pixmap_new(descend_pm, descend_bm);
392                 gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
393                 if (i == 2) {
394                         gtk_widget_show(col_arrows[i].descend_pm);
395                 }
396                 gtk_clist_set_column_widget(GTK_CLIST(rst->table), i, col_arrows[i].table);
397                 gtk_widget_show(col_arrows[i].table);
398         }
399         gtk_clist_column_titles_show(GTK_CLIST(rst->table));
400
401         gtk_clist_set_compare_func(rst->table, srt_sort_column);
402         gtk_clist_set_sort_column(rst->table, 2);
403         gtk_clist_set_sort_type(rst->table, GTK_SORT_DESCENDING);
404
405
406         /*XXX instead of this we should probably have some code to
407                 dynamically adjust the width of the columns */
408         gtk_clist_set_column_width(rst->table, 0, 32);
409         gtk_clist_set_column_width(rst->table, 1, 160);
410         gtk_clist_set_column_width(rst->table, 2, 50);
411         gtk_clist_set_column_width(rst->table, 3, 60);
412         gtk_clist_set_column_width(rst->table, 4, 60);
413         gtk_clist_set_column_width(rst->table, 5, 60);
414
415         gtk_clist_set_shadow_type(rst->table, GTK_SHADOW_IN);
416         gtk_clist_column_titles_show(rst->table);
417         gtk_container_add(GTK_CONTAINER(rst->scrolled_window), (GtkWidget *)rst->table);
418
419         SIGNAL_CONNECT(rst->table, "click-column", srt_click_column_cb, col_arrows);
420
421         gtk_widget_show(GTK_WIDGET(rst->table));
422         gtk_widget_show(rst->scrolled_window);
423
424
425         rst->num_procs=num_procs;
426         rst->procedures=g_malloc(sizeof(srt_procedure_t)*num_procs);
427         for(i=0;i<num_procs;i++){
428                 rst->procedures[i].stats.num=0;
429                 rst->procedures[i].stats.min.secs=0;
430                 rst->procedures[i].stats.min.nsecs=0;
431                 rst->procedures[i].stats.max.secs=0;
432                 rst->procedures[i].stats.max.nsecs=0;
433                 rst->procedures[i].stats.tot.secs=0;
434                 rst->procedures[i].stats.tot.nsecs=0;
435                 for(j=0;j<6;j++){
436                         rst->procedures[i].entries[j]=NULL;
437                 }
438         }
439
440         /* create popup menu for this table */
441         if(rst->filter_string){
442                 srt_create_popup_menu(rst);
443         }
444 }
445
446 void
447 init_srt_table_row(srt_stat_table *rst, int index, const char *procedure)
448 {
449         /* we have discovered a new procedure. Extend the table accordingly */
450         if(index>=rst->num_procs){
451                 int old_num_procs=rst->num_procs;
452                 int i,j;
453                 rst->num_procs=index+1;
454                 rst->procedures=g_realloc(rst->procedures, sizeof(srt_procedure_t)*(rst->num_procs));
455                 for(i=old_num_procs;i<rst->num_procs;i++){
456                         rst->procedures[i].stats.num=0;
457                         rst->procedures[i].stats.min.secs=0;
458                         rst->procedures[i].stats.min.nsecs=0;
459                         rst->procedures[i].stats.max.secs=0;
460                         rst->procedures[i].stats.max.nsecs=0;
461                         rst->procedures[i].stats.tot.secs=0;
462                         rst->procedures[i].stats.tot.nsecs=0;
463                         for(j=0;j<6;j++){
464                                 rst->procedures[i].entries[j]=NULL;
465                         }
466                 }
467         }
468         rst->procedures[index].entries[0]=g_strdup_printf("%d", index);
469
470         rst->procedures[index].entries[1]=g_strdup(procedure);
471
472         rst->procedures[index].entries[2]=g_strdup("0");
473         rst->procedures[index].entries[3]=g_strdup("0");
474         rst->procedures[index].entries[4]=g_strdup("0");
475         rst->procedures[index].entries[5]=g_strdup("0");
476 }
477
478 void
479 add_srt_table_data(srt_stat_table *rst, int index, const nstime_t *req_time, packet_info *pinfo)
480 {
481         srt_procedure_t *rp;
482         nstime_t t, delta;
483         gint row;
484
485         rp=&rst->procedures[index];
486
487         /*
488          * If the count of calls for this procedure is currently zero, it's
489          * going to become non-zero, so add a row for it (we don't want
490          * rows for procedures that have no calls - especially if the
491          * procedure has no calls because the index doesn't correspond
492          * to a procedure, but is an unused/reserved value).
493          *
494          * (Yes, this means that the rows aren't in order by anything
495          * interesting.  That's why we have the table sorted by a column.)
496          */
497         if (rp->stats.num==0){
498                 row=gtk_clist_append(rst->table, rst->procedures[index].entries);
499                 gtk_clist_set_row_data(rst->table, row, (gpointer)(long) index);
500         }
501
502         /* calculate time delta between request and reply */
503         t=pinfo->fd->abs_ts;
504         nstime_delta(&delta, &t, req_time);
505
506         time_stat_update(&rp->stats, &delta, pinfo);
507 }
508
509 void
510 draw_srt_table_data(srt_stat_table *rst)
511 {
512         int i,j;
513         guint64 td;
514         char *strp;
515
516         for(i=0;i<rst->num_procs;i++){
517                 /* ignore procedures with no calls (they don't have CList rows) */
518                 if(rst->procedures[i].stats.num==0){
519                         continue;
520                 }
521
522                 /* scale it to units of 10us.*/
523                 /* for long captures with a large tot time, this can overflow on 32bit */
524                 td=(int)rst->procedures[i].stats.tot.secs;
525                 td=td*100000+(int)rst->procedures[i].stats.tot.nsecs/10000;
526                 td/=rst->procedures[i].stats.num;
527
528                 j=gtk_clist_find_row_from_data(rst->table, (gpointer)(long)i);
529                 strp=g_strdup_printf("%d", rst->procedures[i].stats.num);
530                 gtk_clist_set_text(rst->table, j, 2, strp);
531                 g_free(rst->procedures[i].entries[2]);
532                 rst->procedures[i].entries[2]=strp;
533
534
535                 strp=g_strdup_printf("%3d.%05d",
536                     (int)rst->procedures[i].stats.min.secs,
537                     rst->procedures[i].stats.min.nsecs/10000);
538                 gtk_clist_set_text(rst->table, j, 3, strp);
539                 g_free(rst->procedures[i].entries[3]);
540                 rst->procedures[i].entries[3]=strp;
541
542
543                 strp=g_strdup_printf("%3d.%05d",
544                     (int)rst->procedures[i].stats.max.secs,
545                     rst->procedures[i].stats.max.nsecs/10000);
546                 gtk_clist_set_text(rst->table, j, 4, strp);
547                 g_free(rst->procedures[i].entries[4]);
548                 rst->procedures[i].entries[4]=strp;
549
550                 strp=g_strdup_printf("%3" G_GINT64_MODIFIER "d.%05" G_GINT64_MODIFIER "d",
551                     td/100000, td%100000);
552                 gtk_clist_set_text(rst->table, j, 5, strp);
553                 g_free(rst->procedures[i].entries[5]);
554                 rst->procedures[i].entries[5]=strp;
555         }
556
557         gtk_clist_sort(rst->table);
558 }
559
560
561 void
562 reset_srt_table_data(srt_stat_table *rst)
563 {
564         int i;
565
566         for(i=0;i<rst->num_procs;i++){
567                 time_stat_init(&rst->procedures[i].stats);
568         }
569         gtk_clist_clear(rst->table);
570 }
571
572 void
573 free_srt_table_data(srt_stat_table *rst)
574 {
575         int i,j;
576
577         for(i=0;i<rst->num_procs;i++){
578                 for(j=0;j<6;j++){
579                         if(rst->procedures[i].entries[j]){
580                                 g_free(rst->procedures[i].entries[j]);
581                                 rst->procedures[i].entries[j]=NULL;
582                         }
583                 }
584         }
585         g_free(rst->filter_string);
586         rst->filter_string=NULL;
587         g_free(rst->procedures);
588         rst->procedures=NULL;
589         rst->num_procs=0;
590 }
591