summaryrefslogtreecommitdiff
path: root/ui/cli/tap-iostat.c
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2014-10-13 15:04:21 -0400
committerBill Meier <wmeier@newsguy.com>2014-10-13 19:09:07 +0000
commit6a9479ecf90ef64f944526354fb26ee876d3ad25 (patch)
treeff0542670c21c9323020d89002d3a2c64e93a46c /ui/cli/tap-iostat.c
parent63faad686b49e02b86cd1961dd3bc8283f120da8 (diff)
downloadwireshark-6a9479ecf90ef64f944526354fb26ee876d3ad25.tar.gz
Add editor modelines and/or adjust whilespace.
Change-Id: I626b7bd8ac6e4b91c57cc9152e7ce038754e7278 Reviewed-on: https://code.wireshark.org/review/4658 Reviewed-by: Bill Meier <wmeier@newsguy.com>
Diffstat (limited to 'ui/cli/tap-iostat.c')
-rw-r--r--ui/cli/tap-iostat.c366
1 files changed, 183 insertions, 183 deletions
diff --git a/ui/cli/tap-iostat.c b/ui/cli/tap-iostat.c
index 5bb000b770..e9560d69a5 100644
--- a/ui/cli/tap-iostat.c
+++ b/ui/cli/tap-iostat.c
@@ -52,15 +52,15 @@ typedef struct {
} calc_type_ent_t;
static calc_type_ent_t calc_type_table[] = {
- { "FRAMES", CALC_TYPE_FRAMES },
- { "BYTES", CALC_TYPE_BYTES },
+ { "FRAMES", CALC_TYPE_FRAMES },
+ { "BYTES", CALC_TYPE_BYTES },
{ "FRAMES BYTES", CALC_TYPE_FRAMES_AND_BYTES },
- { "COUNT", CALC_TYPE_COUNT },
- { "SUM", CALC_TYPE_SUM },
- { "MIN", CALC_TYPE_MIN },
- { "MAX", CALC_TYPE_MAX },
- { "AVG", CALC_TYPE_AVG },
- { "LOAD", CALC_TYPE_LOAD },
+ { "COUNT", CALC_TYPE_COUNT },
+ { "SUM", CALC_TYPE_SUM },
+ { "MIN", CALC_TYPE_MIN },
+ { "MAX", CALC_TYPE_MAX },
+ { "AVG", CALC_TYPE_AVG },
+ { "LOAD", CALC_TYPE_LOAD },
{ NULL, 0 }
};
@@ -151,25 +151,25 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
/* Store info in the current structure */
it->frames++;
- switch(it->calc_type) {
+ switch (it->calc_type) {
case CALC_TYPE_FRAMES:
case CALC_TYPE_BYTES:
case CALC_TYPE_FRAMES_AND_BYTES:
it->counter += pinfo->fd->pkt_len;
break;
case CALC_TYPE_COUNT:
- gp=proto_get_finfo_ptr_array(edt->tree, it->hf_index);
- if(gp){
+ gp = proto_get_finfo_ptr_array(edt->tree, it->hf_index);
+ if (gp) {
it->counter += gp->len;
}
break;
case CALC_TYPE_SUM:
- gp=proto_get_finfo_ptr_array(edt->tree, it->hf_index);
- if(gp){
+ gp = proto_get_finfo_ptr_array(edt->tree, it->hf_index);
+ if (gp) {
guint64 val;
- for(i=0;i<gp->len;i++){
- switch(proto_registrar_get_ftype(it->hf_index)){
+ for (i=0; i<gp->len; i++) {
+ switch (proto_registrar_get_ftype(it->hf_index)) {
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
@@ -212,28 +212,28 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
}
break;
case CALC_TYPE_MIN:
- gp=proto_get_finfo_ptr_array(edt->tree, it->hf_index);
- if(gp){
+ gp = proto_get_finfo_ptr_array(edt->tree, it->hf_index);
+ if (gp) {
guint64 val;
gfloat float_val;
gdouble double_val;
- ftype=proto_registrar_get_ftype(it->hf_index);
- for(i=0;i<gp->len;i++){
- switch(ftype){
+ ftype = proto_registrar_get_ftype(it->hf_index);
+ for (i=0; i<gp->len; i++) {
+ switch (ftype) {
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
val = fvalue_get_uinteger(&((field_info *)gp->pdata[i])->value);
- if ((it->frames==1 && i==0) || (val < it->counter)) {
- it->counter=val;
+ if ((it->frames == 1 && i == 0) || (val < it->counter)) {
+ it->counter = val;
}
break;
case FT_UINT64:
val = fvalue_get_integer64(&((field_info *)gp->pdata[i])->value);
- if((it->frames==1 && i==0) || (val < it->counter)){
- it->counter=val;
+ if ((it->frames == 1 && i == 0) || (val < it->counter)) {
+ it->counter = val;
}
break;
case FT_INT8:
@@ -241,33 +241,33 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
case FT_INT24:
case FT_INT32:
val = fvalue_get_sinteger(&((field_info *)gp->pdata[i])->value);
- if((it->frames==1 && i==0) || ((gint32)val < (gint32)it->counter)) {
- it->counter=val;
+ if ((it->frames == 1 && i == 0) || ((gint32)val < (gint32)it->counter)) {
+ it->counter = val;
}
break;
case FT_INT64:
val = fvalue_get_integer64(&((field_info *)gp->pdata[i])->value);
- if((it->frames==1 && i==0) || ((gint64)val < (gint64)it->counter)) {
- it->counter=val;
+ if ((it->frames == 1 && i == 0) || ((gint64)val < (gint64)it->counter)) {
+ it->counter = val;
}
break;
case FT_FLOAT:
- float_val=(gfloat)fvalue_get_floating(&((field_info *)gp->pdata[i])->value);
- if((it->frames==1 && i==0) || (float_val < it->float_counter)) {
- it->float_counter=float_val;
+ float_val = (gfloat)fvalue_get_floating(&((field_info *)gp->pdata[i])->value);
+ if ((it->frames == 1 && i == 0) || (float_val < it->float_counter)) {
+ it->float_counter = float_val;
}
break;
case FT_DOUBLE:
- double_val=fvalue_get_floating(&((field_info *)gp->pdata[i])->value);
- if((it->frames==1 && i==0) || (double_val < it->double_counter)) {
- it->double_counter=double_val;
+ double_val = fvalue_get_floating(&((field_info *)gp->pdata[i])->value);
+ if ((it->frames == 1 && i == 0) || (double_val < it->double_counter)) {
+ it->double_counter = double_val;
}
break;
case FT_RELATIVE_TIME:
new_time = (nstime_t *)fvalue_get(&((field_info *)gp->pdata[i])->value);
val = ((guint64)new_time->secs * NANOSECS_PER_SEC) + (guint64)new_time->nsecs;
- if((it->frames==1 && i==0) || (val < it->counter)) {
- it->counter=val;
+ if ((it->frames == 1 && i == 0) || (val < it->counter)) {
+ it->counter = val;
}
break;
default:
@@ -282,56 +282,56 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
}
break;
case CALC_TYPE_MAX:
- gp=proto_get_finfo_ptr_array(edt->tree, it->hf_index);
- if(gp){
+ gp = proto_get_finfo_ptr_array(edt->tree, it->hf_index);
+ if (gp) {
guint64 val;
gfloat float_val;
gdouble double_val;
- ftype=proto_registrar_get_ftype(it->hf_index);
- for(i=0;i<gp->len;i++){
- switch(ftype){
+ ftype = proto_registrar_get_ftype(it->hf_index);
+ for (i=0; i<gp->len; i++) {
+ switch (ftype) {
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
case FT_UINT32:
val = fvalue_get_uinteger(&((field_info *)gp->pdata[i])->value);
- if(val > it->counter)
- it->counter=val;
+ if (val > it->counter)
+ it->counter = val;
break;
case FT_UINT64:
val = fvalue_get_integer64(&((field_info *)gp->pdata[i])->value);
- if(val > it->counter)
- it->counter=val;
+ if (val > it->counter)
+ it->counter = val;
break;
case FT_INT8:
case FT_INT16:
case FT_INT24:
case FT_INT32:
val = fvalue_get_sinteger(&((field_info *)gp->pdata[i])->value);
- if((gint32)val > (gint32)it->counter)
- it->counter=val;
+ if ((gint32)val > (gint32)it->counter)
+ it->counter = val;
break;
case FT_INT64:
val = fvalue_get_integer64(&((field_info *)gp->pdata[i])->value);
if ((gint64)val > (gint64)it->counter)
- it->counter=val;
+ it->counter = val;
break;
case FT_FLOAT:
float_val = (gfloat)fvalue_get_floating(&((field_info *)gp->pdata[i])->value);
- if(float_val > it->float_counter)
- it->float_counter=float_val;
+ if (float_val > it->float_counter)
+ it->float_counter = float_val;
break;
case FT_DOUBLE:
double_val = fvalue_get_floating(&((field_info *)gp->pdata[i])->value);
- if(double_val > it->double_counter)
- it->double_counter=double_val;
+ if (double_val > it->double_counter)
+ it->double_counter = double_val;
break;
case FT_RELATIVE_TIME:
new_time = (nstime_t *)fvalue_get(&((field_info *)gp->pdata[i])->value);
val = ((guint64)new_time->secs * NANOSECS_PER_SEC) + (guint64)new_time->nsecs;
- if (val>it->counter)
- it->counter=val;
+ if (val > it->counter)
+ it->counter = val;
break;
default:
/*
@@ -345,14 +345,14 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
}
break;
case CALC_TYPE_AVG:
- gp=proto_get_finfo_ptr_array(edt->tree, it->hf_index);
- if(gp){
+ gp = proto_get_finfo_ptr_array(edt->tree, it->hf_index);
+ if (gp) {
guint64 val;
- ftype=proto_registrar_get_ftype(it->hf_index);
- for(i=0;i<gp->len;i++){
+ ftype = proto_registrar_get_ftype(it->hf_index);
+ for (i=0; i<gp->len; i++) {
it->num++;
- switch(ftype) {
+ switch (ftype) {
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
@@ -403,7 +403,7 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
"\ntshark: LOAD() is only supported for relative-time fields such as smb.time\n");
exit(10);
}
- for(i=0;i<gp->len;i++){
+ for (i=0; i<gp->len; i++) {
guint64 val;
int tival;
io_stat_item_t *pit;
@@ -433,12 +433,12 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
* calc the average, round it to the next second and store the seconds. For all other calc types
* of RELATIVE_TIME fields, store the counters without modification.
* fields. */
- switch(it->calc_type) {
+ switch (it->calc_type) {
case CALC_TYPE_FRAMES:
case CALC_TYPE_FRAMES_AND_BYTES:
parent->max_frame[it->colnum] =
MAX(parent->max_frame[it->colnum], it->frames);
- if (it->calc_type==CALC_TYPE_FRAMES_AND_BYTES)
+ if (it->calc_type == CALC_TYPE_FRAMES_AND_BYTES)
parent->max_vals[it->colnum] =
MAX(parent->max_vals[it->colnum], it->counter);
@@ -450,15 +450,15 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
case CALC_TYPE_SUM:
case CALC_TYPE_MIN:
case CALC_TYPE_MAX:
- ftype=proto_registrar_get_ftype(it->hf_index);
- switch(ftype) {
+ ftype = proto_registrar_get_ftype(it->hf_index);
+ switch (ftype) {
case FT_FLOAT:
parent->max_vals[it->colnum] =
MAX(parent->max_vals[it->colnum], (guint64)(it->float_counter+0.5));
break;
case FT_DOUBLE:
parent->max_vals[it->colnum] =
- MAX(parent->max_vals[it->colnum],(guint64)(it->double_counter+0.5));
+ MAX(parent->max_vals[it->colnum], (guint64)(it->double_counter+0.5));
break;
case FT_RELATIVE_TIME:
parent->max_vals[it->colnum] =
@@ -472,17 +472,17 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
}
break;
case CALC_TYPE_AVG:
- if (it->num==0) /* avoid division by zero */
+ if (it->num == 0) /* avoid division by zero */
break;
- ftype=proto_registrar_get_ftype(it->hf_index);
- switch(ftype) {
+ ftype = proto_registrar_get_ftype(it->hf_index);
+ switch (ftype) {
case FT_FLOAT:
parent->max_vals[it->colnum] =
MAX(parent->max_vals[it->colnum], (guint64)it->float_counter/it->num);
break;
case FT_DOUBLE:
parent->max_vals[it->colnum] =
- MAX(parent->max_vals[it->colnum],(guint64)it->double_counter/it->num);
+ MAX(parent->max_vals[it->colnum], (guint64)it->double_counter/it->num);
break;
case FT_RELATIVE_TIME:
parent->max_vals[it->colnum] =
@@ -501,11 +501,11 @@ iostat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt, const void *du
static int
magnitude (guint64 val, int max_w)
{
- int i, mag=0;
+ int i, mag = 0;
for (i=0; i<max_w; i++) {
mag++;
- if ((val /= 10)==0)
+ if ((val /= 10) == 0)
break;
}
return(mag);
@@ -518,12 +518,12 @@ static void
printcenter (const char *label, int lenval, int numpad)
{
int lenlab = (int) strlen(label), len;
- const char spaces[]=" ", *spaces_ptr;
+ const char spaces[] = " ", *spaces_ptr;
len = (int) (strlen(spaces)) - (((lenval-lenlab) / 2) + numpad);
if (len > 0 && len < 6) {
spaces_ptr = &spaces[len];
- if ((lenval-lenlab)%2==0) {
+ if ((lenval-lenlab)%2 == 0) {
printf("%s%s%s|", spaces_ptr, label, spaces_ptr);
} else {
printf("%s%s%s|", spaces_ptr-1, label, spaces_ptr);
@@ -544,15 +544,15 @@ iostat_draw(void *arg)
guint32 num;
guint64 interval, duration, t, invl_end, dv;
int i, j, k, num_cols, num_rows, dur_secs_orig, dur_nsecs_orig, dur_secs, dur_nsecs, dur_mag,
- invl_mag, invl_prec, tabrow_w, borderlen, invl_col_w, numpad=1, namelen, len_filt, type,
+ invl_mag, invl_prec, tabrow_w, borderlen, invl_col_w, numpad = 1, namelen, len_filt, type,
maxfltr_w, ftype;
int fr_mag; /* The magnitude of the max frame number in this column */
int val_mag; /* The magnitude of the max value in this column */
- char *spaces, *spaces_s, *filler_s=NULL, **fmts, *fmt=NULL;
+ char *spaces, *spaces_s, *filler_s = NULL, **fmts, *fmt = NULL;
const char *filter;
static gchar dur_mag_s[3], invl_prec_s[3], fr_mag_s[3], val_mag_s[3], *invl_fmt, *full_fmt;
io_stat_item_t *mit, **stat_cols, *item, **item_in_column;
- gboolean last_row=FALSE;
+ gboolean last_row = FALSE;
io_stat_t *iot;
column_width *col_w;
struct tm *tm_time;
@@ -567,13 +567,13 @@ iostat_draw(void *arg)
(guint64)((cfile.elapsed_time.nsecs + 500) / 1000);
/* Store the pointer to each stat column */
- stat_cols = (io_stat_item_t **) g_malloc(sizeof(io_stat_item_t *) * num_cols);
+ stat_cols = (io_stat_item_t **)g_malloc(sizeof(io_stat_item_t *) * num_cols);
for (j=0; j<num_cols; j++)
stat_cols[j] = &iot->items[j];
/* The following prevents gross inaccuracies when the user specifies an interval that is greater
* than the capture duration. */
- if (iot->interval > duration || iot->interval==G_MAXINT32) {
+ if (iot->interval > duration || iot->interval == G_MAXINT32) {
interval = duration;
iot->interval = G_MAXINT32;
} else {
@@ -592,25 +592,25 @@ iostat_draw(void *arg)
invl_mag = magnitude(interval/G_GUINT64_CONSTANT(1000000), 5);
/* Set or get the interval precision */
- if (interval==duration) {
+ if (interval == duration) {
/*
* An interval arg of 0 or an interval size exceeding the capture duration was specified.
* Set the decimal precision of duration based on its magnitude. */
if (dur_mag >= 2)
invl_prec = 1;
- else if (dur_mag==1)
+ else if (dur_mag == 1)
invl_prec = 3;
else
invl_prec = 6;
- borderlen = 30 + dur_mag + (invl_prec==0 ? 0 : invl_prec+1);
+ borderlen = 30 + dur_mag + (invl_prec == 0 ? 0 : invl_prec+1);
} else {
invl_prec = iot->invl_prec;
- borderlen = 24 + invl_mag + (invl_prec==0 ? 0 : invl_prec+1);
+ borderlen = 24 + invl_mag + (invl_prec == 0 ? 0 : invl_prec+1);
}
/* Round the duration according to invl_prec */
- dv=1000000;
+ dv = 1000000;
for (i=0; i<invl_prec; i++)
dv /= 10;
if ((duration%dv) > 5*(dv/10)) {
@@ -622,11 +622,11 @@ iostat_draw(void *arg)
* Recalc dur_mag in case rounding has increased its magnitude */
dur_mag = magnitude((guint64)dur_secs, 5);
}
- if (iot->interval==G_MAXINT32)
+ if (iot->interval == G_MAXINT32)
interval = duration;
/* Calc the width of the time interval column (incl borders and padding). */
- if (invl_prec==0)
+ if (invl_prec == 0)
invl_col_w = (2*dur_mag) + 8;
else
invl_col_w = (2*dur_mag) + (2*invl_prec) + 10;
@@ -654,13 +654,13 @@ iostat_draw(void *arg)
tabrow_w = invl_col_w;
for (j=0; j<num_cols; j++) {
type = iot->items[j].calc_type;
- if (type==CALC_TYPE_FRAMES_AND_BYTES) {
+ if (type == CALC_TYPE_FRAMES_AND_BYTES) {
namelen = 5;
} else {
namelen = (int) strlen(calc_type_table[type].func_name);
}
- if(type==CALC_TYPE_FRAMES
- || type==CALC_TYPE_FRAMES_AND_BYTES) {
+ if (type == CALC_TYPE_FRAMES
+ || type == CALC_TYPE_FRAMES_AND_BYTES) {
fr_mag = magnitude(iot->max_frame[j], 15);
fr_mag = MAX(6, fr_mag);
@@ -668,7 +668,7 @@ iostat_draw(void *arg)
tabrow_w += col_w[j].fr + 3;
g_snprintf(fr_mag_s, 3, "%u", fr_mag);
- if (type==CALC_TYPE_FRAMES) {
+ if (type == CALC_TYPE_FRAMES) {
fmt = g_strconcat(" %", fr_mag_s, "u |", NULL);
} else {
/* CALC_TYPE_FRAMES_AND_BYTES
@@ -684,7 +684,7 @@ iostat_draw(void *arg)
fmts[j] = fmt;
continue;
}
- switch(type) {
+ switch (type) {
case CALC_TYPE_BYTES:
case CALC_TYPE_COUNT:
@@ -708,7 +708,7 @@ iostat_draw(void *arg)
case FT_RELATIVE_TIME:
/* Convert FT_RELATIVE_TIME field to seconds
* CALC_TYPE_LOAD was already converted in iostat_packet() ) */
- if (type==CALC_TYPE_LOAD) {
+ if (type == CALC_TYPE_LOAD) {
iot->max_vals[j] /= interval;
} else if (type != CALC_TYPE_AVG) {
iot->max_vals[j] = (iot->max_vals[j] + G_GUINT64_CONSTANT(500000000)) / NANOSECS_PER_SEC;
@@ -752,7 +752,7 @@ iostat_draw(void *arg)
/* Calc the max width of the list of filters. */
maxfltr_w = 0;
- for(j=0; j<num_cols; j++) {
+ for (j=0; j<num_cols; j++) {
if (iot->filters[j]) {
k = (int) (strlen(iot->filters[j]) + 11);
maxfltr_w = MAX(maxfltr_w, k);
@@ -770,7 +770,7 @@ iostat_draw(void *arg)
borderlen = MIN(maxfltr_w, 102);
/* Prevent double right border by adding a space */
- if (borderlen-tabrow_w==1)
+ if (borderlen-tabrow_w == 1)
borderlen++;
/* Display the top border */
@@ -778,7 +778,7 @@ iostat_draw(void *arg)
for (i=0; i<borderlen; i++)
printf("=");
- spaces = (char*) g_malloc(borderlen+1);
+ spaces = (char *)g_malloc(borderlen+1);
for (i=0; i<borderlen; i++)
spaces[i] = ' ';
spaces[borderlen] = '\0';
@@ -788,7 +788,7 @@ iostat_draw(void *arg)
spaces_s = &spaces[2];
printf("|%s|\n", spaces_s);
- if (invl_prec==0) {
+ if (invl_prec == 0) {
invl_fmt = g_strconcat("%", dur_mag_s, "u", NULL);
full_fmt = g_strconcat("| Duration: ", invl_fmt, ".%6u secs%s|\n", NULL);
spaces_s = &spaces[25 + dur_mag];
@@ -817,9 +817,9 @@ iostat_draw(void *arg)
/* Display the list of filters and their column numbers vertically */
printf("| Col");
- for(j=0; j<num_cols; j++){
- printf((j==0 ? "%2u: " : "| %2u: "), j+1);
- if (!iot->filters[j] || (iot->filters[j]==0)) {
+ for (j=0; j<num_cols; j++) {
+ printf((j == 0 ? "%2u: " : "| %2u: "), j+1);
+ if (!iot->filters[j] || (iot->filters[j] == 0)) {
/*
* An empty (no filter) comma field was specified */
spaces_s = &spaces[16 + 10];
@@ -841,7 +841,7 @@ iostat_draw(void *arg)
gchar *sfilter1, *sfilter2;
const gchar *pos;
gsize len;
- int next_start, max_w=borderlen-11;
+ int next_start, max_w = borderlen-11;
do {
if (len_filt > max_w) {
@@ -876,7 +876,7 @@ iostat_draw(void *arg)
}
printf("|-");
- for(i=0;i<borderlen-3;i++){
+ for (i=0; i<borderlen-3; i++) {
printf("-");
}
printf("|\n");
@@ -886,11 +886,11 @@ iostat_draw(void *arg)
printf("|%s|", spaces_s);
/* Display column number headers */
- for(j=0; j<num_cols; j++) {
+ for (j=0; j<num_cols; j++) {
item = stat_cols[j];
- if(item->calc_type==CALC_TYPE_FRAMES_AND_BYTES)
+ if (item->calc_type == CALC_TYPE_FRAMES_AND_BYTES)
spaces_s = &spaces[borderlen - (col_w[j].fr + col_w[j].val)] - 3;
- else if (item->calc_type==CALC_TYPE_FRAMES)
+ else if (item->calc_type == CALC_TYPE_FRAMES)
spaces_s = &spaces[borderlen - col_w[j].fr];
else
spaces_s = &spaces[borderlen - col_w[j].val];
@@ -926,11 +926,11 @@ iostat_draw(void *arg)
printf("%s|", spaces_s);
/* Display the stat label in each column */
- for(j=0; j<num_cols; j++) {
+ for (j=0; j<num_cols; j++) {
type = stat_cols[j]->calc_type;
- if(type==CALC_TYPE_FRAMES) {
+ if (type == CALC_TYPE_FRAMES) {
printcenter (calc_type_table[type].func_name, col_w[j].fr, numpad);
- } else if (type==CALC_TYPE_FRAMES_AND_BYTES) {
+ } else if (type == CALC_TYPE_FRAMES_AND_BYTES) {
printcenter ("Frames", col_w[j].fr, numpad);
printcenter ("Bytes", col_w[j].val, numpad);
} else {
@@ -941,7 +941,7 @@ iostat_draw(void *arg)
printf("%s|", filler_s);
printf("\n|-");
- for(i=0; i<tabrow_w-3; i++)
+ for (i=0; i<tabrow_w-3; i++)
printf("-");
printf("|");
@@ -949,8 +949,8 @@ iostat_draw(void *arg)
printf("%s|", &spaces[tabrow_w+1]);
printf("\n");
- t=0;
- if (invl_prec==0 && dur_mag==1)
+ t = 0;
+ if (invl_prec == 0 && dur_mag == 1)
full_fmt = g_strconcat("| ", invl_fmt, " <> ", invl_fmt, " |", NULL);
else
full_fmt = g_strconcat("| ", invl_fmt, " <> ", invl_fmt, " |", NULL);
@@ -962,7 +962,7 @@ iostat_draw(void *arg)
}
/* Load item_in_column with the first item in each column */
- item_in_column = (io_stat_item_t **) g_malloc(sizeof(io_stat_item_t *) * num_cols);
+ item_in_column = (io_stat_item_t **)g_malloc(sizeof(io_stat_item_t *) * num_cols);
for (j=0; j<num_cols; j++) {
item_in_column[j] = stat_cols[j];
}
@@ -972,7 +972,7 @@ iostat_draw(void *arg)
* The outer loop is for time interval rows and the inner loop is for stat column items.*/
for (i=0; i<num_rows; i++) {
- if (i==num_rows-1)
+ if (i == num_rows-1)
last_row = TRUE;
/* Compute the interval for this row */
@@ -1048,13 +1048,13 @@ iostat_draw(void *arg)
case TS_RELATIVE:
case TS_NOT_SET:
- if (invl_prec==0) {
- if(last_row) {
+ if (invl_prec == 0) {
+ if (last_row) {
int maxw;
maxw = dur_mag >= 3 ? dur_mag+1 : 3;
g_free(full_fmt);
g_snprintf(dur_mag_s, 3, "%u", maxw);
- full_fmt = g_strconcat( dur_mag==1 ? "| " : "| ",
+ full_fmt = g_strconcat( dur_mag == 1 ? "| " : "| ",
invl_fmt, " <> ", "%-",
dur_mag_s, "s|", NULL);
printf(full_fmt, (guint32)(t/G_GUINT64_CONSTANT(1000000)), "Dur");
@@ -1083,7 +1083,7 @@ iostat_draw(void *arg)
item = item_in_column[j];
if (item) {
- switch(item->calc_type) {
+ switch (item->calc_type) {
case CALC_TYPE_FRAMES:
printf(fmt, item->frames);
break;
@@ -1099,7 +1099,7 @@ iostat_draw(void *arg)
case CALC_TYPE_MIN:
case CALC_TYPE_MAX:
ftype = proto_registrar_get_ftype(stat_cols[j]->hf_index);
- switch(ftype){
+ switch (ftype) {
case FT_FLOAT:
printf(fmt, item->float_counter);
break;
@@ -1120,10 +1120,10 @@ iostat_draw(void *arg)
case CALC_TYPE_AVG:
num = item->num;
- if(num==0)
- num=1;
+ if (num == 0)
+ num = 1;
ftype = proto_registrar_get_ftype(stat_cols[j]->hf_index);
- switch(ftype){
+ switch (ftype) {
case FT_FLOAT:
printf(fmt, item->float_counter/num);
break;
@@ -1144,7 +1144,7 @@ iostat_draw(void *arg)
case CALC_TYPE_LOAD:
ftype = proto_registrar_get_ftype(stat_cols[j]->hf_index);
- switch(ftype){
+ switch (ftype) {
case FT_RELATIVE_TIME:
if (!last_row) {
printf(fmt,
@@ -1176,7 +1176,7 @@ iostat_draw(void *arg)
t += interval;
}
- for(i=0;i<borderlen;i++){
+ for (i=0; i<borderlen; i++) {
printf("=");
}
printf("\n");
@@ -1205,43 +1205,43 @@ register_io_tap(io_stat_t *io, int i, const char *filter)
char *field;
header_field_info *hfi;
- io->items[i].prev=&io->items[i];
- io->items[i].next=NULL;
- io->items[i].parent=io;
- io->items[i].time=0;
- io->items[i].calc_type=CALC_TYPE_FRAMES_AND_BYTES;
- io->items[i].frames=0;
- io->items[i].counter=0;
- io->items[i].num=0;
-
- io->filters[i]=filter;
- flt=filter;
-
- field=NULL;
- hfi=NULL;
- for(j=0; calc_type_table[j].func_name; j++){
- namelen=strlen(calc_type_table[j].func_name);
- if(filter && strncmp(filter, calc_type_table[j].func_name, namelen) == 0) {
- io->items[i].calc_type=calc_type_table[j].calc_type;
+ io->items[i].prev = &io->items[i];
+ io->items[i].next = NULL;
+ io->items[i].parent = io;
+ io->items[i].time = 0;
+ io->items[i].calc_type = CALC_TYPE_FRAMES_AND_BYTES;
+ io->items[i].frames = 0;
+ io->items[i].counter = 0;
+ io->items[i].num = 0;
+
+ io->filters[i] = filter;
+ flt = filter;
+
+ field = NULL;
+ hfi = NULL;
+ for (j=0; calc_type_table[j].func_name; j++) {
+ namelen = strlen(calc_type_table[j].func_name);
+ if (filter && strncmp(filter, calc_type_table[j].func_name, namelen) == 0) {
+ io->items[i].calc_type = calc_type_table[j].calc_type;
io->items[i].colnum = i;
- if(*(filter+namelen)=='(') {
- p=filter+namelen+1;
- parenp=strchr(p, ')');
- if(!parenp){
+ if (*(filter+namelen) == '(') {
+ p = filter+namelen+1;
+ parenp = strchr(p, ')');
+ if (!parenp) {
fprintf(stderr,
"\ntshark: Closing parenthesis missing from calculated expression.\n");
exit(10);
}
- if(io->items[i].calc_type==CALC_TYPE_FRAMES || io->items[i].calc_type==CALC_TYPE_BYTES){
- if(parenp!=p) {
+ if (io->items[i].calc_type == CALC_TYPE_FRAMES || io->items[i].calc_type == CALC_TYPE_BYTES) {
+ if (parenp != p) {
fprintf(stderr,
"\ntshark: %s does not require or allow a field name within the parens.\n",
calc_type_table[j].func_name);
exit(10);
}
} else {
- if(parenp==p) {
+ if (parenp == p) {
/* bail out if a field name was not specified */
fprintf(stderr, "\ntshark: You didn't specify a field name for %s(*).\n",
calc_type_table[j].func_name);
@@ -1249,34 +1249,34 @@ register_io_tap(io_stat_t *io, int i, const char *filter)
}
}
- field = (char *) g_malloc(parenp-p+1);
+ field = (char *)g_malloc(parenp-p+1);
memcpy(field, p, parenp-p);
field[parenp-p] = '\0';
- flt=parenp + 1;
- if (io->items[i].calc_type==CALC_TYPE_FRAMES || io->items[i].calc_type==CALC_TYPE_BYTES)
+ flt = parenp + 1;
+ if (io->items[i].calc_type == CALC_TYPE_FRAMES || io->items[i].calc_type == CALC_TYPE_BYTES)
break;
- hfi=proto_registrar_get_byname(field);
- if(!hfi){
+ hfi = proto_registrar_get_byname(field);
+ if (!hfi) {
fprintf(stderr, "\ntshark: There is no field named '%s'.\n",
field);
g_free(field);
exit(10);
}
- io->items[i].hf_index=hfi->id;
+ io->items[i].hf_index = hfi->id;
break;
}
} else {
- if (io->items[i].calc_type==CALC_TYPE_FRAMES || io->items[i].calc_type==CALC_TYPE_BYTES)
- flt="";
+ if (io->items[i].calc_type == CALC_TYPE_FRAMES || io->items[i].calc_type == CALC_TYPE_BYTES)
+ flt = "";
io->items[i].colnum = i;
}
}
- if(hfi && !(io->items[i].calc_type==CALC_TYPE_BYTES ||
- io->items[i].calc_type==CALC_TYPE_FRAMES ||
- io->items[i].calc_type==CALC_TYPE_FRAMES_AND_BYTES)){
+ if (hfi && !(io->items[i].calc_type == CALC_TYPE_BYTES ||
+ io->items[i].calc_type == CALC_TYPE_FRAMES ||
+ io->items[i].calc_type == CALC_TYPE_FRAMES_AND_BYTES)) {
/* check that the type is compatible */
- switch(hfi->type){
+ switch (hfi->type) {
case FT_UINT8:
case FT_UINT16:
case FT_UINT24:
@@ -1292,7 +1292,7 @@ register_io_tap(io_stat_t *io, int i, const char *filter)
case FT_FLOAT:
case FT_DOUBLE:
/* these types only support SUM, COUNT, MAX, MIN, AVG */
- switch(io->items[i].calc_type){
+ switch (io->items[i].calc_type) {
case CALC_TYPE_SUM:
case CALC_TYPE_COUNT:
case CALC_TYPE_MAX:
@@ -1309,7 +1309,7 @@ register_io_tap(io_stat_t *io, int i, const char *filter)
break;
case FT_RELATIVE_TIME:
/* this type only supports SUM, COUNT, MAX, MIN, AVG, LOAD */
- switch(io->items[i].calc_type){
+ switch (io->items[i].calc_type) {
case CALC_TYPE_SUM:
case CALC_TYPE_COUNT:
case CALC_TYPE_MAX:
@@ -1330,7 +1330,7 @@ register_io_tap(io_stat_t *io, int i, const char *filter)
* XXX - support all operations on floating-point
* numbers?
*/
- if(io->items[i].calc_type!=CALC_TYPE_COUNT){
+ if (io->items[i].calc_type != CALC_TYPE_COUNT) {
fprintf(stderr,
"\ntshark: %s doesn't have integral values, so %s(*) "
"calculations are not supported on it.\n",
@@ -1343,9 +1343,9 @@ register_io_tap(io_stat_t *io, int i, const char *filter)
g_free(field);
}
- error_string=register_tap_listener("frame", &io->items[i], flt, TL_REQUIRES_PROTO_TREE, NULL,
- iostat_packet, i?NULL:iostat_draw);
- if(error_string){
+ error_string = register_tap_listener("frame", &io->items[i], flt, TL_REQUIRES_PROTO_TREE, NULL,
+ iostat_packet, i ? NULL : iostat_draw);
+ if (error_string) {
g_free(io->items);
g_free(io);
fprintf(stderr, "\ntshark: Couldn't register io,stat tap: %s\n",
@@ -1356,10 +1356,10 @@ register_io_tap(io_stat_t *io, int i, const char *filter)
}
static void
-iostat_init(const char *opt_arg, void* userdata _U_)
+iostat_init(const char *opt_arg, void *userdata _U_)
{
gdouble interval_float;
- guint32 idx=0;
+ guint32 idx = 0;
int i;
io_stat_t *io;
const gchar *filters, *str, *pos;
@@ -1371,7 +1371,7 @@ iostat_init(const char *opt_arg, void* userdata _U_)
exit(1);
}
- filters=opt_arg+idx;
+ filters = opt_arg+idx;
if (*filters) {
if (*filters != ',') {
/* For locale's that use ',' instead of '.', the comma might
@@ -1383,7 +1383,7 @@ iostat_init(const char *opt_arg, void* userdata _U_)
}
}
} else
- filters=NULL;
+ filters = NULL;
switch (timestamp_get_type()) {
case TS_DELTA:
@@ -1395,11 +1395,11 @@ iostat_init(const char *opt_arg, void* userdata _U_)
break;
}
- io = (io_stat_t *) g_malloc(sizeof(io_stat_t));
+ io = (io_stat_t *)g_malloc(sizeof(io_stat_t));
/* If interval is 0, calculate statistics over the whole file by setting the interval to
* G_MAXINT32 */
- if (interval_float==0) {
+ if (interval_float == 0) {
io->interval = G_MAXINT32;
io->invl_prec = 0;
} else {
@@ -1413,7 +1413,7 @@ iostat_init(const char *opt_arg, void* userdata _U_)
break;
io->invl_prec--;
}
- if (io->invl_prec==0) {
+ if (io->invl_prec == 0) {
/* The precision is zero but if the user specified one of more zeros after the decimal point,
they want that many decimal places shown in the table for all time intervals except
response time values such as smb.time which always have 6 decimal places of precision.
@@ -1436,7 +1436,7 @@ iostat_init(const char *opt_arg, void* userdata _U_)
}
}
}
- if (io->interval < 1){
+ if (io->interval < 1) {
fprintf(stderr,
"\ntshark: \"-z\" interval must be >=0.000001 seconds or \"0\" for the entire capture duration.\n");
exit(10);
@@ -1444,30 +1444,30 @@ iostat_init(const char *opt_arg, void* userdata _U_)
/* Find how many ',' separated filters we have */
io->num_cols = 1;
- io->start_time=0;
+ io->start_time = 0;
if (filters && (*filters != '\0')) {
/* Eliminate the first comma. */
filters++;
str = filters;
- while((str = strchr(str, ','))) {
+ while ((str = strchr(str, ','))) {
io->num_cols++;
str++;
}
}
- io->items = (io_stat_item_t *) g_malloc(sizeof(io_stat_item_t) * io->num_cols);
- io->filters = (const char **)g_malloc(sizeof(char *) * io->num_cols);
- io->max_vals = (guint64 *) g_malloc(sizeof(guint64) * io->num_cols);
- io->max_frame = (guint32 *) g_malloc(sizeof(guint32) * io->num_cols);
+ io->items = (io_stat_item_t *)g_malloc(sizeof(io_stat_item_t) * io->num_cols);
+ io->filters = (const char **)g_malloc(sizeof(char *) * io->num_cols);
+ io->max_vals = (guint64 *)g_malloc(sizeof(guint64) * io->num_cols);
+ io->max_frame = (guint32 *)g_malloc(sizeof(guint32) * io->num_cols);
for (i=0; i<io->num_cols; i++) {
- io->max_vals[i] = 0;
+ io->max_vals[i] = 0;
io->max_frame[i] = 0;
}
/* Register a tap listener for each filter */
- if((!filters) || (filters[0]==0)) {
+ if ((!filters) || (filters[0] == 0)) {
register_io_tap(io, 0, NULL);
} else {
gchar *filter;
@@ -1475,9 +1475,9 @@ iostat_init(const char *opt_arg, void* userdata _U_)
str = filters;
do {
pos = (gchar*) strchr(str, ',');
- if(pos==str){
+ if (pos == str) {
register_io_tap(io, i, NULL);
- } else if (pos==NULL) {
+ } else if (pos == NULL) {
str = (const char*) g_strstrip((gchar*)str);
filter = g_strdup(str);
if (*filter)
@@ -1492,7 +1492,7 @@ iostat_init(const char *opt_arg, void* userdata _U_)
}
str = pos+1;
i++;
- } while(pos);
+ } while (pos);
}
}