[mw-devel] [Git][milliways/mw][mwscript-removal] No-op all .mwrc commands apart from 'include'
Andrew Price
welshbyte at sucs.org
Sat Apr 6 15:09:47 BST 2019
Andrew Price pushed to branch mwscript-removal at milliways / mw
Commits:
f62a0c92 by Andrew Price at 2019-04-06T14:08:51Z
No-op all .mwrc commands apart from 'include'
- - - - -
1 changed file:
- src/client/init.c
Changes:
=====================================
src/client/init.c
=====================================
@@ -137,76 +137,6 @@ static int ReadInitFile(const char *base, const char *filename)
if (*a=='#') { free(backup); free(header); continue; }
- /* load command aliases */
- if (!strcasecmp(a,"alias"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed alias in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
- if ((c=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed alias in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
-
- if (AddLink(&alias_list, b, c))
- {
- printf(_("Alias %s already exists. Redefined at line %d in %s.\n"), b, lineno, filename);
- }
- }else
- /* load function binds */
- if (!strcasecmp(a,"bind"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed bind in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
- if ((c=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed bind in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
-
- if (AddLink(&bind_list, b, c))
- {
- printf(_("Bind %s already exists. Redefined at line %d in %s.\n"), b, lineno, filename);
- }
- }else
- /* load rpc binds */
- if (!strcasecmp(a,"rpc"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed rpc bind in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
- if ((c=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed rpc bind in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
-
- if (AddLink(&rpc_list, b, c))
- {
- printf(_("RPC Bind %s already exists. Redefined at line %d in %s.\n"), b, lineno, filename);
- }
- }else
- /* include a seperate script file */
if (!strcasecmp(a, "include"))
{
if ((b=strtok(NULL," \t\n\r"))==NULL)
@@ -224,167 +154,37 @@ static int ReadInitFile(const char *base, const char *filename)
ReadInitFile(base, rpath);
}else
ReadInitFile(base, b);
- }else
- /* check for destroying functions */
- if (!strcasecmp(a, "destroy"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed include in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
- if (!strcasecmp(b, "*")) DestroyAllFunctions(0); else DestroyFunction(b);
- }else
- /* bind event function */
- if (!strcasecmp(a, "event"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed event bind in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
-
- if (AddLink(&event_list, b, ""))
- {
- printf(_("Event bind already exists. Useless instruction at line %d in %s.\n"), lineno, filename);
- }
- }else
- /* bind ipc function */
- if (!strcasecmp(a, "ipc"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed ipc in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
-
- if (AddLink(&ipc_list, b, ""))
- {
- printf(_("IPC bind already exists. Useless instruction at line %d in %s.\n"), lineno, filename);
- }
- }else
- /* allow user to bind log on/off functions */
- if (!strcasecmp(a, "checkonoff"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed checkonoff bind in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
-
- if (AddLink(&onoff_list, b, ""))
- {
- printf(_("Checkonoff bind already exists. Useless instruction at line %d in %s.\n"), lineno, filename);
- }
- }else
- /* allow user to bind shutdown functions */
- if (!strcasecmp(a, "shutdown"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed shutdown bind in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
-
- if (AddLink(&shutdown_list, b, ""))
- {
- printf(_("Shutdown bind already exists. Useless instruction at line %d in %s.\n"), lineno, filename);
- }
- }else
- /* allow user to bind force functions */
- if (!strcasecmp(a, "force"))
- {
- /* force has been removed - this is a no-op */
- }else
- /* load mw-script functions */
- if (!strcasecmp(a,"function"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed Script Function declaration in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
- /* set function to 'normal' */
- LoadFunction(b, header, file, &lineno, filename, 0);
- }else
- /* load mw-script functions (local, hidden function) */
- if (!strcasecmp(a,"lfunction"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed Script Function declaration in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
- /* set function to 'non-interface' (local) */
- LoadFunction(b, header, file, &lineno, filename, FUNCFLAG_LOCAL);
- }else
- /* load mw-script initialisation function */
- if (!strcasecmp(a,"initfunc"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed Script Init declaration in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
- /* set function to 'init' */
- LoadFunction(b, header, file, &lineno, filename, FUNCFLAG_AUTOINIT);
- }else
- /* load a local, hidden mw-script initialisation function */
- if (!strcasecmp(a,"linitfunc"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed Script Init declaration in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
- /* set function to 'init' and 'non-interface'*/
- LoadFunction(b, header, file, &lineno, filename, FUNCFLAG_AUTOINIT | FUNCFLAG_LOCAL);
- }else
- /* load mw-script board initialisation function */
- if (!strcasecmp(a,"boardfunc"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed Script BoardInit declaration in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
- /* set function to 'boardinit' */
- LoadFunction(b, header, file, &lineno, filename, FUNCFLAG_BOARDINIT);
- }else
- /* load a local, hidden mw-script board initialisation function */
- if (!strcasecmp(a,"lboardfunc"))
- {
- if ((b=strtok(NULL," \t\n\r"))==NULL)
- {
- printf(_("Malformed Script BoardInit declaration in %s at line %d\n"),filename,lineno);
- free(backup);
- free(header);
- continue;
- }
- /* set function to 'init' and 'non-interface'*/
- LoadFunction(b, header, file, &lineno, filename, FUNCFLAG_BOARDINIT | FUNCFLAG_LOCAL);
- }else
- printf(_("Loading file %s unrecognised command '%s' on line %d\n"),filename, a, lineno);
+ } else {
+ /* mwscript has gone but we don't want to break old .mwrc's */
+ const char *noopfuncs[] = {
+ "alias",
+ "bind",
+ "rpc",
+ "destroy",
+ "event",
+ "ipc",
+ "checkonoff",
+ "shutdown",
+ "force",
+ "function",
+ "lfunction",
+ "initfunc",
+ "linitfunc",
+ "boardfunc",
+ "lboardfunc",
+ NULL
+ };
+ int noop = 0;
+ for (int i = 0; noopfuncs[i] != NULL; i++) {
+ if (!strcasecmp(a, noopfuncs[i])) {
+ noop = 1;
+ break;
+ }
+ }
+ if (!noop)
+ fprintf(stderr, _("Loading file %s unrecognised command '%s' on line %d\n"),
+ filename, a, lineno);
+ }
free(backup);
free(header);
}
View it on GitLab: https://projects.sucs.org/milliways/mw/commit/f62a0c9249a5bfcdaedb9ab1e38528aa028c75ec
--
View it on GitLab: https://projects.sucs.org/milliways/mw/commit/f62a0c9249a5bfcdaedb9ab1e38528aa028c75ec
You're receiving this email because of your account on projects.sucs.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20190406/b58f8b11/attachment-0001.html>
More information about the mw-devel
mailing list