1 /* Copyright (c) 2008 Sadrul Habib Chowdhury (sadrul@users.sf.net)
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 3, or (at your option)
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program (see the file COPYING); if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
18 ****************************************************************
26 struct scripts
*s_next
;
27 struct ScriptFuncs
*fns
;
30 struct scripts
*scripts
;
33 AddScript(struct ScriptFuncs
*sf
)
35 struct scripts
*ns
= (struct scripts
*)calloc(1, sizeof(*ns
));
43 #define ALL_SCRIPTS(fn, params, stop) do { \
44 struct scripts *iter; \
45 for (iter = scripts; iter; iter = iter->s_next) \
47 if (iter->fns->fn && (ret = (iter->fns->fn params)) && stop) \
55 ALL_SCRIPTS(sf_Init
, (), 0);
58 void ScriptFinit(void)
61 ALL_SCRIPTS(sf_Finit
, (), 0);
64 void ScriptForeWindowChanged(void)
67 ALL_SCRIPTS(sf_ForeWindowChanged
, (), 0);
70 void ScriptSource(const char *path
)
73 /* If one script loader accepts the file, we don't send it to any other loader */
74 ALL_SCRIPTS(sf_Source
, (path
), 1);
77 int ScriptProcessCaption(const char *str
, struct win
*win
, int len
)
80 ALL_SCRIPTS(sf_ProcessCaption
, (str
, win
, len
), 1);
84 int ScriptCommandExecuted(const char *command
, const char **args
, int argc
)
87 ALL_SCRIPTS(sf_CommandExecuted
, (command
, args
, argc
), 0);
91 #define HAVE_LUA 1 /* XXX: Remove */
93 extern struct ScriptFuncs LuaFuncs
;
96 void LoadScripts(void)
98 /* XXX: We could load the script loaders dynamically */
100 AddScript(&LuaFuncs
);