Debian Codegraph @

modules/scripting/perl/api/perl_command.c

raw
1 #include "atheme_perl.h"
2
3 void perl_command_handler(sourceinfo_t *si, const int parc, char **parv)
4 {
5 perl_command_t * pc = (perl_command_t *) si->command;
6
7 dTHX;
8 dSP;
9 ENTER;
10 SAVETMPS;
11 PUSHMARK(SP);
12
13 XPUSHs(pc->handler);
14 SV *sourceinfo_sv = newSV(0);
15 sv_setref_pv(sourceinfo_sv, "Atheme::Sourceinfo", si);
16 XPUSHs(sv_2mortal(sourceinfo_sv));
17
18 for (int i = 0; i < parc; ++i)
19 XPUSHs(sv_2mortal(newSVpv(parv[i], 0)));
20
21 PUTBACK;
22 call_pv("Atheme::Init::call_wrapper", G_VOID | G_DISCARD | G_EVAL);
23 SPAGAIN;
24
25 if (SvTRUE(ERRSV))
26 {
27 command_fail(si, fault_unimplemented, _("Unexpected error occurred: %s"), SvPV_nolen(ERRSV));
28 slog(LG_ERROR, "Perl handler for command %s/%s returned error: %s",
29 si->service->internal_name, si->command->name, SvPV_nolen(ERRSV));
30 }
31
32 PUTBACK;
33 FREETMPS;
34 LEAVE;
35
36 /* Control has now handed back to Atheme, so all references held
37 * by Perl to Atheme objects are invalid.
38 */
39 invalidate_object_references();
40 }
41
42 void perl_command_help_func(sourceinfo_t *si, const char *subcmd)
43 {
44 command_fail(si, fault_unimplemented, _("Perl help commands not yet implemented"));
45 }