upgrade rpm version to 4.14.1
[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 typedef struct rpmluapb_s * rpmluapb;
16
17 struct rpmlua_s {
18     lua_State *L;
19     size_t pushsize;
20     rpmluapb printbuf;
21 };
22
23 struct rpmluav_s {
24     rpmluavType keyType;
25     rpmluavType valueType;
26     union {
27         const char *str;
28         const void *ptr;
29         double num;
30     } key;
31     union {
32         const char *str;
33         const void *ptr;
34         double num;
35     } value;
36     int listmode;
37 };
38
39 #endif /* _RPMLUA_INTERNAL */
40
41 typedef struct rpmlua_s * rpmlua;
42 typedef struct rpmluav_s * rpmluav;
43
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47
48 rpmlua rpmluaNew(void);
49 rpmlua rpmluaFree(rpmlua lua);
50 rpmlua rpmluaGetGlobalState(void);
51
52 int rpmluaCheckScript(rpmlua lua, const char *script,
53                       const char *name);
54 int rpmluaRunScript(rpmlua lua, const char *script,
55                     const char *name);
56 int rpmluaRunScriptFile(rpmlua lua, const char *filename);
57 void rpmluaInteractive(rpmlua lua);
58
59 void *rpmluaGetData(rpmlua lua, const char *key);
60 void rpmluaSetData(rpmlua lua, const char *key, const void *data);
61
62 char *rpmluaPopPrintBuffer(rpmlua lua);
63 void rpmluaPushPrintBuffer(rpmlua lua);
64
65 void rpmluaSetNextFileFunc(char *(*func)(void *), void *funcParam);
66
67 void rpmluaGetVar(rpmlua lua, rpmluav var);
68 void rpmluaSetVar(rpmlua lua, rpmluav var);
69 void rpmluaDelVar(rpmlua lua, const char *key, ...);
70 int rpmluaVarExists(rpmlua lua, const char *key, ...);
71 void rpmluaPushTable(rpmlua lua, const char *key, ...);
72 void rpmluaPop(rpmlua lua);
73
74 rpmluav rpmluavNew(void);
75 rpmluav rpmluavFree(rpmluav var);
76 void rpmluavSetListMode(rpmluav var, int flag);
77 void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value);
78 void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value);
79 void rpmluavGetKey(rpmluav var, rpmluavType *type, void **value);
80 void rpmluavGetValue(rpmluav var, rpmluavType *type, void **value);
81
82 /* Optional helpers for numbers. */
83 void rpmluavSetKeyNum(rpmluav var, double value);
84 void rpmluavSetValueNum(rpmluav var, double value);
85 double rpmluavGetKeyNum(rpmluav var);
86 double rpmluavGetValueNum(rpmluav var);
87 int rpmluavKeyIsNum(rpmluav var);
88 int rpmluavValueIsNum(rpmluav var);
89
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #endif /* RPMLUA_H */