Calendar-CSA

 view release on metacpan or  search on metacpan

CSA.xs  view on Meta::CPAN

static int
not_here(s)
char *s;
{
    croak("%s not implemented on this architecture", s);
    return -1;
}

int max_callback = 0;

AV *callbacks, *callback_mode;

void callback_handler(
				CSA_session_handle session,
				CSA_flags reason,
				CSA_buffer call_data,
				CSA_buffer client_data,
				CSA_extension *callback_extensions)
{
	int callback = (int)client_data;
	SV ** arg = av_fetch(callbacks, callback, 0);
	AV * args = (AV*)SvRV(*arg);
	int i,j;
	dSP;
	PUSHMARK(sp);
	for(i=1;i<=av_len(args);i++)
		XPUSHs(sv_2mortal(newSVsv(*av_fetch(args, i, 0))));
	{
#ifdef CSA_DEBUG
		printf("Dealing with callback type %d, tag %d\n", reason, callback);
#endif

CSA.xs  view on Meta::CPAN

		i = csa_register_callback(session->session, flags, callback_handler, (void*)(max_callback+1), NULL);
		if (i)
			CsaCroak("register_callback", i);
		max_callback++;
#ifdef CSA_DEBUG
		printf("Registered callback %d with action %d\n", max_callback, flags);
#endif
		args = newAV();
		for(i=2;i<items;i++)
			av_push(args, newSVsv(ST(i)));
		av_store(callbacks, max_callback, newRV((SV*)args));
		SvREFCNT_dec(args);
		av_store(callback_mode, max_callback, newSViv(flags));
		RETVAL = max_callback;
	}
	OUTPUT:
	RETVAL

void
call_callbacks(session, mode, ...)
	Calendar::CSA::Session	session
	SV *	mode
	CODE:
	{
		int i,j;
		int flags=0;
		AV * args;
		for(j=1;j<items;j++)
			if (SvROK(mode) && (SvTYPE(SvRV(mode)) == SVt_PVAV)) {
				args = (AV*)SvRV(mode);
				for (i=0;i<=av_len(args);i++)
					flags |= SvCSA_callback_mode(*av_fetch(args, i, 0));
			} else {
				flags |= SvCSA_callback_mode(mode);
			}
		i = csa_call_callbacks(session->session, flags, NULL);
		if (i)
			CsaCroak("call_callbacks", i);
	}

void
unregister_callback(session, tag)
	Calendar::CSA::Session	session
	int	tag
	CODE:
	{
		SV ** s = av_fetch(callback_mode, tag, 0);
		if (*s) {
			int flags = SvIV(*s);
			int i;
			i = csa_unregister_callback(session->session, flags, callback_handler, (void*)(tag), NULL);
			if (i)
				CsaCroak("unregister_callback", i);
			av_store(callbacks, tag, newSVsv(&sv_undef));
			av_store(callback_mode, tag, newSVsv(&sv_undef));
		}
	}

void
x_process_updates(session)
	Calendar::CSA::Session	session
	CODE:
	/*csa_x_process_updates(session->session);*/

CSA.xs  view on Meta::CPAN


			result = sv_newmortal();
			sv_setref_pv(result, 
				     "Calendar::CSA::EntryList",
				     (void *)entrylist);
			XPUSHs(result);
		}
	}

BOOT:
callbacks = newAV();
callback_mode = newAV();
{
	char buffer[54];
	_csa_range_to_iso8601(time(0),time(0)+20,buffer);
}

README  view on Meta::CPAN


    To build this module, you must have the CSA libraries and headers, which
    possibly may not be included with your base CDE installation. The key
    libraries are csa, and possibly DtSvc. The only header required is
    csa/csa.h. Makefile.PL assumes these exist in -L/usr/dt/lib, and
    -I/usr/dt/include.  The names might differ (in which case Makefile.PL
    and Csa.xs will need to be modified), but the files must be present
    somewhere.
    
    The callback mechanism has been completely untested (I was unable to
    provoke any callbacks.)
    
    "We apologize for the inconvenience."

Other information:

    This module was written by Kenneth Albanowski <kjahds@kjahds.com>, with
    considerable assistance by Bharat Mediratta
    <Bharat.Mediratta@Corp.Sun.COM>. It would not existed at all save for
    the generous donation by Red Hat software of a copy of the TriTeal CDE
    Developers Edition for Linux.

test.pl  view on Meta::CPAN

eval
{
#	Segfaults on my machine, in addition to being unimplemented!
#	print Dumper([$session->free_time_search("19970816T040205Z/19970816T040225Z","+PT300S",{user_name=>$user})]);
};
print ($@) if ($@);

# Never been able to trigger a callback.
#$session->register_callback("ENTRY ADDED", sub { print "Callback: @_\n" }, "foo", 1);
#
#$session->call_callbacks("ENTRY ADDED");

@entries = $session->list_entries(
	'-//XAPIA/CSA/ENTRYATTR//NONSGML Date Created//EN' => {
    	type => 'DATE TIME',
        value => '19970612T010654Z',
        match => 'GREATER THAN'
    },
);

if (@entries)



( run in 1.200 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )