From 8bb7ed968db64e9b12a6447e2eec3586ef9e935c Mon Sep 17 00:00:00 2001 From: Dirk Date: Tue, 10 Jun 2014 14:19:40 +0200 Subject: Windows system name changer during bootup. --- windows/bootpgm/win32/Main.cpp | 220 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 windows/bootpgm/win32/Main.cpp (limited to 'windows/bootpgm/win32/Main.cpp') diff --git a/windows/bootpgm/win32/Main.cpp b/windows/bootpgm/win32/Main.cpp new file mode 100644 index 00000000..f23a70ec --- /dev/null +++ b/windows/bootpgm/win32/Main.cpp @@ -0,0 +1,220 @@ +/* The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * + * The Initial Developer of the Original Code is Johannes Rudolph. + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Johannes Rudolph + */ + +#include "StdAfx.h" +#include "Main.h" + +Main *mainSingleton=NULL; + +char **split_args(IO &io,wchar_t* cmdLine,int length,int *pargc) +{ + int argCount=0; + for (int i=0;i(&func); + (p->*f)(io,args); + } + else + func(io,args); +} + + +void Main::showCmds(IO &io,char *args) +{ + io.println("Available commands:"); + Indenter i(io); + for (int i=0;ihelp ? cmd->help : "No help entry available"); +} + +command *Main::findCommand(char *name) +{ + for(int i=0;i\nShow help entries for command if available"); + + if (mainSingleton!=NULL) + { + io.println("Error: Main may be instantiated only once"); + return; + } + else + { + mainSingleton=this; + } +} + +Main::~Main(void) +{ + mainSingleton=NULL; +} + +void Main::run() +{ + showSplashScreen(); + rpl(); +} +void Main::rpl() +{ + io.println("Starting RPL (Read-Print-Loop) Type \"exit\" to stop."); + + char buffer[100]; + buffer[0]=0; + + while (strcmp(buffer,"exit")!=0) + { + io.print("rpl> "); + io.readln(buffer,100); + + command *cmd=findCommand(buffer); + if (cmd) + cmd->invoke(io,buffer + strlen(cmd->name)); + else + io.println("Command not found"); + } + + io.println("Exiting RPL"); +} +void Main::showSplashScreen() +{ + io.println("Boot-time Computername Changer by Johannes Rudolph"); + io.println("v0.1"); + io.print("IO: "); + io.println(io.getVersion()); +} + +void Main::addCommand(char *name,invokeFunc func,char *desc,char *help,void*pObject) +{ + if (funcc>=maxFuncs) + { + io.println("Es kann kein neues Kommando hinzugefügt werden"); + return; + } + + command c; + c.func=func; + c.name=name; + c.description=desc; + c.help=help; + c.pObject=pObject; + + commands[funcc]=c; + + funcc++; +} + +void Main::addCommand(char *name,deleg dg,char *desc,char *help) +{ + addCommand(name,(invokeFunc)dg.func,desc,help,dg.object); +} + + +void* __cdecl operator new(size_t sz) { + IO& io=mainSingleton->get_io(); + void* m = io.malloc((unsigned int)sz); + + if(!m) + io.println("out of memory"); + + return m; +} + +void __cdecl operator delete(void* m) { + mainSingleton->get_io().free(m); +} -- cgit v1.2.3-55-g7522