| 1 |
#ifndef ATHEME_PERL_H |
| 2 |
#define ATHEME_PERL_H |
| 3 |
|
| 4 |
#include <EXTERN.h> |
| 5 |
#include <perl.h> |
| 6 |
#include <XSUB.h> |
| 7 |
|
| 8 |
#undef _ |
| 9 |
|
| 10 |
#include "atheme.h" |
| 11 |
|
| 12 |
struct perl_command_ { |
| 13 |
command_t command; |
| 14 |
SV * handler; |
| 15 |
SV * help_func; |
| 16 |
}; |
| 17 |
|
| 18 |
typedef struct perl_command_ perl_command_t; |
| 19 |
|
| 20 |
void perl_command_handler(sourceinfo_t *si, const int parc, char **parv); |
| 21 |
void perl_command_help_func(sourceinfo_t *si, const char *subcmd); |
| 22 |
|
| 23 |
#define PERL_MODULE_NAME "scripting/perl" |
| 24 |
static const IV invalid_object_pointer = -1; |
| 25 |
|
| 26 |
void register_object_reference(SV *sv); |
| 27 |
void invalidate_object_references(void); |
| 28 |
void free_object_list(void); |
| 29 |
|
| 30 |
/* |
| 31 |
* Wrapper objects for collections. |
| 32 |
* |
| 33 |
* These objects hold a reference to the underlying collection, along with |
| 34 |
* knowledge of which Perl package to bless the contents into. |
| 35 |
*/ |
| 36 |
|
| 37 |
struct perl_list_ { |
| 38 |
mowgli_list_t *list; |
| 39 |
const char *package_name; |
| 40 |
}; |
| 41 |
|
| 42 |
typedef struct perl_list_ perl_list_t; |
| 43 |
|
| 44 |
static inline perl_list_t * perl_list_create(mowgli_list_t *list, const char *package) |
| 45 |
{ |
| 46 |
perl_list_t *ret = smalloc(sizeof(perl_list_t)); |
| 47 |
ret->list = list; |
| 48 |
ret->package_name = sstrdup(package); |
| 49 |
return ret; |
| 50 |
} |
| 51 |
|
| 52 |
/* |
| 53 |
* Utility functions for ease of XS coding |
| 54 |
*/ |
| 55 |
|
| 56 |
SV * bless_pointer_to_package(void *data, const char *package); |
| 57 |
|
| 58 |
#endif |