Ejemplo n.º 1
0
void
read_option_args (int argc, char **argv)
{
  int o, idx = 0;

#ifdef HAVE_LIBGEOIP
  conf.geo_db = GEOIP_MEMORY_CACHE;
#endif

  while ((o = getopt_long (argc, argv, short_options, long_opts, &idx)) >= 0) {
    if (-1 == o || EOF == o)
      break;
    switch (o) {
     case 'f':
       conf.ifile = optarg;
       break;
     case 'p':
       /* ignore it */
       break;
#ifdef HAVE_LIBGEOIP
     case 'g':
       conf.geo_db = GEOIP_STANDARD;
       break;
#endif
     case 'e':
       conf.ignore_host = optarg;
       break;
     case 'a':
       conf.list_agents = 1;
       break;
     case 'c':
       conf.load_conf_dlg = 1;
       break;
     case 'q':
       conf.ignore_qstr = 1;
       break;
     case 'o':
       conf.output_format = optarg;
     case 'l':
       conf.debug_log = optarg;
       dbg_log_open (conf.debug_log);
       break;
     case 'r':
       conf.skip_term_resolver = 1;
       break;
     case 'd':
       conf.enable_html_resolver = 1;
       break;
     case 'm':
       conf.mouse_support = 1;
       break;
     case 'M':
       conf.append_method = 1;
       break;
     case 'h':
       cmd_help ();
       break;
     case 'H':
       conf.append_protocol = 1;
       break;
     case 'V':
       display_version ();
       exit (EXIT_SUCCESS);
       break;
     case 0:

       if (!strcmp ("no-global-config", long_opts[idx].name))
         break; /* ignore it */

       if (!strcmp ("color-scheme", long_opts[idx].name))
         conf.color_scheme = atoi (optarg);
       if (!strcmp ("log-format", long_opts[idx].name))
         conf.log_format = unescape_str (optarg);
       if (!strcmp ("date-format", long_opts[idx].name))
         conf.date_format = unescape_str (optarg);

       if (!strcmp ("static-file", long_opts[idx].name)) {
         if (conf.static_file_max_len < strlen (optarg))
           conf.static_file_max_len = strlen (optarg);
         conf.static_files[conf.static_file_idx++] = optarg;
       }
       if (!strcmp ("real-os", long_opts[idx].name))
         conf.real_os = 1;
       if (!strcmp ("no-color", long_opts[idx].name))
         conf.no_color = 1;
       if (!strcmp ("no-progress", long_opts[idx].name))
         conf.no_progress = 1;

       /* specifies the path of the GeoIP City database file */
       if (!strcmp ("geoip-city-data", long_opts[idx].name))
         conf.geoip_city_data = optarg;

       /* load data from disk */
       if (!strcmp ("load-from-disk", long_opts[idx].name))
         conf.load_from_disk = 1;
       /* keep database files */
       if (!strcmp ("keep-db-files", long_opts[idx].name))
         conf.keep_db_files = 1;

       /* specifies the path of the database file */
       if (!strcmp ("db-path", long_opts[idx].name))
         conf.db_path = optarg;
       /* set the size in bytes of the extra mapped memory */
       if (!strcmp ("xmmap", long_opts[idx].name))
         conf.xmmap = atoi (optarg);
       /* specifies the maximum number of leaf nodes to be cached */
       if (!strcmp ("cache-lcnum", long_opts[idx].name))
         conf.cache_lcnum = atoi (optarg);
       /* specifies the maximum number of non-leaf nodes to be cached */
       if (!strcmp ("cache-ncnum", long_opts[idx].name))
         conf.cache_ncnum = atoi (optarg);
       /* number of members in each leaf page */
       if (!strcmp ("tune-lmemb", long_opts[idx].name))
         conf.tune_lmemb = atoi (optarg);
       /* number of members in each non-leaf page */
       if (!strcmp ("tune-nmemb", long_opts[idx].name))
         conf.tune_nmemb = atoi (optarg);
       /* number of elements of the bucket array */
       if (!strcmp ("tune-bnum", long_opts[idx].name))
         conf.tune_bnum = atoi (optarg);

       /* specifies that each page is compressed with X encoding */
       if (!strcmp ("compression", long_opts[idx].name)) {
#ifdef HAVE_ZLIB
         if (!strcmp ("zlib", optarg))
           conf.compression = TC_ZLIB;
#endif
#ifdef HAVE_BZ2
         if (!strcmp ("bz2", optarg))
           conf.compression = TC_BZ2;
#endif
       }

       break;
     case 's':
       display_storage ();
       exit (EXIT_SUCCESS);
     case '?':
       exit (EXIT_FAILURE);
     default:
       exit (EXIT_FAILURE);
    }
  }

  for (idx = optind; idx < argc; idx++)
    cmd_help ();
}
Ejemplo n.º 2
0
void
read_option_args (int argc, char **argv)
{
  int o, idx = 0;

#ifdef HAVE_LIBGEOIP
  conf.geo_db = GEOIP_MEMORY_CACHE;
#endif

  while ((o = getopt_long (argc, argv, short_options, long_opts, &idx)) >= 0) {
    if (-1 == o || EOF == o)
      break;
    switch (o) {
    case 'f':
      conf.ifile = optarg;
      break;
    case 'p':
      /* ignore it */
      break;
#ifdef HAVE_LIBGEOIP
    case 'g':
      conf.geo_db = GEOIP_STANDARD;
      break;
#endif
    case 'e':
      if (conf.ignore_ip_idx < MAX_IGNORE_IPS)
        conf.ignore_ips[conf.ignore_ip_idx++] = optarg;
      break;
    case 'a':
      conf.list_agents = 1;
      break;
    case 'c':
      conf.load_conf_dlg = 1;
      break;
    case 'i':
      conf.hl_header = 1;
      break;
    case 'q':
      conf.ignore_qstr = 1;
      break;
    case 'o':
      conf.output_format = optarg;
      break;
    case 'l':
      conf.debug_log = optarg;
      dbg_log_open (conf.debug_log);
      break;
    case 'r':
      conf.skip_term_resolver = 1;
      break;
    case 'd':
      conf.enable_html_resolver = 1;
      break;
    case 'm':
      conf.mouse_support = 1;
      break;
    case 'M':
      conf.append_method = 1;
      break;
    case 'h':
      cmd_help ();
      break;
    case 'H':
      conf.append_protocol = 1;
      break;
    case 'V':
      display_version ();
      exit (EXIT_SUCCESS);
      break;
    case 0:

      if (!strcmp ("no-global-config", long_opts[idx].name))
        break;  /* ignore it */

      /* colors */
      if (!strcmp ("color", long_opts[idx].name) &&
          conf.color_idx < MAX_CUSTOM_COLORS)
        conf.colors[conf.color_idx++] = optarg;

      /* color scheme */
      if (!strcmp ("color-scheme", long_opts[idx].name))
        conf.color_scheme = atoi (optarg);

      /* log format */
      if (!strcmp ("log-format", long_opts[idx].name) && !conf.log_format)
        conf.log_format = unescape_str (optarg);

      /* time format */
      if (!strcmp ("time-format", long_opts[idx].name) && !conf.time_format)
        conf.time_format = unescape_str (optarg);

      /* date format */
      if (!strcmp ("date-format", long_opts[idx].name) && !conf.date_format)
        conf.date_format = unescape_str (optarg);

      /* invalid requests */
      if (!strcmp ("invalid-requests", long_opts[idx].name)) {
        conf.invalid_requests_log = optarg;
        invalid_log_open (conf.invalid_requests_log);
      }

      /* static file */
      if (!strcmp ("static-file", long_opts[idx].name) &&
          conf.static_file_idx < MAX_EXTENSIONS) {
        if (conf.static_file_max_len < strlen (optarg))
          conf.static_file_max_len = strlen (optarg);
        conf.static_files[conf.static_file_idx++] = optarg;
      }
      /* 4xx to unique count */
      if (!strcmp ("4xx-to-unique-count", long_opts[idx].name))
        conf.client_err_to_unique_count = 1;

      /* html report title */
      if (!strcmp ("html-report-title", long_opts[idx].name))
        conf.html_report_title = optarg;

      /* 444 as 404 */
      if (!strcmp ("444-as-404", long_opts[idx].name))
        conf.code444_as_404 = 1;

      /* all static files */
      if (!strcmp ("all-static-files", long_opts[idx].name))
        conf.all_static_files = 1;

      /* ignore crawlers */
      if (!strcmp ("ignore-crawlers", long_opts[idx].name))
        conf.ignore_crawlers = 1;

      /* ignore status code */
      if (!strcmp ("ignore-status", long_opts[idx].name) &&
          conf.ignore_status_idx < MAX_IGNORE_STATUS) {
        if (!str_inarray (optarg, conf.ignore_status, conf.ignore_status_idx))
          conf.ignore_status[conf.ignore_status_idx++] = optarg;
      }

      /* ignore panel */
      if (!strcmp ("ignore-panel", long_opts[idx].name) &&
          conf.ignore_panel_idx < TOTAL_MODULES) {
        if (!str_inarray (optarg, conf.ignore_panels, conf.ignore_panel_idx))
          conf.ignore_panels[conf.ignore_panel_idx++] = optarg;
      }

      /* ignore referer */
      if (!strcmp ("ignore-referer", long_opts[idx].name) &&
          conf.ignore_referer_idx < MAX_IGNORE_REF)
        conf.ignore_referers[conf.ignore_referer_idx++] = optarg;

      /* sort view */
      if (!strcmp ("sort-panel", long_opts[idx].name) &&
          conf.sort_panel_idx < TOTAL_MODULES)
        conf.sort_panels[conf.sort_panel_idx++] = optarg;

      /* real os */
      if (!strcmp ("real-os", long_opts[idx].name))
        conf.real_os = 1;

      /* double decode */
      if (!strcmp ("double-decode", long_opts[idx].name))
        conf.double_decode = 1;

      /* no color */
      if (!strcmp ("no-color", long_opts[idx].name))
        conf.no_color = 1;

      /* no columns */
      if (!strcmp ("no-column-names", long_opts[idx].name))
        conf.no_column_names = 1;

      /* no csv summary */
      if (!strcmp ("no-csv-summary", long_opts[idx].name))
        conf.no_csv_summary = 1;

      /* json pretty print */
      if (!strcmp ("json-pretty-print", long_opts[idx].name))
        conf.json_pretty_print = 1;

      /* no progress */
      if (!strcmp ("no-progress", long_opts[idx].name))
        conf.no_progress = 1;

      /* specifies the path of the GeoIP City database file */
      if (!strcmp ("geoip-city-data", long_opts[idx].name) ||
          !strcmp ("geoip-database", long_opts[idx].name))
        conf.geoip_database = optarg;

      /* load data from disk */
      if (!strcmp ("load-from-disk", long_opts[idx].name))
        conf.load_from_disk = 1;

      /* keep database files */
      if (!strcmp ("keep-db-files", long_opts[idx].name))
        conf.keep_db_files = 1;

      /* specifies the path of the database file */
      if (!strcmp ("db-path", long_opts[idx].name))
        conf.db_path = optarg;

      /* set the size in bytes of the extra mapped memory */
      if (!strcmp ("xmmap", long_opts[idx].name))
        conf.xmmap = atoi (optarg);

      /* specifies the maximum number of leaf nodes to be cached */
      if (!strcmp ("cache-lcnum", long_opts[idx].name))
        conf.cache_lcnum = atoi (optarg);

      /* specifies the maximum number of non-leaf nodes to be cached */
      if (!strcmp ("cache-ncnum", long_opts[idx].name))
        conf.cache_ncnum = atoi (optarg);

      /* number of members in each leaf page */
      if (!strcmp ("tune-lmemb", long_opts[idx].name))
        conf.tune_lmemb = atoi (optarg);

      /* number of members in each non-leaf page */
      if (!strcmp ("tune-nmemb", long_opts[idx].name))
        conf.tune_nmemb = atoi (optarg);

      /* number of elements of the bucket array */
      if (!strcmp ("tune-bnum", long_opts[idx].name))
        conf.tune_bnum = atoi (optarg);

      /* specifies that each page is compressed with X encoding */
      if (!strcmp ("compression", long_opts[idx].name)) {
#ifdef HAVE_ZLIB
        if (!strcmp ("zlib", optarg))
          conf.compression = TC_ZLIB;
#endif
#ifdef HAVE_BZ2
        if (!strcmp ("bz2", optarg))
          conf.compression = TC_BZ2;
#endif
      }

      /* default config file --dwf */
      if (!strcmp ("dcf", long_opts[idx].name)) {
        display_default_config_file ();
        exit (EXIT_SUCCESS);
      }

      break;
    case 's':
      display_storage ();
      exit (EXIT_SUCCESS);
    case '?':
      exit (EXIT_FAILURE);
    default:
      exit (EXIT_FAILURE);
    }
  }

  for (idx = optind; idx < argc; idx++)
    cmd_help ();
}
Ejemplo n.º 3
0
/* Read the user's supplied command line options. */
void
read_option_args (int argc, char **argv)
{
  int o, idx = 0;

#ifdef HAVE_LIBGEOIP
  conf.geo_db = GEOIP_MEMORY_CACHE;
#endif

  while ((o = getopt_long (argc, argv, short_options, long_opts, &idx)) >= 0) {
    if (-1 == o || EOF == o)
      break;
    switch (o) {
    case 'f':
      conf.ifile = optarg;
      break;
    case 'p':
      /* ignore it */
      break;
#ifdef HAVE_LIBGEOIP
    case 'g':
      conf.geo_db = GEOIP_STANDARD;
      break;
#endif
    case 'e':
      if (conf.ignore_ip_idx < MAX_IGNORE_IPS)
        conf.ignore_ips[conf.ignore_ip_idx++] = optarg;
      break;
    case 'a':
      conf.list_agents = 1;
      break;
    case 'c':
      conf.load_conf_dlg = 1;
      break;
    case 'i':
      conf.hl_header = 1;
      break;
    case 'q':
      conf.ignore_qstr = 1;
      break;
    case 'o':
      if (conf.output_format_idx < MAX_OUTFORMATS)
        conf.output_formats[conf.output_format_idx++] = optarg;
      break;
    case 'l':
      conf.debug_log = optarg;
      dbg_log_open (conf.debug_log);
      break;
    case 'r':
      conf.skip_term_resolver = 1;
      break;
    case 'd':
      conf.enable_html_resolver = 1;
      break;
    case 'm':
      conf.mouse_support = 1;
      break;
    case 'M':
      if (strcmp ("no", optarg) == 0)
        conf.append_method = 0;
      else
        conf.append_method = 1;
      break;
    case 'h':
      cmd_help ();
      break;
    case 'H':
      if (strcmp ("no", optarg) == 0)
        conf.append_protocol = 0;
      else
        conf.append_protocol = 1;
      break;
    case 'V':
      display_version ();
      exit (EXIT_SUCCESS);
      break;
    case 0:
      parse_long_opt (long_opts[idx].name, optarg);
      break;
    case 's':
      display_storage ();
      exit (EXIT_SUCCESS);
    case '?':
      exit (EXIT_FAILURE);
    default:
      exit (EXIT_FAILURE);
    }
  }

  for (idx = optind; idx < argc; idx++)
    cmd_help ();
}