Sane

 view release on metacpan or  search on metacpan

Sane.xs  view on Meta::CPAN

void
sane_get_option_descriptor (h, n)
		SANE_Handle	h
		SANE_Int	n
	INIT:
		const SANE_Option_Descriptor *	opt;
               	HV* chv = (HV*) sv_2mortal((SV*) newHV());
               	AV* cav = (AV*) sv_2mortal((SV*) newAV());
               	HV* hv = (HV*) sv_2mortal((SV*) newHV());
                int i;
        PPCODE:
       		SV* sv = get_sv("Sane::DEBUG", FALSE);
               	if (SvTRUE(sv)) printf("Getting option description %d from SANE_Handle %p\n", n, (void *) h);
		opt = sane_get_option_descriptor (h, n);
                if (!opt) croak("Error getting sane_get_option_descriptor");
		if (opt->name != NULL) {
			hv_store(hv, "name", 4, newSVpv(opt->name, 0), 0);
		}
		if (opt->title != NULL) {
			hv_store(hv, "title", 5, newSVpv(opt->title, 0), 0);
		}

Sane.xs  view on Meta::CPAN

		XPUSHs(newRV((SV *)hv));

void
sane_get_option (h, n)
		SANE_Handle	h
		SANE_Int	n
	INIT:
		SANE_Status	status;
		void *		value;
		const SANE_Option_Descriptor *	opt;
        PPCODE:
       		SV* sv = get_sv("Sane::DEBUG", FALSE);
               	if (SvTRUE(sv)) printf("Getting option %d from SANE_Handle %p\n", n, (void *) h);
		opt = sane_get_option_descriptor (h, n);
                if (!opt) croak("Error getting sane_get_option_descriptor");
                if ( opt->size == 0 ) {
                        XSRETURN_UNDEF;
                        return;
                }
		value = malloc (opt->size);
		if (!value) croak("Error allocating memory");

Sane.xs  view on Meta::CPAN

                }
		free (value);

void
sane_set_auto (h, n)
		SANE_Handle	h
		SANE_Int	n
	INIT:
		SANE_Status	status;
		SANE_Int	info;
        PPCODE:
       		SV* sv = get_sv("Sane::DEBUG", FALSE);
               	if (SvTRUE(sv)) printf("Setting option %d to automatic on SANE_Handle %p\n", n, (void *) h);
		status = sane_control_option (h, n, SANE_ACTION_SET_AUTO, 0, &info);
       		sv = get_sv("Sane::_status", FALSE);
                sv_setiv(sv, status); 
                XPUSHs(sv_2mortal(newSViv(info)));

void
sane_set_option (h, n, value)
		SANE_Handle	h

