⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 luapatch.txt

📁 linux下从网卡远程启动
💻 TXT
📖 第 1 页 / 共 2 页
字号:
+		single_result(0);+	}+	zero_result(console_setattrib(luaL_check_number(L, 1)));+}++static int l_currticks(lua_State *L) { single_result(currticks()); }++#if	ANSIMODE==-1+static int l_ansiswitch(lua_State *L) {+	int n = lua_gettop(L);+	if (n < 1) {+		single_result(0);+	}+	zero_result(ansiswitch(luaL_check_number(L, 1)));+}+#endif++static const struct luaL_reg userlib[] = {+	{"checkkey",l_checkkey},+	{"cls",l_cls},+	{"getkey",l_getkey},+	{"getshift",l_getshift},+	{"getxy",l_getxy},+	{"gotoxy",l_gotoxy},+	{"ischar",l_ischar},+	{"nocursor",l_nocursor},+	{"setattrib",l_setattrib},+	{"currticks",l_currticks},+#if	ANSIMODE==-1+	{"ansiswitch",l_ansiswitch},+#endif+};++/*+** Open user library+*/+LUALIB_API void lua_userlibopen (lua_State *L) {+  luaL_openl(L, userlib);+}diff -ur --exclude='*.a' --exclude='*.o' --exclude='*.map' --unidirectional-new-file /usr/local/src/lua-4.0.1/src/ldo.c lua-4.0.1/src/ldo.c--- /usr/local/src/lua-4.0.1/src/ldo.c	2002-06-21 00:24:40.000000000 +1000+++ lua-4.0.1/src/ldo.c	2003-01-07 22:27:31.000000000 +1100@@ -260,6 +260,7 @@   static int parse_file (lua_State *L, const char *filename) {+#if	0   ZIO z;   int status;   int bin;  /* flag for file mode */@@ -284,6 +285,9 @@   if (f != stdin)     fclose(f);   return status;+#else+  return 0;+#endif }  diff -ur --exclude='*.a' --exclude='*.o' --exclude='*.map' --unidirectional-new-file /usr/local/src/lua-4.0.1/src/lib/Makefile lua-4.0.1/src/lib/Makefile--- /usr/local/src/lua-4.0.1/src/lib/Makefile	2000-09-20 13:13:52.000000000 +1100+++ lua-4.0.1/src/lib/Makefile	2003-01-07 22:27:31.000000000 +1100@@ -7,8 +7,8 @@ # actually only used in liolib.c EXTRA_DEFS= $(POPEN) -OBJS= lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o lstrlib.o-SRCS= lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c lstrlib.c+OBJS= lauxlib.o lbaselib.o ldblib.o lstrlib.o+SRCS= lauxlib.c lbaselib.c ldblib.c lstrlib.c  T= $(LIB)/liblualib.a diff -ur --exclude='*.a' --exclude='*.o' --exclude='*.map' --unidirectional-new-file /usr/local/src/lua-4.0.1/src/lib/lbaselib.c lua-4.0.1/src/lib/lbaselib.c--- /usr/local/src/lua-4.0.1/src/lib/lbaselib.c	2002-06-12 03:01:50.000000000 +1000+++ lua-4.0.1/src/lib/lbaselib.c	2003-01-07 22:27:31.000000000 +1100@@ -75,11 +75,15 @@     s = lua_tostring(L, -1);  /* get result */     if (s == NULL)       lua_error(L, "`tostring' must return a string to `print'");+#if	0     if (i>1) fputs("\t", stdout);+#endif     fputs(s, stdout);     lua_pop(L, 1);  /* pop result */   }+#if	0   fputs("\n", stdout);+#endif   return 0; } diff -ur --exclude='*.a' --exclude='*.o' --exclude='*.map' --unidirectional-new-file /usr/local/src/lua-4.0.1/src/llimits.h lua-4.0.1/src/llimits.h--- /usr/local/src/lua-4.0.1/src/llimits.h	2000-10-26 23:47:05.000000000 +1100+++ lua-4.0.1/src/llimits.h	2003-01-07 22:28:25.000000000 +1100@@ -42,7 +42,7 @@ typedef LUA_NUM_TYPE Number;  /* function to convert a Number to a string */-#define NUMBER_FMT	"%.16g"		/* LUA_NUMBER */+#define NUMBER_FMT	"%d"		/* LUA_NUMBER */ #define lua_number2str(s,n)	sprintf((s), NUMBER_FMT, (n))  /* function to convert a string to a Number */diff -ur --exclude='*.a' --exclude='*.o' --exclude='*.map' --unidirectional-new-file /usr/local/src/lua-4.0.1/src/lparser.c lua-4.0.1/src/lparser.c--- /usr/local/src/lua-4.0.1/src/lparser.c	2000-11-29 22:57:42.000000000 +1100+++ lua-4.0.1/src/lparser.c	2003-01-07 22:27:31.000000000 +1100@@ -1019,7 +1019,7 @@ }  -static int stat (LexState *ls) {+static int statm (LexState *ls) {   int line = ls->linenumber;  /* may be needed for error messages */   switch (ls->t.token) {     case TK_IF: {  /* stat -> ifstat */@@ -1115,7 +1115,7 @@   /* chunk -> { stat [';'] } */   int islast = 0;   while (!islast && !block_follow(ls->t.token)) {-    islast = stat(ls);+    islast = statm(ls);     optional(ls, ';');     LUA_ASSERT(ls->fs->stacklevel == ls->fs->nactloc,                "stack size != # local vars");diff -ur --exclude='*.a' --exclude='*.o' --exclude='*.map' --unidirectional-new-file /usr/local/src/lua-4.0.1/src/lua/Makefile lua-4.0.1/src/lua/Makefile--- /usr/local/src/lua-4.0.1/src/lua/Makefile	2000-03-31 23:52:56.000000000 +1000+++ lua-4.0.1/src/lua/Makefile	2003-01-07 22:27:31.000000000 +1100@@ -4,7 +4,7 @@  include $(LUA)/config -EXTRA_DEFS= $(POSIX)+EXTRA_DEFS+= $(POSIX)  OBJS= lua.o SRCS= lua.c@@ -13,8 +13,8 @@  all: $T -$T: $(OBJS) $(LIB)/liblua.a $(LIB)/liblualib.a-	$(CC) -o $@ $(OBJS) -L$(LIB) -llua -llualib $(EXTRA_LIBS)+$T: $(OBJS) $(LUA)/sa/startmenu.o $(LIB)/liblua.a $(LIB)/liblualib.a $(LIB)/libsalib.a+	$(LD) -M --oformat binary -N -Ttext $(LUA_RELOC) -e _start -o $@ $(LUA)/sa/startmenu.o $(OBJS) -L$(LIB) -llua -llualib -lsalib $(EXTRA_LIBS) > lua.map  $(LIB)/liblua.a: 	cd ..; $(MAKE)@@ -22,6 +22,12 @@ $(LIB)/liblualib.a: 	cd ../lib; $(MAKE) +$(LUA)/sa/startmenu.o:+	cd ../../sa; $(MAKE) startmenu.o++$(LIB)/libsalib.a:+	cd ../../sa; $(MAKE) ../lib/libsalib.a+ clean: 	rm -f $(OBJS) $T diff -ur --exclude='*.a' --exclude='*.o' --exclude='*.map' --unidirectional-new-file /usr/local/src/lua-4.0.1/src/lua/lua.c lua-4.0.1/src/lua/lua.c--- /usr/local/src/lua-4.0.1/src/lua/lua.c	2000-10-21 03:36:32.000000000 +1100+++ lua-4.0.1/src/lua/lua.c	2003-01-10 13:03:11.000000000 +1100@@ -15,6 +15,12 @@ #include "luadebug.h" #include "lualib.h" +#include "etherboot.h"+#include "elf_boot.h"+#include "byteswap.h"++#define	LUA_VERSION_CHECK	0x04000100	/* 4.0.1.0 */+  static lua_State *L = NULL; @@ -50,11 +56,16 @@  static void userinit (void) {   lua_baselibopen(L);+#if	0   lua_iolibopen(L);+#endif   lua_strlibopen(L);+#if	0   lua_mathlibopen(L);+#endif   lua_dblibopen(L);   /* add your libraries here */+  lua_userlibopen(L); }  @@ -150,6 +161,7 @@ }  +#if	0 static int file_input (const char *argv) {   int result = ldo(lua_dofile, argv);   if (result) {@@ -283,6 +295,7 @@   }   return EXIT_SUCCESS; }+#endif   static void getstacksize (int argc, char *argv[], struct Options *opt) {@@ -306,6 +319,7 @@ }  +#if	0 int main (int argc, char *argv[]) {   struct Options opt;   int status;@@ -319,4 +333,86 @@     lua_close(L);   return status; }+#endif++static void parse_elf_boot_notes(+	void *notes, union infoblock **rheader, struct bootp_t **rbootp)+{+	unsigned char *note, *end;+	Elf_Bhdr *bhdr;+	Elf_Nhdr *hdr;++	bhdr = notes;+	if (bhdr->b_signature != ELF_BHDR_MAGIC) {+		return;+	}++	note = ((char *)bhdr) + sizeof(*bhdr);+	end  = ((char *)bhdr) + bhdr->b_size;+	while (note < end) {+		unsigned char *n_name, *n_desc, *next;+		hdr = (Elf_Nhdr *)note;+		n_name = note + sizeof(*hdr);+		n_desc = n_name + ((hdr->n_namesz + 3) & ~3);+		next = n_desc + ((hdr->n_descsz + 3) & ~3);+		if (next > end) +			break;+#if 0+		printf("n_type: %x n_name(%d): n_desc(%d): \n", +			hdr->n_type, hdr->n_namesz, hdr->n_descsz);+#endif +		if ((hdr->n_namesz == 10) &&+			(memcmp(n_name, "Etherboot", 10) == 0)) {+			switch(hdr->n_type) {+			case EB_BOOTP_DATA:+				*rbootp = *((void **)n_desc);+				break;+			case EB_HEADER:+				*rheader = *((void **)n_desc);+				break;+			default:+				break;+			}+		}+		note = next;+	}+}++static uint32_t getlong(const char *p) {+  union {+    uint8_t c[4];+    uint32_t l;+  } u;+  memcpy(u.c, p, sizeof(uint32_t));+  return (ntohl(u.l));+}++int menu(struct ebinfo *eb, union infoblock *header, struct bootp_t *bootp)+{+  uint32_t l;+  parse_elf_boot_notes(eb, &header, &bootp);+  L = lua_open(0);  /* create state */+  userinit();  /* open libraries */+  print_version();+  const char *name = (const char *)DATA_START;+  if ((l = getlong(name)) != LUA_VERSION_CHECK) {+    fprintf(stderr, "Lua version mismatch (%#X != %#X)\n", l, LUA_VERSION_CHECK);+    return 0;+  }+  name += sizeof(uint32_t);+  int len = (strlen(name) + sizeof(uint32_t)) & ~(sizeof(uint32_t)-1);+  int top = lua_gettop(L);+  int res = lua_dobuffer(L, name + len + sizeof(uint32_t), getlong(name + len), name);+  lua_settop(L, top);  /* remove eventual results */+  lua_close(L);+  /* Lua gives no message in such cases, so lua.c provides one */+  if (res == LUA_ERRMEM) {+    fprintf(stderr, "lua: memory allocation error\n");+  }+  else if (res == LUA_ERRERR)+    fprintf(stderr, "lua: error in error message\n");+  else if (res != 0)+    fprintf(stderr, "lua: error %d\n", res);+  return 0;+}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -