rpm  5.2.1
rpmlua.h
Go to the documentation of this file.
1 #ifndef RPMLUA_H
2 #define RPMLUA_H
3 
4 typedef enum rpmluavType_e {
9 
10 #if defined(_RPMLUA_INTERNAL)
11 
12 #include <stdarg.h>
13 #include <lua.h>
14 
15 struct rpmlua_s {
16  struct rpmioItem_s _item;
17  lua_State *L;
18  int pushsize;
19  int storeprint;
20  size_t printbufsize;
21  size_t printbufused;
22 /*@relnull@*/
23  char *printbuf;
24 };
25 
26 struct rpmluav_s {
27  struct rpmioItem_s _item;
28  rpmluavType keyType;
29  rpmluavType valueType;
30  union {
31  const char *str;
32  const void *ptr;
33  double num;
34  } key;
35  union {
36  const char *str;
37  const void *ptr;
38  double num;
39  } value;
40  int listmode;
41 };
42 
43 #endif /* _RPMLUA_INTERNAL */
44 
45 typedef /*@abstract@*/ struct rpmlua_s * rpmlua;
46 typedef /*@abstract@*/ struct rpmluav_s * rpmluav;
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 /*@unchecked@*/ /*@observer@*/
53 extern const char * rpmluaFiles;
54 
55 /*@unchecked@*/ /*@observer@*/
56 extern const char * rpmluaPath;
57 
58 /*@-exportlocal@*/
59 /*@only@*/ /*@exposed@*/ /*@relnull@*/
60 rpmlua rpmluaGetGlobalState(void)
61  /*@*/;
62 
63 rpmlua rpmluaNew(void)
64  /*@globals fileSystem, internalState @*/
65  /*@modifies fileSystem, internalState @*/;
66 /*@=exportlocal@*/
67 /*@null@*/
68 void *rpmluaFree(/*@only@*/ rpmlua lua)
69  /*@globals internalState @*/
70  /*@modifies lua, internalState @*/;
71 
72 int rpmluaCheckScript(/*@null@*/ rpmlua _lua, const char *script,
73  /*@null@*/ const char *name)
74  /*@globals fileSystem, internalState @*/
75  /*@modifies _lua, fileSystem, internalState @*/;
76 int rpmluaRunScript(/*@null@*/ rpmlua _lua, const char *script,
77  /*@null@*/ const char *name)
78  /*@globals fileSystem, internalState @*/
79  /*@modifies _lua, fileSystem, internalState @*/;
80 /*@-exportlocal@*/
81 int rpmluaRunScriptFile(/*@null@*/ rpmlua _lua, const char *filename)
82  /*@globals fileSystem, internalState @*/
83  /*@modifies _lua, fileSystem, internalState @*/;
84 /*@=exportlocal@*/
85 void rpmluaInteractive(/*@null@*/ rpmlua _lua)
86  /*@globals fileSystem, internalState @*/
87  /*@modifies _lua, fileSystem, internalState @*/;
88 
89 /*@null@*/
90 void *rpmluaGetData(/*@null@*/ rpmlua _lua, const char *key)
91  /*@globals fileSystem, internalState @*/
92  /*@modifies _lua, fileSystem, internalState @*/;
93 /*@-exportlocal@*/
94 void rpmluaSetData(/*@null@*/ rpmlua _lua, const char *key, const void *data)
95  /*@globals fileSystem, internalState @*/
96  /*@modifies _lua, fileSystem, internalState @*/;
97 /*@=exportlocal@*/
98 
99 /*@exposed@*/
100 const char *rpmluaGetPrintBuffer(/*@null@*/ rpmlua _lua)
101  /*@globals fileSystem, internalState @*/
102  /*@modifies _lua, fileSystem, internalState @*/;
103 void rpmluaSetPrintBuffer(/*@null@*/ rpmlua _lua, int flag)
104  /*@globals fileSystem, internalState @*/
105  /*@modifies _lua, fileSystem, internalState @*/;
106 
107 void rpmluaGetVar(/*@null@*/ rpmlua _lua, rpmluav var)
108  /*@globals fileSystem, internalState @*/
109  /*@modifies _lua, var, fileSystem, internalState @*/;
110 void rpmluaSetVar(/*@null@*/ rpmlua _lua, rpmluav var)
111  /*@globals fileSystem, internalState @*/
112  /*@modifies _lua, var, fileSystem, internalState @*/;
113 void rpmluaDelVar(/*@null@*/ rpmlua _lua, const char *key, ...)
114  /*@globals fileSystem, internalState @*/
115  /*@modifies _lua, fileSystem, internalState @*/;
116 int rpmluaVarExists(/*@null@*/ rpmlua _lua, const char *key, ...)
117  /*@globals fileSystem, internalState @*/
118  /*@modifies _lua, fileSystem, internalState @*/;
119 void rpmluaPushTable(/*@null@*/ rpmlua _lua, const char *key, ...)
120  /*@globals fileSystem, internalState @*/
121  /*@modifies _lua, fileSystem, internalState @*/;
122 void rpmluaPop(/*@null@*/ rpmlua _lua)
123  /*@globals fileSystem, internalState @*/
124  /*@modifies _lua, fileSystem, internalState @*/;
125 
126 /*@only@*/
127 rpmluav rpmluavNew(void)
128  /*@*/;
129 /*@null@*/
130 void * rpmluavFree(/*@only@*/ rpmluav var)
131  /*@modifes var @*/;
132 void rpmluavSetListMode(rpmluav var, int flag)
133  /*@modifies var @*/;
134 /*@-exportlocal@*/
135 void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value)
136  /*@modifies var @*/;
137 /*@=exportlocal@*/
138 /*@-exportlocal@*/
139 void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value)
140  /*@modifies var @*/;
141 /*@=exportlocal@*/
142 /*@-exportlocal@*/
143 void rpmluavGetKey(rpmluav var, /*@out@*/ rpmluavType *type, /*@out@*/ void **value)
144  /*@modifies *type, *value @*/;
145 /*@=exportlocal@*/
146 /*@-exportlocal@*/
147 void rpmluavGetValue(rpmluav var, /*@out@*/ rpmluavType *type, /*@out@*/ void **value)
148  /*@modifies *type, *value @*/;
149 /*@=exportlocal@*/
150 
151 /* Optional helpers for numbers. */
152 void rpmluavSetKeyNum(rpmluav var, double value)
153  /*@modifies var @*/;
154 void rpmluavSetValueNum(rpmluav var, double value)
155  /*@modifies var @*/;
156 double rpmluavGetKeyNum(rpmluav var)
157  /*@*/;
158 double rpmluavGetValueNum(rpmluav var)
159  /*@*/;
160 int rpmluavKeyIsNum(rpmluav var)
161  /*@*/;
162 int rpmluavValueIsNum(rpmluav var)
163  /*@*/;
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif /* RPMLUA_H */