Mercurial > mplayer.hg
changeset 33054:ed66afc0b06c
Replace macros to check whether a command is allowed by functions.
Additionally, add checks for commands 'window' and 'end'.
author | ib |
---|---|
date | Tue, 29 Mar 2011 10:21:39 +0000 |
parents | f64d41dac10b |
children | 2be86f1db767 |
files | gui/skin/skin.c |
diffstat | 1 files changed, 48 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/gui/skin/skin.c Tue Mar 29 08:53:07 2011 +0000 +++ b/gui/skin/skin.c Tue Mar 29 10:21:39 2011 +0000 @@ -60,24 +60,26 @@ gmp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_SKIN_ERRORMESSAGE, linenumber, p); } -#define CHECKDEFLIST(str) \ - { \ - if (skin == NULL) \ - { \ - skin_error(MSGTR_SKIN_ERROR_SECTION, str); \ - return 1; \ - } \ +static int section_cmd(char *cmd) +{ + if (!skin) { + skin_error(MSGTR_SKIN_ERROR_SECTION, cmd); + return 0; } -#define CHECKWINLIST(str) \ - { \ - if (!currWinName[0]) \ - { \ - skin_error(MSGTR_SKIN_ERROR_WINDOW, str); \ - return 1; \ - } \ + return 1; +} + +static int window_cmd(char *cmd) +{ + if (!currWinName[0]) { + skin_error(MSGTR_SKIN_ERROR_WINDOW, cmd); + return 0; } + return 1; +} + #define CHECK(name) \ { \ if (!strcmp(currWinName, name)) \ @@ -159,6 +161,9 @@ (void)in; + if (!section_cmd("end")) + return 1; + mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[skin] %send (%s)\n", space, name); if (currWinName[0]) { @@ -175,7 +180,13 @@ // window=main|sub|playbar|menu static int cmd_window(char *in) { - CHECKDEFLIST("window"); + if (!section_cmd("window")) + return 1; + + if (currWinName[0]) { + skin_error(MSGTR_SKIN_ERROR_IN_WINDOW, "window"); + return 1; + } av_strlcpy(currWinName, strlower(in), sizeof(currWinName)); @@ -209,8 +220,8 @@ int x, y; int sx = 0, sy = 0; - CHECKDEFLIST("base"); - CHECKWINLIST("base"); + if (!window_cmd("base")) + return 1; cutItem(in, fname, ',', 0); x = cutItemToInt(in, ',', 1); @@ -326,8 +337,8 @@ // background=R,G,B static int cmd_background(char *in) { - CHECKDEFLIST("background"); - CHECKWINLIST("background"); + if (!window_cmd("background")) + return 1; CHECK("menu"); CHECK("main"); @@ -349,8 +360,8 @@ int x, y, sx, sy; char msg[32]; - CHECKDEFLIST("button"); - CHECKWINLIST("button"); + if (!window_cmd("button")) + return 1; CHECK("sub"); CHECK("menu"); @@ -407,8 +418,8 @@ unsigned char fname[512]; unsigned char tmp[512]; - CHECKDEFLIST("selected"); - CHECKWINLIST("selected"); + if (!window_cmd("selected")) + return 1; CHECK("main"); CHECK("sub"); @@ -440,8 +451,8 @@ int x, y, sx, sy, message; unsigned char tmp[64]; - CHECKDEFLIST("menu"); - CHECKWINLIST("menu"); + if (!window_cmd("menu")) + return 1; CHECK("main"); CHECK("sub"); @@ -482,8 +493,8 @@ unsigned char phfname[512]; wItem *item; - CHECKDEFLIST("hpotmeter"); - CHECKWINLIST("hpotmeter"); + if (!window_cmd("h/v potmeter")) + return 1; CHECK("sub"); CHECK("menu"); @@ -567,8 +578,8 @@ unsigned char phfname[512]; wItem *item; - CHECKDEFLIST("potmeter"); - CHECKWINLIST("potmeter"); + if (!window_cmd("potmeter")) + return 1; CHECK("sub"); CHECK("menu"); @@ -619,8 +630,8 @@ char name[512]; wItem *item; - CHECKDEFLIST("font"); - CHECKWINLIST("font"); + if (!window_cmd("font")) + return 1; CHECK("sub"); CHECK("menu"); @@ -663,8 +674,8 @@ int x, y, id; wItem *item; - CHECKDEFLIST("slabel"); - CHECKWINLIST("slabel"); + if (!window_cmd("slabel")) + return 1; CHECK("sub"); CHECK("menu"); @@ -713,8 +724,8 @@ int x, y, sx, id, a; wItem *item; - CHECKDEFLIST("dlabel"); - CHECKWINLIST("dlabel"); + if (!window_cmd("dlabel")) + return 1; CHECK("sub"); CHECK("menu"); @@ -764,8 +775,8 @@ { char tmp[512]; - CHECKDEFLIST("decoration"); - CHECKWINLIST("decoration"); + if (!window_cmd("decoration")) + return 1; CHECK("sub"); CHECK("menu");