Add macro %isu_package to generate ISU Package
[platform/upstream/rpm.git] / luaext / userconfig.c
1
2 #include "config.h"
3
4 #include "lposix.h"
5 #include "lrexlib.h"
6
7 #define LUA_EXTRALIBS \
8         {"posix", luaopen_posix}, \
9         {"rex", luaopen_rex}, \
10         {"luapath", luapath},
11
12 #if 0
13
14 #define lua_readline    myreadline
15 #define lua_saveline    mysaveline
16
17 #include <ctype.h>
18 #include <readline/readline.h>
19 #include <readline/history.h>
20
21 static int myreadline (lua_State *L, const char *prompt) {
22   char *s=readline(prompt);
23   if (s==NULL)
24     return 0;
25   else {
26     lua_pushstring(L,s);
27     lua_pushliteral(L,"\n");
28     lua_concat(L,2);
29     free(s);
30     return 1;
31   }
32 }
33
34 static void mysaveline (lua_State *L, const char *s) {
35   const char *p;
36   for (p=s; isspace(*p); p++);
37   if (*p!=0) {
38     size_t n=strlen(s)-1;
39     if (s[n]!='\n')
40       add_history(s);
41     else {
42       lua_pushlstring(L,s,n);
43       s=lua_tostring(L,-1);
44       add_history(s);
45       lua_remove(L,-1);
46     }
47   }
48 }
49 #endif
50
51 static int luapath(lua_State *L)
52 {
53         lua_pushstring(L, "LUA_PATH");
54         lua_pushfstring(L, "%s/%s", rpmConfigDir(), "/lua/?.lua;?.lua");
55         lua_rawset(L, LUA_GLOBALSINDEX);
56         return 0;
57 }