http://qs1969.pair.com?node_id=426

perlguts3

Current Perl documentation can be found at perldoc.perl.org.

Here is our local, out-dated (pre-5.6) version:

sv_chop

Efficient removal of characters from the beginning of the string buffer. SvPOK(sv) must be true and the ptr must be a pointer to somewhere inside the string buffer. The ptr becomes the first character of the adjusted string.

        void    sv_chop(SV* sv, char *ptr)
sv_cmp

Compares the strings in two SVs. Returns -1, 0, or 1 indicating whether the string in sv1 is less than, equal to, or greater than the string in sv2.

        I32     sv_cmp (SV* sv1, SV* sv2)
SvCUR

Returns the length of the string which is in the SV. See perlman:perlguts.

        int     SvCUR (SV* sv)
SvCUR_set

Set the length of the string which is in the SV. See perlman:perlguts.

        void    SvCUR_set (SV* sv, int val )
sv_dec

Auto-decrement of the value in the SV.

        void    sv_dec (SV* sv)
sv_derived_from

Returns a boolean indicating whether the SV is a subclass of the specified class.

        int     sv_derived_from(SV* sv, char* class)
sv_derived_from

Returns a boolean indicating whether the SV is derived from the specified class. This is the function that implements UNIVERSAL::isa. It works for class names as well as for objects.

        bool    sv_derived_from _((SV* sv, char* name));
SvEND

Returns a pointer to the last character in the string which is in the SV. See perlman:perlguts. Access the character as

        char*   SvEND(sv)
sv_eq

Returns a boolean indicating whether the strings in the two SVs are identical.

        I32     sv_eq (SV* sv1, SV* sv2)
SvGETMAGIC

Invokes perlman:perlguts on an SV if it has 'get' magic. This macro evaluates its argument more than once.

        void    SvGETMAGIC( SV *sv )
SvGROW

Expands the character buffer in the SV so that it has room for the indicated number of bytes (remember to reserve space for an extra trailing NUL character). Calls perlman:perlguts to perform the expansion if necessary. Returns a pointer to the character buffer.

        char*   SvGROW( SV* sv, int len )
sv_grow

Expands the character buffer in the SV. This will use perlman:perlguts and will upgrade the SV to perlman:perlguts. Returns a pointer to the character buffer. Use perlman:perlguts.

sv_inc

Auto-increment of the value in the SV.

        void    sv_inc (SV* sv)
sv_insert

Inserts a string at the specified offset/length within the SV. Similar to the Perl substr() function.

        void    sv_insert(SV *sv, STRLEN offset, STRLEN len,
                          char *str, STRLEN strlen)
SvIOK

Returns a boolean indicating whether the SV contains an integer.

        int     SvIOK (SV* SV)
SvIOK_off

Unsets the IV status of an SV.

        void    SvIOK_off (SV* sv)
SvIOK_on

Tells an SV that it is an integer.

        void    SvIOK_on (SV* sv)
SvIOK_only

Tells an SV that it is an integer and disables all other OK bits.

        void    SvIOK_only (SV* sv)
SvIOKp

Returns a boolean indicating whether the SV contains an integer. Checks the private setting. Use perlman:perlguts.

        int     SvIOKp (SV* SV)
sv_isa

Returns a boolean indicating whether the SV is blessed into the specified class. This does not check for subtypes; use perlman:perlguts to verify an inheritance relationship.

        int     sv_isa (SV* sv, char* name)
sv_isobject

Returns a boolean indicating whether the SV is an RV pointing to a blessed object. If the SV is not an RV, or if the object is not blessed, then this will return false.

        int     sv_isobject (SV* sv)
SvIV

Returns the integer which is in the SV.

        int SvIV (SV* sv)
SvIVX

Returns the integer which is stored in the SV.

        int     SvIVX (SV* sv)
SvLEN

Returns the size of the string buffer in the SV. See perlman:perlguts.

        int     SvLEN (SV* sv)
sv_len

Returns the length of the string in the SV. Use perlman:perlguts.

        STRLEN  sv_len (SV* sv)
sv_magic

Adds magic to an SV.

        void    sv_magic (SV* sv, SV* obj, int how, char* name, I32 namlen)
sv_mortalcopy

Creates a new SV which is a copy of the original SV. The new SV is marked as mortal.

        SV*     sv_mortalcopy (SV* oldsv)
sv_newmortal

Creates a new SV which is mortal. The reference count of the SV is set to 1.

        SV*     sv_newmortal (void)
SvNIOK

Returns a boolean indicating whether the SV contains a number, integer or double.

        int     SvNIOK (SV* SV)
SvNIOK_off

Unsets the NV/IV status of an SV.

        void    SvNIOK_off (SV* sv)
SvNIOKp

Returns a boolean indicating whether the SV contains a number, integer or double. Checks the private setting. Use perlman:perlguts.

        int     SvNIOKp (SV* SV)
PL_sv_no

This is the false SV. See perlman:perlguts. Always refer to this as perlman:perlguts.

SvNOK

Returns a boolean indicating whether the SV contains a double.

        int     SvNOK (SV* SV)
SvNOK_off

Unsets the NV status of an SV.

        void    SvNOK_off (SV* sv)
SvNOK_on

Tells an SV that it is a double.

        void    SvNOK_on (SV* sv)
SvNOK_only

Tells an SV that it is a double and disables all other OK bits.

        void    SvNOK_only (SV* sv)
SvNOKp

Returns a boolean indicating whether the SV contains a double. Checks the private setting. Use perlman:perlguts.

        int     SvNOKp (SV* SV)
SvNV

Returns the double which is stored in the SV.

        double  SvNV (SV* sv)
SvNVX

Returns the double which is stored in the SV.

        double  SvNVX (SV* sv)
SvOK

Returns a boolean indicating whether the value is an SV.

        int     SvOK (SV* sv)
SvOOK

Returns a boolean indicating whether the SvIVX is a valid offset value for the SvPVX. This hack is used internally to speed up removal of characters from the beginning of a SvPV. When SvOOK is true, then the start of the allocated string buffer is really (SvPVX - SvIVX).

        int     SvOOK(SV* sv)
SvPOK

Returns a boolean indicating whether the SV contains a character string.

        int     SvPOK (SV* SV)
SvPOK_off

Unsets the PV status of an SV.

        void    SvPOK_off (SV* sv)
SvPOK_on

Tells an SV that it is a string.

        void    SvPOK_on (SV* sv)
SvPOK_only

Tells an SV that it is a string and disables all other OK bits.

        void    SvPOK_only (SV* sv)
SvPOKp

Returns a boolean indicating whether the SV contains a character string. Checks the private setting. Use perlman:perlguts.

        int     SvPOKp (SV* SV)
SvPV

Returns a pointer to the string in the SV, or a stringified form of the SV if the SV does not contain a string. If len is perlman:perlguts then Perl will handle the length on its own. Handles 'get' magic.

        char*   SvPV (SV* sv, int len )
SvPV_force

Like <SvPV> but will force the SV into becoming a string (SvPOK). You want force if you are going to update the SvPVX directly.

        char*   SvPV_force(SV* sv, int len)
SvPVX

Returns a pointer to the string in the SV. The SV must contain a string.

        char*   SvPVX (SV* sv)
SvREFCNT

Returns the value of the object's reference count.

        int     SvREFCNT (SV* sv)
SvREFCNT_dec

Decrements the reference count of the given SV.

        void    SvREFCNT_dec (SV* sv)
SvREFCNT_inc

Increments the reference count of the given SV.

        void    SvREFCNT_inc (SV* sv)
SvROK

Tests if the SV is an RV.

        int     SvROK (SV* sv)
SvROK_off

Unsets the RV status of an SV.

        void    SvROK_off (SV* sv)
SvROK_on

Tells an SV that it is an RV.

        void    SvROK_on (SV* sv)
SvRV

Dereferences an RV to return the SV.

        SV*     SvRV (SV* sv)
SvSETMAGIC

Invokes perlman:perlguts on an SV if it has 'set' magic. This macro evaluates its argument more than once.

        void    SvSETMAGIC( SV *sv )
sv_setiv

Copies an integer into the given SV. Does not handle 'set' magic. See perlman:perlguts.

        void    sv_setiv (SV* sv, IV num)
sv_setiv_mg

Like perlman:perlguts, but also handles 'set' magic.

        void    sv_setiv_mg (SV* sv, IV num)
sv_setnv

Copies a double into the given SV. Does not handle 'set' magic. See perlman:perlguts.

        void    sv_setnv (SV* sv, double num)
