ARSperl

 view release on metacpan or  search on metacpan

supportrev.c  view on Meta::CPAN

rev_ARValueStructKW2KN(ARControlStruct * ctrl,
		       char *keyword, unsigned int *n);
static int 
rev_ARValueStructDiary(ARControlStruct * ctrl,
		       HV * h, char *k, char **d);
static int 
rev_ARAssignFieldStruct_helper(ARControlStruct * ctrl,
			       HV * h, ARAssignFieldStruct * m);
static int 
rev_ARAssignFieldStructStr2NMO(ARControlStruct * ctrl,
			       char *s, unsigned int *nmo);
static int 
rev_ARAssignFieldStructStr2MMO(ARControlStruct * ctrl,
			       char *s, unsigned int *mmo);
static int 
rev_ARStatHistoryValue_helper(ARControlStruct * ctrl,
			      HV * h, ARStatHistoryValue * s);
static int 
rev_ARArithOpAssignStruct_helper(ARControlStruct * ctrl,
				 HV * h, ARArithOpAssignStruct * s);
static int 
rev_ARArithOpAssignStructStr2OP(ARControlStruct * ctrl,
				char *c, unsigned int *o);
static int 
rev_ARFunctionAssignStructStr2FCODE(ARControlStruct * ctrl,
				    char *c, unsigned int *o);
static int 
rev_ARAssignStruct_helper(ARControlStruct * ctrl,
			  HV * h, ARAssignStruct * m);
static int 
rev_ARActiveLinkMacroStruct_helper(ARControlStruct * ctrl, HV * h,
				   ARActiveLinkMacroStruct * m);
static int 
rev_ARAssignList_helper(ARControlStruct * ctrl,
			HV * h, ARFieldAssignList * m, int i);

#if AR_EXPORT_VERSION >= 3
static int 
#if AR_CURRENT_API_VERSION >= 14
rev_ARByteListStr2Type(ARControlStruct * ctrl,
		       char *ts, ARULong32 *tv);
#else
rev_ARByteListStr2Type(ARControlStruct * ctrl,
		       char *ts, unsigned long *tv);
#endif
static int 
rev_ARCoordList_helper(ARControlStruct * ctrl,
		       HV * h, ARCoordList * m, int idx);
static int 
rev_ARPropList_helper(ARControlStruct * ctrl,
		      HV * h, ARPropList * m, int idx);
#endif




/* ROUTINE
 *   revTypeName(TypeMapStruct *tms, char *type)
 *
 * DESCRIPTION
 *   given a typemapstruct and a string, return the 
 *   enumeration value if string exists in struct.
 *
 * RETURNS
 *   >=0 on success
 *   TYPEMAP_LAST on failure
 */

unsigned int
revTypeName(TypeMapStruct *t, char *type) 
{
	if(type && *type && t) {
		int i = 0;
		while((t[i].number != TYPEMAP_LAST) && strcmp(t[i].name, type))
			i++;
		return t[i].number;
	}
	return TYPEMAP_LAST;
}

/* ROUTINE
 *   strcpyHVal(hash, key, buffer, bufferLen - 1)
 *
 * DESCRIPTION
 *   given a hash (HV *), a key, a pre-allocated buffer and
 *   the length of that buffer, retrieve the value from the hash
 *   (assuming it is a string value [PV]) and place it in the buffer.
 *
 * NOTES
 *   The value of hash is truncate at len bytes if it exceeds len.
 *   buffer, once filled in, will be null terminated. Thus the 
 *   bufferLen should be the real length minus 1, because the
 *   address at buffer[bufferLen] is set to zero all the time.
 *
 * RETURNS
 *    0 on success
 *   -1 on failure and pushes some info in the error hash
 *   -2 on warning and pushes some info into the error hash
 *
 */

