Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lzio.c File Reference
#include <string.h>
#include "lua.h"
#include "llimits.h"
#include "lmem.h"
#include "lstate.h"
#include "lzio.h"

Go to the source code of this file.

Macros

#define lzio_c
 
#define LUA_CORE
 

Functions

int luaZ_fill (ZIO *z)
 
int luaZ_lookahead (ZIO *z)
 
void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data)
 
size_t luaZ_read (ZIO *z, void *b, size_t n)
 
char * luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n)
 

Macro Definition Documentation

◆ LUA_CORE

#define LUA_CORE

Definition at line 11 of file lua-5.1.5/src/lzio.c.

◆ lzio_c

#define lzio_c

Definition at line 10 of file lua-5.1.5/src/lzio.c.

Function Documentation

◆ luaZ_fill()

int luaZ_fill ( ZIO * z)

Definition at line 21 of file lua-5.1.5/src/lzio.c.

21 {
22 size_t size;
23 lua_State *L = z->L;
24 const char *buff;
25 lua_unlock(L);
26 buff = z->reader(L, z->data, &size);
27 lua_lock(L);
28 if (buff == NULL || size == 0) return EOZ;
29 z->n = size - 1;
30 z->p = buff;
31 return char2int(*(z->p++));
32}
#define NULL
Definition gmacros.h:924
#define lua_unlock(L)
#define lua_lock(L)
#define EOZ
#define char2int(c)
void * data
lua_Reader reader
lua_State * L
const char * p

References char2int, Zio::data, EOZ, Zio::L, lua_lock, lua_unlock, Zio::n, NULL, Zio::p, and Zio::reader.

Referenced by luaZ_lookahead().

◆ luaZ_init()

void luaZ_init ( lua_State * L,
ZIO * z,
lua_Reader reader,
void * data )

Definition at line 48 of file lua-5.1.5/src/lzio.c.

48 {
49 z->L = L;
50 z->reader = reader;
51 z->data = data;
52 z->n = 0;
53 z->p = NULL;
54}
static const char * reader(lua_State *L, void *ud, size_t *size)

References Zio::data, Zio::L, Zio::n, NULL, Zio::p, Zio::reader, and reader().

Referenced by lua_load(), and lua_load().

◆ luaZ_lookahead()

int luaZ_lookahead ( ZIO * z)

Definition at line 35 of file lua-5.1.5/src/lzio.c.

35 {
36 if (z->n == 0) {
37 if (luaZ_fill(z) == EOZ)
38 return EOZ;
39 else {
40 z->n++; /* luaZ_fill removed first byte; put back it */
41 z->p--;
42 }
43 }
44 return char2int(*z->p);
45}
int luaZ_fill(ZIO *z)

References char2int, EOZ, luaZ_fill(), Zio::n, and Zio::p.

Referenced by f_parser(), and luaZ_read().

◆ luaZ_openspace()

char * luaZ_openspace ( lua_State * L,
Mbuffer * buff,
size_t n )

Definition at line 74 of file lua-5.1.5/src/lzio.c.

74 {
75 if (n > buff->buffsize) {
76 if (n < LUA_MINBUFFER) n = LUA_MINBUFFER;
77 luaZ_resizebuffer(L, buff, n);
78 }
79 return buff->buffer;
80}
#define LUA_MINBUFFER
#define luaZ_resizebuffer(L, buff, size)

References Mbuffer::buffer, Mbuffer::buffsize, LUA_MINBUFFER, and luaZ_resizebuffer.

Referenced by LoadString(), LoadString(), luaV_concat(), and luaV_concat().

◆ luaZ_read()

size_t luaZ_read ( ZIO * z,
void * b,
size_t n )

Definition at line 58 of file lua-5.1.5/src/lzio.c.

58 {
59 while (n) {
60 size_t m;
61 if (luaZ_lookahead(z) == EOZ)
62 return n; /* return number of missing bytes */
63 m = (n <= z->n) ? n : z->n; /* min. between n and z->n */
64 memcpy(b, z->p, m);
65 z->n -= m;
66 z->p += m;
67 b = (char *)b + m;
68 n -= m;
69 }
70 return 0;
71}
int luaZ_lookahead(ZIO *z)

References EOZ, luaZ_lookahead(), Zio::n, and Zio::p.

Referenced by LoadBlock(), LoadBlock(), LoadBlock(), and loadBlock().