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