Date: Fri, 20 Jul 2007 11:31:27 GMT From: dongmei <dongmei@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 123780 for review Message-ID: <200707201131.l6KBVRhq056771@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=123780 Change 123780 by dongmei@dongmei2007 on 2007/07/20 11:30:26 Correctly get the display format for record list Affected files ... .. //depot/projects/soc2007/dongmei-auditanalyzer/gtk/list_view.c#4 edit .. //depot/projects/soc2007/dongmei-auditanalyzer/gtk/tree_view.c#5 edit .. //depot/projects/soc2007/dongmei-auditanalyzer/gtk/tree_view.h#5 edit Differences ... ==== //depot/projects/soc2007/dongmei-auditanalyzer/gtk/list_view.c#4 (text+ko) ==== @@ -12,6 +12,7 @@ #include <string.h> #include "compat_macros.h" #include "../tfile.h" +#include "tree_view.h" extern trailer_file cfile; static GtkWidget *window = NULL; @@ -38,10 +39,10 @@ /* create list store */ record_list = gtk_list_store_new (NUM_COLUMNS, G_TYPE_INT, - G_TYPE_INT, - G_TYPE_INT, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_INT, - G_TYPE_INT, G_TYPE_INT); return GTK_TREE_MODEL (record_list); @@ -174,15 +175,26 @@ { GtkTreeIter iter; /* add data to the list store */ + gchar *s; + gchar *ms; + gchar *event; + sprint_event(&event,data->tt.hdr32.e_type,NULL); + sprint_sec32(&s, data->tt.hdr32.s, NULL); + sprint_msec32(&ms, data->tt.hdr32.ms,NULL); + gtk_list_store_append (record_list, &iter); + gtk_list_store_set (record_list, &iter, COLUMN_NUMBER, number, - COLUMN_CREATE_TIME,data->tt.hdr32.s, - COLUMN_MS,data->tt.hdr32.ms, - COLUMN_EVENT,data->tt.hdr32.e_type, + COLUMN_CREATE_TIME,s, + COLUMN_MS,ms, + COLUMN_EVENT,event, COLUMN_VERSION,data->tt.hdr32.version, COLUMN_RECORD_LEN,data->tt.hdr32.size, -1); + free(s); + free(ms); + free(event); } ==== //depot/projects/soc2007/dongmei-auditanalyzer/gtk/tree_view.c#5 (text+ko) ==== @@ -44,7 +44,7 @@ /* * Prints a single byte in the given format. */ -static void +void sprint_1_byte(gchar **str, u_char val, const gchar *format,const gchar *label) { *str=(gchar *)malloc(sizeof(label)+LEN_FOR_BYTES_MARGIN); @@ -57,7 +57,7 @@ /* * Prints a single byte in the default format. */ -static void +void sprint_1_byte_df(gchar **str, u_char val, const gchar *label) { *str=(gchar *)malloc(sizeof(label)+LEN_FOR_BYTES_MARGIN); @@ -67,7 +67,7 @@ /* * Print 2 bytes in the given format. */ -static void +void sprint_2_bytes(gchar **str, u_int16_t val, const gchar *format,const gchar *label) { *str=(gchar *)malloc(sizeof(label)+LEN_FOR_BYTES_MARGIN); @@ -80,7 +80,7 @@ /* * Print 2 bytes in the default format. */ -static void +void sprint_2_bytes_df(gchar **str, u_int16_t val, const gchar *label) { *str=(gchar *)malloc(sizeof(label)+LEN_FOR_BYTES_MARGIN); @@ -90,7 +90,7 @@ /* * Prints 4 bytes in the given format. */ -static void +void sprint_4_bytes(gchar **str, u_int32_t val, const gchar *format,const gchar *label) { *str=(gchar *)malloc(sizeof(label)+LEN_FOR_BYTES_MARGIN); @@ -103,7 +103,7 @@ /* * Prints 4 bytes in the defautl format. */ -static void +void sprint_4_bytes_df(gchar **str, u_int32_t val, const gchar *label) { *str=(gchar *)malloc(sizeof(label)+LEN_FOR_BYTES_MARGIN); @@ -113,7 +113,7 @@ /* * Prints 8 bytes in the given format. */ -static void +void sprint_8_bytes(gchar **str, u_int64_t val, const gchar *format,const gchar *label) { *str=(gchar *)malloc(sizeof(label)+LEN_FOR_BYTES_MARGIN); @@ -127,7 +127,7 @@ /* * Prints 8 bytes in the default format. */ -static void +void sprint_8_bytes_df(gchar **str, u_int64_t val, const gchar *label) { *str=(gchar *)malloc(sizeof(label)+LEN_FOR_BYTES_MARGIN); @@ -137,7 +137,7 @@ /* * Prints the given size of data bytes in hex. */ -static void +void sprint_mem(gchar **str, u_char *data, size_t len,const gchar *label) { *str=(gchar *)malloc(len+sizeof(label)+1); @@ -155,7 +155,7 @@ /* * Prints the given size of arbitray data in give format. */ -static void +void sprint_arb_data(gchar **str, u_char *data, u_char count, size_t size,const gchar *format) { *str=(gchar *)malloc(count+1); @@ -184,7 +184,7 @@ /* * Prints the given data bytes as a string. */ -static void +void sprint_string(gchar **dstr, const char *sstr, size_t len, const gchar *label) { int i; @@ -203,7 +203,7 @@ /* * Prints seconds in the ctime format. */ -static void +void sprint_sec32(gchar **str, u_int32_t sec, const gchar *label) { time_t timestamp; @@ -212,14 +212,17 @@ timestamp = (time_t)sec; ctime_r(×tamp, timestr); timestr[24] = '\0'; /* No new line */ - g_sprintf(*str,"%s:%s",label,timestr); + if (label==NULL) + g_sprintf(*str,"%s",timestr); + else + g_sprintf(*str,"%s:%s",label,timestr); } /* * XXXRW: 64-bit token streams make use of 64-bit time stamps; since we * assume a 32-bit time_t, we simply truncate for now. */ -static void +void sprint_sec64(gchar **str, u_int64_t sec,const gchar *label) { time_t timestamp; @@ -234,30 +237,36 @@ /* * Prints the excess milliseconds. */ -static void +void sprint_msec32(gchar **str, u_int32_t msec, const gchar *label) { *str=(gchar *)malloc(sizeof(label)+1+50); - g_sprintf(*str,"%s:+ %u msec",label,msec); + if (label==NULL) + g_sprintf(*str,"+ %u msec",msec); + else + g_sprintf(*str,"%s:+ %u msec",label,msec); } /* * XXXRW: 64-bit token streams make use of 64-bit time stamps; since we assume * a 32-bit msec, we simply truncate for now. */ -static void +void sprint_msec64(gchar **str, u_int64_t msec, const gchar *label) { *str=(gchar *)malloc(sizeof(label)+1+50); msec &= 0xffffffff; - g_sprintf(*str,"%s:+ %u msec",label,(u_int32_t)msec); + if (label==NULL) + g_sprintf(*str,"+ %u msec",(u_int32_t)msec); + else + g_sprintf(*str,"%s:+ %u msec",label,(u_int32_t)msec); } #define IP_V4_ADDRESS_LEN 20 #define IP_V6_ADDRESS_LEN 25 /* * Prints a dotted form for the IP address. */ -static void +void sprint_ip_address(gchar **str, u_int32_t ip,const gchar *label) { struct in_addr ipaddr; @@ -269,7 +278,7 @@ /* * Prints a string value for the given ip address. */ -static void +void sprint_ip_ex_address(gchar **str, u_int32_t type, u_int32_t *ipaddr,const gchar *label) { struct in_addr ipv4; @@ -298,7 +307,7 @@ /* * Prints return value as success or failure. */ -static void +void sprint_retval(gchar **str, u_char status, const gchar *label) { *str=(gchar *)malloc(sizeof(label)+1+RETVAL_MAX_LEN); @@ -312,7 +321,7 @@ /* * Prints the exit value. */ -static void +void sprint_errval(gchar **str, u_int32_t val,const gchar *label) { *str=(gchar *)malloc(sizeof(label)+1+RETVAL_MAX_LEN); @@ -322,7 +331,7 @@ /* * Prints IPC type. */ -static void +void sprint_ipctype(gchar **str, u_char type, const gchar *label) { if (type == AT_IPC_MSG) @@ -339,7 +348,7 @@ * Prints the event from the header token in either the short, default or raw * form. */ -static void +void sprint_event(gchar **event_name, u_int16_t ev,const gchar *label) { char event_ent_name[AU_EVENT_NAME_MAX]; @@ -354,17 +363,23 @@ ep = getauevnum_r(&e, ev); if (ep == NULL) { - g_sprintf(*event_name, "%s:%u", label, ev); + if (label==NULL) + g_sprintf(*event_name,"%u",ev); + else + g_sprintf(*event_name, "%s:%u", label, ev); return; } - g_sprintf(*event_name, "%s:%s",label,e.ae_name); + if (label==NULL) + g_sprintf(*event_name,"%s",e.ae_name); + else + g_sprintf(*event_name, "%s:%s",label,e.ae_name); } #define ENTITY_NAME_MAX_LEN 100 /* * Prints a user value. */ -static void +void sprint_user(gchar **str, u_int32_t usr,const gchar *label) { *str=(gchar *)malloc(sizeof(label)+1+ENTITY_NAME_MAX_LEN); @@ -379,7 +394,7 @@ /* * Prints a group value. */ -static void +void sprint_group(gchar **str, u_int32_t grp,const gchar *label) { *str=(gchar *)malloc(sizeof(label)+1+ENTITY_NAME_MAX_LEN); ==== //depot/projects/soc2007/dongmei-auditanalyzer/gtk/tree_view.h#5 (text+ko) ==== @@ -14,3 +14,134 @@ create_tree(void); void parse_token_tree(record_data *rdata); void clear_tree_view_rows(void); +/* + * Prints a single byte in the given format. + */ +void +sprint_1_byte(gchar **str, u_char val, const gchar *format,const gchar *label); +/* + * Prints a single byte in the default format. + */ +void +sprint_1_byte_df(gchar **str, u_char val, const gchar *label); + +/* + * Print 2 bytes in the given format. + */ +void +sprint_2_bytes(gchar **str, u_int16_t val, const gchar *format,const gchar *label); +/* + * Print 2 bytes in the default format. + */ +void +sprint_2_bytes_df(gchar **str, u_int16_t val, const gchar *label); + +/* + * Prints 4 bytes in the given format. + */ +void +sprint_4_bytes(gchar **str, u_int32_t val, const gchar *format,const gchar *label); +/* + * Prints 4 bytes in the defautl format. + */ +void +sprint_4_bytes_df(gchar **str, u_int32_t val, const gchar *label); + +/* + * Prints 8 bytes in the given format. + */ +void +sprint_8_bytes(gchar **str, u_int64_t val, const gchar *format,const gchar *label); + +/* + * Prints 8 bytes in the default format. + */ +void +sprint_8_bytes_df(gchar **str, u_int64_t val, const gchar *label); + +/* + * Prints the given size of data bytes in hex. + */ +void +sprint_mem(gchar **str, u_char *data, size_t len,const gchar *label); +/* + * Prints the given size of arbitray data in give format. + */ +void +sprint_arb_data(gchar **str, u_char *data, u_char count, size_t size,const gchar *format); + +/* + * Prints the given data bytes as a string. + */ +void +sprint_string(gchar **dstr, const char *sstr, size_t len, const gchar *label); +/* + * Prints seconds in the ctime format. + */ +void +sprint_sec32(gchar **str, u_int32_t sec, const gchar *label); + +/* + * XXXRW: 64-bit token streams make use of 64-bit time stamps; since we + * assume a 32-bit time_t, we simply truncate for now. + */ +void +sprint_sec64(gchar **str, u_int64_t sec,const gchar *label); + +/* + * Prints the excess milliseconds. + */ +void +sprint_msec32(gchar **str, u_int32_t msec, const gchar *label); + +/* + * XXXRW: 64-bit token streams make use of 64-bit time stamps; since we assume + * a 32-bit msec, we simply truncate for now. + */ +void +sprint_msec64(gchar **str, u_int64_t msec, const gchar *label); +/* + * Prints a dotted form for the IP address. + */ +void +sprint_ip_address(gchar **str, u_int32_t ip,const gchar *label); +/* + * Prints a string value for the given ip address. + */ +void +sprint_ip_ex_address(gchar **str, u_int32_t type, u_int32_t *ipaddr,const gchar *label); +/* + * Prints return value as success or failure. + */ +void +sprint_retval(gchar **str, u_char status, const gchar *label); + +/* + * Prints the exit value. + */ +void +sprint_errval(gchar **str, u_int32_t val,const gchar *label); + +/* + * Prints IPC type. + */ +void +sprint_ipctype(gchar **str, u_char type, const gchar *label); + +/* + * Prints the event from the header token in either the short, default or raw + * form. + */ +void +sprint_event(gchar **event_name, u_int16_t ev,const gchar *label); +/* + * Prints a user value. + */ +void +sprint_user(gchar **str, u_int32_t usr,const gchar *label); +/* + * Prints a group value. + */ +void +sprint_group(gchar **str, u_int32_t grp,const gchar *label); +
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707201131.l6KBVRhq056771>