Lua Application Programming Helper Libraries
Lua
Latest commit 81882c0 Apr 15, 2016 William Adams Change strlen to use char * cast instead of uint8_t *
Permalink
Failed to load latest commit information.
docs new file: ../ColorsHollasch.lua Jan 17, 2013
experimental
tests Adding another table with bit values to play with Oct 5, 2015
CHANGELOG.md changes to changelog markup Jun 18, 2015
LICENSE.txt Making all functions local consistantly Jun 15, 2015
README.md Fix typographical error(s) Oct 7, 2015
aestable.lua
alt_getopt.lua Adding getopt variants Jun 17, 2015
ascii.lua Making function signatures consistant Jun 15, 2015
bencode.lua fixed bencode to make local references Jun 16, 2015
binarystream.lua Fixing up binarystream, memorystream, and tests Jun 18, 2015
bitbang.lua Added extractbits32/64, setbits32/64 to bitbang.lua Jun 17, 2015
c99_types.lua modified: ../c99_types.lua Jan 3, 2013
cctype.lua Adding getopt variants Jun 17, 2015
colorshollasch.lua Renaming to all lowercase file names Jun 16, 2015
colorspace.lua Renaming to all lowercase file names Jun 16, 2015
colorsresene.lua Renaming to all lowercase file names Jun 16, 2015
colorssgi.lua
crc32.lua Various renames to all lowercase filenames Jun 16, 2015
enumbits.lua
ffi_stack.lua Changes to MemoryStream Jul 28, 2012
filestream.lua Changes to make filestream conformant to current stream API Jun 29, 2015
get_opts.lua Adding getopt variants Jun 17, 2015
getopt_alt.lua Adding getopt variants Jun 17, 2015
getopt_posix.lua Adding getopt variants Jun 17, 2015
hashes.lua Various renames to all lowercase filenames Jun 16, 2015
httpheaders.lua Added httpheaders.lua Jun 16, 2012
limits.lua Added CHANGELOG.md and moved some files around Jun 18, 2015
ltin.lua fixed bencode to make local references Jun 16, 2015
lua_ffi.lua modified: LICENSE.txt Apr 3, 2013
luastate.lua
luxl.lua modified: MemoryStream.lua Apr 3, 2013
maths.lua Added min_bytes_needed() to maths.lua Jun 18, 2015
md5.lua Adding getopt variants Jun 17, 2015
memorystream.lua
memutils.lua Adding getopt variants Jun 17, 2015
mime.lua Making all functions local consistantly Jun 15, 2015
mimetypes.lua
pixel.lua Fixed BGRA_t to include Alpha field in structure Jul 29, 2015
printutils.lua moved atoi to stdc.lua Jun 18, 2015
sha2.lua new file: ../ColorsHollasch.lua Jan 17, 2013
stdc.lua
stream.lua
stringutils.lua Making all functions local consistantly Jun 15, 2015
stringzutils.lua Change strlen to use char * cast instead of uint8_t * Apr 15, 2016
tls.lua Various renames to all lowercase filenames Jun 16, 2015
utf.lua moved atoi to stdc.lua Jun 18, 2015
vector.lua

README.md

LAPHLibs

Lua Application Programming Helper Libraries

This is a repository of things I have found to be useful while programming in LuaJIT.

As the purpose of most of these routines are to offer some amount of function typically found in standard C libraries, there is at least usage of bit operations, memmory manipulation, and the like. For most of these cases, the LuaJIT ffi and "bit" modules are used. So, this code is not necessarily meant for usage with vanilla Lua.

In cases where 'C' functions are being supported, it's important to note the memory allocation strategy. For the most part, the 'C' semantics are utilized. That is, in the case of 'strdup', for example, memory for the new string is allocated using malloc, and not ffi.new. This means that whichever code was responsible for calling strdup in the first place will need to call 'free()' when they want to free up the string. Such functions are primarily meant for interop with C library routines that accept a "char *", and will then take over ownership of that memory. In most cases when the function is not going to hold onto the pointer ("const char *"), this string function should not be used.

The original sets of routines came directly out of the earliest projects where I was learning to use the LuaJIT ffi mechanism. As such, they were kind of rough, and a hodge podge of styles and usefulness. Over time, various of the routines have been surpassed by better implementations in various projects, or by functions being implemented in the LuaJIT compiler itself.

Latest: 15/06/2015 Updated to ensure nothing spills into global namespace by default Updated to use a consistent function signature style

Current: Works against LUAJIT git HEAD as of 15/06/2015

ascii.lua

This file contains a table of the ASCII character set, with numeric values and descriptions. There are routines to create constant values from the table.

bencode.lua

Implementation of the bencode format, which is used to encode/decode torrent files.

BinaryStream.lua

A 'class' that can deal with reading and writing of binary values from/to a stream. You can configure the stream to deal with a big or little endian source.

BitBang.lua

Lowest level bit twiddling. Builds upon the bitops allowing the getting/setting of bit values within a larger array of values.

c99_types.lua

Helper support for types typically found in stdint.h

cctype.lua

Implementation of the isxxx() character classification functions typically found in the libc libraries. These routines operate on numbers, and return boolean values.

CRC32.lua

Implementation of a CRC32 routine

httpheaders.lua

A simple Lua table containing HTTP headers. The table contains information as to whether the header is used for requests, responses, or both. This simple table can be used directly, or turned into another form, depending on your requirements.

limits.lua

Values for various limits on numeric values

LUXL.lua

Implementation of very low level XML lexer/parser. This is not a conformant validating XML parser, but it's enough to get the job done on typical .xml configuration files, and many data streams.

This implementation does no memory allocations. It returns pointers and sizes as a result of the lexing activities.

MD5.lua

Implementation of the MD5 hash algorithm

MemoryStream.lua

Implementation of a streaming interface over a chunk of memory

memutils.lua

contains several routines that have C equivalents, such as memset, memcpy, memcmp, memchr, memmove. Also contains a few convenience functions related to dealing with chunks of memory.

mime.lua

Contains a table and function that maps between a file extension and the appropriate mime type.

mimetypes.lua

A simple Lua table which contains mime type information.

stringzutils.lua

Contains a set of functions that deal with null terminated strings. All the typical security hole opening functions such as strcpy, strcmp are there, as well as their marginally more secure counterparts such as strlcpy, and strlcat.

strtoul.lua

Turns a string value into a number value. Operates on a pointer to a string value, so it does not require the source to be a Lua String.