1N/A/*
1N/A * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
1N/A *
1N/A * Common includes and defines for Sun::Solaris::Exacct.
1N/A */
1N/A
1N/A#ifndef _EXACCT_COMMON_H
1N/A#define _EXACCT_COMMON_H
1N/A
1N/A/* Exacct related includes. */
1N/A#include <exacct.h>
1N/A
1N/A/*
1N/A * On i386 Solaris defines SP, which conflicts with the perl definition of SP
1N/A * We don't need the Solaris one, so get rid of it to avoid warnings.
1N/A */
1N/A#undef SP
1N/A
1N/A/* Perl XS includes. */
1N/A#include "EXTERN.h"
1N/A#include "perl.h"
1N/A#include "XSUB.h"
1N/A
1N/A/* Root of the Exacct namespace. */
1N/A#define PKGBASE "Sun::Solaris::Exacct"
1N/A
1N/A/* Debugging assertion macros. */
1N/A#ifdef EXACCT_DEBUG
1N/A#define PERL_ASSERT(EXPR) ((void)((EXPR) || \
1N/A (croak("%s(%d) assertion failed: %s", __FILE__, __LINE__, #EXPR), 0), \
1N/A 0))
1N/A#define PERL_ASSERTMSG(EXPR, MSG) ((void)((EXPR) || \
1N/A (croak("%s(%d) %s", __FILE__ __LINE__, MSG), 0), 0))
1N/A#else
1N/A#define PERL_ASSERT(EXP) ((void)0)
1N/A#define PERL_ASSERTMSG(EXP, MSG) ((void)0)
1N/A#endif
1N/A
1N/A/*
1N/A * Object stash pointers - caching these speeds up the creation and
1N/A * typechecking of perl objects by removing the need to do a hash lookup.
1N/A * The peculiar variable names are so that typemaps can generate the correct
1N/A * package name using the typemap '$Package' variable as the root of the name.
1N/A */
1N/Aextern HV *Sun_Solaris_Exacct_Catalog_stash;
1N/Aextern HV *Sun_Solaris_Exacct_File_stash;
1N/Aextern HV *Sun_Solaris_Exacct_Object_Item_stash;
1N/Aextern HV *Sun_Solaris_Exacct_Object_Group_stash;
1N/Aextern HV *Sun_Solaris_Exacct_Object__Array_stash;
1N/A
1N/A/* Populate the stash pointers, provided by Exacct.xs. */
1N/Aextern void init_stashes(void);
1N/A
1N/A/*
1N/A * Pointer to part of the hash tree built by define_catalog_constants in
1N/A * Catalog.xs. This is used by catalog_id_str() in Exacct.xs when mapping
1N/A * from a catalog to an id string.
1N/A */
1N/Aextern HV *IdValueHash;
1N/Aextern char *catalog_id_str(ea_catalog_t catalog);
1N/A
1N/A/*
1N/A * Structure for holding an ::Exacct::Object. Different bits of this structure
1N/A * will be populated depending on the type of Object (Item or Group), and on
1N/A * how the Object was created (read from file or by the script).
1N/A *
1N/A * Simple Items
1N/A * Only the ea_obj part is populated, and that points to an ea_object_t
1N/A * that is used to hold the Item.
1N/A *
1N/A * Items containing embedded Objects
1N/A * If an Item of this type has been read from file and has not been accessed,
1N/A * just the ea_obj part will be populated. If the object has been accessed, or
1N/A * if it has been created from within the script, the perl_obj part will be
1N/A * populated.
1N/A *
1N/A * Groups
1N/A * If a Group has been read from file and has not been accessed, just the
1N/A * ea_obj part will be populated. If the object has been accessed, or if it has
1N/A * been created from within the script, the perl_obj part will be populated.
1N/A */
1N/Atypedef struct {
1N/A ea_object_t *ea_obj; /* Underlying exacct object. */
1N/A SV *perl_obj; /* Underlying perl object. */
1N/A uchar_t flags; /* Object type and status. */
1N/A} xs_ea_object_t;
1N/A
1N/A/* Macros for manipulating flag bits. */
1N/A#define TYPE_MASK 0x03
1N/A#define PLAIN_ITEM 0x00
1N/A#define EMBED_ITEM 0x01
1N/A#define GROUP 0x02
1N/A
1N/A#define GET_TYPE_BITS(X) ((X)->flags & TYPE_MASK)
1N/A#define SET_TYPE_BITS(X, Y) ((X)->flags = (((X)->flags & ~TYPE_MASK) | Y)
1N/A#define SET_PLAIN_ITEM(X) (SET_TYPE_BITS(X, PLAIN_ITEM))
1N/A#define SET_EMBED_ITEM(X) (SET_TYPE_BITS(X, EMBED_ITEM))
1N/A#define SET_GROUP(X) (SET_TYPE_BITS(X, GROUP))
1N/A#define IS_ITEM(X) (GET_TYPE_BITS(X) < GROUP)
1N/A#define IS_PLAIN_ITEM(X) (GET_TYPE_BITS(X) == PLAIN_ITEM)
1N/A#define IS_EMBED_ITEM(X) (GET_TYPE_BITS(X) == EMBED_ITEM)
1N/A#define IS_GROUP(X) (GET_TYPE_BITS(X) == GROUP)
1N/A
1N/A#define INIT_PLAIN_ITEM_FLAGS(X) ((X)->flags = PLAIN_ITEM)
1N/A#define INIT_EMBED_ITEM_FLAGS(X) ((X)->flags = EMBED_ITEM)
1N/A#define INIT_GROUP_FLAGS(X) ((X)->flags = GROUP)
1N/A
1N/A/* Fast way to make catalog objects, provided by Exacct.xs. */
1N/Aextern SV *new_catalog(ea_catalog_t cat);
1N/A
1N/A/* Return the integer catalog value from the passed object or SV. */
1N/Aextern ea_catalog_t catalog_value(SV *catalog);
1N/A
1N/A/* Fast way to make exacct objects, provided by Exacct.xs. */
1N/Aextern SV *new_xs_ea_object(ea_object_t *obj);
1N/A
1N/A/* Deflate an xs_ea_object, provided by Exacct.xs. */
1N/Aextern ea_object_t *deflate_xs_ea_object(SV *sv);
1N/A
1N/A/*
1N/A * Structure and associated function for creating perl constants
1N/A * and populating @_Constants, used for constant lookup by the modules.
1N/A * See Exacct.xs for the definition of define_constants().
1N/A */
1N/Atypedef enum { other = 0, type, catlg, id } consttype_t;
1N/Atypedef struct {
1N/A const char *name;
1N/A const int len;
1N/A const consttype_t consttype;
1N/A const unsigned int value;
1N/A} constval_t;
1N/Aextern void define_constants(const char *pkg, constval_t *dvp);
1N/A
1N/A#endif /* _EXACCT_COMMON_H */