ARSperl

 view release on metacpan or  search on metacpan

ARS.xs  view on Meta::CPAN

#ifdef PROFILE
		struct timeval   tv;
#endif

		DBG( ("ars_Login(%s, %s, %s, %s, %s, %d, %d)\n", 
			SAFEPRT(server),
			SAFEPRT(username),
			SAFEPRT(password),
			SAFEPRT(lang),
			SAFEPRT(authString),
			tcpport,
			rpcnumber) 
		    );

		RETVAL = NULL;
		Zero(&status, 1, ARStatusList);
		Zero(&serverList, 1, ARServerNameList);
		(void) ARError_reset();  
#ifdef PROFILE
	  /* XXX
	     This is something of a hack... a safemalloc will always
	     complain about differing structures.  However, it's 
	     pretty deep into the code.  Perhaps a static would be cleaner?
	  */
		ctrl = (ARControlStruct *)MALLOCNN(sizeof(ars_ctrl));
		Zero(ctrl, 1, ars_ctrl);
		((ars_ctrl *)ctrl)->queries = 0;
		((ars_ctrl *)ctrl)->startTime = 0;
		((ars_ctrl *)ctrl)->endTime = 0;
#else
		DBG( ("safemalloc ARControlStruct\n") );
		ctrl = (ARControlStruct *)safemalloc(sizeof(ARControlStruct));
		/* DBG( ("malloc ARControlStruct\n") );
		ctrl = (ARControlStruct *)MALLOCNN(sizeof(ARControlStruct)); */
		Zero(ctrl, 1, ARControlStruct);
#endif
#ifdef PROFILE
		if (gettimeofday(&tv, 0) != -1)
			((ars_ctrl *)ctrl)->startTime = tv.tv_sec;
		else
			perror("gettimeofday");
#endif
		ctrl->cacheId = 0;
#if AR_EXPORT_VERSION >= 4
	 	ctrl->sessionId = 0;
#endif
		ctrl->operationTime = 0;
		strncpy(ctrl->user, username, sizeof(ctrl->user));
		ctrl->user[sizeof(ctrl->user)-1] = 0;
		strncpy(ctrl->password, password, sizeof(ctrl->password));
		ctrl->password[sizeof(ctrl->password)-1] = 0;
#ifndef AR_MAX_LOCALE_SIZE
		/* 6.0.1 and 6.3 are AR_EXPORT_VERSION = 8L but 6.3 does not
	         * contain the language field
	         */
		ctrl->language[0] = 0;
		if ( CVLD(lang) ) {
			strncpy(ctrl->language, lang, AR_MAX_LANG_SIZE);
		}
#else 
		ctrl->localeInfo.locale[0] = 0;
		if ( CVLD(lang) ) {
			strncpy(ctrl->localeInfo.locale, lang, AR_MAX_LANG_SIZE);
		}

		if( items > staticParams ){
			int i;
			HV *h;

			if( (items - staticParams) % 2 ){
				(void) ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_ARGS);
#ifdef PROFILE
				AP_FREE(ctrl); /* invalid, cleanup */
#else
				safefree(ctrl);
#endif
				goto ar_login_end;
			}

			h = newHV();			
			for( i = staticParams; i < items; i+=2 ){
				hv_store_ent( h, newSVsv(ST(i)), newSVsv(ST(i+1)), 0 );
			}

			if( hv_exists(h,"charSet",7) ){
				strncpy( ctrl->localeInfo.charSet, SvPV_nolen( *(hv_fetch(h,"charSet",7,0)) ), AR_MAX_LANG_SIZE );
			}
			if( hv_exists(h,"timeZone",8) ){
				strncpy( ctrl->localeInfo.timeZone, SvPV_nolen( *(hv_fetch(h,"timeZone",8,0)) ), AR_MAX_LOCALE_SIZE );
			}
			if( hv_exists(h,"customDateFormat",16) ){
				strncpy( ctrl->localeInfo.customDateFormat, SvPV_nolen( *(hv_fetch(h,"customDateFormat",16,0)) ), AR_MAX_FORMAT_SIZE );
			}
			if( hv_exists(h,"customTimeFormat",16) ){
				strncpy( ctrl->localeInfo.customTimeFormat, SvPV_nolen( *(hv_fetch(h,"customTimeFormat",16,0)) ), AR_MAX_FORMAT_SIZE );
			}
			if( hv_exists(h,"separators",10) ){
				strncpy( ctrl->localeInfo.separators, SvPV_nolen( *(hv_fetch(h,"separators",10,0)) ), AR_MAX_LANG_SIZE );
			}

			hv_undef( h );
		}
