return e;
}
+boolean getTokenValueFromString(char *string, char **token, char **value)
+{
+ return getTokenValueFromSetupLine(string, token, value);
+}
+
/* ------------------------------------------------------------------------- */
/* counter functions */
if (mode & ERR_WARN && !options.verbose)
return;
- if (mode == ERR_RETURN_LINE)
+ if (mode == ERR_INFO_LINE)
{
if (!last_line_was_separator)
fprintf_line(program.error_file, format, 79);
{ KSYM_asciitilde, "XK_asciitilde", "~" },
/* special (non-ASCII) keys */
+ { KSYM_degree, "XK_degree", "°" },
{ KSYM_Adiaeresis, "XK_Adiaeresis", "Ä" },
{ KSYM_Odiaeresis, "XK_Odiaeresis", "Ö" },
{ KSYM_Udiaeresis, "XK_Udiaeresis", "Ü" },
char getCharFromKey(Key key)
{
char *keyname = getKeyNameFromKey(key);
- char letter = 0;
+ char c = 0;
if (strlen(keyname) == 1)
- letter = keyname[0];
+ c = keyname[0];
else if (strEqual(keyname, "space"))
- letter = ' ';
- else if (strEqual(keyname, "circumflex"))
- letter = '^';
+ c = ' ';
+
+ return c;
+}
+
+char getValidConfigValueChar(char c)
+{
+ if (c == '#' || /* used to mark comments */
+ c == '\\') /* used to mark continued lines */
+ c = 0;
- return letter;
+ return c;
}
{
result = (strEqual(value, "left") ? ALIGN_LEFT :
strEqual(value, "right") ? ALIGN_RIGHT :
- strEqual(value, "center") ? ALIGN_CENTER : ALIGN_DEFAULT);
+ strEqual(value, "center") ? ALIGN_CENTER :
+ strEqual(value, "middle") ? ALIGN_CENTER : ALIGN_DEFAULT);
+ }
+ else if (strEqual(suffix, ".valign"))
+ {
+ result = (strEqual(value, "top") ? VALIGN_TOP :
+ strEqual(value, "bottom") ? VALIGN_BOTTOM :
+ strEqual(value, "middle") ? VALIGN_MIDDLE :
+ strEqual(value, "center") ? VALIGN_MIDDLE : VALIGN_DEFAULT);
}
else if (strEqual(suffix, ".anim_mode"))
{
if (string_has_parameter(value, "static_panel"))
result |= ANIM_STATIC_PANEL;
}
+ else if (strEqual(suffix, ".font"))
+ {
+ result = gfx.get_font_from_token_function(value);
+ }
else /* generic parameter of type integer or boolean */
{
result = (strEqual(value, ARG_UNDEFINED) ? ARG_UNDEFINED_VALUE :
return result;
}
-int get_auto_parameter_value(char *token, char *value_raw)
+int get_token_parameter_value(char *token, char *value_raw)
{
char *suffix;
if (suffix == NULL)
suffix = token;
+#if 0
+ if (strncmp(suffix, ".font", 5) == 0)
+ {
+ int i;
+
+ /* !!! OPTIMIZE THIS BY USING HASH !!! */
+ for (i = 0; i < NUM_FONTS; i++)
+ if (strEqual(value_raw, font_info[i].token_name))
+ return i;
+
+ /* if font not found, use reliable default value */
+ return FONT_INITIAL_1;
+ }
+#endif
+
return get_parameter_value(value_raw, suffix, TYPE_INTEGER);
}
!strEqual(&config_list[i].value[len_config_value - 4], ".wav") &&
!strEqual(config_list[i].value, UNDEFINED_FILENAME))
{
- Error(ERR_RETURN, "Configuration directive '%s' -> '%s':",
+ Error(ERR_INFO, "Configuration directive '%s' -> '%s':",
config_list[i].token, config_list[i].value);
Error(ERR_EXIT, "This seems to be no valid definition -- please fix");
}
file_list[list_pos].token = config_list[i].token;
file_list[list_pos].default_filename = config_list[i].value;
+
+#if 0
+ printf("::: '%s' => '%s'\n", config_list[i].token, config_list[i].value);
+#endif
}
}
num_file_list_entries_found = list_pos + 1;
if (num_file_list_entries_found != num_file_list_entries)
{
- Error(ERR_RETURN_LINE, "-");
- Error(ERR_RETURN, "inconsistant config list information:");
- Error(ERR_RETURN, "- should be: %d (according to 'src/conf_gfx.h')",
+ Error(ERR_INFO_LINE, "-");
+ Error(ERR_INFO, "inconsistant config list information:");
+ Error(ERR_INFO, "- should be: %d (according to 'src/conf_xxx.h')",
num_file_list_entries);
- Error(ERR_RETURN, "- found to be: %d (according to 'src/conf_gfx.c')",
+ Error(ERR_INFO, "- found to be: %d (according to 'src/conf_xxx.c')",
num_file_list_entries_found);
Error(ERR_EXIT, "please fix");
}
+#if 0
+ printf("::: ---------- DONE ----------\n");
+#endif
+
return file_list;
}
if (options.debug && dynamic_tokens_found)
{
- Error(ERR_RETURN_LINE, "-");
- Error(ERR_RETURN, "dynamic token(s) found in config file:");
- Error(ERR_RETURN, "- config file: '%s'", filename);
+ Error(ERR_INFO_LINE, "-");
+ Error(ERR_INFO, "dynamic token(s) found in config file:");
+ Error(ERR_INFO, "- config file: '%s'", filename);
for (list = setup_file_list; list != NULL; list = list->next)
{
char *value = getHashEntry(extra_file_hash, list->token);
if (value != NULL && strEqual(value, known_token_value))
- Error(ERR_RETURN, "- dynamic token: '%s'", list->token);
+ Error(ERR_INFO, "- dynamic token: '%s'", list->token);
}
- Error(ERR_RETURN_LINE, "-");
+ Error(ERR_INFO_LINE, "-");
}
if (unknown_tokens_found)
{
- Error(ERR_RETURN_LINE, "-");
- Error(ERR_RETURN, "warning: unknown token(s) found in config file:");
- Error(ERR_RETURN, "- config file: '%s'", filename);
+ Error(ERR_INFO_LINE, "-");
+ Error(ERR_INFO, "warning: unknown token(s) found in config file:");
+ Error(ERR_INFO, "- config file: '%s'", filename);
for (list = setup_file_list; list != NULL; list = list->next)
{
char *value = getHashEntry(extra_file_hash, list->token);
if (value != NULL && !strEqual(value, known_token_value))
- Error(ERR_RETURN, "- dynamic token: '%s'", list->token);
+ Error(ERR_INFO, "- dynamic token: '%s'", list->token);
}
- Error(ERR_RETURN_LINE, "-");
+ Error(ERR_INFO_LINE, "-");
}
if (undefined_values_found)
{
- Error(ERR_RETURN_LINE, "-");
- Error(ERR_RETURN, "warning: undefined values found in config file:");
- Error(ERR_RETURN, "- config file: '%s'", filename);
+ Error(ERR_INFO_LINE, "-");
+ Error(ERR_INFO, "warning: undefined values found in config file:");
+ Error(ERR_INFO, "- config file: '%s'", filename);
for (list = setup_file_list; list != NULL; list = list->next)
{
char *value = getHashEntry(empty_file_hash, list->token);
if (value != NULL)
- Error(ERR_RETURN, "- undefined value for token: '%s'", list->token);
+ Error(ERR_INFO, "- undefined value for token: '%s'", list->token);
}
- Error(ERR_RETURN_LINE, "-");
+ Error(ERR_INFO_LINE, "-");
}
freeSetupFileList(setup_file_list);
struct FileInfo *file_list_entry)
{
#if 0
- printf("GOT CUSTOM ARTWORK FILE '%s'\n", filename);
+ printf("GOT CUSTOM ARTWORK FILE '%s'\n", file_list_entry->filename);
#endif
if (strEqual(file_list_entry->filename, UNDEFINED_FILENAME))
#if DEBUG
-#define DEBUG_NUM_TIMESTAMPS 3
+#define DEBUG_NUM_TIMESTAMPS 3
+#define DEBUG_TIME_IN_MICROSECONDS 0
+
+#if DEBUG_TIME_IN_MICROSECONDS
+static double Counter_Microseconds()
+{
+ static struct timeval base_time = { 0, 0 };
+ struct timeval current_time;
+ double counter;
+
+ gettimeofday(¤t_time, NULL);
+
+ /* reset base time in case of wrap-around */
+ if (current_time.tv_sec < base_time.tv_sec)
+ base_time = current_time;
+
+ counter =
+ ((double)(current_time.tv_sec - base_time.tv_sec)) * 1000000 +
+ ((double)(current_time.tv_usec - base_time.tv_usec));
+
+ return counter; /* return microseconds since last init */
+}
+#endif
void debug_print_timestamp(int counter_nr, char *message)
{
+#if DEBUG_TIME_IN_MICROSECONDS
+ static double counter[DEBUG_NUM_TIMESTAMPS][2];
+
+ if (counter_nr >= DEBUG_NUM_TIMESTAMPS)
+ Error(ERR_EXIT, "debugging: increase DEBUG_NUM_TIMESTAMPS in misc.c");
+
+ counter[counter_nr][0] = Counter_Microseconds();
+
+ if (message)
+ printf("%s %.3f ms\n", message,
+ (counter[counter_nr][0] - counter[counter_nr][1]) / 1000);
+
+ counter[counter_nr][1] = counter[counter_nr][0];
+#else
static long counter[DEBUG_NUM_TIMESTAMPS][2];
if (counter_nr >= DEBUG_NUM_TIMESTAMPS)
counter[counter_nr][0] = Counter();
if (message)
- printf("%s %.3f seconds\n", message,
+ printf("%s %.3f s\n", message,
(float)(counter[counter_nr][0] - counter[counter_nr][1]) / 1000);
counter[counter_nr][1] = counter[counter_nr][0];
+#endif
}
void debug_print_parent_only(char *format, ...)