Commit 5241a7a1 authored by Yves Combe's avatar Yves Combe
Browse files

refuse --reread-menu if db is read-only.

quote boards strings before inserting in db with sqlite3_mprintf.
parent 598bb65a
2005-09-12 Yves Combe,,, <yves@ycombe.net>
refuse --reread-menu if db is read-only.
quote boards strings before inserting in db with sqlite3_mprintf.
* src/gcompris/gcompris.c: (gcompris_init):
* src/gcompris/gcompris_db.c: (gcompris_db_board_update),
(gcompris_db_get_board_id):
2005-09-11 Bruno coudoin <bruno.coudoin@free.fr>
Fixed comilation option --disable-sqlite.
......
......@@ -1147,7 +1147,10 @@ gcompris_init (int argc, char *argv[])
if (popt_reread_menu){
g_warning("Rebuild db from xml files");
properties->reread_menu = TRUE;
if (access(properties->database, W_OK)==-1)
g_warning("Cannot reread menu when database is read-only !");
else
properties->reread_menu = TRUE;
}
......
......@@ -369,9 +369,10 @@ gboolean gcompris_db_check_boards()
}
#define Q(a) a==NULL ? "" : "\"", a==NULL ? "NULL" : a, a==NULL ? "" : "\""
#define BOARD_INSERT(board_id, name, section_id, section, author, type, mode, difficulty, icon, boarddir, mandatory_sound_file, mandatory_sound_dataset, filename, title, description, prerequisite, goal, manual, credit) \
"INSERT OR REPLACE INTO boards VALUES (%d, %s%s%s, %d, %s%s%s, %s%s%s, %s%s%s, %s%s%s, %d, %s%s%s, %s%s%s, %s%s%s, %s%s%s, %s%s%s, %s%s%s, %s%s%s, %s%s%s, %s%s%s, %s%s%s, %s%s%s);", board_id, Q(name), section_id, Q(section), Q(author), Q(type), Q(mode), difficulty, Q(icon), Q(boarddir), Q(mandatory_sound_file), Q(mandatory_sound_dataset), Q(filename), Q(title), Q(description), Q(prerequisite), Q(goal), Q(manual), Q(credit)
#define Q(a) a==NULL ? "" : "\'", a==NULL ? "NULL" : a, a==NULL ? "" : "\'"
#define BOARD_INSERT \
"INSERT OR REPLACE INTO boards VALUES (%d, %Q, %d, %Q, %Q, %Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q);"
#define MAX_BOARD_ID \
"SELECT MAX(board_id) FROM boards;"
......@@ -514,12 +515,28 @@ void gcompris_db_board_update(gint *board_id,
sqlite3_free_table(result);
}
request = g_strdup_printf(BOARD_INSERT( *board_id, name, *section_id, section,
author, type, mode, difficulty, icon, boarddir,
mandatory_sound_file, mandatory_sound_dataset,
filename, title, description, prerequisite, goal,
manual, credit));
request = sqlite3_mprintf( BOARD_INSERT,
*board_id,
name,
*section_id,
section,
author,
type,
mode,
difficulty,
icon,
boarddir,
mandatory_sound_file,
mandatory_sound_dataset,
filename,
title,
description,
prerequisite,
goal,
manual,
credit
);
rc = sqlite3_get_table(gcompris_db,
request,
&result,
......@@ -534,7 +551,7 @@ void gcompris_db_board_update(gint *board_id,
sqlite3_free_table(result);
g_free(request);
sqlite3_free(request);
#endif
}
......@@ -673,7 +690,7 @@ GList *gcompris_db_get_board_id(GList *list)
return board_id_list;
#else
return NULL;
return list;
#endif
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment