ARSperl
view release on metacpan or search on metacpan
/*
$Header: /cvsroot/arsperl/ARSperl/ARS.xs,v 1.127 2011/07/29 13:05:27 tstapff Exp $
ARSperl - An ARS v2 - v5 / Perl5 Integration Kit
Copyright (C) 1995-2003
Joel Murphy, jmurphy@acsu.buffalo.edu
Jeff Murphy, jcmurphy@acsu.buffalo.edu
This program is free software; you can redistribute it and/or modify
it under the terms as Perl itself.
Refer to the file called "Artistic" that accompanies the source
distribution of ARSperl (or the one that accompanies the source
distribution of Perl itself) for a full description.
Comments to: arsperl@arsperl.org
(this is a *mailing list* and you must be
a subscriber before posting)
http://www.arsperl.org
*/
#include "support.h"
#include "supportrev.h"
#include "supportrev_generated.h"
#if AR_EXPORT_VERSION < 3
#define AR_LIST_SCHEMA_ALL 1
#endif
#if defined(ARSPERL_UNDEF_MALLOC) && defined(malloc)
#undef malloc
#undef calloc
#undef realloc
#undef free
#endif
MODULE = ARS PACKAGE = ARS PREFIX = ARS
PROTOTYPES: ENABLE
int
isa_int(...)
CODE:
{
if (items != 1)
croak("usage: isa_int(value)");
RETVAL = SvIOKp(ST(0));
}
OUTPUT:
RETVAL
int
isa_float(...)
CODE:
{
if (items != 1)
croak("usage: isa_int(value)");
RETVAL = SvNOKp(ST(0));
}
OUTPUT:
RETVAL
int
isa_string(...)
CODE:
{
if (items != 1)
croak("usage: isa_int(value)");
RETVAL = SvPOKp(ST(0));
}
OUTPUT:
RETVAL
}
server = serverList.nameList[0];
DBG( ("changing s_ok to 0, picked server %s\n",
SAFEPRT(server)) );
s_ok = 0;
}
strncpy(ctrl->server, server, sizeof(ctrl->server));
ctrl->server[sizeof(ctrl->server)-1] = 0;
/* set the tcp/rpc port if given */
ret = ARSetServerPort(ctrl, ctrl->server, tcpport, rpcnumber,
&status);
if (ARError(ret, status)) {
DBG( ("ARSetServerPort failed %d\n", ret) );
ARTermination(ctrl, &status);
ARError(ret, status);
#ifdef PROFILE
AP_FREE(ctrl);
#else
safefree(ctrl);
#endif
RETVAL = NULL;
goto ar_login_end;
}
/* finally, check to see if the user id is valid */
ret = ARVerifyUser(ctrl, NULL, NULL, NULL, &status);
if(ARError( ret, status)) {
DBG( ("ARVerifyUser failed %d\n", ret) );
ARTermination(ctrl, &status);
ARError(ret, status);
#ifdef PROFILE
AP_FREE(ctrl); /* invalid, cleanup */
#else
safefree(ctrl);
#endif
RETVAL = NULL;
} else {
RETVAL = ctrl; /* valid, return ctrl struct */
}
if(s_ok == 0) {
DBG( ("s_ok == 0, cleaning ServerNameList\n") );
FreeARServerNameList(&serverList, FALSE);
}
ar_login_end:;
DBG( ("finished.\n") );
}
OUTPUT:
RETVAL
HV*
ars_VerifyUser(ctrl)
ARControlStruct * ctrl
CODE:
{
int ret = 0;
ARBoolean adminFlag = 0,
subAdminFlag = 0,
customFlag = 0;
ARStatusList status;
(void) ARError_reset();
Zero(&status, 1, ARStatusList);
ret = ARVerifyUser( ctrl, &adminFlag, &subAdminFlag, &customFlag, &status );
/* printf( "ret = %d, adminFlag = %d, subAdminFlag = %d, customFlag = %d\n",
ret, adminFlag, subAdminFlag, customFlag ); */
if(! ARError(ret, status)) {
RETVAL = newHV();
sv_2mortal( (SV*) RETVAL );
hv_store( RETVAL, "adminFlag", strlen("adminFlag"), newSViv(adminFlag), 0);
hv_store( RETVAL, "subAdminFlag", strlen("subAdminFlag"), newSViv(subAdminFlag), 0);
hv_store( RETVAL, "customFlag", strlen("customFlag"), newSViv(customFlag), 0);
}else{
XSRETURN_UNDEF;
}
}
OUTPUT:
RETVAL
void
ars_GetControlStructFields(ctrl)
ARControlStruct * ctrl
PPCODE:
{
(void) ARError_reset();
if(!ctrl) return;
XPUSHs(sv_2mortal(newSViv(ctrl->cacheId)));
XPUSHs(sv_2mortal(newSViv(ctrl->operationTime)));
XPUSHs(sv_2mortal(newSVpv(ctrl->user, 0)));
XPUSHs(sv_2mortal(newSVpv(ctrl->password, 0)));
#ifndef AR_MAX_LOCALE_SIZE
XPUSHs(sv_2mortal(newSVpv(ctrl->language, 0)));
#else
XPUSHs(sv_2mortal(newSVpv(ctrl->localeInfo.locale, 0)));
#endif
XPUSHs(sv_2mortal(newSVpv(ctrl->server, 0)));
XPUSHs(sv_2mortal(newSViv(ctrl->sessionId)));
#if AR_EXPORT_VERSION >= 7
XPUSHs(sv_2mortal(newSVpv(ctrl->authString, 0)));
#endif
}
SV *
ars_GetCurrentServer(ctrl)
ARControlStruct * ctrl
CODE:
{
RETVAL = NULL;
(void) ARError_reset();
if(ctrl && ctrl->server) {
RETVAL = newSVpv( ctrl->server, strlen(ctrl->server) );
}
}
OUTPUT:
RETVAL
HV *
ars_GetProfileInfo(ctrl)
ARControlStruct * ctrl
CODE:
{
RETVAL = newHV();
sv_2mortal( (SV*) RETVAL );
(void) ARError_reset();
#ifdef PROFILE
hv_store(RETVAL, "queries", strlen("queries") ,
newSViv(((ars_ctrl *)ctrl)->queries), 0);
hv_store(RETVAL, "startTime", strlen("startTime") ,
newSViv(((ars_ctrl *)ctrl)->startTime), 0);
#else /* profiling not compiled in */
(void) ARError_add( AR_RETURN_ERROR, AP_ERR_OPT_NA,
( run in 0.661 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )