Ejemplo n.º 1
0
/* load raw hash table's data into holder */
void
load_data_to_holder (GRawData * raw_data, GHolder * h, GModule module,
                     GSort sort)
{
   char *data;
   int hits, i;
   int size = 0;;
   unsigned long long bw = 0;

   size = raw_data->size;
   h->holder_size = size > MAX_CHOICES ? MAX_CHOICES : size;
   h->idx = 0;
   h->module = module;
   h->sub_items_size = 0;
   h->items = new_gholder_item (h->holder_size);

   for (i = 0; i < h->holder_size; i++) {
      bw = raw_data->items[i].bw;
      data = raw_data->items[i].data;
      hits = raw_data->items[i].hits;

      switch (module) {
       case OS:
       case BROWSERS:
          add_os_browser_node (h, hits, data, bw);
          break;
       case HOSTS:
          add_host_node (h, hits, data, bw, raw_data->items[i].usecs);
          break;
       case STATUS_CODES:
          add_status_code_node (h, hits, data, bw);
          break;
       default:
          h->items[h->idx].bw = bw;
          h->items[h->idx].data = xstrdup (data);
          h->items[h->idx].hits = hits;
          if (conf.serve_usecs)
             h->items[h->idx].usecs = raw_data->items[i].usecs;
          h->idx++;
      }
   }
   sort_holder_items (h->items, h->idx, sort);
   /* HOSTS module does not have "real" sub items, thus we don't include it */
   if (module == OS || module == BROWSERS || module == STATUS_CODES)
      sort_sub_list (h, sort);

   free_raw_data (raw_data);
}
Ejemplo n.º 2
0
/* Load raw data into our holder structure */
void
load_holder_data (GRawData * raw_data, GHolder * h, GModule module, GSort sort)
{
  int i, size = 0;
  const GPanel *panel = panel_lookup (module);

  size = raw_data->size;
  h->holder_size = size > MAX_CHOICES ? MAX_CHOICES : size;
  h->ht_size = size;
  h->idx = 0;
  h->module = module;
  h->sub_items_size = 0;
  h->items = new_gholder_item (h->holder_size);

  for (i = 0; i < h->holder_size; i++) {
    panel->insert (raw_data->items[i], h, panel);
  }
  sort_holder_items (h->items, h->idx, sort);
  if (h->sub_items_size)
    sort_sub_list (h, sort);
  free_raw_data (raw_data);
}