Sun-Solaris-Exacct

 view release on metacpan or  search on metacpan

File/File.xs  view on Meta::CPAN

	RETVAL

void
DESTROY(self)
	ea_file_t	*self;
CODE:
	ea_close(self);
	ea_free(self, sizeof(ea_file_t));

 #
 # Return the creator of the file.
 #
SV*
creator(self)
	ea_file_t	*self;
PREINIT:
	const char	*creator;
CODE:
	if ((creator = ea_get_creator(self)) == NULL) {
		RETVAL = &PL_sv_undef;
	} else {
		RETVAL = newSVpv(creator, 0);
	}
OUTPUT:
	RETVAL

 #
 # Return the hostname the file was created on.
 #
SV*
hostname(self)
	ea_file_t	*self;
PREINIT:
	const char	*hostname;
CODE:
	if ((hostname = ea_get_hostname(self)) == NULL) {
		RETVAL = &PL_sv_undef;
	} else {
		RETVAL = newSVpv(hostname, 0);
	}
OUTPUT:
	RETVAL

 #
 # Get the next/previous record from the file and return its type.
 # These two operations are so similar that the XSUB ALIAS functionality is
 # used to merge them into one function.
 #
void
next(self)
	ea_file_t	*self;
ALIAS:
	previous = 1
PREINIT:
	ea_object_type_t		type;
	const char			*type_str;
	ea_object_t			object;
	SV				*sv;
	static const char *const	type_map[] =
	    { "EO_NONE", "EO_GROUP", "EO_ITEM" };
PPCODE:
	/* Call the appropriate next/last function. */
	if (ix == 0) {
		type = ea_next_object(self, &object);
	} else {
		type = ea_previous_object(self, &object);
	}

	/* Work out the call context. */
	switch (GIMME_V) {
	case G_SCALAR:
		/* In a scalar context, just return the type. */
		EXTEND(SP, 1);
		if (type == EO_ERROR) {
			PUSHs(&PL_sv_undef);
		} else {
			sv = newSVuv(type);
			sv_setpv(sv, type_map[type]);
			SvIOK_on(sv);
			PUSHs(sv_2mortal(sv));
		}
		break;
	case G_ARRAY:
		/* In a list contect, return the type and catalog. */
		EXTEND(SP, 2);
		if (type == EO_ERROR) {
			PUSHs(&PL_sv_undef);
			PUSHs(&PL_sv_undef);
		} else {
			sv = newSVuv(type);
			sv_setpv(sv, type_map[type]);
			SvIOK_on(sv);
			PUSHs(sv_2mortal(sv));
			PUSHs(sv_2mortal(new_catalog(object.eo_catalog)));
		}
		break;
	case G_VOID:
	default:
		/* In a void context, return nothing. */
		break;
	}

 #
 # Get the next object from the file and return as an ::Object.
 #
SV*
get(self)
	ea_file_t	*self;
PREINIT:
	ea_object_t	*obj;
CODE:
	if ((obj = ea_get_object_tree(self, 1)) != NULL) {
		RETVAL = new_xs_ea_object(obj);
	} else {
		RETVAL = &PL_sv_undef;
	}
OUTPUT:
	RETVAL

 #
 # Write the passed list of ::Objects to the file.



( run in 1.927 second using v1.01-cache-2.11-cpan-5511b514fd6 )