Esempio n. 1
0
static void load_inifile(void)
{
    const char *str;

    str = config_get("game.base");
    if (str) {
        set_basepath(str);
    }
    str = config_get("game.report");
    if (str) {
        set_reportpath(str);
    }
    str = config_get("game.data");
    if (str) {
        set_datapath(str);
    }

    verbosity = config_get_int("game.verbose", 2);
    memdebug = config_get_int("game.memcheck", memdebug);
#ifdef USE_CURSES
    /* only one value in the [editor] section */
    force_color = config_get_int("editor.color", force_color);
    gm_codepage = config_get_int("editor.codepage", gm_codepage);
#endif
}
Esempio n. 2
0
int 
main (int argc, char **argv)
{
  ProgTime StartTime;
  int ch;
  opterr = 0;
  msg_prefix = argv[0];
  while ((ch = getopt (argc, argv, "f:d:b:sh")) != -1)
    switch (ch)
      {
      case 'f':		/* input file */
	file_name = optarg;
	break;
      case 'd':
	set_basepath (optarg);
	break;
      case 'b':
	bits = atoi (optarg);
	if (bits > 32)
	  {
	    fprintf (stderr, "b may only take values 0-32\n");
	    exit (1);
	  }
	break;
      case 'h':
      case '?':
	fprintf (stderr, "usage: %s [-f input_file]"
		 "[-d data directory] [-b bits] [-s] [-h]\n", argv[0]);
	exit (1);
      }
  GetTime (&StartTime);

  GenerateWeights ();

  Make_weight_approx ();

  Make_text_idx_wgt ();

  Message ("%s", ElapsedTime (&StartTime, NULL));
  exit (0);
}
Esempio n. 3
0
static void load_inifile(dictionary * d)
{
    const char *reportdir = reportpath();
    const char *datadir = datapath();
    const char *basedir = basepath();
    const char *str;

    assert(d);

    str = iniparser_getstring(d, "eressea:base", basedir);
    if (str != basedir) {
        set_basepath(str);
    }
    str = iniparser_getstring(d, "eressea:report", reportdir);
    if (str != reportdir) {
        set_reportpath(str);
    }
    str = iniparser_getstring(d, "eressea:data", datadir);
    if (str != datadir) {
        set_datapath(str);
    }

    lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0;

    str = iniparser_getstring(d, "eressea:encoding", NULL);
    if (str && (_strcmpl(str, "utf8") == 0 || _strcmpl(str, "utf-8") == 0)) {
        enc_gamedata = ENCODING_UTF8;
    }

    verbosity = iniparser_getint(d, "eressea:verbose", 2);
    battledebug = iniparser_getint(d, "eressea:debug", battledebug) ? 1 : 0;

    str = iniparser_getstring(d, "eressea:locales", "de,en");
    make_locales(str);

    if (global.inifile) iniparser_freedict(global.inifile);
    global.inifile = d;
}
Esempio n. 4
0
void 
main (int argc, char **argv)
{
  ProgTime StartTime;
  int ch;
  char type = 'C';
  char mode = '0';
  int lookback = 2;
  double k = 0;
  u_long mem_reqd;
  opterr = 0;
  msg_prefix = argv[0];
  while ((ch = getopt (argc, argv, "0123CPSf:d:l:hk:HBDYM")) != -1)
    switch (ch)
      {
      case 'H':
	novel_method = MG_NOVEL_HUFFMAN_CHARS;
	break;
      case 'B':
	novel_method = MG_NOVEL_BINARY;
	break;
      case 'D':
	novel_method = MG_NOVEL_DELTA;
	break;
      case 'Y':
	novel_method = MG_NOVEL_HYBRID;
	break;
      case 'M':
	novel_method = MG_NOVEL_HYBRID_MTF;
	break;
      case 'f':		/* input file */
	file_name = optarg;
	break;
      case 'd':
	set_basepath (optarg);
	break;
      case 'C':
      case 'P':
      case 'S':
	type = ch;
	break;
      case '0':
      case '1':
      case '2':
      case '3':
	mode = ch;
	break;
      case 'l':
	lookback = atoi (optarg);
	if (!is_power_of_two (lookback))
	  FatalError (1, "The lookback value must be a power of 2");
	lookback = floorlog_2 (lookback);
	break;
      case 'k':
	k = atof (optarg) * 1024;
	break;
      case 'h':
      case '?':
	fprintf (stderr, "usage: %s [-l lookback] [-f input_file]"
	"[-d data directory] [-h] [-0|-1|-2|-3] [-C|-P|-S] [-k mem (Kb)]\n",
		 argv[0]);
	exit (1);
      }
  GetTime (&StartTime);

  ReadInWords (file_name);

  if (type == 'C')
    {
      Select_all ();
      mem_reqd = WriteOutWords (file_name, MG_COMPLETE_DICTIONARY, lookback);
    }
  else
    {
      switch (mode)
	{
	case '0':
	  Select_all ();
	  break;
	case '1':
	  Message ("Dictionary limit of %.2f Kb", k / 1024);
	  Select_on ((int) k, OccuranceOrder);
	  break;
	case '2':
	  Message ("Dictionary limit of %.2f Kb", k / 1024);
	  Select_on ((int) k, DecFreqIncWL);
	  break;
	case '3':
	  Message ("Dictionary limit of %.2f Kb", k / 1024);
	  Method3 ((int) k);
	  break;
	}
      if (type == 'P')
	{
	  mem_reqd = WriteOutWords (file_name, MG_PARTIAL_DICTIONARY, lookback);
	}
      else
	{
	  mem_reqd = WriteOutWords (file_name, MG_SEED_DICTIONARY, lookback);
	}
    }

  Message ("Num words           : %8u -> %8u\n", Num[1], keep[1].num_wds);
  Message ("Num non-words       : %8u -> %8u\n", Num[0], keep[0].num_wds);
  Message ("Chars of words      : %8u -> %8u\n", chars[1], keep[1].chars);
  Message ("Chars of non-words  : %8u -> %8u\n", chars[0], keep[0].chars);
  Message ("Mem usage           : %8u -> %8u\n",
	   (Num[0] + Num[1]) * sizeof (char *) + chars[0] + chars[1],
	     (keep[0].num_wds + keep[1].num_wds) * sizeof (char *) +
	   keep[0].chars + keep[1].chars);
  Message ("Actual mem required : %8u\n", mem_reqd);

  Message ("%s", ElapsedTime (&StartTime, NULL));
  exit (0);
}