2014-03-27 15:34:17 +00:00
|
|
|
#ifndef R2_LANG_H
|
|
|
|
#define R2_LANG_H
|
2009-02-05 21:08:46 +00:00
|
|
|
|
|
|
|
#include <r_types.h>
|
2011-02-06 13:10:16 +00:00
|
|
|
#include <r_list.h>
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2013-06-18 10:09:23 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2013-06-14 00:51:33 +00:00
|
|
|
R_LIB_VERSION_HEADER(r_lang);
|
|
|
|
|
2015-03-19 01:48:44 +00:00
|
|
|
typedef char* (*RCoreCmdStrCallback)(void* core, const char *s);
|
2016-05-31 00:32:30 +00:00
|
|
|
typedef int (*RCoreCmdfCallback)(void* core, const char *s, ...);
|
2014-12-19 02:17:28 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
typedef struct r_lang_t {
|
2010-05-25 23:42:22 +00:00
|
|
|
struct r_lang_plugin_t *cur;
|
2009-09-19 23:03:57 +00:00
|
|
|
void *user;
|
2011-02-06 13:10:16 +00:00
|
|
|
RList *defs;
|
|
|
|
RList *langs;
|
2015-08-08 18:15:13 +00:00
|
|
|
PrintfCallback cb_printf;
|
2015-03-19 01:48:44 +00:00
|
|
|
RCoreCmdStrCallback cmd_str;
|
2016-05-31 00:32:30 +00:00
|
|
|
RCoreCmdfCallback cmdf;
|
2010-01-26 00:28:33 +00:00
|
|
|
} RLang;
|
2009-09-19 23:03:57 +00:00
|
|
|
|
2010-05-25 23:42:22 +00:00
|
|
|
typedef struct r_lang_plugin_t {
|
2009-02-11 12:31:26 +00:00
|
|
|
const char *name;
|
2017-05-27 23:50:08 +00:00
|
|
|
const char *alias;
|
2009-02-11 12:31:26 +00:00
|
|
|
const char *desc;
|
2016-05-31 00:32:30 +00:00
|
|
|
const char *license;
|
2009-02-14 11:49:02 +00:00
|
|
|
const char **help;
|
2013-08-17 17:53:04 +00:00
|
|
|
const char *ext;
|
2012-07-21 10:11:21 +00:00
|
|
|
int (*init)(RLang *user);
|
2017-05-09 00:42:51 +00:00
|
|
|
bool (*setup)(RLang *user);
|
2012-07-21 10:11:21 +00:00
|
|
|
int (*fini)(RLang *user);
|
|
|
|
int (*prompt)(RLang *user);
|
|
|
|
int (*run)(RLang *user, const char *code, int len);
|
|
|
|
int (*run_file)(RLang *user, const char *file);
|
|
|
|
int (*set_argv)(RLang *user, int argc, char **argv);
|
2010-05-25 23:42:22 +00:00
|
|
|
} RLangPlugin;
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
typedef struct r_lang_def_t {
|
2009-09-19 23:03:57 +00:00
|
|
|
char *name;
|
|
|
|
char *type;
|
|
|
|
void *value;
|
2010-01-26 00:28:33 +00:00
|
|
|
} RLangDef;
|
2009-09-19 23:03:57 +00:00
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
#ifdef R_API
|
2015-01-13 02:40:01 +00:00
|
|
|
R_API RLang *r_lang_new(void);
|
2011-02-06 13:10:16 +00:00
|
|
|
R_API void *r_lang_free(RLang *lang);
|
2017-05-09 00:42:51 +00:00
|
|
|
R_API bool r_lang_setup(RLang *lang);
|
|
|
|
R_API bool r_lang_add(RLang *lang, RLangPlugin *foo);
|
|
|
|
R_API bool r_lang_list(RLang *lang);
|
|
|
|
R_API bool r_lang_use(RLang *lang, const char *name);
|
2011-02-06 13:10:16 +00:00
|
|
|
R_API int r_lang_run(RLang *lang, const char *code, int len);
|
2010-04-09 13:57:22 +00:00
|
|
|
R_API int r_lang_run_string(RLang *lang, const char *code);
|
2009-09-19 23:03:57 +00:00
|
|
|
/* TODO: user_ptr must be deprecated */
|
2011-02-06 13:10:16 +00:00
|
|
|
R_API void r_lang_set_user_ptr(RLang *lang, void *user);
|
2017-05-09 00:42:51 +00:00
|
|
|
R_API bool r_lang_set_argv(RLang *lang, int argc, char **argv);
|
2011-02-06 13:10:16 +00:00
|
|
|
R_API int r_lang_run(RLang *lang, const char *code, int len);
|
|
|
|
R_API int r_lang_run_file(RLang *lang, const char *file);
|
|
|
|
R_API int r_lang_prompt(RLang *lang);
|
2012-07-21 10:11:21 +00:00
|
|
|
R_API void r_lang_plugin_free(RLangPlugin *p); // XXX
|
2013-08-17 17:53:04 +00:00
|
|
|
R_API RLangPlugin *r_lang_get_by_name(RLang *lang, const char *name);
|
|
|
|
R_API RLangPlugin *r_lang_get_by_extension(RLang *lang, const char *ext);
|
2011-02-06 13:10:16 +00:00
|
|
|
// TODO: rename r_Lang_add for r_lang_plugin_add
|
2009-02-05 21:08:46 +00:00
|
|
|
|
2017-05-09 00:42:51 +00:00
|
|
|
R_API bool r_lang_define(RLang *lang, const char *type, const char *name, void *value);
|
2011-02-06 13:10:16 +00:00
|
|
|
R_API void r_lang_undef(RLang *lang, const char *name);
|
2012-07-21 10:11:21 +00:00
|
|
|
R_API void r_lang_def_free(RLangDef *def);
|
2013-06-18 10:09:23 +00:00
|
|
|
|
2009-02-05 21:08:46 +00:00
|
|
|
#endif
|
2013-06-18 10:09:23 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-12-24 02:17:53 +00:00
|
|
|
#endif
|