File: options.c

package info (click to toggle)
moc 1%3A2.5.0~alpha3%2Bsvn20080629-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,832 kB
  • ctags: 2,829
  • sloc: ansic: 28,929; sh: 4,988; cpp: 523; makefile: 229
file content (691 lines) | stat: -rw-r--r-- 18,603 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
/*
 * MOC - music on console
 * Copyright (C) 2004 - 2006 Damian Pietras <daper@daper.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <assert.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "common.h"
#include "log.h"
#include "options.h"

#define OPTIONS_MAX	128
#define OPTION_NAME_MAX	32

enum option_type
{
	OPTION_INT,
	OPTION_STR,
	OPTION_ANY
};

union option_value
{
	char *str;
	int num;
};

struct option
{
	char name[OPTION_NAME_MAX];
	enum option_type type;
	union option_value value;
	int ignore_in_config;
	int set_in_config;
};

static struct option options[OPTIONS_MAX];
static int options_num = 0;

/* Add an integer option to the options table. This is intended to be used at
 * initialization to make a table of valid options and its default values. */
static void option_add_int (const char *name, const int value)
{
	assert (strlen(name) < OPTION_NAME_MAX);
	assert (options_num < OPTIONS_MAX);

	strcpy (options[options_num].name, name);
	options[options_num].type = OPTION_INT;
	options[options_num].value.num = value;
	options[options_num].ignore_in_config = 0;
	options[options_num].set_in_config = 0;

	options_num++;
}

/* Add an string option to the options table. This is intended to be used at
 * initialization to make a table of valid options and its default values. */
static void option_add_str (const char *name, const char *value)
{
	assert (strlen(name) < OPTION_NAME_MAX);
	assert (options_num < OPTIONS_MAX);

	strcpy (options[options_num].name, name);
	options[options_num].type = OPTION_STR;
	options[options_num].value.str = xstrdup (value);
	options[options_num].ignore_in_config = 0;
	options[options_num].set_in_config = 0;

	options_num++;
}
/* Return an index on an option in the options table. If there is no such
 * option return -1. */
static int find_option (const char *name, enum option_type type)
{
	int i;

	for (i = 0; i < options_num; i++) {
		if (!strcasecmp(options[i].name, name)) {
			if (type != OPTION_ANY && options[i].type != type)
				return -1;
			return i;
		}
	}

	return -1;
}

/* Set an integer option to the value. */
void option_set_int (const char *name, const int value)
{
	int i = find_option(name, OPTION_INT);

	if (i == -1)
		fatal ("Tried to set wrong option '%s'!", name);
	options[i].value.num = value;
}

/* Set a string option to the value. The string is duplicated. */
void option_set_str (const char *name, const char *value)
{
	int opt = find_option(name, OPTION_STR);

	if (opt == -1)
		fatal ("Tried to set wrong option '%s'!", name);
	
	if (options[opt].value.str)
		free (options[opt].value.str);
	options[opt].value.str = xstrdup (value);
}

void option_ignore_config (const char *name)
{
	int opt = find_option(name, OPTION_ANY);

	if (opt == -1)
		fatal ("Tried to set wrong option '%s'!", name);

	options[opt].ignore_in_config = 1;
}

/* Make a table of options and its default values. */
void options_init ()
{
	memset (options, 0, sizeof(options));

	option_add_int ("ReadTags", 1);
	option_add_str ("MusicDir", NULL);
	option_add_int ("StartInMusicDir", 0);
	option_add_int ("ShowStreamErrors", 0);
	option_add_int ("Repeat", 0);
	option_add_int ("Shuffle", 0);
	option_add_int ("AutoNext", 1);
	option_add_str ("Sort", "FileName");
	option_add_str ("FormatString",
			"%(n:%n :)%(a:%a - :)%(t:%t:)%(A: \\(%A\\):)");
	option_add_int ("OutputBuffer", 512);
	option_add_str ("OSSDevice", "/dev/dsp");
	option_add_str ("OSSMixerDevice", "/dev/mixer");
	option_add_str ("OSSMixerChannel", "pcm");
	option_add_str ("OSSMixerChannel2", "master");
	option_add_str ("SoundDriver", "Jack, ALSA, OSS");
	option_add_int ("ShowHiddenFiles", 1);
	option_add_str ("AlsaDevice", "default");
	option_add_str ("AlsaMixer", "PCM");
	option_add_str ("AlsaMixer2", "Master");
	option_add_int ("HideFileExtension", 0);
	option_add_int ("ShowFormat", 1);
	option_add_str ("ShowTime", "IfAvailable");
	option_add_str ("Theme", NULL);
	option_add_str ("XTermTheme", NULL);
	option_add_str ("ForceTheme", NULL); /* Used when -T is set */
	option_add_str ("MOCDir", "~/.moc");
	option_add_int ("UseMmap", 0);
	option_add_int ("Precache", 1);
	option_add_int ("SavePlaylist", 1);
	option_add_str ("Keymap", NULL);
	option_add_int ("SyncPlaylist", 1);
	option_add_int ("InputBuffer", 512);
	option_add_int ("Prebuffering", 64);
	option_add_str ("JackOutLeft", "alsa_pcm:playback_1");
	option_add_str ("JackOutRight", "alsa_pcm:playback_2");
	option_add_int ("ASCIILines", 0);
	option_add_str ("FastDir1", NULL);
	option_add_str ("FastDir2", NULL);
	option_add_str ("FastDir3", NULL);
	option_add_str ("FastDir4", NULL);
	option_add_str ("FastDir5", NULL);
	option_add_str ("FastDir6", NULL);
	option_add_str ("FastDir7", NULL);
	option_add_str ("FastDir8", NULL);
	option_add_str ("FastDir9", NULL);
	option_add_str ("FastDir10", NULL);
	option_add_str ("ExecCommand1", NULL);
	option_add_str ("ExecCommand2", NULL);
	option_add_str ("ExecCommand3", NULL);
	option_add_str ("ExecCommand4", NULL);
	option_add_str ("ExecCommand5", NULL);
	option_add_str ("ExecCommand6", NULL);
	option_add_str ("ExecCommand7", NULL);
	option_add_str ("ExecCommand8", NULL);
	option_add_str ("ExecCommand9", NULL);
	option_add_str ("ExecCommand10", NULL);
	option_add_int ("Mp3IgnoreCRCErrors", 1);
	option_add_int ("SeekTime", 1);
	option_add_int ("SilentSeekTime", 5);
	option_add_str ("ResampleMethod", "Linear");
	option_add_int ("ForceSampleRate", 0);
	option_add_str ("HTTPProxy", NULL);
	option_add_int ("UseRealtimePriority", 0);
	option_add_int ("TagsCacheSize", 256);
	option_add_int ("PlaylistNumbering", 1);
	option_add_str ("Layout1",
			"directory:0,0,50%,100% playlist:50%,0,FILL,100%");
	option_add_str ("Layout2",
			"directory:0,0,100%,100% playlist:0,0,100%,100%");
	option_add_str ("Layout3", NULL);
	option_add_int ("FollowPlayedFile", 1);
	option_add_int ("CanStartInPlaylist", 1);
	option_add_int ("UseCursorSelection", 0);
	option_add_str ("ID3v1TagsEncoding", "WINDOWS-1250");
	option_add_int ("UseRCC", 1);
 	option_add_int ("UseRCCForFilesystem", 1);
	option_add_int ("SetXtermTitle", 1);
	option_add_int ("SetScreenTitle", 1);
	option_add_int ("PlaylistFullPaths", 1);
	option_add_int ("Allow24bitOutput", 0);

        option_add_int ("ModPlug_Channels", 2);
        option_add_int ("ModPlug_Frequency", 44100);
        option_add_int ("ModPlug_Bits", 16);

        option_add_int ("ModPlug_Oversampling", 1);
        option_add_int ("ModPlug_NoiseReduction", 1);
        option_add_int ("ModPlug_Reverb", 0);
        option_add_int ("ModPlug_MegaBass", 0);
        option_add_int ("ModPlug_Surround", 0);

        option_add_str ("ModPlug_ResamplingMode", "FIR");

        option_add_int ("ModPlug_ReverbDepth", 0);
        option_add_int ("ModPlug_ReverbDelay", 0);
        option_add_int ("ModPlug_BassAmount", 0);
        option_add_int ("ModPlug_BassRange", 10);
        option_add_int ("ModPlug_SurroundDepth", 0);
        option_add_int ("ModPlug_SurroundDelay", 0);
        option_add_int ("ModPlug_LoopCount", 0);

        option_add_int ("TiMidity_Volume", 100);
        option_add_int ("TiMidity_Rate", 44100);
        option_add_int ("TiMidity_Bits", 16);
        option_add_int ("TiMidity_Channels", 2);
        option_add_str ("TiMidity_Config", NULL);

	option_add_int ("SidPlay2_DefaultSongLength", 180);
	option_add_int ("SidPlay2_MinimumSongLength", 0);
	option_add_str ("SidPlay2_Database", NULL);
	option_add_int ("SidPlay2_Frequency", 44100);
	option_add_int ("SidPlay2_Bits", 16);
	option_add_str ("SidPlay2_PlayMode", "M");
	option_add_int ("SidPlay2_Optimisation", 0);
	option_add_int ("SidPlay2_StartAtStart", 1);
	option_add_int ("SidPlay2_PlaySubTunes", 1);

	option_add_str ("OnSongChange", NULL);
	option_add_str ("OnStop", NULL);

        option_add_int ("Softmixer_SaveState", 1);
}

