static Prototype* LoadBinary(lua_State* L, Input* input, const char* name) { Header header; size_t length = Input_ReadBlock(input, &header, sizeof(header)); if (length < sizeof(Header)) { return NULL; } // Check that the buffer is a compiled Lua chunk. if (header.magic[0] != '\033') { return NULL; } // Check for compatible platform if (header.endianness != 1 || header.intSize != sizeof(int) || header.sizetSize != sizeof(size_t) || header.numberSize != sizeof(lua_Number)) { return NULL; } char* data = Input_Read(input, &length); Prototype* prototype = Prototype_Create(L, data, length, name); Free(L, data, length); return prototype; }
int main(int argc, char **argv) { __INIT(argc, argv); __IMPORT(Basic__init); __IMPORT(Input__init); __REGMAIN("TestInput", 0); /* BEGIN */ Basic_Init(); do { TestInput_key = Input_Read(); Basic_PRCHAR(TestInput_key); } while (!(TestInput_key == '0')); Basic_Quit(); __FINI; }