sv_setnv_mg

Like perlman:perlguts, but also handles 'set' magic.

        void    sv_setnv_mg (SV* sv, double num)
sv_setpv

Copies a string into an SV. The string must be null-terminated. Does not handle 'set' magic. See perlman:perlguts.

        void    sv_setpv (SV* sv, char* ptr)
sv_setpv_mg

Like perlman:perlguts, but also handles 'set' magic.

        void    sv_setpv_mg (SV* sv, char* ptr)
sv_setpviv

Copies an integer into the given SV, also updating its string value. Does not handle 'set' magic. See perlman:perlguts.

        void    sv_setpviv (SV* sv, IV num)
sv_setpviv_mg

Like perlman:perlguts, but also handles 'set' magic.

        void    sv_setpviv_mg (SV* sv, IV num)
sv_setpvn

Copies a string into an SV. The len parameter indicates the number of bytes to be copied. Does not handle 'set' magic. See perlman:perlguts.

        void    sv_setpvn (SV* sv, char* ptr, STRLEN len)
sv_setpvn_mg

Like perlman:perlguts, but also handles 'set' magic.

        void    sv_setpvn_mg (SV* sv, char* ptr, STRLEN len)
sv_setpvf

Processes its arguments like sprintf and sets an SV to the formatted output. Does not handle 'set' magic. See perlman:perlguts.

        void    sv_setpvf (SV* sv, const char* pat, ...)
sv_setpvf_mg

Like perlman:perlguts, but also handles 'set' magic.

        void    sv_setpvf_mg (SV* sv, const char* pat, ...)
sv_setref_iv

Copies an integer into a new SV, optionally blessing the SV. The rv argument will be upgraded to an RV. That RV will be modified to point to the new SV. The classname argument indicates the package for the blessing. Set classname to perlman:perlguts to avoid the blessing. The new SV will be returned and will have a reference count of 1.

        SV*     sv_setref_iv (SV *rv, char *classname, IV iv)
sv_setref_nv

Copies a double into a new SV, optionally blessing the SV. The rv argument will be upgraded to an RV. That RV will be modified to point to the new SV. The classname argument indicates the package for the blessing. Set classname to perlman:perlguts to avoid the blessing. The new SV will be returned and will have a reference count of 1.

        SV*     sv_setref_nv (SV *rv, char *classname, double nv)
sv_setref_pv

Copies a pointer into a new SV, optionally blessing the SV. The rv argument will be upgraded to an RV. That RV will be modified to point to the new SV. If the pv argument is NULL then perlman:perlguts will be placed into the SV. The classname argument indicates the package for the blessing. Set classname to perlman:perlguts to avoid the blessing. The new SV will be returned and will have a reference count of 1.

        SV*     sv_setref_pv (SV *rv, char *classname, void* pv)

Do not use with integral Perl types such as HV, AV, SV, CV, because those objects will become corrupted by the pointer copy process.

Note that perlman:perlguts copies the string while this copies the pointer.

sv_setref_pvn

Copies a string into a new SV, optionally blessing the SV. The length of the string must be specified with n. The rv argument will be upgraded to an RV. That RV will be modified to point to the new SV. The classname argument indicates the package for the blessing. Set classname to perlman:perlguts to avoid the blessing. The new SV will be returned and will have a reference count of 1.

        SV*     sv_setref_pvn (SV *rv, char *classname, char* pv, I32 n)

Note that perlman:perlguts copies the pointer while this copies the string.

SvSetSV

Calls perlman:perlguts if dsv is not the same as ssv. May evaluate arguments more than once.

        void    SvSetSV (SV* dsv, SV* ssv)
SvSetSV_nosteal

Calls a non-destructive version of perlman:perlguts if dsv is not the same as ssv. May evaluate arguments more than once.

        void    SvSetSV_nosteal (SV* dsv, SV* ssv)
sv_setsv

Copies the contents of the source SV ssv into the destination SV dsv. The source SV may be destroyed if it is mortal. Does not handle 'set' magic. See the macro forms perlman:perlguts, perlman:perlguts and perlman:perlguts.

        void    sv_setsv (SV* dsv, SV* ssv)
sv_setsv_mg

Like perlman:perlguts, but also handles 'set' magic.

        void    sv_setsv_mg (SV* dsv, SV* ssv)
sv_setuv

