Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
// This file:
//   http://anggtwu.net/LUA/Gdb1.c.html
//   http://anggtwu.net/LUA/Gdb1.c
//          (find-angg "LUA/Gdb1.c")
// Author: Eduardo Ochs <eduardoochs@gmail.com>
//
// Superseded by:
//   (find-lisptree "call-lua.c")
//
// (defun c  () (interactive) (message (find-sh0 "~/LUA/Gdb1.sh compileandrun")))
// (defun cs () (interactive) (find-fline "~/LUA/Gdb1.sh"))
// (defun ec () (interactive) (find-angg "LUA/Gdb1.c"))
// (defun eg () (interactive) (find-angg "LUA/Gdb1.gdb"))
// (defun el () (interactive) (find-angg "LUA/Gdb1.lua"))
// (defun es () (interactive) (find-angg "LUA/Gdb1.sh"))
// (defun oc () (interactive) (find-angg ".lua51/PP.c"))
// (defun og () (interactive) (find-angg ".lua51/PP.gdb"))
// (defun rs () (interactive) (find-angg "LISP/2025-lua-runstring-0.c"))
// (find-lua53manual "#lua_pop")
// (find-lua53manual "#lua_pushvalue")
// (find-lua53manual "#lua_pushnumber")
// (find-lua53manual "#lua_call")
//
// «.lua_my_init»	(to "lua_my_init")
// «.PP»		(to "PP")
// «.PPstack»		(to "PPstack")
// «.lua_fs»		(to "lua_fs")
// «.lua_fss»		(to "lua_fss")

#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <stdio.h>

static lua_State *L = NULL;

// «lua_my_init»  (to ".lua_my_init")
void lua_my_init(void) {
 if (!L) {
    L = luaL_newstate();
    luaL_openlibs (L);
  }
}

// «PP»  (to ".PP")
// Old, from: (find-angg ".lua51/PP.c")
void PP(lua_State *L, int index) {
  lua_getglobal(L, "PP");
  if (index==0) {		/* 0 is never a valid index */
    lua_pushnil(L);
  } else {
    lua_pushvalue(L, index);
  }
  lua_call(L, 1, 0);
}

// «PPstack»  (to ".PPstack")
// Calls: (find-angg "LUA/Gdb1.lua" "PPstack")
// to print the whole stack with indices.
// Leaves the stack unchanged.
void PPstack(lua_State *L) {
  int n = lua_gettop(L);
  int i;
  lua_getglobal   (L, "PPstack");
  for (i=0;i<n;++i)
    lua_pushvalue (L, -n-1);
  lua_call        (L, n, 0);
}

// «lua_fs»  (to ".lua_fs")
// Returns tostring(f(arg1))
const char *lua_fs(char *f, char *arg1) {
  const char *result;
  lua_getglobal  (L, "tostring");
  lua_getglobal  (L, f);
  lua_pushstring (L, arg1);
  lua_call       (L, 1, 1);
  lua_call       (L, 1, 1);
  result = lua_tostring(L, -1);
  lua_pop(L, 1);
  return result;
}

// «lua_fss»  (to ".lua_fss")
// Returns tostring(f(arg1,arg2))
const char *lua_fss(char *f, char *arg1, char *arg2) {
  const char *result;
  lua_getglobal  (L, "tostring");
  lua_getglobal  (L, f);
  lua_pushstring (L, arg1);
  lua_pushstring (L, arg2);
  lua_call       (L, 2, 1);
  lua_call       (L, 1, 1);
  result = lua_tostring(L, -1);
  lua_pop(L, 1);
  return result;
}

#ifdef MAIN
int main(int argc, const char ** argv) {
  lua_my_init();
  lua_fs ("dofile", "/home/edrx/LUA/Gdb1.lua");
  lua_fs ("eval",   "foo = function (a,b) return 10*a+b end");
  lua_fs ("eval",   "PPexpr = function (str) PP(expr(str)) end");
  lua_fs ("PPexpr", "2+3");
  lua_fs ("PPexpr", "foo(2,3)");
  lua_fs ("print", "a");
  lua_fss("print", "a", "b");
  return 0;
}
#endif

// (load    "~/LUA/Gdb1.el")
// (find-angg "LUA/Gdb1.el")
// (find-preproc :end)
#ifdef PREPROC
  lua_call(L, 22, 33);
#endif

/*
* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
LUA_INCLUDE_DIR=/usr/include/lua5.3
LUA_LIB=lua5.3
STEM=Gdb1
gcc -gdwarf-4 -g3 -shared -I${LUA_INCLUDE_DIR} -o ${STEM}.so ${STEM}.c -l${LUA_LIB}
gcc -gdwarf-4 -g3 -DMAIN  -I${LUA_INCLUDE_DIR} -o ${STEM}    ${STEM}.c -l${LUA_LIB}
ls -lAF ${STEM}*
      ./${STEM}

* (eepitch-sbcl)
* (eepitch-kill)
* (eepitch-sbcl)

* (eepitch-sly)
* (eepitch-kill)
* (eepitch-sly)
** (find-angg "LUA/Gdb1.sh")
* (find-sh0 "~/LUA/Gdb1.sh compile")
(load #P"~/quicklisp/setup.lisp")
(ql:quickload :cffi)
(cffi:load-foreign-library "./Gdb1.so")
** (find-es "lisp" "cffi")

(defun lua-my-init ()
  (cffi:foreign-funcall "lua_my_init"))
(defun lua-fs (f arg1)
  (cffi:foreign-funcall "lua_fs"  :string f :string arg1 :string))
(defun lua-fss (f arg1 arg2)
  (cffi:foreign-funcall "lua_fss" :string f :string arg1 :string arg2 :string))
(defun lua-verbatimbox (str)
  (lua-fs (f arg1)


  (cffi:foreign-funcall "lua_fss" :string f :string arg1 :string arg2 :string))

(lua-my-init)
(lua-fs  "dofile" "/home/edrx/LUA/Gdb1.lua")
(lua-fs  "PP"     "/home/edrx/LUA/Gdb1.lua")
(lua-fs  "eval"   "foo = function (a,b) return 10*a+b end")
(lua-fss "foo"    "2" "3")
(lua-fs  "verbatimbgbox" "a__b")
(lua-fs  "verbatimbgbox" "a__.
|  |
b  c")



(lua-runstring "return 'ab'..'cd'")

** (find-angg ".emacs" "my-gud-mode")

*/







// Local Variables:
// coding:  utf-8-unix
// End: