Warning: this is an htmlized version!
The original is across this link,
and the conversion rules are here.
 * The "loadlib" function for Lua 4.0,
 * inspired by rborges' work:
 *   (find-shttpw3 "www.tecgraf.puc-rio.br/~rborges/loadlib/")
 * This file must be installed as <luasrcdir>/src/lib/lloadlib.c, and
 * some files have to be patched to make it be included in lualib;
 * see: (find-es "lua" "loadlib-patch")
 * and: (find-angg "LUA/loadlib/loadlib.patch")
 * If the Elisp hyperlinks above make no sense to you then please
 * access the htmlized version of this file at:
 *   http://angg.twu.net/LUA/loadlib/lloadlib.c.html
 * Written by Eduardo Ochs <http://angg.twu.net/>; version 2001feb25. 
 * Public domain.

#include <lualib.h>
#include <lauxlib.h>
#include <dlfcn.h>

static int loadlib(lua_State *L) {
  void *libptr;
  lua_CFunction f;
  libptr=dlopen(lua_tostring(L, 1), RTLD_LAZY);
  if (libptr==0)
    luaL_argerror(L, 1, "dlopen cannot open shared library");
  else {
    f=dlsym(libptr, lua_tostring(L, 2));
    if (f==0)
      luaL_argerror(L, 2, "dlsym cannot find init function");
  return 0;

LUALIB_API void lua_loadlib_open(lua_State *L) {
  lua_register(L, "loadlib", loadlib);