summaryrefslogtreecommitdiffhomepage
path: root/clientfiles
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-08-23 11:58:41 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-08-23 11:58:41 +0200
commit5871f5fb0d7aac67bbac7055d22a59f80576621b (patch)
tree49b0a1a4dcbf241cdc653489165bf3b4679fc693 /clientfiles
parentc15a456ac6df79a001250fc5b877751db4a30875 (diff)
game-data: chomp newlines in extractor
Some of the XML data is malformed. Chomp newlines to ease Perl's job.
Diffstat (limited to 'clientfiles')
-rw-r--r--clientfiles/very-important-source-code/important-stuff/game_data.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/clientfiles/very-important-source-code/important-stuff/game_data.c b/clientfiles/very-important-source-code/important-stuff/game_data.c
index f80a7d44..48774187 100644
--- a/clientfiles/very-important-source-code/important-stuff/game_data.c
+++ b/clientfiles/very-important-source-code/important-stuff/game_data.c
@@ -114,6 +114,20 @@ static void game_data_close()
#define ltr_int_log_message(...) fprintf(stderr, __VA_ARGS__)
+static void remove_newlines(const char* str, char* out, int out_len)
+{
+ int i, j;
+ int len = strlen(str);
+ for (i = 0, j = 0; str[i] && j + 1 < out_len; i++)
+ {
+ if (str[i] == '\r' || str[i] == '\n')
+ continue;
+ out[j++] = str[i];
+ }
+ if (j < out_len)
+ out[j] = '\0';
+}
+
bool get_game_data(const char *input_fname, const char *output_fname, bool from_update)
{
FILE *outfile = NULL;
@@ -129,19 +143,21 @@ bool get_game_data(const char *input_fname, const char *output_fname, bool from_
mxml_node_t *game;
const char *name;
const char *id;
- for(game = mxmlFindElement(tree, tree, "Game", NULL, NULL, MXML_DESCEND);
+ for(game = mxmlFindElement(tree, tree, "Game", NULL, NULL, MXML_DESCEND);
game != NULL;
- game = mxmlFindElement(game, tree, "Game", NULL, NULL, MXML_DESCEND)){
+ game = mxmlFindElement(game, tree, "Game", NULL, NULL, MXML_DESCEND))
+ {
name = mxmlElementGetAttr(game, "Name");
id = mxmlElementGetAttr(game, "Id");
-
+
mxml_node_t *appid = mxmlFindElement(game, game, "ApplicationID", NULL, NULL, MXML_DESCEND);
- if(appid == NULL){
- fprintf(outfile, "%s \"%s\"\n", id, name);
- }else{
- fprintf(outfile, "%s \"%s\" (%s)\n", id, name, appid->child->value.text.string);
- }
- }
+ char name_[256];
+ remove_newlines(name, name_, sizeof(name_));
+ if(appid == NULL)
+ fprintf(outfile, "%s \"%s\"\n", id, name_);
+ else
+ fprintf(outfile, "%s \"%s\" (%s)\n", id, name_, appid->child->value.text.string);
+ }
fclose(outfile);
game_data_close();
return true;