The server tree of https://code.moenext.com/nanahira/ygopro.git, branch server, commit 52c868ce071ea0f2fcb0cf39bf2fb4151d12b90c, stock: gframe/, premake5.lua, .ci/, LICENSE, and gframe/ygopro.rc + .ico (upstream keeps them in resource/ and copies them in before building). No game assets, no scripts, no ocgcore submodule: the core is ../core. The third-party sources upstream's Windows CI downloads are vendored here at the positions its premake expects, each with its premake fragment from upstream's premake/ folder inside it: lua 5.4.8, sqlite 3.53.3, libevent 2.1.13-stable (tests, samples and autotools helpers left out; the files its Windows prebuild copies into include/ left out), zlib 1.3.2 (contrib and examples left out), xz 5.8.3 (src/liblzma + src/common only), and irrlicht 1.9 from mycard at 20f86d25: include/ plus the source/Irrlicht headers and the 11 .cpp files the server's zip reader project compiles. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
69 lines
1.3 KiB
C
69 lines
1.3 KiB
C
/*
|
|
** $Id: lzio.c $
|
|
** Buffered streams
|
|
** See Copyright Notice in lua.h
|
|
*/
|
|
|
|
#define lzio_c
|
|
#define LUA_CORE
|
|
|
|
#include "lprefix.h"
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include "lua.h"
|
|
|
|
#include "llimits.h"
|
|
#include "lmem.h"
|
|
#include "lstate.h"
|
|
#include "lzio.h"
|
|
|
|
|
|
int luaZ_fill (ZIO *z) {
|
|
size_t size;
|
|
lua_State *L = z->L;
|
|
const char *buff;
|
|
lua_unlock(L);
|
|
buff = z->reader(L, z->data, &size);
|
|
lua_lock(L);
|
|
if (buff == NULL || size == 0)
|
|
return EOZ;
|
|
z->n = size - 1; /* discount char being returned */
|
|
z->p = buff;
|
|
return cast_uchar(*(z->p++));
|
|
}
|
|
|
|
|
|
void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
|
|
z->L = L;
|
|
z->reader = reader;
|
|
z->data = data;
|
|
z->n = 0;
|
|
z->p = NULL;
|
|
}
|
|
|
|
|
|
/* --------------------------------------------------------------- read --- */
|
|
size_t luaZ_read (ZIO *z, void *b, size_t n) {
|
|
while (n) {
|
|
size_t m;
|
|
if (z->n == 0) { /* no bytes in buffer? */
|
|
if (luaZ_fill(z) == EOZ) /* try to read more */
|
|
return n; /* no more input; return number of missing bytes */
|
|
else {
|
|
z->n++; /* luaZ_fill consumed first byte; put it back */
|
|
z->p--;
|
|
}
|
|
}
|
|
m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
|
|
memcpy(b, z->p, m);
|
|
z->n -= m;
|
|
z->p += m;
|
|
b = (char *)b + m;
|
|
n -= m;
|
|
}
|
|
return 0;
|
|
}
|
|
|