Sane.xs  view on Meta::CPAN

		SANE_Status	status;
		SANE_Int	info;
		void *		valuep;
		const SANE_Option_Descriptor *	opt;
		SANE_Bool	b;
		SANE_Fixed      fixed;
		int		i, vector_length = 0;
		SV **		svp;
		SANE_Word *	vector;
		char *		string;
        PPCODE:
       		SV* sv = get_sv("Sane::DEBUG", FALSE);
               	if (SvTRUE(sv)) printf("Setting option %d on SANE_Handle %p\n", n, (void *) h);
		opt = sane_get_option_descriptor (h, n);
                if (!opt) croak("Error getting sane_get_option_descriptor");
		switch (opt->type) {
			case SANE_TYPE_BOOL:
				b = (SANE_Bool)SvIV(value);
				valuep = &b;
				break;
			case SANE_TYPE_INT:

Sane.xs  view on Meta::CPAN

                sv = get_sv("Sane::_status", FALSE);
                sv_setiv(sv, status); 

void
sane_get_parameters (handle)
		SANE_Handle		handle
	INIT:
		SANE_Status		status;
		SANE_Parameters		params;
               	HV* hv = (HV*) sv_2mortal((SV*) newHV());
        PPCODE:
       		SV* sv = get_sv("Sane::DEBUG", FALSE);
               	if (SvTRUE(sv)) printf("Getting parameters for SANE_Handle %p\n", (void *) handle);
		status = sane_get_parameters (handle, &params);
		sv = get_sv("Sane::_status", FALSE);
                sv_setiv(sv, status);
                if (status) {
                	XPUSHs(sv_2mortal(newSV(0)));
                }
                else {
			hv_store(hv, "format", 6, newSViv(params.format), 0);

Sane.xs  view on Meta::CPAN

                }

void
sane_read (handle, max_length)
		SANE_Handle	handle
		SANE_Int	max_length
	INIT:
		SANE_Status	status;
                SANE_Byte *	data;
                SANE_Int	length;
        PPCODE:
		data = malloc (max_length);
		status = sane_read (handle, data, max_length, &length);
       		SV* sv = get_sv("Sane::_status", FALSE);
                sv_setiv(sv, status); 
                if (status) {
                	XPUSHs(sv_2mortal(newSV(0)));
                	XPUSHs(sv_2mortal(newSViv(0)));
                }
                else {
                	XPUSHs(sv_2mortal(newSVpvn(data, length)));

Sane.xs  view on Meta::CPAN

       		status = sane_set_io_mode (handle, non_blocking);
                sv = get_sv("Sane::_status", FALSE);
                sv_setiv(sv, status); 

void
sane_get_select_fd (handle)
		SANE_Handle	handle
	INIT:
		SANE_Status	status;
		SANE_Int	fd;
        PPCODE:
       		SV* sv = get_sv("Sane::DEBUG", FALSE);
               	if (SvTRUE(sv)) printf("Getting file handle of SANE_Handle %p\n", (void *) handle);
		status = sane_get_select_fd (handle, &fd);
                sv = get_sv("Sane::_status", FALSE);
                sv_setiv(sv, status); 
                if (status) {
                	XPUSHs(sv_2mortal(newSV(0)));
                }
                else {
	                XPUSHs(sv_2mortal(newSViv(fd)));

Sane.xs  view on Meta::CPAN

	newCONSTSUB(stash, "SANE_NAME_CAL_LAMP_DEN", newSVpv(SANE_NAME_CAL_LAMP_DEN, 0));
	newCONSTSUB(stash, "SANE_NAME_SCAN_LAMP_DEN", newSVpv(SANE_NAME_SCAN_LAMP_DEN, 0));
	newCONSTSUB(stash, "SANE_NAME_SELECT_LAMP_DENSITY", newSVpv(SANE_NAME_SELECT_LAMP_DENSITY, 0));
	newCONSTSUB(stash, "SANE_NAME_LAMP_OFF_AT_EXIT", newSVpv(SANE_NAME_LAMP_OFF_AT_EXIT, 0));

void
sane__init (class)
	INIT:
		SANE_Status		status;
                SANE_Int		version_code;
	PPCODE:
       		SV* sv = get_sv("Sane::DEBUG", FALSE);
               	if (SvTRUE(sv)) printf("Running sane_init\n");
		status = sane_init(&version_code, NULL);
                sv = get_sv("Sane::_status", FALSE);
                sv_setiv(sv, status); 
                if (status) {
                	XPUSHs(sv_2mortal(newSV(0)));
                }
                else {
	                XPUSHs(sv_2mortal(newSViv(version_code)));

Sane.xs  view on Meta::CPAN

## 
## 		printf ("Returned %s and %s\n\n", POPs, POPs);
## 
## 		PUTBACK;
## 		FREETMPS;
## 		LEAVE;

void
sane__get_version (class, version_code)
                SANE_Int	version_code
        PPCODE:
		XPUSHs(sv_2mortal(newSViv(SANE_VERSION_MAJOR (version_code))));
		XPUSHs(sv_2mortal(newSViv(SANE_VERSION_MINOR (version_code))));
		XPUSHs(sv_2mortal(newSViv(SANE_VERSION_BUILD (version_code))));

void
sane__get_devices (local=SANE_FALSE)
		SANE_Bool	local
	INIT:
		SANE_Status	status;
		AV * array;
                int i;
                const SANE_Device **	device_list;
		array = (AV *)sv_2mortal((SV *)newAV());
        PPCODE:
       		SV* sv = get_sv("Sane::DEBUG", FALSE);
               	if (SvTRUE(sv)) printf("Running sane_get_devices\n");
                status = sane_get_devices (&device_list, local);
                sv = get_sv("Sane::_status", FALSE);
                sv_setiv(sv, status); 
                if (status) {
                	XPUSHs(sv_2mortal(newSV(0)));
                }
                else {
			for (i = 0; device_list[i]; ++i) {

Sane.xs  view on Meta::CPAN

				XPUSHs(newRV((SV *)hv));
	                }
                }

void
sane__open(class, name)
		SANE_String_Const	name
	INIT:
		SANE_Status		status;
                SANE_Handle		h;
        PPCODE:
        	status = sane_open(name, &h);
		SV* sv = get_sv("Sane::DEBUG", FALSE);
		if (SvTRUE(sv)) printf("sane_open returned SANE_Handle %p\n", (void *) h);
                sv = get_sv("Sane::_status", FALSE);
                sv_setiv(sv, status); 
                if (status) {
                	XPUSHs(sv_2mortal(newSV(0)));
                }
                else {
	                XPUSHs(sv_2mortal(newSViv(PTR2IV(h))));



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