#endif
#if AR_EXPORT_VERSION >= 7L
		ctrl->authString[0] = 0;
		if ( CVLD(authString) ) {
			strncpy(ctrl->authString, authString, AR_MAX_NAME_SIZE);
		}
#endif
#if AR_EXPORT_VERSION >= 4
		/* call ARInitialization */
		ret = ARInitialization(ctrl, &status);

		if(ARError(ret, status)) {
			DBG( ("ARInitialization failed %d\n", ret) );
			ARTermination(ctrl, &status);
			ARError(ret, status);
#ifdef PROFILE
			AP_FREE(ctrl);
#else
			safefree(ctrl);
#endif
			goto ar_login_end;
		}

		/*
		printf( "ctrl->localeInfo.customDateFormat <%s>\n", ctrl->localeInfo.customDateFormat );
		printf( "ctrl->localeInfo.separators <%s>\n",       ctrl->localeInfo.separators );
		*/
#endif

		if (!server || !*server) {
			DBG( ("no server given. picking one.\n") );
#if AR_EXPORT_VERSION >= 4
	  		ret = ARGetListServer(ctrl, &serverList, &status);
#else
	  		ret = ARGetListServer(&serverList, &status);
#endif
	  		if (ARError( ret, status)) {
				ARTermination(ctrl, &status);
				ARError(ret, status);
#ifdef PROFILE
				AP_FREE(ctrl); /* invalid, cleanup */
#else
				safefree(ctrl);
#endif
				
				DBG( ("ARGetListServer failed %d\n", ret) );
	   			goto ar_login_end;
	  		}
			status.numItems = 0;
	  		if (serverList.numItems == 0) {
				DBG( ("serverList is empty.\n") );
	     			(void) ARError_add( AR_RETURN_ERROR, AP_ERR_NO_SERVERS);
				ARTermination(ctrl, &status);
				ARError(ret, status);
#ifdef PROFILE
				AP_FREE(ctrl); /* invalid, cleanup */
#else
				safefree(ctrl);
#endif
				goto ar_login_end;
	    		}
	    		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;
		}

ARS.xs  view on Meta::CPAN

	  		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, 
			     "Optional profiling code not compiled into this build of ARSperl");
#endif
	}
	OUTPUT:
	RETVAL

void
ars_Logoff(ctrl)
	ARControlStruct *	ctrl
	CODE:
	{
		int          ret = 0;
		ARStatusList status;
		Zero(&status, 1, ARStatusList);
		(void) ARError_reset();
		if (!ctrl) return;
#if AR_EXPORT_VERSION >= 4
		ret = ARTermination(ctrl, &status);
#else
		ret = ARTermination(&status);
#endif
		(void) ARError( ret, status);
		/*AP_FREE(ctrl); let DESTROY free it*/

ARS.xs  view on Meta::CPAN

#endif
	           break;
	        default:
	           rlist[count++] = i+1;
	        }
         }
	  }else if(items > AR_MAX_SERVER_INFO_USED + 1) {
	    ARError_add( AR_RETURN_ERROR, AP_ERR_BAD_ARGS);
	  }else { /* user has asked for specific ones */
	     for(i = 1 ; i < items ; i++) {
	        rlist[count++] = SvIV(ST(i));
	     }
	  }
	  if(count > 0) {
	     requestList.numItems = count;
	     requestList.requestList = rlist;
	     ret = ARGetServerInfo(ctrl, &requestList, &serverInfo, &status);
#ifdef PROFILE
	     ((ars_ctrl *)ctrl)->queries++;
#endif
	     if(!ARError( ret, status)) {
	        for(ui = 0 ; ui < serverInfo.numItems ; ui++) {
		/* provided we have a mapping for the operation code, 
		 * push out it's translation. else push out the code itself
		 */
		   if(serverInfo.serverInfoList[ui].operation <= AR_MAX_SERVER_INFO_USED) {
		      /* printf( "%d %s: data type = %d\n", serverInfo.serverInfoList[ui].operation, ServerInfoMap[serverInfo.serverInfoList[ui].operation].name, serverInfo.serverInfoList[ui].value.dataType ); */
	  	      XPUSHs(sv_2mortal(newSVpv(ServerInfoMap[serverInfo.serverInfoList[ui].operation].name, 0)));
		   } else {
		      XPUSHs(sv_2mortal(newSViv(serverInfo.serverInfoList[ui].operation)));
		   }
		      XPUSHs(sv_2mortal(perl_ARValueStruct(ctrl,
			&(serverInfo.serverInfoList[ui].value))));
	        }
	     }
	    FreeARServerInfoList(&serverInfo, FALSE);
	  }
	}

HV *
ars_GetVUI(ctrl, schema, vuiId)
	ARControlStruct *	ctrl
	char *			schema
	ARInternalId		vuiId
	CODE:
	{
#if AR_EXPORT_VERSION >= 3
	  ARStatusList status;
	  ARNameType   vuiName;
	  ARPropList   dPropList;
	  char        *helpText = CPNULL;
	  ARTimestamp  timestamp;
	  ARAccessNameType   owner;
	  ARAccessNameType   lastChanged;
	  char        *changeDiary = CPNULL;
	  int          ret = 0;
	  ARDiaryList  diaryList;
	  ARPropList   objPropList;
# if AR_EXPORT_VERSION >= 6
	  unsigned int vuiType = 0;
	  ARLocaleType locale;
	  Zero(locale, 1, ARLocaleType);
# endif
	  RETVAL = newHV();
	  sv_2mortal( (SV*) RETVAL );
	  (void) ARError_reset();
	  Zero(&status, 1,ARStatusList);
	  Zero(vuiName, 1, ARNameType);
	  Zero(&dPropList, 1, ARPropList);
	  Zero(&objPropList, 1, ARPropList);
	  Zero(&timestamp, 1, ARTimestamp);
	  Zero(owner, 1, ARAccessNameType);
	  Zero(lastChanged, 1, ARAccessNameType);
	  ret = ARGetVUI(ctrl, schema, vuiId, vuiName,
# if AR_EXPORT_VERSION >= 6
			 locale, &vuiType,
# endif
			 &dPropList, &helpText, 
			 &timestamp, owner, lastChanged, &changeDiary,
#if AR_CURRENT_API_VERSION >= 17
			 &objPropList,
#endif
			 &status);
# ifdef PROFILE
	  ((ars_ctrl *)ctrl)->queries++;
# endif
	  if(!ARError( ret, status)) {
# if AR_EXPORT_VERSION >= 6
	     hv_store(RETVAL, "locale", strlen("locale"), newSVpv(locale, 0), 0);
	     hv_store(RETVAL, "vuiType", strlen("vuiType"), newSViv(vuiType), 0);
# endif
	     hv_store(RETVAL,  "schema", strlen("schema") , newSVpv(schema, 0), 0);
	     hv_store(RETVAL,  "vuiId", strlen("vuiId") , newSViv(vuiId), 0);
	     hv_store(RETVAL,  "vuiName", strlen("vuiName") , newSVpv(vuiName, 0), 0);
	     hv_store(RETVAL,  "owner", strlen("owner") , newSVpv(owner, 0), 0);
	     if(helpText)
	        hv_store(RETVAL,  "helpText", strlen("helpText") , newSVpv(helpText, 0), 0);
	     hv_store(RETVAL,  "lastChanged", strlen("lastChanged") , newSVpv(lastChanged, 0), 0);
	     if (changeDiary) {
#if AR_EXPORT_VERSION >= 4
		ret = ARDecodeDiary(ctrl, changeDiary, &diaryList, &status);
#else
		ret = ARDecodeDiary(changeDiary, &diaryList, &status);
#endif
		if (!ARError(ret, status)) {
			hv_store(RETVAL,  "changeDiary", strlen("changeDiary") ,
				perl_ARList(ctrl,
				(ARList *)&diaryList,
				(ARS_fn)perl_diary,
				sizeof(ARDiaryStruct)), 0);
			FreeARDiaryList(&diaryList, FALSE);
		}
	     }
	     hv_store(RETVAL,  "timestamp", strlen("timestamp") , newSViv(timestamp), 0);
	     hv_store(RETVAL,  "props", strlen("props") ,
		 perl_ARList( ctrl,
			    (ARList *)&dPropList,
			    (ARS_fn)perl_ARPropStruct,
			    sizeof(ARPropStruct)), 0);
	     hv_store(RETVAL,  "objPropList", strlen("objPropList") ,
		 perl_ARList( ctrl,
			    (ARList *)&objPropList,
			    (ARS_fn)perl_ARPropStruct,
			    sizeof(ARPropStruct)), 0);
	  }
	  FreeARPropList(&dPropList, FALSE);
	  FreeARPropList(&objPropList, FALSE);
	  if(helpText) {
	    	AP_FREE(helpText);
	  }
	  if(changeDiary) {
	    	AP_FREE(changeDiary);
	  }
#else /* ars 2.x */
	  (void) ARError_reset();
	  (void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED, "Not available in 2.x");
	  RETVAL = newHV();
#endif

	}
	OUTPUT:
	RETVAL



