ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

lzio.cpp

Go to the documentation of this file.
00001 /*
00002 ** a generic input stream interface
00003 ** See Copyright Notice in lua.h
00004 */
00005 
00006 
00007 #include "engines/grim/lua/lzio.h"
00008 
00009 #include "common/file.h"
00010 
00011 namespace Grim {
00012 
00013 int32 zgeteoz(ZIO *) {
00014     return EOZ;
00015 }
00016 
00017 ZIO *zopen(ZIO *z, const char *b, int32 size, const char *name) {
00018     if (!b)
00019         return nullptr;
00020     z->n = size;
00021     z->p = (const byte *)b;
00022     z->name = name;
00023     return z;
00024 }
00025 
00026 int32 zread (ZIO *z, void *b, int32 n) {
00027     while (n) {
00028         int32 m;
00029         if (z->n == 0) {
00030             return n;
00031         }
00032         m = (n <= z->n) ? n : z->n;
00033         memcpy(b, z->p, m);
00034         z->n -= m;
00035         z->p += m;
00036         b = (char *)b + m;
00037         n -= m;
00038     }
00039     return 0;
00040 }
00041 
00042 } // end of namespace Grim


Generated on Sat Mar 16 2019 05:01:44 for ResidualVM by doxygen 1.7.1
curved edge   curved edge