int
strcpyHVal(HV * h, char *k, char *b, int len)
{
	SV            **val;

	if (!b) {
		ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
			    "strcpyHVal: char buffer parameter is NULL");
		return -1;
	}
	if (!h) {
		ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL,
			    "strcpyHVal: hash parameter is NULL");
		return -1;
	}
	if (SvTYPE((SV *) h) == SVt_PVHV) {
		if (hv_exists(h,  k, strlen(k) )) {
			val = hv_fetch(h,  k, strlen(k) , 0);
			if (val && *val) {
				if (SvPOK(*val)) {

supportrev.c  view on Meta::CPAN

				ARError_add(AR_RETURN_WARNING, AP_ERR_GENERAL, "rev_ARReferenceStruct: hv_fetch returned null");
				return -2;
			}
		}else{
			ARError_add(AR_RETURN_WARNING, AP_ERR_GENERAL, "rev_ARReferenceStruct: key doesn't exist");
			ARError_add(AR_RETURN_WARNING, AP_ERR_GENERAL, k );
			return -2;
		}
	}else{
		ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL, "rev_ARReferenceStruct: first argument is not a hash");
		return -1;
	}

	return 0;
}


int
rev_ARCharMenuItemStruct( ARControlStruct *ctrl, HV *h, char *k, ARCharMenuItemStruct *p ){
	SV  **val;
	int i = 0;

	if( !p ){
		ARError_add(AR_RETURN_ERROR, AP_ERR_GENERAL, "rev_ARCharMenuItemStruct: AR Object param is NULL" );
		return -1;
	}

	if( SvTYPE((SV*) h) == SVt_PVHV ){

		// printf( "ARCharMenuItemStruct: k = <%s>\n", k );
		if( hv_exists(h,k,strlen(k)) ){
			val = hv_fetch( h, k, strlen(k), 0 );
			if( val && *val ){
				{
				
					{
						char *pcase = NULL;
						char errText[512];
				
						HV *h;
						SV **hval = NULL;
						char *k   = NULL;
						if( SvTYPE(SvRV(*val)) != SVt_PVHV ){
							ARError_add( AR_RETURN_ERROR, AP_ERR_GENERAL, "rev_ARCharMenuItemStruct: not a hash value" );
							return -1;
						}
						h = (HV* ) SvRV((SV*) *val);
				
							if( 0 ){
				
							}else if( hv_exists(h,"menuValue",9) ){
								p->menuType = AR_MENU_TYPE_VALUE;
								k = "menuValue";
				
				
							}else if( hv_exists(h,"childMenu",9) ){
								p->menuType = AR_MENU_TYPE_MENU;
								k = "childMenu";
				
							}else{
							    ARError_add( AR_RETURN_ERROR, AP_ERR_GENERAL, "rev_ARCharMenuItemStruct: map error" );
							}
				
				
							switch( p->menuType ){
				
							case AR_MENU_TYPE_VALUE:
								{
								
								
									if( SvTYPE(SvRV(*val)) == SVt_PVHV ){
										int i = 0, num = 0;
										HV *h = (HV* ) SvRV((SV*) *val);
										char k[256];
										k[255] = '\0';
								
								
									{
										SV **val;
										strncpy( k, "menuValue", 255 );
										val = hv_fetch( h, "menuValue", 9, 0 );
										if( val	&& *val ){
											{
												p->u.menuValue = strdup( SvPV_nolen(*val) );
											}
										}else{
											ARError_add( AR_RETURN_ERROR, AP_ERR_GENERAL, "hv_fetch error: key \"menuValue\"" );
											return -1;
										}
									}
								
								
									}else{
										ARError_add( AR_RETURN_ERROR, AP_ERR_GENERAL, "rev_ARCharMenuItemStruct: hash value is not a hash reference" );
										return -1;
									}
								
								
								}
								break;
				
				
							case AR_MENU_TYPE_MENU:
								{
								
								
									if( SvTYPE(SvRV(*val)) == SVt_PVHV ){
										int i = 0, num = 0;
										HV *h = (HV* ) SvRV((SV*) *val);
										char k[256];
										k[255] = '\0';
								
								
									{
										SV **val;
										strncpy( k, "childMenu", 255 );
										val = hv_fetch( h, "childMenu", 9, 0 );
										if( val	&& *val ){
											{
												p->u.childMenu = (ARCharMenuStruct*) MALLOCNN( sizeof(ARCharMenuStruct) );
												p->u.childMenu->menuType = AR_CHAR_MENU_LIST;



( run in 1.319 second using v1.01-cache-2.11-cpan-39bf76dae61 )