This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Handle PERLIO= and document a bit.
[perl5.git] / mg.h
CommitLineData
a0d0e21e 1/* mg.h
79072805 2 *
3f774658 3 * Copyright (c) 1991-2002, 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
0f4eea8f
DL
10#ifdef STRUCT_MGVTBL_DEFINITION
11STRUCT_MGVTBL_DEFINITION;
12#else
79072805 13struct mgvtbl {
cea2e8a9
GS
14 int (CPERLscope(*svt_get)) (pTHX_ SV *sv, MAGIC* mg);
15 int (CPERLscope(*svt_set)) (pTHX_ SV *sv, MAGIC* mg);
16 U32 (CPERLscope(*svt_len)) (pTHX_ SV *sv, MAGIC* mg);
17 int (CPERLscope(*svt_clear))(pTHX_ SV *sv, MAGIC* mg);
18 int (CPERLscope(*svt_free)) (pTHX_ SV *sv, MAGIC* mg);
68795e93
NIS
19 int (CPERLscope(*svt_copy)) (pTHX_ SV *sv, MAGIC* mg,
20 SV *nsv, const char *name, int namlen);
21 int (CPERLscope(*svt_dup)) (pTHX_ MAGIC *mg, CLONE_PARAMS *param);
79072805 22};
0f4eea8f 23#endif
79072805
LW
24
25struct magic {
26 MAGIC* mg_moremagic;
27 MGVTBL* mg_virtual; /* pointer to magic functions */
28 U16 mg_private;
29 char mg_type;
30 U8 mg_flags;
31 SV* mg_obj;
32 char* mg_ptr;
565764a8 33 I32 mg_len;
79072805 34};
8990e307 35
cb50f42d
YST
36#define MGf_TAINTEDDIR 1 /* PERL_MAGIC_envelem only */
37#define MGf_MINMATCH 1 /* PERL_MAGIC_regex_global only */
85e6fe83 38#define MGf_REFCOUNTED 2
a0d0e21e 39#define MGf_GSKIP 4
68795e93
NIS
40#define MGf_COPY 8
41#define MGf_DUP 16
748a9306 42
1e422769
PP
43#define MgTAINTEDDIR(mg) (mg->mg_flags & MGf_TAINTEDDIR)
44#define MgTAINTEDDIR_on(mg) (mg->mg_flags |= MGf_TAINTEDDIR)
45#define MgTAINTEDDIR_off(mg) (mg->mg_flags &= ~MGf_TAINTEDDIR)
99069129 46
32da55ab 47#define MgPV(mg,lp) ((((int)(lp = (mg)->mg_len)) == HEf_SVKEY) ? \
5aabfad6
PP
48 SvPV((SV*)((mg)->mg_ptr),lp) : \
49 (mg)->mg_ptr)
33c27489
GS
50
51#define SvTIED_mg(sv,how) \
52 (SvRMAGICAL(sv) ? mg_find((sv),(how)) : Null(MAGIC*))
53#define SvTIED_obj(sv,mg) \
54 ((mg)->mg_obj ? (mg)->mg_obj : sv_2mortal(newRV(sv)))