Copies an unsigned integer into the given SV. Does not handle 'set' magic. See perlman:perlguts.

        void    sv_setuv (SV* sv, UV num)
sv_setuv_mg

Like perlman:perlguts, but also handles 'set' magic.

        void    sv_setuv_mg (SV* sv, UV num)
SvSTASH

Returns the stash of the SV.

        HV*     SvSTASH (SV* sv)
SvTAINT

Taints an SV if tainting is enabled

        void    SvTAINT (SV* sv)
SvTAINTED

Checks to see if an SV is tainted. Returns TRUE if it is, FALSE if not.

        int     SvTAINTED (SV* sv)
SvTAINTED_off

Untaints an SV. Be very careful with this routine, as it short-circuits some of Perl's fundamental security features. XS module authors should not use this function unless they fully understand all the implications of unconditionally untainting the value. Untainting should be done in the standard perl fashion, via a carefully crafted regexp, rather than directly untainting variables.

        void    SvTAINTED_off (SV* sv)
SvTAINTED_on

Marks an SV as tainted.

        void    SvTAINTED_on (SV* sv)
SVt_IV

Integer type flag for scalars. See perlman:perlguts.

SVt_PV

Pointer type flag for scalars. See perlman:perlguts.

SVt_PVAV

Type flag for arrays. See perlman:perlguts.

SVt_PVCV

Type flag for code refs. See perlman:perlguts.

SVt_PVHV

Type flag for hashes. See perlman:perlguts.

SVt_PVMG

Type flag for blessed scalars. See perlman:perlguts.

SVt_NV

Double type flag for scalars. See perlman:perlguts.

SvTRUE

Returns a boolean indicating whether Perl would evaluate the SV as true or false, defined or undefined. Does not handle 'get' magic.

        int     SvTRUE (SV* sv)
SvTYPE

Returns the type of the SV. See perlman:perlguts.

        svtype  SvTYPE (SV* sv)
svtype

An enum of flags for Perl types. These are found in the file sv.h in the perlman:perlguts enum. Test these flags with the perlman:perlguts macro.

PL_sv_undef

This is the undef SV. Always refer to this as perlman:perlguts.

sv_unref

Unsets the RV status of the SV, and decrements the reference count of whatever was being referenced by the RV. This can almost be thought of as a reversal of perlman:perlguts. See perlman:perlguts.

        void    sv_unref (SV* sv)
SvUPGRADE

Used to upgrade an SV to a more complex form. Uses perlman:perlguts to perform the upgrade if necessary. See perlman:perlguts.

        bool    SvUPGRADE (SV* sv, svtype mt)
sv_upgrade

Upgrade an SV to a more complex form. Use perlman:perlguts. See perlman:perlguts.

sv_usepvn

Tells an SV to use ptr to find its string value. Normally the string is stored inside the SV but sv_usepvn allows the SV to use an outside string. The ptr should point to memory that was allocated by malloc. The string length, len, must be supplied. This function will realloc the memory pointed to by ptr, so that pointer should not be freed or used by the programmer after giving it to sv_usepvn. Does not handle 'set' magic. See perlman:perlguts.

        void    sv_usepvn (SV* sv, char* ptr, STRLEN len)
sv_usepvn_mg

Like perlman:perlguts, but also handles 'set' magic.

        void    sv_usepvn_mg (SV* sv, char* ptr, STRLEN len)
sv_vcatpvfn(sv, pat, patlen, args, svargs, svmax, used_locale)

Processes its arguments like vsprintf and appends the formatted output to an SV. Uses an array of SVs if the C style variable argument list is missing (NULL). Indicates if locale information has been used for formatting.

        void    sv_catpvfn _((SV* sv, const char* pat, STRLEN patlen,
                              va_list *args, SV **svargs, I32 svmax,
                              bool *used_locale));
sv_vsetpvfn(sv, pat, patlen, args, svargs, svmax, used_locale)

Works like vcatpvfn but copies the text into the SV instead of appending it.

        void    sv_setpvfn _((SV* sv, const char* pat, STRLEN patlen,
                              va_list *args, SV **svargs, I32 svmax,
                              bool *used_locale));
SvUV

Returns the unsigned integer which is in the SV.

        UV      SvUV(SV* sv)
SvUVX

Returns the unsigned integer which is stored in the SV.

        UV      SvUVX(SV* sv)
