1 #ifndef __PERL_CORE_H 2 #define __PERL_CORE_H 3 4 typedef struct { 5 char *name; /* unique name */ 6 char *package; /* package name */ 7 8 /* Script can be loaded from a file, or from some data in memory */ 9 char *path; /* FILE: full path for file */ 10 char *data; /* DATA: data used for the script */ 11 } PERL_SCRIPT_REC; 12 13 extern GSList *perl_scripts; 14 15 /* Initialize perl interpreter */ 16 void perl_scripts_init(void); 17 /* Destroy all perl scripts and deinitialize perl interpreter */ 18 void perl_scripts_deinit(void); 19 /* Load all the scripts in the autorun/ folder */ 20 void perl_scripts_autorun(void); 21 22 /* Load a perl script, path must be a full path. */ 23 PERL_SCRIPT_REC *perl_script_load_file(const char *path); 24 /* Load a perl script from given data */ 25 PERL_SCRIPT_REC *perl_script_load_data(const char *data); 26 /* Unload perl script */ 27 void perl_script_unload(PERL_SCRIPT_REC *script); 28 29 /* Find loaded script by name */ 30 PERL_SCRIPT_REC *perl_script_find(const char *name); 31 /* Find loaded script by package */ 32 PERL_SCRIPT_REC *perl_script_find_package(const char *package); 33 34 /* Returns full path for the script */ 35 char *perl_script_get_path(const char *name); 36 /* Modify the script name so that all non-alphanumeric characters are 37 translated to '_' */ 38 void script_fix_name(char *name); 39 40 /* If core should handle printing script errors */ 41 void perl_core_print_script_error(int print); 42 43 /* Returns the perl module's API version. */ 44 int perl_get_api_version(void); 45 46 /* Checks that the API version is correct. */ 47 #define perl_api_version_check(library) \ 48 if (perl_get_api_version() != IRSSI_PERL_API_VERSION) { \ 49 die("Version of perl module (%d) doesn't match the " \ 50 "version of "library" library (%d)", \ 51 perl_get_api_version(), IRSSI_PERL_API_VERSION); \ 52 return; \ 53 } 54 55 void perl_core_init(void); 56 void perl_core_deinit(void); 57 58 #endif 59