Commit 260304b4 authored by Andrew Price's avatar Andrew Price

No-op all .mwrc commands apart from 'include'

parent d4aad6f5
Pipeline #559 passed with stage
in 8 minutes and 23 seconds
......@@ -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);
}
......
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