int
ars_CreateCharMenu( ctrl, menuDefRef, removeFlag=TRUE )
	ARControlStruct *	ctrl
	SV * menuDefRef

ARS.xs  view on Meta::CPAN

			ARError_add( AR_RETURN_ERROR, AP_ERR_PREREVFAIL);
			RETVAL = 0;
		}

	    if( helpText != NULL ){
			AP_FREE( helpText );
		}
	    if( changeDiary != NULL ){
			AP_FREE( changeDiary );
		}
		if( compoundSchema != NULL ){
			FreeARCompoundSchema( compoundSchema, TRUE );
		}
		if( groupList != NULL ){
			FreeARPermissionList( groupList, TRUE );
		}
		if( admingrpList != NULL ){
			FreeARInternalIdList( admingrpList, TRUE );
		}
		if( getListFields != NULL ){
			FreeAREntryListFieldList( getListFields, TRUE );
		}
		if( sortList != NULL ){
			FreeARSortList( sortList, TRUE );
		}
		if( indexList != NULL ){
			FreeARIndexList( indexList, TRUE );
		}
#if AR_EXPORT_VERSION >= 8L
		if( archiveInfo != NULL ){
			FreeARArchiveInfoStruct( archiveInfo, TRUE );
		}
#endif
		if( objPropList != NULL ){
			FreeARPropList( objPropList, TRUE );
		}
#else /* < 5.0 */
	  XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
	  (void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED, 
			"ARSperl supports SetSchema() only for ARSystem >= 5.0");
      RETVAL = AR_RETURN_ERROR;
#endif
	}
	OUTPUT:
	RETVAL



int
ars_CreateVUI( ctrl, schemaName, vuiDefRef )
	ARControlStruct *	ctrl
	ARNameType schemaName
	SV * vuiDefRef

	CODE:
	{
#if AR_EXPORT_VERSION >= 6L
		int ret = 0, rv = 0;
		ARInternalId vuiId = 0;
		ARNameType vuiName;
		ARLocaleType locale;
		unsigned int vuiType;
		ARPropList dPropList;
		char *helpText = NULL;
		ARAccessNameType owner;
		char *changeDiary = NULL;
		ARPropList objPropList;
		ARStatusList status;
		HV *vuiDef = NULL;
		SV **pSvTemp;

		RETVAL = 0; /* assume error */
		(void) ARError_reset();
		Zero(vuiName, 1,ARNameType);
		Zero(locale, 1,ARLocaleType);
		Zero(&dPropList, 1,ARPropList);
		Zero(&objPropList, 1,ARPropList);
		Zero(owner, 1,ARAccessNameType);
		Zero(&status, 1,ARStatusList);

		if( SvROK(vuiDefRef) && SvTYPE(SvRV(vuiDefRef)) == SVt_PVHV ){
			vuiDef = (HV*) SvRV(vuiDefRef);
		}else{
			croak("usage: ars_CreateVUI(...)");
		}


		rv += ulongcpyHVal( vuiDef, "vuiId", &vuiId ); 
		rv += strcpyHVal( vuiDef, "vuiName", vuiName, AR_MAX_NAME_SIZE ); 
#if AR_CURRENT_API_VERSION >= 11
		rv += strcpyHVal( vuiDef, "locale", locale, AR_MAX_LOCALE_SIZE ); 
#else
		rv += strcpyHVal( vuiDef, "locale", locale, AR_MAX_LANG_SIZE ); 
#endif
		rv += uintcpyHVal( vuiDef, "vuiType", &vuiType ); 

		dPropList.numItems = 0;
		dPropList.props = NULL;
		pSvTemp = hv_fetch( vuiDef, "props", strlen("props") , 0 );
		if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
			/* dPropList.props = (ARPropStruct*) MALLOCNN( sizeof(ARPropStruct) ); */
			rv += rev_ARPropList( ctrl, vuiDef, "props", &dPropList );
		}