PL_sv_yes

This is the true SV. See perlman:perlguts. Always refer to this as perlman:perlguts.

THIS

Variable which is setup by xsubpp to designate the object in a C++ XSUB. This is always the proper type for the C++ object. See perlman:perlguts and perlman:perlxs.

toLOWER

Converts the specified character to lowercase.

        int     toLOWER (char c)
toUPPER

Converts the specified character to uppercase.

        int     toUPPER (char c)
warn

This is the XSUB-writer's interface to Perl's perlman:perlguts function. Use this function the same way you use the C printf function. See perlman:perlguts.

XPUSHi

Push an integer onto the stack, extending the stack if necessary. Handles 'set' magic. See perlman:perlguts.

        XPUSHi(int d)
XPUSHn

Push a double onto the stack, extending the stack if necessary. Handles 'set' magic. See perlman:perlguts.

        XPUSHn(double d)
XPUSHp

Push a string onto the stack, extending the stack if necessary. The len indicates the length of the string. Handles 'set' magic. See perlman:perlguts.

        XPUSHp(char *c, int len)
XPUSHs

Push an SV onto the stack, extending the stack if necessary. Does not handle 'set' magic. See perlman:perlguts.

        XPUSHs(sv)
XPUSHu

Push an unsigned integer onto the stack, extending the stack if necessary. See perlman:perlguts.

XS

Macro to declare an XSUB and its C parameter list. This is handled by xsubpp.

XSRETURN

Return from XSUB, indicating number of items on the stack. This is usually handled by xsubpp.

        XSRETURN(int x)
XSRETURN_EMPTY

Return an empty list from an XSUB immediately.

        XSRETURN_EMPTY;
XSRETURN_IV

Return an integer from an XSUB immediately. Uses perlman:perlguts.

        XSRETURN_IV(IV v)
XSRETURN_NO

Return perlman:perlguts from an XSUB immediately. Uses perlman:perlguts.

        XSRETURN_NO;
XSRETURN_NV

Return an double from an XSUB immediately. Uses perlman:perlguts.

        XSRETURN_NV(NV v)
XSRETURN_PV

Return a copy of a string from an XSUB immediately. Uses perlman:perlguts.

        XSRETURN_PV(char *v)
XSRETURN_UNDEF

Return perlman:perlguts from an XSUB immediately. Uses perlman:perlguts.

        XSRETURN_UNDEF;
XSRETURN_YES

Return perlman:perlguts from an XSUB immediately. Uses perlman:perlguts.

        XSRETURN_YES;
XST_mIV

Place an integer into the specified position i on the stack. The value is stored in a new mortal SV.

        XST_mIV( int i, IV v )
XST_mNV

Place a double into the specified position i on the stack. The value is stored in a new mortal SV.

        XST_mNV( int i, NV v )
XST_mNO

Place perlman:perlguts into the specified position i on the stack.

        XST_mNO( int i )
XST_mPV

Place a copy of a string into the specified position i on the stack. The value is stored in a new mortal SV.

        XST_mPV( int i, char *v )
XST_mUNDEF

Place perlman:perlguts into the specified position i on the stack.

        XST_mUNDEF( int i )
XST_mYES

Place perlman:perlguts into the specified position i on the stack.

        XST_mYES( int i )
XS_VERSION

The version identifier for an XS module. This is usually handled automatically by ExtUtils::MakeMaker. See perlman:perlguts.

XS_VERSION_BOOTCHECK

Macro to verify that a PM module's $VERSION variable matches the XS module's perlman:perlguts variable. This is usually handled automatically by xsubpp. See perlman:perlxs.

Zero

The XSUB-writer's interface to the C memzero function. The d is the destination, n is the number of items, and t is the type.

        void    Zero( d, n, t )


AUTHORS

Until May 1997, this document was maintained by Jeff Okamoto <okamoto@corp.hp.com> It is now maintained as part of Perl itself.

With lots of help and suggestions from Dean Roehrich, Malcolm Beattie, Andreas Koenig, Paul Hudson, Ilya Zakharevich, Paul Marquess, Neil Bowers, Matthew Green, Tim Bunce, Spider Boardman, Ulrich Pfeifer, Stephen McCamant, and Gurusamy Sarathy.

API Listing originally by Dean Roehrich <roehrich@cray.com>



Return to the Library