Axe the rpmsq debug code which was never getting built anyway
[platform/upstream/rpm.git] / rpmio / rpmlua.h
1 #ifndef RPMLUA_H
2 #define RPMLUA_H
3
4 typedef enum rpmluavType_e {
5     RPMLUAV_NIL         = 0,
6     RPMLUAV_STRING      = 1,
7     RPMLUAV_NUMBER      = 2
8 } rpmluavType;
9
10 #if defined(_RPMLUA_INTERNAL)
11
12 #include <stdarg.h>
13 #include <lua.h>
14
15 struct rpmlua_s {
16     lua_State *L;
17     size_t pushsize;
18     int storeprint;
19     size_t printbufsize;
20     size_t printbufused;
21     char *printbuf;
22 };
23
24 struct rpmluav_s {
25     rpmluavType keyType;
26     rpmluavType valueType;
27     union {
28         const char *str;
29         const void *ptr;
30         double num;
31     } key;
32     union {
33         const char *str;
34         const void *ptr;
35         double num;
36     } value;
37     int listmode;
38 };
39
40 #endif /* _RPMLUA_INTERNAL */
41
42 typedef struct rpmlua_s * rpmlua;
43 typedef struct rpmluav_s * rpmluav;
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 rpmlua rpmluaNew(void);
50 rpmlua rpmluaFree(rpmlua lua);
51 rpmlua rpmluaGetGlobalState(void);
52
53 int rpmluaCheckScript(rpmlua lua, const char *script,
54                       const char *name);
55 int rpmluaRunScript(rpmlua lua, const char *script,
56                     const char *name);
57 int rpmluaRunScriptFile(rpmlua lua, const char *filename);
58 void rpmluaInteractive(rpmlua lua);
59
60 void *rpmluaGetData(rpmlua lua, const char *key);
61 void rpmluaSetData(rpmlua lua, const char *key, const void *data);
62
63 const char *rpmluaGetPrintBuffer(rpmlua lua);
64 void rpmluaSetPrintBuffer(rpmlua lua, int flag);
65
66 void rpmluaGetVar(rpmlua lua, rpmluav var);
67 void rpmluaSetVar(rpmlua lua, rpmluav var);
68 void rpmluaDelVar(rpmlua lua, const char *key, ...);
69 int rpmluaVarExists(rpmlua lua, const char *key, ...);
70 void rpmluaPushTable(rpmlua lua, const char *key, ...);
71 void rpmluaPop(rpmlua lua);
72
73 rpmluav rpmluavNew(void);
74 rpmluav rpmluavFree(rpmluav var);
75 void rpmluavSetListMode(rpmluav var, int flag);
76 void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value);
77 void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value);
78 void rpmluavGetKey(rpmluav var, rpmluavType *type, void **value);
79 void rpmluavGetValue(rpmluav var, rpmluavType *type, void **value);
80
81 /* Optional helpers for numbers. */
82 void rpmluavSetKeyNum(rpmluav var, double value);
83 void rpmluavSetValueNum(rpmluav var, double value);
84 double rpmluavGetKeyNum(rpmluav var);
85 double rpmluavGetValueNum(rpmluav var);
86 int rpmluavKeyIsNum(rpmluav var);
87 int rpmluavValueIsNum(rpmluav var);
88
89 #ifdef __cplusplus
90 }
91 #endif
92
93 #endif /* RPMLUA_H */