ARSperl

 view release on metacpan or  search on metacpan

support.c  view on Meta::CPAN

#if AR_EXPORT_VERSION >= 4
 /* added cases for new ACTIONS in ARS v4.0 API, Geoff Endresen, 6/28/2000
    copied from AR_ACTIVE_LINK_ACTION_FIELP */
        case AR_FILTER_ACTION_FIELDP:
          {
            ARList *pushFields = NULL;
#if AR_EXPORT_VERSION >= 8L
            hv_store(hash, "fieldp", strlen("fieldp") ,
                perl_ARPushFieldsActionStruct(ctrl,&(in->u.pushFields)), 0 );
#else
            pushFields = (ARList *)& in->u.pushFieldsList;
            /*ARPushFieldsList;*/
            hv_store(hash,  "fieldp", strlen("fieldp") ,
                     perl_ARList(ctrl,
                                 pushFields,
                                 (ARS_fn) perl_ARPushFieldsStruct,
                                 sizeof(ARPushFieldsStruct)),0);
#endif
          }
          break;
         case AR_FILTER_ACTION_SQL:
                 /*ARSQLStruct;*/
                 hv_store(hash,  "sqlCommand", strlen("sqlCommand") ,
                          perl_ARSQLStruct(ctrl, &(in->u.sqlCommand)),0);
                 break;
         case AR_FILTER_ACTION_GOTOACTION:
                 /*ARGotoActionStruct;*/
		hv_store(hash,  "gotoAction", strlen("gotoAction") ,
			 perl_ARGotoActionStruct(ctrl, &in->u.gotoAction), 0);
                break;
# if AR_EXPORT_VERSION >= 6L
        case AR_FILTER_ACTION_CALLGUIDE:
                /*ARCallGuideStruct;*/
		hv_store(hash,  "callGuide", strlen("callGuide") ,
			 perl_ARCallGuideStruct(ctrl, &in->u.callGuide), 0);
                break;
        case AR_FILTER_ACTION_EXITGUIDE:
                /*ARExitGuideStruct;*/
		hv_store(hash,  "exitGuide", strlen("exitGuide") ,
			 perl_ARExitGuideStruct(ctrl, &in->u.exitGuide), 0);
                break;
        case AR_FILTER_ACTION_GOTOGUIDELABEL:
                /*ARGotoGuideLabelStruct;*/
		hv_store(hash,  "gotoGuide", strlen("gotoGuide") ,
			 newSVpv(in->u.gotoGuide.label, 0), 0);
                break;
# endif 
#endif
	case AR_FILTER_ACTION_NONE:
	default:
		hv_store(hash,  "none", strlen("none") , &PL_sv_undef, 0);
		break;
	}

	DBG( ("leave\n") );

	return newRV_noinc((SV *) hash);
}

SV             *
perl_expandARCharMenuStruct(ARControlStruct * ctrl,
			    ARCharMenuStruct * in)
{
	ARCharMenuStruct menu, *which;
	int             ret;
        unsigned int    i;
	ARStatusList    status;
	AV             *array;
	SV             *sub;
	char           *string;

	DBG( ("enter\n") );

	Zero(&status, 1, ARStatusList);
	Zero(&menu,   1, ARCharMenuStruct);

	if (in->menuType != AR_CHAR_MENU_LIST) {
		DBG( ("input menu is not a LIST, calling ARExpandCharMenu\n") );
		ret = ARExpandCharMenu(ctrl, in, 
#if AR_CURRENT_API_VERSION >= 18
			0,      /* maxRetrieve */
#endif
			&menu,
#if AR_CURRENT_API_VERSION >= 18
			NULL,   /* numMatches */
#endif
			&status);
		DBG( ("ARECM ret=%d\n", ret) );
		if (ARError(ret, status)) {
			FreeARCharMenuStruct(&menu, FALSE);
			return &PL_sv_undef;
		}
		which = &menu;
	} else {
		DBG( ("input menu is a LIST, just using that\n") );
		which = in;
	}

	array = newAV();

	DBG( ("expanded menu has %d items\n", 
	      which->u.menuList.numItems) );

	for (i = 0; i < which->u.menuList.numItems; i++) {
		string = which->u.menuList.charMenuList[i].menuLabel;
		av_push(array, newSVpv(string, strlen(string)));
		switch (which->u.menuList.charMenuList[i].menuType) {
		case AR_MENU_TYPE_VALUE:
			string = which->u.menuList.charMenuList[i].u.menuValue;
			av_push(array, newSVpv(string, strlen(string)));
			break;
		case AR_MENU_TYPE_MENU:
			sub = perl_expandARCharMenuStruct(ctrl,
			     which->u.menuList.charMenuList[i].u.childMenu);
			if (!sub) {
				FreeARCharMenuStruct(&menu, FALSE);
				return &PL_sv_undef;
			}
			av_push(array, sub);
			break;
		case AR_MENU_TYPE_NONE:
		default:
			av_push(array, &PL_sv_undef);
			break;
		}
	}

	FreeARCharMenuStruct(&menu, FALSE);
	return newRV_noinc((SV *) array);
}

SV             *
perl_MenuRefreshCode2Str(ARControlStruct * ctrl, unsigned int rc)
{
	int             i;

	for (i = 0;
	     CharMenuRefreshCodeTypeMap[i].number != TYPEMAP_LAST &&
	     CharMenuRefreshCodeTypeMap[i].number != rc;
	     i++);

	return newSVpv(CharMenuRefreshCodeTypeMap[i].name, 0);
}


SV             *
perl_AREntryListFieldStruct(ARControlStruct * ctrl, AREntryListFieldStruct * in)
{
	HV             *hash = newHV();

	hv_store(hash,  "fieldId", strlen("fieldId") , newSViv(in->fieldId), 0);
	hv_store(hash,  "columnWidth", strlen("columnWidth") , newSViv(in->columnWidth), 0);
	hv_store(hash,  "separator", strlen("separator") , newSVpv(in->separator, 0), 0);
	return newRV_noinc((SV *) hash);
}

SV             *
perl_ARIndexStruct(ARControlStruct * ctrl, ARIndexStruct * in)
{
	HV             *hash = newHV();
	AV             *array = newAV();
	unsigned int   i;

	if (in->unique)
		hv_store(hash,  "unique", strlen("unique") , newSViv(1), 0);
	for (i = 0; i < in->numFields; i++)
		av_push(array, perl_ARInternalId(ctrl, &(in->fieldIds[i])));
	hv_store(hash,  "fieldIds", strlen("fieldIds") , newRV_noinc((SV *) array), 0);

	return newRV_noinc((SV *) hash);
}

SV             *



( run in 0.942 second using v1.01-cache-2.11-cpan-5b529ec07f3 )