RE: [PATCH] compress 2.018
[p5sagit/p5-mst-13.2.git] / mg.h
CommitLineData
a0d0e21e 1/* mg.h
79072805 2 *
4bb101f2 3 * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999,
1129b882 4 * 2000, 2002, 2005, 2006, 2007, 2008 by Larry Wall and others
79072805 5 *
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
8 *
79072805 9 */
10
0f4eea8f 11#ifdef STRUCT_MGVTBL_DEFINITION
12STRUCT_MGVTBL_DEFINITION;
13#else
79072805 14struct mgvtbl {
cea2e8a9 15 int (CPERLscope(*svt_get)) (pTHX_ SV *sv, MAGIC* mg);
16 int (CPERLscope(*svt_set)) (pTHX_ SV *sv, MAGIC* mg);
17 U32 (CPERLscope(*svt_len)) (pTHX_ SV *sv, MAGIC* mg);
18 int (CPERLscope(*svt_clear))(pTHX_ SV *sv, MAGIC* mg);
19 int (CPERLscope(*svt_free)) (pTHX_ SV *sv, MAGIC* mg);
68795e93 20 int (CPERLscope(*svt_copy)) (pTHX_ SV *sv, MAGIC* mg,
3468c7ea 21 SV *nsv, const char *name, I32 namlen);
68795e93 22 int (CPERLscope(*svt_dup)) (pTHX_ MAGIC *mg, CLONE_PARAMS *param);
a5063e7c 23 int (CPERLscope(*svt_local))(pTHX_ SV *nsv, MAGIC *mg);
79072805 24};
0f4eea8f 25#endif
79072805 26
27struct magic {
28 MAGIC* mg_moremagic;
92e67595 29 MGVTBL* mg_virtual; /* pointer to magic functions */
79072805 30 U16 mg_private;
31 char mg_type;
32 U8 mg_flags;
9bd87817 33 I32 mg_len;
79072805 34 SV* mg_obj;
35 char* mg_ptr;
79072805 36};
8990e307 37
cb50f42d 38#define MGf_TAINTEDDIR 1 /* PERL_MAGIC_envelem only */
39#define MGf_MINMATCH 1 /* PERL_MAGIC_regex_global only */
85e6fe83 40#define MGf_REFCOUNTED 2
a0d0e21e 41#define MGf_GSKIP 4
a5063e7c 42#define MGf_COPY 8 /* has an svt_copy MGVTBL entry */
43#define MGf_DUP 0x10 /* has an svt_dup MGVTBL entry */
44#define MGf_LOCAL 0x20 /* has an svt_local MGVTBL entry */
748a9306 45
1e422769 46#define MgTAINTEDDIR(mg) (mg->mg_flags & MGf_TAINTEDDIR)
47#define MgTAINTEDDIR_on(mg) (mg->mg_flags |= MGf_TAINTEDDIR)
48#define MgTAINTEDDIR_off(mg) (mg->mg_flags &= ~MGf_TAINTEDDIR)
99069129 49
32da55ab 50#define MgPV(mg,lp) ((((int)(lp = (mg)->mg_len)) == HEf_SVKEY) ? \
b1bc3f34 51 SvPV(MUTABLE_SV((mg)->mg_ptr),lp) : \
5aabfad6 52 (mg)->mg_ptr)
01b8bcb7 53#define MgPV_const(mg,lp) ((((int)(lp = (mg)->mg_len)) == HEf_SVKEY) ? \
b1bc3f34 54 SvPV_const(MUTABLE_SV((mg)->mg_ptr),lp) : \
01b8bcb7 55 (const char*)(mg)->mg_ptr)
b1bc3f34 56#define MgPV_nolen_const(mg) (((((int)(mg)->mg_len)) == HEf_SVKEY) ? \
57 SvPV_nolen_const(MUTABLE_SV((mg)->mg_ptr)) : \
fa28a6c6 58 (const char*)(mg)->mg_ptr)
33c27489 59
4608196e 60#define SvTIED_mg(sv,how) (SvRMAGICAL(sv) ? mg_find((sv),(how)) : NULL)
33c27489 61#define SvTIED_obj(sv,mg) \
62 ((mg)->mg_obj ? (mg)->mg_obj : sv_2mortal(newRV(sv)))
e9a8c099 63
64/*
65 * Local variables:
66 * c-indentation-style: bsd
67 * c-basic-offset: 4
68 * indent-tabs-mode: t
69 * End:
70 *
71 * ex: set ts=8 sts=4 sw=4 noet:
72 */