#if AR_CURRENT_API_VERSION >= 17
		objPropList.numItems = 0;
		objPropList.props = NULL;
		pSvTemp = hv_fetch( vuiDef, "objPropList", strlen("objPropList") , 0 );
		if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
			/* objPropList.props = (ARPropStruct*) MALLOCNN( sizeof(ARPropStruct) ); */
			rv += rev_ARPropList( ctrl, vuiDef, "objPropList", &objPropList );
		}
#endif
		if( hv_exists(vuiDef,"helpText",8) ){
			rv += strmakHVal( vuiDef, "helpText", &helpText ); 
		}
		if( hv_exists(vuiDef,"owner",5) ){
			rv += strcpyHVal( vuiDef, "owner", owner, AR_MAX_ACCESS_NAME_SIZE ); 
		}
		if( hv_exists(vuiDef,"changeDiary",11) ){
			rv += strmakHVal( vuiDef, "changeDiary", &changeDiary );
		}

		if( rv == 0 ){
			ret = ARCreateVUI( ctrl,
				schemaName,
				&vuiId,
				vuiName,
				locale,
				vuiType,
				&dPropList,
				helpText,
				owner,
				changeDiary,
#if AR_CURRENT_API_VERSION >= 17
				&objPropList,
#endif
				&status );

			RETVAL = ARError(ret,status) ? 0 : 1;
		}else{ 
			ARError_add( AR_RETURN_ERROR, AP_ERR_PREREVFAIL);
			RETVAL = 0;
		}

	    if( helpText != NULL ){
			AP_FREE( helpText );
		}
	    if( changeDiary != NULL ){
			AP_FREE( changeDiary );
		}
		FreeARPropList( &dPropList, FALSE );
		FreeARPropList( &objPropList, FALSE );
#else /* < 5.0 */
	  XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
	  (void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED, 
			"ARSperl supports CreateVUI() only for ARSystem >= 5.0");
      RETVAL = AR_RETURN_ERROR;
#endif
	}
	OUTPUT:
	RETVAL



int
ars_SetVUI( ctrl, schemaName, vuiId, vuiDefRef )
	ARControlStruct *	ctrl
	ARNameType schemaName
	ARInternalId vuiId
	SV * vuiDefRef

	CODE:
	{
#if AR_EXPORT_VERSION >= 6L
		int ret = 0, rv = 0;
		ARNameType vuiName;
		char *vuiNamePtr = NULL;
		ARLocaleType locale;
		char *localePtr = NULL;
		unsigned int vuiType;
		unsigned int *vuiTypePtr = NULL;
		ARPropList *dPropList = NULL;
		char *helpText = NULL;
		ARAccessNameType owner;
		char *ownerPtr = NULL;
		char *changeDiary = NULL;
		ARPropList *objPropList = NULL;
		ARStatusList status;
		HV *vuiDef = NULL;
		SV **pSvTemp;

		RETVAL = 0; /* assume error */
		(void) ARError_reset();
		Zero(vuiName, 1,ARNameType);
		Zero(locale, 1,ARLocaleType);
		Zero(owner, 1,ARAccessNameType);
		Zero(&status, 1,ARStatusList);


		if( SvROK(vuiDefRef) && SvTYPE(SvRV(vuiDefRef)) == SVt_PVHV ){
			vuiDef = (HV*) SvRV(vuiDefRef);
		}else{
			croak("usage: ars_SetVUI(...)");
		}


		/* rv += ulongcpyHVal( vuiDef, "vuiId", &vuiId ); */

		
		if( hv_exists(vuiDef,"vuiName",7) ){
			rv += strcpyHVal( vuiDef, "vuiName", vuiName, AR_MAX_NAME_SIZE ); 
			vuiNamePtr = vuiName;
		}
		if( hv_exists(vuiDef,"locale",6) ){
#if AR_CURRENT_API_VERSION >= 11
			rv += strcpyHVal( vuiDef, "locale", locale, AR_MAX_LOCALE_SIZE );
#else
			rv += strcpyHVal( vuiDef, "locale", locale, AR_MAX_LANG_SIZE );
#endif
			localePtr = locale;
		}
		
		if( hv_exists(vuiDef,"vuiType",7) ){
			rv += uintcpyHVal( vuiDef, "vuiType", &vuiType ); 
			vuiTypePtr = &vuiType;
		}


		pSvTemp = hv_fetch( vuiDef, "props", strlen("props") , 0 );
		if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
			dPropList = (ARPropList*) MALLOCNN( sizeof(ARPropList) );
			rv += rev_ARPropList( ctrl, vuiDef, "props", dPropList );
		}
