This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[asperl] various tweaks
[perl5.git] / mg.h
CommitLineData
a0d0e21e 1/* mg.h
79072805 2 *
9607fc9c 3 * Copyright (c) 1991-1997, Larry Wall
79072805
LW
4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
79072805
LW
8 */
9
10struct mgvtbl {
76e3520e
GS
11 int (CPERLscope(*svt_get)) _((SV *sv, MAGIC* mg));
12 int (CPERLscope(*svt_set)) _((SV *sv, MAGIC* mg));
13 U32 (CPERLscope(*svt_len)) _((SV *sv, MAGIC* mg));
14 int (CPERLscope(*svt_clear)) _((SV *sv, MAGIC* mg));
15 int (CPERLscope(*svt_free)) _((SV *sv, MAGIC* mg));
79072805
LW
16};
17
18struct magic {
19 MAGIC* mg_moremagic;
20 MGVTBL* mg_virtual; /* pointer to magic functions */
21 U16 mg_private;
22 char mg_type;
23 U8 mg_flags;
24 SV* mg_obj;
25 char* mg_ptr;
76e3520e 26 I32 mg_length;
79072805 27};
8990e307
LW
28
29#define MGf_TAINTEDDIR 1
85e6fe83 30#define MGf_REFCOUNTED 2
a0d0e21e 31#define MGf_GSKIP 4
748a9306
LW
32
33#define MGf_MINMATCH 1
34
1e422769
PP
35#define MgTAINTEDDIR(mg) (mg->mg_flags & MGf_TAINTEDDIR)
36#define MgTAINTEDDIR_on(mg) (mg->mg_flags |= MGf_TAINTEDDIR)
37#define MgTAINTEDDIR_off(mg) (mg->mg_flags &= ~MGf_TAINTEDDIR)
99069129 38
76e3520e 39#define MgPV(mg,lp) (((lp = (mg)->mg_length) == HEf_SVKEY) ? \
5aabfad6
PP
40 SvPV((SV*)((mg)->mg_ptr),lp) : \
41 (mg)->mg_ptr)