rpm 5.3.7

rpmio/rpmlua.h

Go to the documentation of this file.
00001 #ifndef RPMLUA_H
00002 #define RPMLUA_H
00003 
00004 typedef enum rpmluavType_e {
00005     RPMLUAV_NIL         = 0,
00006     RPMLUAV_STRING      = 1,
00007     RPMLUAV_NUMBER      = 2
00008 } rpmluavType;
00009 
00010 #if defined(_RPMLUA_INTERNAL)
00011 
00012 #include <stdarg.h>
00013 #include <lua.h>
00014 
00015 struct rpmlua_s {
00016     struct rpmioItem_s _item;   
00017     lua_State *L;
00018     int pushsize;
00019     int storeprint;
00020     size_t printbufsize;
00021     size_t printbufused;
00022 /*@relnull@*/
00023     char *printbuf;
00024 #if defined(__LCLINT__)
00025 /*@refs@*/
00026     int nrefs;                  
00027 #endif
00028 };
00029 
00030 struct rpmluav_s {
00031     struct rpmioItem_s _item;   
00032     rpmluavType keyType;
00033     rpmluavType valueType;
00034     union {
00035         const char *str;
00036         const void *ptr;
00037         double num;
00038     } key;
00039     union {
00040         const char *str;
00041         const void *ptr;
00042         double num;
00043     } value;
00044     int listmode;
00045 #if defined(__LCLINT__)
00046 /*@refs@*/
00047     int nrefs;                  
00048 #endif
00049 };
00050 
00051 #endif /* _RPMLUA_INTERNAL */
00052 
00053 typedef /*@abstract@*/ struct rpmlua_s * rpmlua;
00054 typedef /*@abstract@*/ struct rpmluav_s * rpmluav;
00055 
00056 #ifdef __cplusplus
00057 extern "C" {
00058 #endif
00059 
00060 /*@unchecked@*/ /*@observer@*/
00061 extern const char * rpmluaFiles;
00062 
00063 /*@unchecked@*/ /*@observer@*/
00064 extern const char * rpmluaPath;
00065 
00066 /*@-exportlocal@*/
00067 /*@only@*/ /*@exposed@*/ /*@relnull@*/
00068 rpmlua rpmluaGetGlobalState(void)
00069         /*@*/;
00070 
00071 rpmlua rpmluaNew(void)
00072         /*@globals fileSystem, internalState @*/
00073         /*@modifies fileSystem, internalState @*/;
00074 /*@=exportlocal@*/
00075 /*@null@*/
00076 void *rpmluaFree(/*@only@*/ rpmlua lua)
00077         /*@globals internalState @*/
00078         /*@modifies lua, internalState @*/;
00079 
00080 int rpmluaCheckScript(/*@null@*/ rpmlua _lua, const char *script,
00081                       /*@null@*/ const char *name)
00082         /*@globals fileSystem, internalState @*/
00083         /*@modifies _lua, fileSystem, internalState @*/;
00084 int rpmluaRunScript(/*@null@*/ rpmlua _lua, const char *script,
00085                     /*@null@*/ const char *name)
00086         /*@globals fileSystem, internalState @*/
00087         /*@modifies _lua, fileSystem, internalState @*/;
00088 /*@-exportlocal@*/
00089 int rpmluaRunScriptFile(/*@null@*/ rpmlua _lua, const char *filename)
00090         /*@globals fileSystem, internalState @*/
00091         /*@modifies _lua, fileSystem, internalState @*/;
00092 /*@=exportlocal@*/
00093 void rpmluaInteractive(/*@null@*/ rpmlua _lua)
00094         /*@globals fileSystem, internalState @*/
00095         /*@modifies _lua, fileSystem, internalState @*/;
00096 
00097 /*@null@*/
00098 void *rpmluaGetData(/*@null@*/ rpmlua _lua, const char *key)
00099         /*@globals fileSystem, internalState @*/
00100         /*@modifies _lua, fileSystem, internalState @*/;
00101 /*@-exportlocal@*/
00102 void rpmluaSetData(/*@null@*/ rpmlua _lua, const char *key, const void *data)
00103         /*@globals fileSystem, internalState @*/
00104         /*@modifies _lua, fileSystem, internalState @*/;
00105 /*@=exportlocal@*/
00106 
00107 /*@exposed@*/
00108 const char *rpmluaGetPrintBuffer(/*@null@*/ rpmlua _lua)
00109         /*@globals fileSystem, internalState @*/
00110         /*@modifies _lua, fileSystem, internalState @*/;
00111 void rpmluaSetPrintBuffer(/*@null@*/ rpmlua _lua, int flag)
00112         /*@globals fileSystem, internalState @*/
00113         /*@modifies _lua, fileSystem, internalState @*/;
00114 
00115 void rpmluaGetVar(/*@null@*/ rpmlua _lua, rpmluav var)
00116         /*@globals fileSystem, internalState @*/
00117         /*@modifies _lua, var, fileSystem, internalState @*/;
00118 void rpmluaSetVar(/*@null@*/ rpmlua _lua, rpmluav var)
00119         /*@globals fileSystem, internalState @*/
00120         /*@modifies _lua, var, fileSystem, internalState @*/;
00121 void rpmluaDelVar(/*@null@*/ rpmlua _lua, const char *key, ...)
00122         /*@globals fileSystem, internalState @*/
00123         /*@modifies _lua, fileSystem, internalState @*/;
00124 int rpmluaVarExists(/*@null@*/ rpmlua _lua, const char *key, ...)
00125         /*@globals fileSystem, internalState @*/
00126         /*@modifies _lua, fileSystem, internalState @*/;
00127 void rpmluaPushTable(/*@null@*/ rpmlua _lua, const char *key, ...)
00128         /*@globals fileSystem, internalState @*/
00129         /*@modifies _lua, fileSystem, internalState @*/;
00130 #if defined(_RPMLUA_INTERNAL)
00131 void rpmluaPop(/*@null@*/ rpmlua _lua)
00132         /*@globals fileSystem, internalState @*/
00133         /*@modifies _lua, fileSystem, internalState @*/;
00134 #endif
00135 
00136 /*@only@*/
00137 rpmluav rpmluavNew(void)
00138         /*@*/;
00139 /*@null@*/
00140 void * rpmluavFree(/*@only@*/ rpmluav var)
00141         /*@modifes var @*/;
00142 void rpmluavSetListMode(rpmluav var, int flag)
00143         /*@modifies var @*/;
00144 /*@-exportlocal@*/
00145 void rpmluavSetKey(rpmluav var, rpmluavType type, const void *value)
00146         /*@modifies var @*/;
00147 /*@=exportlocal@*/
00148 /*@-exportlocal@*/
00149 void rpmluavSetValue(rpmluav var, rpmluavType type, const void *value)
00150         /*@modifies var @*/;
00151 /*@=exportlocal@*/
00152 /*@-exportlocal@*/
00153 void rpmluavGetKey(rpmluav var, /*@out@*/ rpmluavType *type, /*@out@*/ void **value)
00154         /*@modifies *type, *value @*/;
00155 /*@=exportlocal@*/
00156 /*@-exportlocal@*/
00157 void rpmluavGetValue(rpmluav var, /*@out@*/ rpmluavType *type, /*@out@*/ void **value)
00158         /*@modifies *type, *value @*/;
00159 /*@=exportlocal@*/
00160 
00161 /* Optional helpers for numbers. */
00162 void rpmluavSetKeyNum(rpmluav var, double value)
00163         /*@modifies var @*/;
00164 void rpmluavSetValueNum(rpmluav var, double value)
00165         /*@modifies var @*/;
00166 double rpmluavGetKeyNum(rpmluav var)
00167         /*@*/;
00168 double rpmluavGetValueNum(rpmluav var)
00169         /*@*/;
00170 int rpmluavKeyIsNum(rpmluav var)
00171         /*@*/;
00172 int rpmluavValueIsNum(rpmluav var)
00173         /*@*/;
00174 
00175 #ifdef __cplusplus
00176 }
00177 #endif
00178 
00179 #endif /* RPMLUA_H */