return getStringCat3WithSeparator(path1, path2, path3, STRING_PATH_SEPARATOR);
}
-char *getImg2(char *path1, char *path2)
+static char *getPngOrPcxIfNotExists(char *filename)
{
- char *filename = getPath2(path1, path2);
-
- if (!fileExists(filename) && strSuffix(path2, ".png"))
- {
- // backward compatibility: if PNG file not found, check for PCX file
- char *path2pcx = getStringCopy(path2);
+ // switch from PNG to PCX file and vice versa, if file does not exist
+ // (backwards compatibility with PCX files used in previous versions)
- strcpy(&path2pcx[strlen(path2pcx) - 3], "pcx");
-
- free(filename);
-
- filename = getPath2(path1, path2pcx);
-
- free(path2pcx);
- }
+ if (!fileExists(filename) && strSuffix(filename, ".png"))
+ strcpy(&filename[strlen(filename) - 3], "pcx");
+ else if (!fileExists(filename) && strSuffix(filename, ".pcx"))
+ strcpy(&filename[strlen(filename) - 3], "png");
return filename;
}
-char *getImg3(char *path1, char *path2, char *path3)
+char *getImg2(char *path1, char *path2)
{
- char *filename = getPath3(path1, path2, path3);
-
- if (!fileExists(filename) && strSuffix(path3, ".png"))
- {
- // backward compatibility: if PNG file not found, check for PCX file
- char *path3pcx = getStringCopy(path3);
-
- strcpy(&path3pcx[strlen(path3pcx) - 3], "pcx");
-
- free(filename);
-
- filename = getPath3(path1, path2, path3pcx);
-
- free(path3pcx);
- }
+ return getPngOrPcxIfNotExists(getPath2(path1, path2));
+}
- return filename;
+char *getImg3(char *path1, char *path2, char *path3)
+{
+ return getPngOrPcxIfNotExists(getPath3(path1, path2, path3));
}
char *getStringCopy(const char *s)
return NULL;
}
+char *get_special_base_token(struct ArtworkListInfo *artwork_info, char *token)
+{
+ /* !!! make this dynamically configurable (init.c:InitArtworkConfig) !!! */
+ static struct ConfigTypeInfo prefix_list[] =
+ {
+ { "global.anim_1" },
+ { "global.anim_2" },
+ { "global.anim_3" },
+ { "global.anim_4" },
+ { "global.anim_5" },
+ { "global.anim_6" },
+ { "global.anim_7" },
+ { "global.anim_8" },
+
+ { NULL }
+ };
+ struct ConfigTypeInfo *suffix_list = artwork_info->suffix_list;
+ boolean prefix_found = FALSE;
+ int len_suffix = 0;
+ int i;
+
+ /* search for prefix to check if base token has to be created */
+ for (i = 0; prefix_list[i].token != NULL; i++)
+ if (strPrefix(token, prefix_list[i].token))
+ prefix_found = TRUE;
+
+ if (!prefix_found)
+ return NULL;
+
+ /* search for suffix (parameter) to determine base token length */
+ for (i = 0; suffix_list[i].token != NULL; i++)
+ if (strSuffix(token, suffix_list[i].token))
+ len_suffix = strlen(suffix_list[i].token);
+
+ return getStringCopyN(token, strlen(token) - len_suffix);
+}
+
/* This function checks if a string <s> of the format "string1, string2, ..."
exactly contains a string <s_contained>. */
}
else if (strEqual(suffix, ".class"))
{
- result = get_hash_from_key(value);
+ result = (strEqual(value, ARG_UNDEFINED) ? ARG_UNDEFINED_VALUE :
+ get_hash_from_key(value));
}
else if (strEqual(suffix, ".style"))
{
SetupFileHash *setup_file_hash, *valid_file_hash;
SetupFileHash *extra_file_hash, *empty_file_hash;
char *known_token_value = KNOWN_TOKEN_VALUE;
+ char *base_token_value = UNDEFINED_FILENAME;
int i, j, k, l;
if (filename == NULL)
}
END_HASH_ITERATION(valid_file_hash, itr)
+ /* add special base tokens (using prefix match and replace) */
+ BEGIN_HASH_ITERATION(valid_file_hash, itr)
+ {
+ char *token = HASH_ITERATION_TOKEN(itr);
+ char *base_token = get_special_base_token(artwork_info, token);
+
+ if (base_token != NULL)
+ {
+ /* add base token only if it does not already exist */
+ if (getHashEntry(valid_file_hash, base_token) == NULL)
+ setHashEntry(valid_file_hash, base_token, base_token_value);
+
+ free(base_token);
+ }
+ }
+ END_HASH_ITERATION(valid_file_hash, itr)
+
/* read parameters for all known config file tokens */
for (i = 0; i < num_file_list_entries; i++)
read_token_parameters(valid_file_hash, suffix_list, &file_list[i]);