/* allocate memory for an instance of holder */ static void allocate_holder (void) { #ifdef TCB_BTREE TCBDB *ht = NULL; #elif TCB_MEMHASH TCMDB *ht = NULL; #else GHashTable *ht; #endif GModule module; GRawData *raw_data; int i; unsigned int ht_size = 0; holder = new_gholder (TOTAL_MODULES); for (i = 0; i < TOTAL_MODULES; i++) { module = i; /* extract data from the corresponding hash table */ ht = get_ht_by_module (module); ht_size = get_ht_size_by_module (module); raw_data = parse_raw_data (ht, ht_size, module); load_holder_data (raw_data, holder + module, module, module_sort[module]); } }
/* allocate memory for an instance of holder */ static void allocate_holder_by_module (GModule module) { #ifdef TCB_BTREE TCBDB *ht = NULL; #elif TCB_MEMHASH TCMDB *ht = NULL; #else GHashTable *ht; #endif GRawData *raw_data; unsigned int ht_size = 0; /* extract data from the corresponding hash table */ ht = get_ht_by_module (module); ht_size = get_ht_size_by_module (module); raw_data = parse_raw_data (ht, ht_size, module); load_holder_data (raw_data, holder + module, module, module_sort[module]); }
static void print_html_request_report (FILE * fp, GHolder * h, int process) { #ifdef TCB_BTREE TCBDB *ht = NULL; #elif TCB_MEMHASH TCMDB *ht = NULL; #else GHashTable *ht; #endif char *data, *bandwidth, *usecs; const char *desc = REQUE_DESC; const char *head = REQUE_HEAD; const char *id = REQUE_ID; float percent; int hits; int i, until = 0; if (h->idx == 0) return; ht = get_ht_by_module (h->module); if (ht == ht_requests_static) { head = STATI_HEAD; id = STATI_ID; desc = STATI_DESC; } else if (ht == ht_not_found_requests) { head = FOUND_HEAD; id = FOUND_ID; desc = FOUND_DESC; } print_html_h2 (fp, head, id); print_p (fp, desc); print_html_begin_table (fp); print_html_begin_thead (fp); fprintf (fp, "<tr>"); fprintf (fp, "<th>Hits</th>"); fprintf (fp, "<th>%%</th>"); fprintf (fp, "<th>Bandwidth</th>"); if (conf.serve_usecs) fprintf (fp, "<th>Time served</th>"); if (conf.append_protocol) fprintf (fp, "<th>Protocol</th>"); if (conf.append_method) fprintf (fp, "<th>Method</th>"); fprintf (fp, "<th>URL<span class=\"r\" onclick=\"t(this)\">◀</span>"); fprintf (fp, "</th>"); fprintf (fp, "</tr>"); print_html_end_thead (fp); print_html_begin_tbody (fp); until = h->idx < MAX_CHOICES ? h->idx : MAX_CHOICES; for (i = 0; i < until; i++) { hits = h->items[i].hits; data = h->items[i].data; percent = get_percentage (process, hits); percent = percent < 0 ? 0 : percent; bandwidth = filesize_str (h->items[i].bw); print_html_begin_tr (fp, i > OUTPUT_N ? 1 : 0); /* hits */ fprintf (fp, "<td>%d</td>", hits); /* percent */ fprintf (fp, "<td>%4.2f%%</td>", percent); /* bandwidth */ fprintf (fp, "<td>"); clean_output (fp, bandwidth); fprintf (fp, "</td>"); /* usecs */ if (conf.serve_usecs) { usecs = usecs_to_str (h->items[i].usecs); fprintf (fp, "<td>"); clean_output (fp, usecs); fprintf (fp, "</td>"); free (usecs); } /* protocol */ if (conf.append_protocol) { fprintf (fp, "<td>"); clean_output (fp, h->items[i].protocol); fprintf (fp, "</td>"); } /* method */ if (conf.append_method) { fprintf (fp, "<td>"); clean_output (fp, h->items[i].method); fprintf (fp, "</td>"); } /* data */ fprintf (fp, "<td>"); clean_output (fp, data); fprintf (fp, "</td>"); print_html_end_tr (fp); free (bandwidth); } print_html_end_tbody (fp); print_html_end_table (fp); }