/* Return 1 if a parameter to an integer option is valid. */
int check_int_option (const char *name, const int val)
{
	/* YES/NO options */
	if (!strcasecmp(name, "ReadTags")
			|| !strcasecmp(name, "ShowStreamErrors")
			|| !strcasecmp(name, "Repeat")
			|| !strcasecmp(name, "Shuffle")
			|| !strcasecmp(name, "AutoNext")
			|| !strcasecmp(name, "ShowHiddenFiles")
			|| !strcasecmp(name, "StartInMusicDir")
			|| !strcasecmp(name, "HideFileExtension")
			|| !strcasecmp(name, "ShowFormat")
			|| !strcasecmp(name, "SavePlaylist")
			|| !strcasecmp(name, "SyncPlaylist")
			|| !strcasecmp(name, "Mp3IgnoreCRCErrors")
			|| !strcasecmp(name, "PlaylistNumbering")
			|| !strcasecmp(name, "FollowPlayedFile")
			|| !strcasecmp(name, "CanStartInPlaylist")
			|| !strcasecmp(name, "UseCursorSelection")
			|| !strcasecmp(name, "UseRCC")
			|| !strcasecmp(name, "UseRCCForFilesystem")
			|| !strcasecmp(name, "SetXtermTitle")
			|| !strcasecmp(name, "SetScreenTitle")
			|| !strcasecmp(name, "PlaylistFullPaths")
			|| !strcasecmp(name, "Allow24bitOutput")
			|| !strcasecmp(name, "SidPlay2_StartAtStart")
			|| !strcasecmp(name, "SidPlay2_PlaySubTunes")
			|| !strcasecmp(name, "Softmixer_SaveState")
			) {
		if (!(val == 1 || val == 0))
			return 0;
	}
	else if (!strcasecmp(name, "OutputBuffer")) {
		if (val < 128)
			return 0;
	}
	else if (!strcasecmp(name, "InputBuffer")) {
		if (val < 32)
			return 0;
	}
	else if (!strcasecmp(name, "Prebuffering")) {
		if (val < 0)
			return 0;
	}
	else if (!strcasecmp(name, "SeekTime")) {
		if (val < 1)
			return 0;
	}
	else if (!strcasecmp(name, "SilentSeekTime")) {
		if (val < 1)
			return 0;
	}
	else if (!strcasecmp(name, "ForceSampleRate")) {
		if (val < 0 || val > 500000)
			return 0;
	}
	else if (!strcasecmp(name, "TagsCacheSize")) {
		if (val < 0)
			return 0;
	}
        else if(
          !strcasecmp(name, "ModPlug_Oversampling")
          || !strcasecmp(name, "ModPlug_NoiseReduction")
          || !strcasecmp(name, "ModPlug_Reverb")
          || !strcasecmp(name, "ModPlug_MegaBass")
          || !strcasecmp(name, "ModPlug_Surround")
          ) {
          if(!(val==0 || val==1))
            return 0;
        }
        else  if(!strcasecmp(name, "ModPlug_Channels"))
        {
            if (!(val==1 || val==2))
              return 0;
        }
        else  if(!strcasecmp(name, "ModPlug_Frequency"))
        {
            if (!(val==11025 || val==22050 || val==44100 || val==48000))
              return 0;
        }
        else  if(!strcasecmp(name, "ModPlug_Bits"))
        {
            if (!(val==8 || val==16 || val==32))
              return 0;
        }
        else  if(!strcasecmp(name, "ModPlug_ReverbDepth"))
        {
            if (!(val>=0 && val<=100))
              return 0;
        }
        else  if(!strcasecmp(name, "ModPlug_ReverbDelay"))
        {
            if (val < 0)
              return 0;
        }
        else  if(!strcasecmp(name, "ModPlug_BassAmount"))
        {
            if (!(val>=0 && val<=100))
              return 0;
        }
        else  if(!strcasecmp(name, "ModPlug_BassRange"))
        {
            if (!(val>=10 && val<=100))
              return 0;
        }
        else  if(!strcasecmp(name, "ModPlug_SurroundDepth"))
        {
            if (!(val>=0 && val<=100))
              return 0;
        }
        else  if(!strcasecmp(name, "ModPlug_SurroundDelay"))
        {
            if (val < 0)
              return 0;
        }
        else  if(!strcasecmp(name, "ModPlug_LoopCount"))
        {
            if (val < -1)
              return 0;
        }
        else  if(!strcasecmp(name, "TiMidity_Channels"))
        {
            if (!(val == 1 || val == 2)  )
              return 0;
        }
        else  if(!strcasecmp(name, "TiMidity_Bits"))
        {
            if (!(val == 8 || val == 16)  )
              return 0;
        }
        else  if(!strcasecmp(name, "TiMidity_Volume"))
        {
            if (val < 0 || val > 800)
              return 0;
        }
        else  if(!strcasecmp(name, "TiMidity_Rate"))
        {
            // not sure about the limits... I like 44100
            if (val < 8000 || val > 48000)
              return 0;
        }
        else if(!strcasecmp(name, "SidPlay2_DefaultSongLength"))
        {
          if(val < 0)
            return 0;
        }
        else if(!strcasecmp(name, "SidPlay2_MinimumSongLength"))
        {
          if(val < 0)
            return 0;
        }
        else if(!strcasecmp(name, "SidPlay2_Frequency"))
        {
          if(val < 4000 || val > 48000)
            return 0;
        }
        else if(!strcasecmp(name, "SidPlay2_Bits"))
        {
          if(!(val == 8 || val == 16))
            return 0;
        }
        else if(!strcasecmp(name, "SidPlay2_Optimisation"))
        {
          if(val < 0 || val > 2)
            return 0;
        }
	return 1;
}

