2019-05-01 16:22:22 -04:00
|
|
|
#ifndef IRSSI_PERL_PERL_CORE_H
|
|
|
|
#define IRSSI_PERL_PERL_CORE_H
|
2001-07-29 05:17:53 -04:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char *name; /* unique name */
|
|
|
|
char *package; /* package name */
|
|
|
|
|
|
|
|
/* Script can be loaded from a file, or from some data in memory */
|
|
|
|
char *path; /* FILE: full path for file */
|
|
|
|
char *data; /* DATA: data used for the script */
|
2020-07-05 19:20:08 -04:00
|
|
|
int refcount; /* 0 = destroy */
|
2001-07-29 05:17:53 -04:00
|
|
|
} PERL_SCRIPT_REC;
|
|
|
|
|
|
|
|
extern GSList *perl_scripts;
|
|
|
|
|
|
|
|
/* Initialize perl interpreter */
|
|
|
|
void perl_scripts_init(void);
|
|
|
|
/* Destroy all perl scripts and deinitialize perl interpreter */
|
|
|
|
void perl_scripts_deinit(void);
|
2016-09-11 10:59:21 -04:00
|
|
|
/* Load all the scripts in the autorun/ folder */
|
|
|
|
void perl_scripts_autorun(void);
|
2001-07-29 05:17:53 -04:00
|
|
|
|
|
|
|
/* Load a perl script, path must be a full path. */
|
|
|
|
PERL_SCRIPT_REC *perl_script_load_file(const char *path);
|
|
|
|
/* Load a perl script from given data */
|
|
|
|
PERL_SCRIPT_REC *perl_script_load_data(const char *data);
|
|
|
|
/* Unload perl script */
|
|
|
|
void perl_script_unload(PERL_SCRIPT_REC *script);
|
|
|
|
|
2020-07-05 17:31:07 -04:00
|
|
|
/* Mark a script as entered */
|
2020-07-05 19:20:08 -04:00
|
|
|
void perl_script_ref(PERL_SCRIPT_REC *script);
|
2020-07-05 17:31:07 -04:00
|
|
|
/* Mark a script as exited */
|
2020-07-05 19:20:08 -04:00
|
|
|
void perl_script_unref(PERL_SCRIPT_REC *script);
|
2020-07-05 17:31:07 -04:00
|
|
|
|
2001-07-29 05:17:53 -04:00
|
|
|
/* Find loaded script by name */
|
|
|
|
PERL_SCRIPT_REC *perl_script_find(const char *name);
|
|
|
|
/* Find loaded script by package */
|
|
|
|
PERL_SCRIPT_REC *perl_script_find_package(const char *package);
|
|
|
|
|
|
|
|
/* Returns full path for the script */
|
|
|
|
char *perl_script_get_path(const char *name);
|
2001-11-25 11:17:44 -05:00
|
|
|
/* Modify the script name so that all non-alphanumeric characters are
|
|
|
|
translated to '_' */
|
|
|
|
void script_fix_name(char *name);
|
2001-07-29 05:17:53 -04:00
|
|
|
|
2001-10-20 09:19:25 -04:00
|
|
|
/* If core should handle printing script errors */
|
|
|
|
void perl_core_print_script_error(int print);
|
|
|
|
|
|
|
|
/* Returns the perl module's API version. */
|
|
|
|
int perl_get_api_version(void);
|
|
|
|
|
|
|
|
/* Checks that the API version is correct. */
|
|
|
|
#define perl_api_version_check(library) \
|
|
|
|
if (perl_get_api_version() != IRSSI_PERL_API_VERSION) { \
|
2001-11-11 17:39:56 -05:00
|
|
|
die("Version of perl module (%d) doesn't match the " \
|
|
|
|
"version of "library" library (%d)", \
|
|
|
|
perl_get_api_version(), IRSSI_PERL_API_VERSION); \
|
2001-10-20 09:19:25 -04:00
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
2001-07-29 05:17:53 -04:00
|
|
|
void perl_core_init(void);
|
|
|
|
void perl_core_deinit(void);
|
|
|
|
|
|
|
|
#endif
|