mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-03 16:04:44 +01:00
Perl typemap for const char* subprofiles[]
This is the only language-dependent nontrivial portion of the SWIG bindings, and this should be good enough for anyone who is still using the Perl bindings now Signed-off-by: Ryan Lee <ryan.lee@canonical.com>
This commit is contained in:
parent
e085a23b40
commit
5730fb6d2d
1 changed files with 29 additions and 0 deletions
|
@ -278,6 +278,35 @@ extern int aa_is_enabled(void);
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPERL
|
||||
// Copied from perl's argcargv.i, which should be good enough for us
|
||||
%typemap(in) (const char *subprofiles[]) {
|
||||
int i;
|
||||
SSize_t len;
|
||||
AV *av = (AV *)SvRV($input);
|
||||
if (SvTYPE(av) != SVt_PVAV) {
|
||||
SWIG_croak("in method '$symname', Expecting reference to argv array");
|
||||
goto fail;
|
||||
}
|
||||
len = av_len(av) + 1;
|
||||
$1 = (char **) malloc((len+1)*sizeof(char *));
|
||||
for (i = 0; i < len; i++) {
|
||||
SV **tv = av_fetch(av, i, 0);
|
||||
$1[i] = SvPV_nolen(*tv);
|
||||
}
|
||||
$1[i] = NULL;
|
||||
}
|
||||
|
||||
%typemap(typecheck, precedence=SWIG_TYPECHECK_STRING_ARRAY) (const char *subprofiles[]) {
|
||||
AV *av = (AV *)SvRV($input);
|
||||
$1 = SvTYPE(av) == SVt_PVAV;
|
||||
}
|
||||
|
||||
%typemap(freearg) (const char *subprofiles[]) {
|
||||
free((void *)$1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* These should not receive the VOID_Object typemap */
|
||||
extern int aa_change_hat(const char *subprofile, unsigned long magic_token);
|
||||
extern int aa_change_profile(const char *profile);
|
||||
|
|
Loading…
Add table
Reference in a new issue