/* Return 1 if a parameter to a string option is valid. */
int check_str_option (const char *name, const char *val)
{
	if (!strcasecmp(name, "Sort")) {
		if (strcasecmp(val, "FileName"))
			return 0;
	}
	else if (!strcasecmp(name, "ShowTime")) {
		if (strcasecmp(val, "yes") && strcasecmp(val, "no")
				&& strcasecmp(val, "IfAvailable"))
			return 0;
	}
	else if (!strcmp(name, "ResampleMethod")) {
		if (strcasecmp(val, "SincBestQuality")
				&& strcasecmp(val, "SincMediumQuality")
				&& strcasecmp(val, "SincFastest")
				&& strcasecmp(val, "ZeroOrderHold")
				&& strcasecmp(val, "Linear"))
			return 0;
	}
        else if(!strcasecmp(name, "ModPlug_ResamplingMode")) {
          if (
              strcasecmp(val, "FIR")
              && strcasecmp(val, "SPLINE")
              && strcasecmp(val, "LINEAR")
              && strcasecmp(val, "NEAREST")
             )
            return 0;
        }
        else if(!strcasecmp(name, "SidPlay2_PlayMode")) {
          if (
              strcasecmp(val, "M")
              && strcasecmp(val, "S")
              && strcasecmp(val, "L")
              && strcasecmp(val, "R")
             )
            return 0;
        }
	return 1;
}

static int is_deprecated_option (const char *name)
{
	if (!strcmp(name, "TagsIconv")
			|| !strcmp(name, "FileNamesIconv"))
		return 1;

	return 0;
}