#if AR_CURRENT_API_VERSION >= 17
		pSvTemp = hv_fetch( vuiDef, "objPropList", strlen("objPropList") , 0 );
		if( pSvTemp && *pSvTemp && SvTYPE(*pSvTemp) != SVt_NULL ){
			objPropList = (ARPropList*) MALLOCNN( sizeof(ARPropList) );
			rv += rev_ARPropList( ctrl, vuiDef, "objPropList", objPropList );
		}
#endif
		if( hv_exists(vuiDef,"helpText",8) ){
			rv += strmakHVal( vuiDef, "helpText", &helpText ); 
		}
		
		if( hv_exists(vuiDef,"owner",5) ){
			rv += strcpyHVal( vuiDef, "owner", owner, AR_MAX_ACCESS_NAME_SIZE );
			ownerPtr = owner;
		}
		if( hv_exists(vuiDef,"changeDiary",11) ){
			rv += strmakHVal( vuiDef, "changeDiary", &changeDiary );
		}

		if( rv == 0 ){
			ret = ARSetVUI( ctrl,
				schemaName,
				vuiId,
				vuiNamePtr,
				localePtr,
				vuiTypePtr,
				dPropList,
				helpText,
				owner,
				changeDiary,
#if AR_CURRENT_API_VERSION >= 17
				objPropList,
#endif
				&status );

			RETVAL = ARError(ret,status) ? 0 : 1;
		}else{ 
			ARError_add( AR_RETURN_ERROR, AP_ERR_PREREVFAIL);
			RETVAL = 0;
		}

	    if( helpText != NULL ){
			AP_FREE( helpText );
		}
	    if( changeDiary != NULL ){
			AP_FREE( changeDiary );
		}
		FreeARPropList( dPropList, TRUE );
		FreeARPropList( objPropList, TRUE );
#else /* < 5.0 */
	  XPUSHs(sv_2mortal(newSViv(0))); /* ERR */
	  (void) ARError_add( AR_RETURN_ERROR, AP_ERR_DEPRECATED, 
			"ARSperl supports SetVUI() only for ARSystem >= 5.0");
      RETVAL = AR_RETURN_ERROR;
#endif
	}
	OUTPUT:
	RETVAL




int
ars_CreateContainer( ctrl, containerDefRef, removeFlag=TRUE )
	ARControlStruct *	ctrl
	SV * containerDefRef
	ARBoolean removeFlag;

	CODE:
	{
#if AR_EXPORT_VERSION >= 6L
		int ret = 0, rv = 0;
		ARNameType name;
		ARPermissionList groupList;
		ARInternalIdList admingrpList;
		ARContainerOwnerObjList ownerObjList;
		char *label = NULL;
		char *description = NULL;
		char *typeStr = NULL;
		unsigned int type;
		ARReferenceList references;
		char *helpText = NULL;
		ARAccessNameType owner;
		char *changeDiary = NULL;
		ARPropList objPropList;



( run in 0.427 second using v1.01-cache-2.11-cpan-5a3173703d6 )