File: perl_command.c

package info (click to toggle)
atheme-services 7.2.12-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,256 kB
  • sloc: ansic: 95,899; sh: 8,462; php: 5,032; perl: 3,327; makefile: 1,279; sed: 16; ruby: 15; python: 3
file content (45 lines) | stat: -rw-r--r-- 1,116 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "atheme_perl.h"

void perl_command_handler(sourceinfo_t *si, const int parc, char **parv)
{
	perl_command_t * pc = (perl_command_t *) si->command;

	dTHX;
	dSP;
	ENTER;
	SAVETMPS;
	PUSHMARK(SP);

	XPUSHs(pc->handler);
	SV *sourceinfo_sv = newSV(0);
	sv_setref_pv(sourceinfo_sv, "Atheme::Sourceinfo", si);
	XPUSHs(sv_2mortal(sourceinfo_sv));

	for (int i = 0; i < parc; ++i)
		XPUSHs(sv_2mortal(newSVpv(parv[i], 0)));

	PUTBACK;
	call_pv("Atheme::Init::call_wrapper", G_VOID | G_DISCARD | G_EVAL);
	SPAGAIN;

	if (SvTRUE(ERRSV))
	{
		command_fail(si, fault_unimplemented, _("Unexpected error occurred: %s"), SvPV_nolen(ERRSV));
		slog(LG_ERROR, "Perl handler for command %s/%s returned error: %s",
				si->service->internal_name, si->command->name, SvPV_nolen(ERRSV));
	}

	PUTBACK;
	FREETMPS;
	LEAVE;

	/* Control has now handed back to Atheme, so all references held
	 * by Perl to Atheme objects are invalid.
	 */
	invalidate_object_references();
}

void perl_command_help_func(sourceinfo_t *si, const char *subcmd)
{
	command_fail(si, fault_unimplemented, _("Perl help commands not yet implemented"));
}