/* Set an option read from the configuration file. Return 0 on error. */
static int set_option (const char *name, const char *value)
{
	int i = find_option (name, OPTION_ANY);

	if (is_deprecated_option(name)) {
		fprintf (stderr, "Option '%s' was ignored, remove it "
				"from the configuration file.\n", name);
		sleep (1);
		return 1;
	}

	if (i == -1) {
		fprintf (stderr, "Wrong option name: '%s'.", name);
		return 0;
	}

	if (options[i].ignore_in_config) 
		return 1;

	if (options[i].set_in_config) {
		fprintf (stderr, "Tried to set an option that has been already "
				"set in the config file ('%s').", name);
		return 0;
	}

	options[i].set_in_config = 1;

	if (options[i].type == OPTION_INT) {
		int num;

		if (!strcasecmp(value, "yes"))
			num = 1;
		else if (!strcasecmp(value, "no"))
			num = 0;
		else {
			char *end;

			num = strtol (value, &end, 10);
			if (*end)
				return 0;
		}
		
		if (!check_int_option(name, num))
			return 0;
		option_set_int (name, num);
	}
	else {
		if (!check_str_option(name, value))
			return 0;
		option_set_str (name, value);
	}
	
	return 1;
}

/* Check if values of options make sense. This only check options that can't be
 * check without parsing the whole file. */
static void options_sanity_check ()
{
	if (options_get_int("Prebuffering") > options_get_int("InputBuffer"))
		fatal ("Prebuffering is set to a value greater than "
				"InputBuffer.");
}

/* Parse the configuration file. */
void options_parse (const char *config_file)
{
	int ch;
	int comm = 0; /* comment? */
	int eq = 0; /* equal character appeard? */
	int quote = 0; /* are we in quotes? */
	int esc = 0;
	char opt_name[30];
	char opt_value[100];
	int line = 1;
	int name_pos = 0;
	int value_pos = 0;
	FILE *file;

	if (!(file = fopen(config_file, "r"))) {
		logit ("Can't open config file: %s", strerror(errno));
		return;
	}

	while ((ch = getc(file)) != EOF) {

		/* Skip comment */
		if (comm && ch != '\n')
			continue;
		
		/* Interpret parameter */
		if (ch == '\n') {
			comm = 0;

			opt_name[name_pos] = 0;
			opt_value[value_pos] = 0;

			if (name_pos) {
				if (value_pos == 0
						|| !set_option(opt_name,
							opt_value))
					fatal ("Error in config file, line %d.",
							line);
			}

			opt_name[0] = 0;
			opt_value[0] = 0;
			name_pos = 0;
			value_pos = 0;
			eq = 0;
			quote = 0;
			esc = 0;

			line++;
		}

		/* Turn on comment */
		else if (ch == '#' && !quote)
			comm = 1;

		/* Turn on quote */
		else if (!quote && !esc && (ch == '"'))
			quote = 1;

		/* Turn off quote */
		else if (!esc && quote && ch == '"')
			quote = 0;

		else if (ch == '=' && !quote) {
			if (eq)
				fatal ("Error in config file, line %d.",
						line);
			if (!opt_name[0])
				fatal ("Error in config file, line %d.",
						line);
				eq = 1;
			opt_value[0] = 0;
		}

		/* Turn on escape */
		else if (ch == '\\' && !esc)
			esc = 1;

		/* Add char to parameter value */
		else if ((!isblank(ch) || quote) && eq) {
			if (esc && ch != '"') {
				if (sizeof(opt_value) == value_pos)
					fatal ("Error in config file, line %d "
							"is too long.", line);
				opt_value[value_pos++] = '\\';
			}
			
			if (sizeof(opt_value) == value_pos)
				fatal ("Error in config file, line %d is "
						"too long.", line);
			opt_value[value_pos++] = ch;
			esc = 0;
		}

		/* Add char to parameter name */
		else if (!isblank(ch) || quote) {
			if (sizeof(opt_name) == name_pos)
				fatal ("Error in config file, line %d is "
						"too long.", line);
			opt_name[name_pos++] = ch;
			esc = 0;
		}
	}

	if (opt_name[0] || opt_value[0])
		fatal ("Parse error at the end of the config file (need end of "
				"line?).");

	options_sanity_check ();

	fclose (file);
}

void options_free ()
{
	int i;
	
	for (i = 0; i < options_num; i++)
		if (options[i].type == OPTION_STR && options[i].value.str)
			free (options[i].value.str);
}

int options_get_int (const char *name)
{
	int i = find_option(name, OPTION_INT);

	if (i == -1)
		fatal ("Tried to get wrong option '%s'!", name);
	
	return options[i].value.num;
}

char *options_get_str (const char *name)
{
	int i = find_option(name, OPTION_STR);

	if (i == -1)
		fatal ("Tried to get wrong option '%s'!", name);

	return options[i].value.str;
}