/*
 *      $Id: MapRGDataHandler.c,v 1.5 2003-07-14 23:12:00 dbrown Exp $
 */
/************************************************************************
*									*
*			     Copyright (C)  1992			*
*	     University Corporation for Atmospheric Research		*
*			     All Rights Reserved			*
*									*
************************************************************************/
/*
 *	File:
 *
 *	Author:		David I. Brown
 *			National Center for Atmospheric Research
 *			PO 3000, Boulder, Colorado
 *
 *	Date:		Thu Apr 23 12:01:04 MDT 1998
 *
 *	Description:
 */

#include <ncarg/hlu/MapRGDataHandlerP.h>

#define Oset(field)	NhlOffset(NhlMapRGDataHandlerLayerRec,maprgdh.field)

static NhlResource resources[] = {
	{NhlNmpDataResolution,NhlCmpDataResolution,
		NhlTMapDataResolution,sizeof(NhlMapDataResolution),
	 	Oset(data_resolution),NhlTImmediate,
	 	_NhlUSET((NhlPointer)NhlUNSPECIFIEDRESOLUTION),0,NULL}
};

static NhlErrorTypes MapRGDHClassPartInit(
#if	NhlNeedProto
	NhlClass	lc
#endif
);

static NhlErrorTypes MapRGDHInitialize(
#if	NhlNeedProto
        NhlClass	class,
        NhlLayer	req,
        NhlLayer	new,
        _NhlArgList	args,
        int             num_args
#endif
);

static NhlErrorTypes  MapRGDHSetValues(
#if	NhlNeedProto
        NhlLayer	old,
        NhlLayer	reference,
        NhlLayer	new,
        _NhlArgList	args,
        int             num_args
#endif
);

static NhlErrorTypes    MapRGDHGetValues(
#if	NhlNeedProto
	NhlLayer        l,
	_NhlArgList     args,
	int             num_args
#endif
);

static NhlErrorTypes    MapRGDHDestroy(
#if	NhlNeedProto
	NhlLayer        l
#endif
);

static NhlErrorTypes MapRGDHUpdateDrawList(
#if	NhlNeedProto
	NhlLayer		instance,
        NhlBoolean  		init,
        NhlMapPlotLayer 	newmp,
        NhlMapPlotLayer 	oldmp,
        _NhlArgList		args,
        int             	num_args
#endif
);

static NhlErrorTypes MapRGDHDrawMapList(
#if	NhlNeedProto
	NhlLayer		instance,
        NhlMapPlotLayer 	mp,
        mpDrawOp		draw_op,
	NhlBoolean		init_draw
#endif
);

static void   load_hlumap_routines(
#if	NhlNeedProto
	NhlBoolean	flag
#endif
);

void   (_NHLCALLF(hlumapeod,HLUMAPEOD))(
#if	NhlNeedProto
	int *nout,
	int *nseg,
	int *idls,
	int *idrs,
	int *npts,
	float *pnts
#endif
);

NhlMapRGDataHandlerClassRec NhlmapRGDataHandlerClassRec = {
	{
/* class_name 		*/      "mapRGDataHandlerClass",
/* nrm_class 		*/      NrmNULLQUARK,
/* layer_size 		*/      sizeof(NhlMapRGDataHandlerLayerRec),
/* class_inited 	*/	False,
/* superclass		*/      (NhlClass)&NhlmapDataHandlerClassRec,
/* cvt_table		*/	NULL,

/* layer_resources 	*/   	resources,
/* num_resources 	*/     	NhlNumber(resources),
/* all_resources 	*/	NULL,
/* callbacks		*/	NULL,
/* num_callbacks	*/	0,
/* class_callbacks	*/	NULL,
/* num_class_callbacks	*/	0,

/* class_part_initialize */     MapRGDHClassPartInit,
/* class_initialize 	*/  	NULL,
/* layer_initialize 	*/  	MapRGDHInitialize,
/* layer_set_values 	*/  	MapRGDHSetValues,
/* layer_set_values_hook */  	NULL,
/* layer_get_values 	*/  	MapRGDHGetValues,
/* layer_reparent 	*/  	NULL,
/* layer_destroy 	*/    	MapRGDHDestroy,
	},
	{
/* update_map_draw_list */	MapRGDHUpdateDrawList,
/* draw_map_list        */      MapRGDHDrawMapList
	}
};

NhlClass NhlmapRGDataHandlerClass = (NhlClass)&NhlmapRGDataHandlerClassRec;

static NrmQuark Qdata_resolution = NrmNULLQUARK;

static NhlMapPlotLayer Mpl;
static NhlMapPlotLayerPart *Mpp;
static NhlMapRGDataHandlerClassPart	*Mrgcp;
static NhlMapRGDataHandlerLayerPart	*Mrgp;
static NhlBoolean Grid_Setup;

static NhlErrorTypes
MapRGDHClassPartInit
#if	NhlNeedProto
(
	NhlClass	lc
)
#else
(lc)
	NhlClass	lc;
#endif
{
	NhlMapRGDataHandlerClass	mdhc = (NhlMapRGDataHandlerClass)lc;

	Qdata_resolution = NrmStringToQuark(NhlNmpDataResolution);

        Mrgcp = &mdhc->maprgdh_class;

	load_hlumap_routines(False);

	return NhlNOERROR;
}

/*
 * Function:  mdhManageDynamicArrays
 *
 * Description: Creates and manages internal copies of each of the
 *	MapDataHandler GenArrays.
 *
 * In Args:
 *
 * Out Args:
 *
 * Return Values:
 *
 * Side Effects:
 */

/*ARGSUSED*/
static NhlErrorTypes    mdhManageDynamicArrays
#if	NhlNeedProto
(
	NhlMapRGDataHandlerLayer	mv4new,
	NhlMapRGDataHandlerLayer	mv4old,
	NhlBoolean			init,
	_NhlArgList			args,
	int				num_args)
#else
(mdhnew,mdhold,init,args,num_args)
	NhlMapRGDataHandlerLayer	mv4new;
	NhlMapRGDataHandlerLayer	mv4old;
	NhlBoolean			init;
	_NhlArgList			args;
	int				num_args;
#endif

{

	NhlErrorTypes ret = NhlNOERROR;

	return ret;
}

/*
 * Function:	MapRGDHInitialize
 *
 * Description:
 *
 * In Args: 	class	objects layer_class
 *		req	instance record of requested values
 *		new	instance record of new object
 *		args	list of resources and values for reference
 *		num_args 	number of elements in args.
 *
 * Out Args:	NONE
 *
 * Return Values:	Error Conditions
 *
 * Side Effects:
 */
/*ARGSUSED*/
static NhlErrorTypes
MapRGDHInitialize
#if	NhlNeedProto
(
	NhlClass	class,
	NhlLayer	req,
	NhlLayer	new,
	_NhlArgList	args,
	int		num_args
)
#else
(class,req,new,args,num_args)
        NhlClass   class;
        NhlLayer        req;
        NhlLayer        new;
        _NhlArgList     args;
        int             num_args;
#endif
{
        NhlMapRGDataHandlerLayer mrgl = (NhlMapRGDataHandlerLayer) new;
        NhlMapRGDataHandlerLayerPart *mrgp = &mrgl->maprgdh;
	NhlErrorTypes		ret = NhlNOERROR, subret = NhlNOERROR;
	char			*entry_name = "MapRGDHInitialize";
	char			*e_text;

	mrgp->aws_id = -1;
	mrgp->fws_id = -1;

	mrgp->real_data_resolution = mrgp->data_resolution;

/* Manage the dynamic arrays */

	subret = mdhManageDynamicArrays((NhlMapRGDataHandlerLayer)new,
                                        (NhlMapRGDataHandlerLayer)req,
                                        True,args,num_args);
	if ((ret = MIN(ret,subret)) < NhlWARNING) {
		e_text = "%s: error managing dynamic arrays";
		NhlPError(NhlFATAL,NhlEUNKNOWN,e_text,entry_name);
		return(ret);
	}

        return ret;
}

/*
 * Function:	MapRGDHSetValues
 *
 * Description:
 *
 * In Args:	old	copy of old instance record
 *		reference	requested instance record
 *		new	new instance record
 *		args 	list of resources and values for reference
 *		num_args	number of elements in args.
 *
 * Out Args:	NONE
 *
 * Return Values:	ErrorConditions
 *
 * Side Effects:
 */
/*ARGSUSED*/
static NhlErrorTypes MapRGDHSetValues
#if	NhlNeedProto
(
	NhlLayer	old,
	NhlLayer	reference,
	NhlLayer	new,
	_NhlArgList	args,
	int		num_args
)
#else
(old,reference,new,args,num_args)
	NhlLayer	old;
	NhlLayer	reference;
	NhlLayer	new;
	_NhlArgList	args;
	int		num_args;
#endif
{
	NhlErrorTypes		ret = NhlNOERROR, subret = NhlNOERROR;
	char			*entry_name = "MapRGDHSetValues";
	char			*e_text;

/* Manage the dynamic arrays */

	subret = mdhManageDynamicArrays((NhlMapRGDataHandlerLayer)new,
                                        (NhlMapRGDataHandlerLayer)old,
                                        False,args,num_args);
	if ((ret = MIN(ret,subret)) < NhlWARNING) {
		e_text = "%s: error managing dynamic arrays";
		NhlPError(NhlFATAL,NhlEUNKNOWN,e_text,entry_name);
		return(ret);
	}

        return ret;
}

/*
 * Function:    MapRGDHGetValues
 *
 * Description: Retrieves the current setting of MapRGDataHandler resources.
 *      Actually the resources belong to the superclass MapDataHandler --
 *      but they get their contents from the subclass.
 *
 *
 * In Args:
 *
 * Out Args:
 *
 * Return Values:
 *
 * Side Effects:
 *      Memory is allocated when any of the following resources are retrieved:
 *		NhlNmpAreaNames
 *		NhlNmpAreaTypes
 *		NhlNmpDynamicAreaGroups
 *		NhlNmpSpecifiedFillColors
 *
 *      The caller is responsible for freeing this memory.
 */

static NhlErrorTypes    MapRGDHGetValues
#if	NhlNeedProto
(NhlLayer l, _NhlArgList args, int num_args)
#else
(l,args,num_args)
        NhlLayer        l;
        _NhlArgList     args;
        int     	num_args;
#endif
{

        return(NhlNOERROR);

}

/*
 * Function:    MapRGDHDestroy
 *
 * Description: Retrieves the current setting of MapRGDataHandler resources.
 *      Actually the resources belong to the superclass MapDataHandler --
 *      but they get their contents from the subclass.
 *
 *
 * In Args:
 *
 * Out Args:
 *
 * Return Values:
 *
 * Side Effects:
 *      Memory is allocated when any of the following resources are retrieved:
 *		NhlNmpAreaNames
 *		NhlNmpAreaTypes
 *		NhlNmpDynamicAreaGroups
 *		NhlNmpSpecifiedFillColors
 *
 *      The caller is responsible for freeing this memory.
 */

static NhlErrorTypes    MapRGDHDestroy
#if	NhlNeedProto
(
        NhlLayer l
        )
#else
(l)
        NhlLayer        l;
#endif
{
        NhlMapRGDataHandlerLayer mrgl = (NhlMapRGDataHandlerLayer) l;
        NhlMapRGDataHandlerLayerPart *mrgp = &mrgl->maprgdh;

	if (mrgp->aws_id > 0)
		_NhlFreeWorkspace(mrgp->aws_id);
	if (mrgp->fws_id > 0)
		_NhlFreeWorkspace(mrgp->fws_id);

        return NhlNOERROR;
}

static NhlErrorTypes MapRGDHUpdateDrawList
#if	NhlNeedProto
(
	NhlLayer	instance,
        NhlBoolean  	init,
        NhlMapPlotLayer newmp,
        NhlMapPlotLayer oldmp,
        _NhlArgList	args,
        int             num_args
        )
#else
(instance,newmp,oldmp,args,num_args)
	NhlLayer	instance;
        NhlBoolean  	init;
        NhlMapPlotLayer newmp;
        NhlMapPlotLayer oldmp;
        _NhlArgList	args;
        int             num_args;
#endif
{
        NhlErrorTypes ret = NhlNOERROR;

        return ret;
}

/*
 * Function:	mpFill
 *
 * Description:
 *
 * In Args:
 *
 * Out Args:	NONE
 *
 * Return Values: Error Conditions
 *
 * Side Effects: NONE
 */

static NhlErrorTypes mpFill
#if	NhlNeedProto
(
        NhlMapRGDataHandlerLayer 	mrgl,
	NhlMapPlotLayer			mpl,
	NhlString			entry_name
)
#else
(mrgl,mpl,entry_name)
        NhlMapRGDataHandlerLayer 	mrgl;
        NhlMapPlotLayer 		mpl;
	NhlString			entry_name;
#endif
{
        NhlMapRGDataHandlerLayerPart *mrgp = &mrgl->maprgdh;
	NhlErrorTypes		ret = NhlNOERROR, subret = NhlNOERROR;
	char			*e_text;
        NhlWorkspace		*aws = NULL;
        NhlWorkspace		*fws = NULL;
	int 			irgl;

	if (mrgp->fws_id < 1) {
		mrgp->fws_id =
			_NhlNewWorkspace(NhlwsOTHER,NhlwsNONE,
					 mpRG_FLT_REQ_SIZE);
		if (mrgp->fws_id < 1)
			return MIN(ret,(NhlErrorTypes)mrgp->fws_id);
	}
	if ((fws = _NhlUseWorkspace(mrgp->fws_id)) == NULL) {
		e_text = "%s: error reserving area map workspace";
		NhlPError(NhlFATAL,NhlEUNKNOWN,e_text,entry_name);
		return(NhlFATAL);
	}

	if (mrgp->aws_id < 1) {
		/*
		 * can't use NhlwsAREAMaP because the new map
		 * database doesn't do error recovery; so can't
		 * afford to trim the workspace -- it will result
		 * in errors later on
		 */
		mrgp->aws_id =
			_NhlNewWorkspace(NhlwsOTHER,NhlwsNONE,
					 mpRG_AREAMAP_REQ_SIZE);
		if (mrgp->aws_id < 1) {
			ret = MIN(ret,(NhlErrorTypes)mrgp->aws_id);
			goto error_ret;
		}
	}
	if ((aws = _NhlUseWorkspace(mrgp->aws_id)) == NULL) {
		e_text = "%s: error reserving area map workspace";
		NhlPError(NhlFATAL,NhlEUNKNOWN,e_text,entry_name);
		ret = NhlFATAL;
		goto error_ret;
	}

	if (mrgp->data_resolution == NhlUNSPECIFIEDRESOLUTION)
		c_mdrgdl(&irgl);
	else
		irgl = (int)mrgp->data_resolution;

	mrgp->real_data_resolution = (NhlMapDataResolution) irgl;

	subret = _NhlMdrgsf(irgl,fws,aws,entry_name);
        ret = MIN(subret,ret);

        subret = _NhlIdleWorkspace(aws);
        ret = MIN(subret,ret);

 error_ret:

        subret = _NhlIdleWorkspace(fws);
        ret = MIN(subret,ret);

	return ret;
}

/*
 * Function:	mpGrid
 *
 * Description:
 *
 * In Args:
 *
 * Out Args:	NONE
 *
 * Return Values: Error Conditions
 *
 * Side Effects: NONE
 */

static NhlErrorTypes mpGrid
#if	NhlNeedProto
(
        NhlMapRGDataHandlerLayer 	mrgl,
	NhlMapPlotLayer			mpl,
	NhlString			entry_name
)
#else
(mrgl,mpl,entry_name)
        NhlMapRGDataHandlerLayer 	mrgl;
        NhlMapPlotLayer 		mpl;
	NhlString			entry_name;
#endif
{
	NhlErrorTypes		ret = NhlNOERROR;
	NhlMapPlotLayerPart	*mpp = &(mpl->mapplot);
        float pole_param;

	Grid_Setup = False;
	c_mpseti("C2",mpp->grid.gks_color);
	_NhlLLErrCheckPrnt(NhlWARNING,entry_name);
	c_mpseti("C4", mpp->limb.gks_color);
	_NhlLLErrCheckPrnt(NhlWARNING,entry_name);

	c_mpsetr("GT",mpp->grid_lat_spacing);
	_NhlLLErrCheckPrnt(NhlWARNING,entry_name);
	c_mpsetr("GN",mpp->grid_lon_spacing);
	_NhlLLErrCheckPrnt(NhlWARNING,entry_name);
        pole_param = 1000.0 * mpp->grid_max_lat + mpp->grid_polar_lon_spacing;
        c_mpsetr("GP",pole_param);
	_NhlLLErrCheckPrnt(NhlWARNING,entry_name);

	if (mpp->grid_mask_mode != NhlMASKNONE) {
		char *e_text =
		    "%s: Grid masking not supported for rangs-gshhs database";
		NhlPError(NhlWARNING,NhlEUNKNOWN,e_text,entry_name);
		ret = MIN(ret,NhlWARNING);
	}
	c_mapgrd();
	_NhlLLErrCheckPrnt(NhlWARNING,entry_name);

	return ret;
}

static void SetLineAttrs
(
	NhlMapPlotLayerPart	  *mpp,
	NhlString		  entry_name
        )
{
        int color,dash_pattern;
        float thickness,dash_seglen;
	int type = 1;

        switch (type) {
            case 1:
            case 2:
	    default:
                    color = Mpp->geophysical.gks_color;
                    dash_pattern = Mpp->geophysical.dash_pat;
                    dash_seglen = Mpp->geophysical.dash_seglen;
                    thickness = Mpp->geophysical.thickness;
                    break;
            case 3:
                    color = Mpp->national.gks_color;
                    dash_pattern = Mpp->national.dash_pat;
                    dash_seglen = Mpp->national.dash_seglen;
                    thickness = Mpp->national.thickness;
                    break;
            case 4:
                    color = Mpp->us_state.gks_color;
                    dash_pattern = Mpp->us_state.dash_pat;
                    dash_seglen = Mpp->us_state.dash_seglen;
                    thickness = Mpp->us_state.thickness;
                    break;
        }

#if 0
	/* dash patterns don't work because lines are drawn using GPL at
	   the low level
	*/

	{
                int	dpat;
                NhlString *sp;
                float	p0,p1,jcrt;
                int	slen;
                char	buffer[128];
		int     i;

                dpat = dash_pattern % Mpp->dash_table->num_elements;
                sp = (NhlString *) Mpp->dash_table->data;
                slen = strlen(sp[dpat]);
                p0 =  (float) c_kfpy(0.0);
                _NhlLLErrCheckPrnt(NhlWARNING,entry_name);
                p1 = dash_seglen;
                p1 = (float) c_kfpy(p1);
                _NhlLLErrCheckPrnt(NhlWARNING,entry_name);
                jcrt = (int) ((p1 - p0) / slen + 0.5);
                jcrt = jcrt > 1 ? jcrt : 1;
                strcpy(buffer,sp[dpat]);

                c_dashdc(buffer,jcrt,4);
                _NhlLLErrCheckPrnt(NhlWARNING,entry_name);
        }
#endif
	{
              	gset_linewidth(thickness);
                _NhlLLErrCheckPrnt(NhlWARNING,entry_name);
        }
        return;
}

/*
 * Function:	mpOutline
 *
 * Description:
 *
 * In Args:
 *
 * Out Args:	NONE
 *
 * Return Values: Error Conditions
 *
 * Side Effects: NONE
 */

static NhlErrorTypes mpOutline
#if	NhlNeedProto
(
        NhlMapRGDataHandlerLayer 	mrgl,
	NhlMapPlotLayer			mpl,
	NhlString			entry_name
)
#else
(mrgl,mp,entry_name)
        NhlMapRGDataHandlerLayer 	mrgl;
        NhlMapPlotLayer 		mpl;
	NhlString			entry_name;
#endif
{
        NhlMapRGDataHandlerLayerPart *mrgp = &mrgl->maprgdh;
	NhlErrorTypes		ret = NhlNOERROR, subret = NhlNOERROR;
	char			*e_text;
	NhlMapPlotLayerPart	*mpp = &(mpl->mapplot);
	NhlWorkspace		*fws;
	int 			irgl;

	if (mrgp->fws_id < 1) {
		mrgp->fws_id =
			_NhlNewWorkspace(NhlwsOTHER,NhlwsNONE,
					 mpRG_FLT_REQ_SIZE);
		if (mrgp->fws_id < 1)
			return MIN(ret,(NhlErrorTypes)mrgp->fws_id);
	}
	if ((fws = _NhlUseWorkspace(mrgp->fws_id)) == NULL) {
		e_text = "%s: error reserving area map workspace";
		NhlPError(NhlFATAL,NhlEUNKNOWN,e_text,entry_name);
		return(NhlFATAL);
	}

	if (mrgp->data_resolution == NhlUNSPECIFIEDRESOLUTION)
		c_mdrgdl(&irgl);
	else
		irgl = (int)mrgp->data_resolution;

	mrgp->real_data_resolution = (NhlMapDataResolution) irgl;

	_NhlLLErrCheckPrnt(NhlWARNING,entry_name);

	SetLineAttrs(mpp,entry_name);

	subret = _NhlMdrgol(irgl,fws,entry_name);
	ret = MIN(subret,ret);

        subret = _NhlIdleWorkspace(fws);
        if ((ret = MIN(subret,ret)) < NhlWARNING) return ret;

	return ret;
}

static NhlErrorTypes MapRGDHDrawMapList
#if	NhlNeedProto
(
	NhlLayer		instance,
        NhlMapPlotLayer 	mpl,
        mpDrawOp		draw_op,
	NhlBoolean		init_draw
        )
#else
(instance,mpl,draw_op,init_draw)
	NhlLayer		instance;
        NhlMapPlotLayer 	mpl;
        mpDrawOp		draw_op;
	NhlDrawOrder		init_draw;
#endif
{
        NhlMapRGDataHandlerLayer mrgl =
		(NhlMapRGDataHandlerLayer) instance;
	NhlMapPlotLayerPart	  *mpp = &mpl->mapplot;
	NhlString entry_name = "MapRGDHDrawMapList";
        NhlErrorTypes ret = NhlNOERROR;
        int lcol[5], lcsf[5];

	Mpp = mpp;
	Mpl = mpl;
	Mrgp = &mrgl->maprgdh;

	lcsf[0] = Mpp->ocean.color;
	lcsf[1] = Mpp->land.color;
	lcsf[2] = Mpp->inland_water.color;
	lcsf[3] = Mpp->land.color;
	lcsf[4] = Mpp->inland_water.color;

	lcol[0] = lcol[1] = lcol[2] = lcol[3] = lcol[4]
		= Mpp->geophysical.color;

	c_mdrgsc(lcol,lcsf);

        switch (draw_op) {
	case mpDRAWFILL:
		ret =  mpFill(mrgl,mpl,entry_name);
		break;
	case mpDRAWOUTLINE:
		ret =  mpOutline(mrgl,mpl,entry_name);
		break;
	case mpDRAWGRID:
		ret =  mpGrid(mrgl,mpl,entry_name);
		break;
	default:
		break;
        }

	Mpp = NULL;
	Mpl = NULL;
	Mrgp = NULL;

        return ret;
}

#if 0

/*
 * Function:  mdrgdi
 *
 * Description:
 *
 * In Args:
 *
 * Out Args:
 *
 * Return Values:
 *
 * Side Effects:
 */

/*ARGSUSED*/
void   (_NHLCALLF(mdrgdi,MDRGDI))
#if	NhlNeedProto
(
        NGstring dinm,
	int len
)

#else
(dinm,len)
        NGstring dinm;
	int len;
#endif

{
	NhlString path = getenv("NCARG_RANGS");
	int length;

	if (! path) {
		NhlPError(NhlWARNING,NhlEUNKNOWN,
			  "NCARG_RANGS environment variable not set\n\t\n");
		path = ".";
		strcpy(dinm,NGCstrToFstr(path,1));
		return;
        }

	length = NGSTRLEN(path);

	strcpy(dinm,NGCstrToFstr(path,length));

	return;
}

#endif
/*
 * Function:  load_hlumap_routines
 *
 * Description: Forces the hlumap... routines to load from the HLU library
 *
 * In Args:   NhlBoolean flag - should always be False - dont actually
 *			        want to call the routines.
 *
 * Out Args:
 *
 * Return Values:
 *
 * Side Effects:
 */

/*ARGSUSED*/
static void   load_hlumap_routines
#if	NhlNeedProto
(
	NhlBoolean	flag
)
#else
(flag)
	NhlBoolean	flag;
#endif
{
	int idum;
	float fdum;

	if (flag) {
		_NHLCALLF(hlumapeod,HLUMAPEOD)
			(&idum,&idum,&idum,&idum,&idum,&fdum);
	}
	return;
}

{'repo_name': 'NCAR/ncl', 'stars': '143', 'repo_language': 'C', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': 866916527390776953, 'source_dataset': 'data'}


'use strict';

// ------------------------------------------------------------------------------
// Requirements
// ------------------------------------------------------------------------------

var rule = require('../rules/no-services');
var RuleTester = require('eslint').RuleTester;
var commonFalsePositives = require('./utils/commonFalsePositives');

// ------------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------------

var eslintTester = new RuleTester();

var angularObjectList = ['controller', 'filter', 'directive'];
var defaultBadService = ['$http', '$resource', 'Restangular', '$q', '$filter'];
var defaultBadServiceExcaped = [/\$http/, /\$resource/, 'Restangular', /\$q/, /\$filter/];
var mapAngularObjectToBarServices = {
    controller: defaultBadServiceExcaped,
    filter: defaultBadServiceExcaped,
    directive: defaultBadServiceExcaped
};
var valid = [];
var invalid = [];

angularObjectList.forEach(function(object) {
    valid.push({
        code: 'app.' + object + '("name", function(Service1) {});',
        options: [defaultBadService]
    }, {
        code: 'app.' + object + '("name", ["Service1", function(Service1) {}]);',
        options: [defaultBadService]
    }, {
        code: '"use strict";app.' + object + '("name", ["Service1", function(Service1) {}]);',
        options: [defaultBadService]
    });

    defaultBadService.forEach(function(badService) {
        invalid.push({
            code: 'app.' + object + '("name", function(' + badService + ') {});',
            options: [defaultBadServiceExcaped],
            errors: [{message: 'REST API calls should be implemented in a specific service (' + badService + ' in ' + object + ')'}]
        }, {
            code: 'app.' + object + '("name", ["' + badService + '", function(' + badService + ') {}]);',
            options: [defaultBadServiceExcaped],
            errors: [{message: 'REST API calls should be implemented in a specific service (' + badService + ' in ' + object + ')'}]
        });
    });
});

angularObjectList.forEach(function(object) {
    valid.push({
        code: 'app.' + object + '("name", function(Service1) {});',
        options: [defaultBadService, [object]]
    }, {
        code: 'app.' + object + '("name", ["Service1", function(Service1) {}]);',
        options: [defaultBadService, [object]]
    });

    defaultBadService.forEach(function(badService) {
        invalid.push({
            code: 'app.' + object + '("name", function(' + badService + ') {});',
            options: [defaultBadServiceExcaped, [object]],
            errors: [{message: 'REST API calls should be implemented in a specific service (' + badService + ' in ' + object + ')'}]
        }, {
            code: 'app.' + object + '("name", ["' + badService + '", function(' + badService + ') {}]);',
            options: [defaultBadServiceExcaped, [object]],
            errors: [{message: 'REST API calls should be implemented in a specific service (' + badService + ' in ' + object + ')'}]
        });
    });
});

angularObjectList.forEach(function(object) {
    valid.push({
        code: 'app.' + object + '("name", function(Service1) {});',
        options: [mapAngularObjectToBarServices]
    }, {
        code: 'app.' + object + '("name", ["Service1", function(Service1) {}]);',
        options: [mapAngularObjectToBarServices]
    });

    defaultBadService.forEach(function(badService) {
        invalid.push({
            code: 'app.' + object + '("name", function(' + badService + ') {});',
            options: [mapAngularObjectToBarServices],
            errors: [{message: 'REST API calls should be implemented in a specific service (' + badService + ' in ' + object + ')'}]
        }, {
            code: 'app.' + object + '("name", ["' + badService + '", function(' + badService + ') {}]);',
            options: [mapAngularObjectToBarServices],
            errors: [{message: 'REST API calls should be implemented in a specific service (' + badService + ' in ' + object + ')'}]
        });
    });
});

// ------------------------------------------------------------------------------
// Tests
// ------------------------------------------------------------------------------

eslintTester.run('no-services', rule, {
    valid: valid.concat(commonFalsePositives),
    invalid: invalid
});

{'repo_name': 'EmmanuelDemey/eslint-plugin-angular', 'stars': '609', 'repo_language': 'JavaScript', 'file_name': 'commonFalsePositives.js', 'mime_type': 'text/plain', 'hash': -2948461860706720137, 'source_dataset': 'data'}


<?php
/**
 * Created by PhpStorm.
 * User: howie
 * Date: 01/01/18
 * Time: 16:39
 */

namespace Weathermap\Tests;

use Weathermap\Core\ScaleEntry;
use Weathermap\Core\Colour;

class ScaleEntryTest extends \PHPUnit_Framework_TestCase
{

    public function testGetColour()
    {
        $lowColour = new Colour(254, 254, 254);
        $highColour = new Colour(0, 0, 0);

        $singleColourEntry = new ScaleEntry(0, 10, $lowColour);
        $gradientEntry = new ScaleEntry(0, 10, $lowColour, $highColour);
        $twoSameEntry = new ScaleEntry(0, 10, $lowColour, $lowColour);

        $result = $gradientEntry->getColour(0);
        $this->assertTrue($result->equals($lowColour));

        $result = $singleColourEntry->getColour(0);
        $this->assertTrue($result->equals($lowColour));

        $result = $gradientEntry->getColour(10);
        $this->assertTrue($result->equals($highColour));

        $result = $singleColourEntry->getColour(10);
        $this->assertTrue($result->equals($lowColour));

        $result = $singleColourEntry->getColour(5);
        $this->assertTrue($result->equals($lowColour));

        $result = $gradientEntry->getColour(5);
        $this->assertTrue($result->equals(new Colour(127, 127, 127)));

        $result = $twoSameEntry->getColour(0);
        $this->assertTrue($result->equals($lowColour));
        $result = $twoSameEntry->getColour(5);
        $this->assertTrue($result->equals($lowColour));
        $result = $twoSameEntry->getColour(10);
        $this->assertTrue($result->equals($lowColour));
    }

    public function testAsConfig()
    {
        $entry1 = new ScaleEntry(0, 10, new Colour(0, 0, 0));
        $entry2 = new ScaleEntry(-220, 10, new Colour(0, 0, 0), null, "TAG");
        $entry3 = new ScaleEntry(0, 5, new Colour(0, 0, 0), new Colour(100, 100, 100));
        $entry4 = new ScaleEntry(0, 5, new Colour(0, 0, 0), new Colour(100, 100, 100), "MY TAG");

        $this->assertEquals("\tSCALE DEFAULT 0    10     0 0 0   \n", $entry1->asConfig("DEFAULT", 1000, "."));
        $this->assertEquals("\tSCALE DEFAULT -220 10     0 0 0   TAG\n", $entry2->asConfig("DEFAULT", 1000, "."));
        $this->assertEquals(
            "\tSCALE DEFAULT 0    5      0 0 0  100 100 100   \n",
            $entry3->asConfig("DEFAULT", 1000, ".")
        );
        $this->assertEquals(
            "\tSCALE DEFAULT 0    5      0 0 0  100 100 100   MY TAG\n",
            $entry4->asConfig("DEFAULT", 1000, ".")
        );

        $entry5 = new ScaleEntry(2500, 5000, new Colour(0, 0, 0), new Colour(100, 100, 100), "MY TAG");
        $this->assertEquals(
            "\tSCALE DEFAULT 2.5K 5K     0 0 0  100 100 100   MY TAG\n",
            $entry5->asConfig("DEFAULT", 1000, ".")
        );
    }

    public function testCompare()
    {
        $entry1 = new ScaleEntry(0, 10, new Colour(0, 0, 0));
        $entry2 = new ScaleEntry(-220, 10, new Colour(0, 0, 0));
        $entry3 = new ScaleEntry(0, 5, new Colour(0, 0, 0));
        $entry4 = new ScaleEntry(0, 5, new Colour(0, 0, 0));

        $this->assertTrue($entry1->compare($entry2) > 0);
        $this->assertTrue($entry1->compare($entry3) > 0);
        $this->assertTrue($entry2->compare($entry1) < 0);

        $this->assertTrue($entry3->compare($entry4) == 0);
    }

    public function testHit()
    {
        $entry1 = new ScaleEntry(0, 10, new Colour(0, 0, 0));

        $this->assertTrue($entry1->hit(0));
        $this->assertTrue($entry1->hit(5));
        $this->assertTrue($entry1->hit(10));

        $this->assertFalse($entry1->hit(10.1));
        $this->assertFalse($entry1->hit(-10.1));
        $this->assertFalse($entry1->hit(-0.1));

        $entry2 = new ScaleEntry(-220, 10, new Colour(0, 0, 0));

        $this->assertTrue($entry2->hit(0));
        $this->assertTrue($entry2->hit(-10));
        $this->assertTrue($entry2->hit(-220));
        $this->assertTrue($entry2->hit(5));
        $this->assertTrue($entry2->hit(10));

        $this->assertFalse($entry2->hit(10.1));
        $this->assertFalse($entry2->hit(-310.1));
        $this->assertFalse($entry2->hit(-220.1));
    }

    public function testSpan()
    {
        $entry1 = new ScaleEntry(0, 10, new Colour(0, 0, 0));
        $entry2 = new ScaleEntry(-220, 10, new Colour(0, 0, 0));

        $this->assertEquals(10, $entry1->span());
        $this->assertEquals(230, $entry2->span());
    }

    public function test__toString()
    {
        $entry1 = new ScaleEntry(0, 10, new Colour(0, 0, 0));
        $entry2 = new ScaleEntry(-220, 10, new Colour(0, 0, 0));

        $this->assertEquals("[Entry 0.000000-10.000000]", "$entry1");
        $this->assertEquals("[Entry -220.000000-10.000000]", "$entry2");
    }
}

{'repo_name': 'howardjones/network-weathermap', 'stars': '355', 'repo_language': 'PHP', 'file_name': 'front.php', 'mime_type': 'text/x-php', 'hash': 1079425365210202511, 'source_dataset': 'data'}


// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PPAPI_CPP_PRIVATE_FLASH_DRM_H_
#define PPAPI_CPP_PRIVATE_FLASH_DRM_H_

#include <stdint.h>

#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/file_ref.h"
#include "ppapi/cpp/resource.h"

namespace pp {

class FileRef;

namespace flash {

class DRM : public Resource {
 public:
  DRM();
  explicit DRM(const InstanceHandle& instance);

  // On success, returns a string var.
  int32_t GetDeviceID(const CompletionCallbackWithOutput<Var>& callback);
  // Outputs the HMONITOR associated with the current plugin instance in
  // |hmonitor|. True is returned upon success.
  bool GetHmonitor(int64_t* hmonitor);
  // Returns the voucher file as a FileRef or an invalid resource on failure.
  int32_t GetVoucherFile(const CompletionCallbackWithOutput<FileRef>& callback);
  // On success, returns a value indicating if the monitor associated with the
  // current plugin instance is external.
  int32_t MonitorIsExternal(
      const CompletionCallbackWithOutput<PP_Bool>& callback);
};

}  // namespace flash
}  // namespace pp

#endif  // PPAPI_CPP_PRIVATE_FLASH_DRM_H_

{'repo_name': 'Samsung/ChromiumGStreamerBackend', 'stars': '105', 'repo_language': 'None', 'file_name': 'keyboard_utils.js', 'mime_type': 'text/plain', 'hash': -4237375599068992093, 'source_dataset': 'data'}


package net.openhft.chronicle.wire.utils;

public class JsonSourceCodeFormatter extends SourceCodeFormatter{
    public JsonSourceCodeFormatter() {
        super(2);
    }
}

{'repo_name': 'OpenHFT/Chronicle-Wire', 'stars': '176', 'repo_language': 'Java', 'file_name': 'boon.txt', 'mime_type': 'text/plain', 'hash': 8651306323840704360, 'source_dataset': 'data'}


<!DOCTYPE Linker_Placement_File>
<Root name="Flash Section Placement">
  <MemorySegment name="$(FLASH_NAME:FLASH)">
    <ProgramSection alignment="0x100" load="Yes" name=".vectors" start="$(FLASH_START:)" />
    <ProgramSection alignment="4" load="Yes" name=".init" />
    <ProgramSection alignment="4" load="Yes" name=".init_rodata" />
    <ProgramSection alignment="4" load="Yes" name=".text" />
    <ProgramSection alignment="4" load="Yes" name=".dtors" />
    <ProgramSection alignment="4" load="Yes" name=".ctors" />
    <ProgramSection alignment="4" load="Yes" name=".rodata" />
    <ProgramSection alignment="4" load="Yes" name=".ARM.exidx" address_symbol="__exidx_start" end_symbol="__exidx_end" />
    <ProgramSection alignment="4" load="Yes" runin=".fast_run" name=".fast" />
    <ProgramSection alignment="4" load="Yes" runin=".data_run" name=".data" />
    <ProgramSection alignment="4" load="Yes" runin=".tdata_run" name=".tdata" />
  </MemorySegment>
  <MemorySegment name="$(RAM_NAME:RAM);SRAM">
    <ProgramSection alignment="0x100" load="No" name=".vectors_ram" start="$(RAM_START:$(SRAM_START:))" />
    <ProgramSection alignment="4" load="No" name=".fast_run" />
    <ProgramSection alignment="4" load="No" name=".data_run" />
    <ProgramSection alignment="4" load="No" name=".bss" />
    <ProgramSection alignment="4" load="No" name=".tbss" />
    <ProgramSection alignment="4" load="No" name=".tdata_run" />
    <ProgramSection alignment="4" load="No" name=".non_init" />
    <ProgramSection alignment="4" size="__HEAPSIZE__" load="No" name=".heap" />
    <ProgramSection alignment="8" size="__STACKSIZE__" load="No" place_from_segment_end="Yes" name=".stack" />
    <ProgramSection alignment="8" size="__STACKSIZE_PROCESS__" load="No" name=".stack_process" />
  </MemorySegment>
  <MemorySegment name="$(FLASH2_NAME:FLASH2)">
    <ProgramSection alignment="4" load="Yes" name=".text2" />
    <ProgramSection alignment="4" load="Yes" name=".rodata2" />
    <ProgramSection alignment="4" load="Yes" runin=".data2_run" name=".data2" />
  </MemorySegment>
  <MemorySegment name="$(RAM2_NAME:RAM2)">
    <ProgramSection alignment="4" load="No" name=".data2_run" />
    <ProgramSection alignment="4" load="No" name=".bss2" />
  </MemorySegment>
</Root>

{'repo_name': 'hathach/tinyusb', 'stars': '594', 'repo_language': 'C', 'file_name': 'nrf_mbr.h', 'mime_type': 'text/x-c', 'hash': -1957829567126861304, 'source_dataset': 'data'}


//------------------------------------------------------------------------------
// tri_functions: four variants of outer-product triangle counting
//------------------------------------------------------------------------------

#include "tri_def.h"

//------------------------------------------------------------------------------
// outer-product methods, no binary search
//------------------------------------------------------------------------------

// tri_mark
#include "tri_template.c"

// tri_bit
#define BIT
#include "tri_template.c"

// tri_mark_parallel
#define PARALLEL
#include "tri_template.c"

// tri_bit_parallel
#define PARALLEL
#define BIT
#include "tri_template.c"

//------------------------------------------------------------------------------
// dot product methods
//------------------------------------------------------------------------------

// tri_dot
#include "tri_dot_template.c"

// tri_dot_parallel
#define PARALLEL
#include "tri_dot_template.c"

//------------------------------------------------------------------------------
// outer-product methods, with binary search
//------------------------------------------------------------------------------

// tri_logmark
#define LOGSEARCH
#include "tri_template.c"

// tri_logbit
#define LOGSEARCH
#define BIT
#include "tri_template.c"

// tri_logmark_parallel
#define LOGSEARCH
#define PARALLEL
#include "tri_template.c"

// tri_logbit_parallel
#define LOGSEARCH
#define PARALLEL
#define BIT
#include "tri_template.c"

{'repo_name': 'RedisGraph/RedisGraph', 'stars': '1085', 'repo_language': 'C', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': -5955476996581930566, 'source_dataset': 'data'}


# Class cis::el7:1_1_8
#
# CIS Security Benchmark for RHEL7
#

class cis::el7::1_1_8   {
  include cis::linuxcontrols::c0000
}

{'repo_name': 'arildjensen/cis-puppet', 'stars': '119', 'repo_language': 'Puppet', 'file_name': 'f0007.rb', 'mime_type': 'text/x-ruby', 'hash': 3730702878436113035, 'source_dataset': 'data'}


--TEST--
Testing static call method using the original class name
--FILE--
<?php

class foo {
	static public function msg() {
		print "hello\n";
	}
}

interface test { }

class_alias('foo', 'baz');

class bar extends baz {
	public function __construct() {
		foo::msg();
	}
}

new bar;

?>
--EXPECT--
hello

{'repo_name': 'infusion/PHP', 'stars': '137', 'repo_language': 'C', 'file_name': 'autoload_012.phpt', 'mime_type': 'text/plain', 'hash': -1697190324608169568, 'source_dataset': 'data'}


# Question

* For questions, please use [this forum](https://forum.xda-developers.com/android/apps-games/source-email-t3824168).

# Feature request

* Did you check if there wasn't a similar feature request?
* Did you read [this FAQ](https://github.com/M66B/FairEmail/blob/master/FAQ.md#FAQ15)?

# Bug report

* Did you check if there wasn't a similar bug report?
* Are you using the [latest version](https://github.com/M66B/FairEmail/releases) of the app?

## Expected behavior

## Actual behavior

## Steps to reproduce the problem

1.
1.
1.

## Version

* App version:
* Android version:

{'repo_name': 'M66B/FairEmail', 'stars': '1151', 'repo_language': 'Java', 'file_name': 'ParcelFileDescriptorUtil.java', 'mime_type': 'text/x-java', 'hash': 6008481390472679447, 'source_dataset': 'data'}


/*
 * Driver for PowerMac AWACS onboard soundchips
 * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de>
 *   based on dmasound.c.
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 */

#ifndef __AWACS_H
#define __AWACS_H

/*******************************/
/* AWACs Audio Register Layout */
/*******************************/

struct awacs_regs {
    unsigned	control;	/* Audio control register */
    unsigned	pad0[3];
    unsigned	codec_ctrl;	/* Codec control register */
    unsigned	pad1[3];
    unsigned	codec_stat;	/* Codec status register */
    unsigned	pad2[3];
    unsigned	clip_count;	/* Clipping count register */
    unsigned	pad3[3];
    unsigned	byteswap;	/* Data is little-endian if 1 */
};

/*******************/
/* Audio Bit Masks */
/*******************/

/* Audio Control Reg Bit Masks */
/* ----- ------- --- --- ----- */
#define MASK_ISFSEL	(0xf)		/* Input SubFrame Select */
#define MASK_OSFSEL	(0xf << 4)	/* Output SubFrame Select */
#define MASK_RATE	(0x7 << 8)	/* Sound Rate */
#define MASK_CNTLERR	(0x1 << 11)	/* Error */
#define MASK_PORTCHG	(0x1 << 12)	/* Port Change */
#define MASK_IEE	(0x1 << 13)	/* Enable Interrupt on Error */
#define MASK_IEPC	(0x1 << 14)	/* Enable Interrupt on Port Change */
#define MASK_SSFSEL	(0x3 << 15)	/* Status SubFrame Select */

/* Audio Codec Control Reg Bit Masks */
/* ----- ----- ------- --- --- ----- */
#define MASK_NEWECMD	(0x1 << 24)	/* Lock: don't write to reg when 1 */
#define MASK_EMODESEL	(0x3 << 22)	/* Send info out on which frame? */
#define MASK_EXMODEADDR	(0x3ff << 12)	/* Extended Mode Address -- 10 bits */
#define MASK_EXMODEDATA	(0xfff)		/* Extended Mode Data -- 12 bits */

/* Audio Codec Control Address Values / Masks */
/* ----- ----- ------- ------- ------ - ----- */
#define MASK_ADDR0	(0x0 << 12)	/* Expanded Data Mode Address 0 */
#define MASK_ADDR_MUX	MASK_ADDR0	/* Mux Control */
#define MASK_ADDR_GAIN	MASK_ADDR0

#define MASK_ADDR1	(0x1 << 12)	/* Expanded Data Mode Address 1 */
#define MASK_ADDR_MUTE	MASK_ADDR1
#define MASK_ADDR_RATE	MASK_ADDR1

#define MASK_ADDR2	(0x2 << 12)	/* Expanded Data Mode Address 2 */
#define MASK_ADDR_VOLA	MASK_ADDR2	/* Volume Control A -- Headphones */
#define MASK_ADDR_VOLHD MASK_ADDR2

#define MASK_ADDR4	(0x4 << 12)	/* Expanded Data Mode Address 4 */
#define MASK_ADDR_VOLC	MASK_ADDR4	/* Volume Control C -- Speaker */
#define MASK_ADDR_VOLSPK MASK_ADDR4

/* additional registers of screamer */
#define MASK_ADDR5	(0x5 << 12)	/* Expanded Data Mode Address 5 */
#define MASK_ADDR6	(0x6 << 12)	/* Expanded Data Mode Address 6 */
#define MASK_ADDR7	(0x7 << 12)	/* Expanded Data Mode Address 7 */

/* Address 0 Bit Masks & Macros */
/* ------- - --- ----- - ------ */
#define MASK_GAINRIGHT	(0xf)		/* Gain Right Mask */
#define MASK_GAINLEFT	(0xf << 4)	/* Gain Left Mask */
#define MASK_GAINLINE	(0x1 << 8)	/* Disable Mic preamp */
#define MASK_GAINMIC	(0x0 << 8)	/* Enable Mic preamp */
#define MASK_MUX_CD	(0x1 << 9)	/* Select CD in MUX */
#define MASK_MUX_MIC	(0x1 << 10)	/* Select Mic in MUX */
#define MASK_MUX_AUDIN	(0x1 << 11)	/* Select Audio In in MUX */
#define MASK_MUX_LINE	MASK_MUX_AUDIN
#define SHIFT_GAINLINE	8
#define SHIFT_MUX_CD	9
#define SHIFT_MUX_MIC	10
#define SHIFT_MUX_LINE	11

#define GAINRIGHT(x)	((x) & MASK_GAINRIGHT)
#define GAINLEFT(x)	(((x) << 4) & MASK_GAINLEFT)

/* Address 1 Bit Masks */
/* ------- - --- ----- */
#define MASK_ADDR1RES1	(0x3)		/* Reserved */
#define MASK_RECALIBRATE (0x1 << 2)	/* Recalibrate */
#define MASK_SAMPLERATE	(0x7 << 3)	/* Sample Rate: */
#define MASK_LOOPTHRU	(0x1 << 6)	/* Loopthrough Enable */
#define SHIFT_LOOPTHRU	6
#define MASK_CMUTE	(0x1 << 7)	/* Output C (Speaker) Mute when 1 */
#define MASK_SPKMUTE	MASK_CMUTE
#define SHIFT_SPKMUTE	7
#define MASK_ADDR1RES2	(0x1 << 8)	/* Reserved */
#define MASK_AMUTE	(0x1 << 9)	/* Output A (Headphone) Mute when 1 */
#define MASK_HDMUTE	MASK_AMUTE
#define SHIFT_HDMUTE	9
#define MASK_PAROUT	(0x3 << 10)	/* Parallel Out (???) */
#define MASK_PAROUT0	(0x1 << 10)	/* Parallel Out (???) */
#define MASK_PAROUT1	(0x1 << 11)	/* Parallel Out (enable speaker) */
#define SHIFT_PAROUT	10
#define SHIFT_PAROUT0	10
#define SHIFT_PAROUT1	11

#define SAMPLERATE_48000	(0x0 << 3)	/* 48 or 44.1 kHz */
#define SAMPLERATE_32000	(0x1 << 3)	/* 32 or 29.4 kHz */
#define SAMPLERATE_24000	(0x2 << 3)	/* 24 or 22.05 kHz */
#define SAMPLERATE_19200	(0x3 << 3)	/* 19.2 or 17.64 kHz */
#define SAMPLERATE_16000	(0x4 << 3)	/* 16 or 14.7 kHz */
#define SAMPLERATE_12000	(0x5 << 3)	/* 12 or 11.025 kHz */
#define SAMPLERATE_9600		(0x6 << 3)	/* 9.6 or 8.82 kHz */
#define SAMPLERATE_8000		(0x7 << 3)	/* 8 or 7.35 kHz */

/* Address 2 & 4 Bit Masks & Macros */
/* ------- - - - --- ----- - ------ */
#define MASK_OUTVOLRIGHT (0xf)		/* Output Right Volume */
#define MASK_ADDR2RES1	(0x2 << 4)	/* Reserved */
#define MASK_ADDR4RES1	MASK_ADDR2RES1
#define MASK_OUTVOLLEFT	(0xf << 6)	/* Output Left Volume */
#define MASK_ADDR2RES2	(0x2 << 10)	/* Reserved */
#define MASK_ADDR4RES2	MASK_ADDR2RES2

#define VOLRIGHT(x)	(((~(x)) & MASK_OUTVOLRIGHT))
#define VOLLEFT(x)	(((~(x)) << 6) & MASK_OUTVOLLEFT)

/* address 6 */
#define MASK_MIC_BOOST  (0x4)		/* screamer mic boost */
#define SHIFT_MIC_BOOST	2

/* Audio Codec Status Reg Bit Masks */
/* ----- ----- ------ --- --- ----- */
#define MASK_EXTEND	(0x1 << 23)	/* Extend */
#define MASK_VALID	(0x1 << 22)	/* Valid Data? */
#define MASK_OFLEFT	(0x1 << 21)	/* Overflow Left */
#define MASK_OFRIGHT	(0x1 << 20)	/* Overflow Right */
#define MASK_ERRCODE	(0xf << 16)	/* Error Code */
#define MASK_REVISION	(0xf << 12)	/* Revision Number */
#define MASK_MFGID	(0xf << 8)	/* Mfg. ID */
#define MASK_CODSTATRES	(0xf << 4)	/* bits 4 - 7 reserved */
#define MASK_INSENSE	(0xf)		/* port sense bits: */
#define MASK_HDPCONN		8	/* headphone plugged in */
#define MASK_LOCONN		4	/* line-out plugged in */
#define MASK_LICONN		2	/* line-in plugged in */
#define MASK_MICCONN		1	/* microphone plugged in */
#define MASK_LICONN_IMAC	8	/* line-in plugged in */
#define MASK_HDPRCONN_IMAC	4	/* headphone right plugged in */
#define MASK_HDPLCONN_IMAC	2	/* headphone left plugged in */
#define MASK_LOCONN_IMAC	1	/* line-out plugged in */

/* Clipping Count Reg Bit Masks */
/* -------- ----- --- --- ----- */
#define MASK_CLIPLEFT	(0xff << 7)	/* Clipping Count, Left Channel */
#define MASK_CLIPRIGHT	(0xff)		/* Clipping Count, Right Channel */

/* DBDMA ChannelStatus Bit Masks */
/* ----- ------------- --- ----- */
#define MASK_CSERR	(0x1 << 7)	/* Error */
#define MASK_EOI	(0x1 << 6)	/* End of Input --
					   only for Input Channel */
#define MASK_CSUNUSED	(0x1f << 1)	/* bits 1-5 not used */
#define MASK_WAIT	(0x1)		/* Wait */

/* Various Rates */
/* ------- ----- */
#define RATE_48000	(0x0 << 8)	/* 48 kHz */
#define RATE_44100	(0x0 << 8)	/* 44.1 kHz */
#define RATE_32000	(0x1 << 8)	/* 32 kHz */
#define RATE_29400	(0x1 << 8)	/* 29.4 kHz */
#define RATE_24000	(0x2 << 8)	/* 24 kHz */
#define RATE_22050	(0x2 << 8)	/* 22.05 kHz */
#define RATE_19200	(0x3 << 8)	/* 19.2 kHz */
#define RATE_17640	(0x3 << 8)	/* 17.64 kHz */
#define RATE_16000	(0x4 << 8)	/* 16 kHz */
#define RATE_14700	(0x4 << 8)	/* 14.7 kHz */
#define RATE_12000	(0x5 << 8)	/* 12 kHz */
#define RATE_11025	(0x5 << 8)	/* 11.025 kHz */
#define RATE_9600	(0x6 << 8)	/* 9.6 kHz */
#define RATE_8820	(0x6 << 8)	/* 8.82 kHz */
#define RATE_8000	(0x7 << 8)	/* 8 kHz */
#define RATE_7350	(0x7 << 8)	/* 7.35 kHz */

#define RATE_LOW	1	/* HIGH = 48kHz, etc;  LOW = 44.1kHz, etc. */

#endif /* __AWACS_H */

{'repo_name': 'chenshuo/linux-study', 'stars': '104', 'repo_language': 'C', 'file_name': 'g84.c', 'mime_type': 'text/x-c', 'hash': -1471539994593936155, 'source_dataset': 'data'}


/*
Copyright 2015 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package controller contains code for controllers (like the replication
// controller).
package controller

{'repo_name': 'kubernetes-retired/kube-mesos-framework', 'stars': '107', 'repo_language': 'HTML', 'file_name': 'funcs.go', 'mime_type': 'text/plain', 'hash': -8775851820757352824, 'source_dataset': 'data'}


import RangeSelectorModel from "src/viewmodel/widgets/range-selector-model"
import Deferred           from "src/utils/deferred"
import Validators         from "src/utils/validation/validators"

describe("RangeSelectorModel", () => {

  var model;

  beforeEach(() => {

    model = new RangeSelectorModel(
      Validators.backtest.startTime,
      Validators.backtest.endTime
    );
    model.initialize(new Date(2015,10,1), new Date(2015,10,15),
      new Date(2015,10,2), new Date(2015,10,3));
  });

  it("初期状態", () => {
    expect(model.startTime).toEqual( new Date(2015,10,2) );
    expect(model.endTime).toEqual( new Date(2015,10,3) );
    expect(model.minDate).toEqual( new Date(2015,10,1) );
    expect(model.maxDate).toEqual( new Date(2015,10,15) );
    expect(model.startTimeError).toEqual( null );
    expect(model.endTimeError).toEqual( null );
  });

  describe("validate", () => {
    it("問題がない場合", () => {
      expect(model.validate()).toEqual( true );

      expect(model.startTime).toEqual( new Date(2015,10,2) );
      expect(model.endTime).toEqual( new Date(2015,10,3) );
      expect(model.minDate).toEqual( new Date(2015,10,1) );
      expect(model.maxDate).toEqual( new Date(2015,10,15) );
      expect(model.startTimeError).toEqual( null );
      expect(model.endTimeError).toEqual( null );
    });
    it("startTimeが未入力の場合", () => {
      model.startTime = null;
      expect(model.validate()).toEqual( false );

      expect(model.startTime).toEqual( null );
      expect(model.endTime).toEqual( new Date(2015,10,3) );
      expect(model.minDate).toEqual( new Date(2015,10,1) );
      expect(model.maxDate).toEqual( new Date(2015,10,15) );
      expect(model.startTimeError).toEqual( "開始日時を入力してください" );
      expect(model.endTimeError).toEqual( null );
    });
    it("endTimeが未入力の場合", () => {
      model.endTime = null;
      expect(model.validate()).toEqual( false );

      expect(model.startTime).toEqual( new Date(2015,10,2) );
      expect(model.endTime).toEqual( null );
      expect(model.minDate).toEqual( new Date(2015,10,1) );
      expect(model.maxDate).toEqual( new Date(2015,10,15) );
      expect(model.startTimeError).toEqual( null );
      expect(model.endTimeError).toEqual( "終了日時を入力してください" );
    });
    it("startTime >= endTimeの場合", () => {
      model.endTime = new Date(2015,10,2);
      expect(model.validate()).toEqual( false );

      expect(model.startTime).toEqual( new Date(2015,10,2) );
      expect(model.endTime).toEqual(  new Date(2015,10,2) );
      expect(model.minDate).toEqual( new Date(2015,10,1) );
      expect(model.maxDate).toEqual( new Date(2015,10,15) );
      expect(model.startTimeError).toEqual( "開始日時が不正です" );
      expect(model.endTimeError).toEqual( null );

      model.endTime = new Date(2015,10,1,23);
      expect(model.validate()).toEqual( false );

      expect(model.startTime).toEqual( new Date(2015,10,2) );
      expect(model.endTime).toEqual(  new Date(2015,10,1,23) );
      expect(model.minDate).toEqual( new Date(2015,10,1) );
      expect(model.maxDate).toEqual( new Date(2015,10,15) );
      expect(model.startTimeError).toEqual( "開始日時が不正です" );
      expect(model.endTimeError).toEqual( null );
    });
  });
});

{'repo_name': 'unageanu/jiji2', 'stars': '202', 'repo_language': 'JavaScript', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': 445891865216168186, 'source_dataset': 'data'}


@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\..\mime\cli.js" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "%~dp0\..\mime\cli.js" %*
)

{'repo_name': 'lps243492947/learn_git', 'stars': '120', 'repo_language': 'JavaScript', 'file_name': 'cli.js', 'mime_type': 'text/plain', 'hash': 3575881156422218061, 'source_dataset': 'data'}


This directory provides a collection of block ciphers

  * AES
  * IDEA
  * MARS
  * RC6
  * Serpent
  * TEA
  * TWOFISH

(and their functional correctness proofs), plus some modes
of operation (modesScript.sml). Also the hash algorithm SHA-1
has been formalized. A worked example in data encryption may
be found in tea.data.encrypt.

{'repo_name': 'HOL-Theorem-Prover/HOL', 'stars': '382', 'repo_language': 'Standard ML', 'file_name': 'Makefile', 'mime_type': 'text/x-makefile', 'hash': 1947167071453273472, 'source_dataset': 'data'}


package golomb

import (
	"bufio"
	"bytes"
	"crypto/md5"
	"encoding/hex"
	"fmt"
	"io"
	"os"
	"reflect"
	"sort"
	"strconv"
	"testing"

	"github.com/tcnksm/go-casper/internal/bits"
)

func TestDecode(t *testing.T) {
	cases := []struct {
		input []byte
		p     uint
		want  uint
		err   error
	}{
		{
			[]byte{0xcb, 0x80}, // 11001011 10000000
			1 << 6,
			151,
			nil,
		},
		{
			[]byte{0xcb}, // 11001011
			1 << 5,
			75,
			io.EOF,
		},
		{
			[]byte{0x00}, // 00000000
			1 << 7,
			0,
			errPadding,
		},
	}

	for _, tc := range cases {
		rd := bytes.NewReader(tc.input)
		br := bits.NewReader(rd)
		got, err := decode(br, tc.p)
		if err != tc.err {
			t.Errorf("error=%v, want=%v", err, tc.err)
		}

		if got != tc.want {
			t.Errorf("decode=%v, want=%v", got, tc.want)
		}

	}
}

func TestDecodeAll(t *testing.T) {
	cases := []struct {
		input []byte
		p     uint
		want  []uint
	}{
		{
			[]byte{0xcb, 0x80}, // 11001011 10000000
			1 << 6,
			[]uint{151},
		},

		{
			[]byte{0xcb, 0xcf}, // 11001011 11001111
			1 << 5,
			[]uint{75, 154},
		},

		{
			[]byte{0x81, 0x4e},
			1 << 6,
			[]uint{65, 104},
		},
	}

	for _, tc := range cases {
		rd := bytes.NewReader(tc.input)
		got, err := DecodeAll(rd, tc.p)
		if err != nil {
			t.Fatal(err)
		}

		if !reflect.DeepEqual(got, tc.want) {
			t.Errorf("Decode=%v, want=%v", got, tc.want)
		}

	}
}

func TestEncoding(t *testing.T) {
	cases := []struct {
		input []uint
		p     uint
		want  []byte
	}{
		{
			[]uint{151},
			1 << 6,
			[]byte{0xcb, 0x80}, // 11001011 10000000
		},

		{
			[]uint{65, 104},
			1 << 6,
			[]byte{0x81, 0x4e}, // 10000001 1001110
		},
	}

	for _, tc := range cases {
		var buf bytes.Buffer
		if err := Encode(&buf, tc.input, tc.p); err != nil {
			t.Fatal(err)
		}

		if got := buf.Bytes(); !bytes.Equal(got, tc.want) {
			t.Errorf("Encode=%x, want=%x", got, tc.want)
		}
	}
}

func ExampleEncode() {
	// Number of elements and false positive probability.
	//
	// Minimum number of bits is N*log(P)
	// = 26 * log(1<<6) = 156 bits = 19 bytes
	N, P := uint(26), uint(1<<6)

	// Example data set comes from https://github.com/rasky/gcs
	file := "./testdata/words.nato"
	f, _ := os.Open(file)
	sc := bufio.NewScanner(f)
	defer f.Close()

	hashF := func(v []byte) uint {
		h := md5.New()
		h.Write(v)
		b := h.Sum(nil)

		s := hex.EncodeToString(b[12:16])
		i, err := strconv.ParseUint(s, 16, 32)
		if err != nil {
			panic(err)
		}
		return uint(i) % (N * P)
	}

	a := make([]uint, 0, N)
	for sc.Scan() {
		a = append(a, hashF(sc.Bytes()))
	}
	sort.Slice(a, func(i, j int) bool {
		return a[i] < a[j]
	})

	// Encode hash value array to Golomb-coded sets
	// and write it to buffer.
	var buf bytes.Buffer
	Encode(&buf, a, P)

	fmt.Printf("%x", buf.Bytes())
	// Output: cba920f780663a061f2065198ab1032d624c50331e66ae9818
}

{'repo_name': 'tcnksm/go-casper', 'stars': '111', 'repo_language': 'Go', 'file_name': 'words.nato', 'mime_type': 'text/plain', 'hash': 8567641695869594087, 'source_dataset': 'data'}


#!/usr/bin/python
######################################################################
# Cloud Routes Availability Manager: heroku-dyno-status module
# ------------------------------------------------------------------
# This module will query Heroku's api and check for a single dyno's status
# This will return true if no errors or false if there are errors
# ------------------------------------------------------------------
# Author: Benjamin J. Cane - madflojo@cloudrout.es
######################################################################

import requests
import json
import base64

def check(**kwargs):
    """ Checks Heroku's api status for dyno status"""
    jdata = kwargs['jdata']
    logger = kwargs['logger']
    basekey = base64.b64encode(":" + jdata['data']['apikey'])
    headers = {
        "Accept": "application/vnd.heroku+json; version=3",
        "Authorization": basekey
    }
    timeout = 5.00
    url = "https://api.heroku.com/apps/" + jdata['data']['appname'] + "/dynos"
    try:
        result = requests.get(
            url, timeout=timeout, headers=headers, verify=True)
    except:
        return None
    line = "heroku-dyno-status: Got response from heroku for monitor - %s" % (
        result.text)
    logger.debug(line)
    retdata = json.loads(result.text)
    false = 0
    if result.status_code >= 200 and result.status_code <= 299:
        for dyno in retdata:
            if dyno['state'] == "idle":
                false = false + 1
    else:
        return None

    if false == 0:
        return True
    else:
        return False

{'repo_name': 'Runbook/runbook', 'stars': '194', 'repo_language': 'Python', 'file_name': 'Dockerfile', 'mime_type': 'text/plain', 'hash': -4300676553604826095, 'source_dataset': 'data'}


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<TITLE>
Uses of Interface org.apache.fop.fo.properties.BreakPropertySet (Apache FOP 0.95 API)
</TITLE>

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../../stylesheet.css" TITLE="Style">

      Overview
      Package
      Class
    Use
      Tree
      Deprecated
      Index
      Help

fop 0.95

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes

Uses of Interface
org.apache.fop.fo.properties.BreakPropertySet

Packages that use BreakPropertySet

org.apache.fop.fo.flow
All the block- and inline-level flow formatting objects.

org.apache.fop.fo.flow.table

Uses of BreakPropertySet in org.apache.fop.fo.flow

Classes in org.apache.fop.fo.flow that implement BreakPropertySet

 class
Block

          Class modelling the fo:block object.

 class
BlockContainer

          Class modelling the fo:block-container object.

 class
ListBlock

          Class modelling the fo:list-block object.

 class
ListItem

          Class modelling the fo:list-item object.

Uses of BreakPropertySet in org.apache.fop.fo.flow.table

Classes in org.apache.fop.fo.flow.table that implement BreakPropertySet

 class
Table

          Class modelling the fo:table object.

 class
TableRow

          Class modelling the fo:table-row object.

      Overview
      Package
      Class
    Use
      Tree
      Deprecated
      Index
      Help

fop 0.95

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes

Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.

{'repo_name': 'keymanapp/keyman', 'stars': '131', 'repo_language': 'Pascal', 'file_name': 'main_donators.dfm', 'mime_type': 'text/plain', 'hash': 2963765743637200700, 'source_dataset': 'data'}


{*
 +--------------------------------------------------------------------+
 | Copyright CiviCRM LLC. All rights reserved.                        |
 |                                                                    |
 | This work is published under the GNU AGPLv3 license with some      |
 | permitted exceptions and without any warranty. For full license    |
 | and copyright information, see https://civicrm.org/licensing       |
 +--------------------------------------------------------------------+
*}
{foreach from=$blocks item=block}

{$block.subject}

      {$block.content}

{/foreach}

{'repo_name': 'civicrm/civicrm-core', 'stars': '382', 'repo_language': 'PHP', 'file_name': 'jquery.crmEditable.js', 'mime_type': 'text/plain', 'hash': -6680474587386649044, 'source_dataset': 'data'}


/*
 * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
 *
 * This program is free software; you may redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 *
 */

#ifndef USNIC_UIOM_H_
#define USNIC_UIOM_H_

#include <linux/list.h>
#include <linux/scatterlist.h>

#include "usnic_uiom_interval_tree.h"

#define USNIC_UIOM_READ			(1)
#define USNIC_UIOM_WRITE		(2)

#define USNIC_UIOM_MAX_PD_CNT		(1000)
#define USNIC_UIOM_MAX_MR_CNT		(1000000)
#define USNIC_UIOM_MAX_MR_SIZE		(~0UL)
#define USNIC_UIOM_PAGE_SIZE		(PAGE_SIZE)

struct usnic_uiom_dev {
	struct device			*dev;
	struct list_head		link;
};

struct usnic_uiom_pd {
	struct iommu_domain		*domain;
	spinlock_t			lock;
	struct rb_root			rb_root;
	struct list_head		devs;
	int				dev_cnt;
};

struct usnic_uiom_reg {
	struct usnic_uiom_pd		*pd;
	unsigned long			va;
	size_t				length;
	int				offset;
	int				page_size;
	int				writable;
	struct list_head		chunk_list;
	struct work_struct		work;
	struct mm_struct		*mm;
	unsigned long			diff;
};

struct usnic_uiom_chunk {
	struct list_head		list;
	int				nents;
	struct scatterlist		page_list[0];
};

struct usnic_uiom_pd *usnic_uiom_alloc_pd(void);
void usnic_uiom_dealloc_pd(struct usnic_uiom_pd *pd);
int usnic_uiom_attach_dev_to_pd(struct usnic_uiom_pd *pd, struct device *dev);
void usnic_uiom_detach_dev_from_pd(struct usnic_uiom_pd *pd,
					struct device *dev);
struct device **usnic_uiom_get_dev_list(struct usnic_uiom_pd *pd);
void usnic_uiom_free_dev_list(struct device **devs);
struct usnic_uiom_reg *usnic_uiom_reg_get(struct usnic_uiom_pd *pd,
						unsigned long addr, size_t size,
						int access, int dmasync);
void usnic_uiom_reg_release(struct usnic_uiom_reg *uiomr, int closing);
int usnic_uiom_init(char *drv_name);
void usnic_uiom_fini(void);
#endif /* USNIC_UIOM_H_ */

{'repo_name': 'ljrcore/linuxmooc', 'stars': '217', 'repo_language': 'C', 'file_name': 'ecc.c', 'mime_type': 'text/x-c', 'hash': -7269402659421905462, 'source_dataset': 'data'}


//
// Book:      OpenGL(R) ES 2.0 Programming Guide
// Authors:   Aaftab Munshi, Dan Ginsburg, Dave Shreiner
// ISBN-10:   0321502795
// ISBN-13:   9780321502797
// Publisher: Addison-Wesley Professional
// URLs:      http://safari.informit.com/9780321563835
//            http://www.opengles-book.com
// Additional contributions copyright (c) 2011 Research In Motion Limited

// esUtil_TGA.c
//
//    This file contains the QNX implementation of a TGA image loader

#include <stdio.h>
#include <stdlib.h>

#include "esUtil.h"

////////////////////////////////////////////////////////////////////////////////////
//
//  Public Functions
//
//

///
//  LoadTGA()
//
int LoadTGA(const char *fileName, char **buffer, int *width, int *height)
{
    char path[255];
    strcpy(path, "./app/native/");
    strcat(path, fileName);

    FILE* file = fopen(path, "rb");
    if (!file)
    {
        return FALSE;
    }

    // Read the image header
    unsigned char header[12];
    fread(header, sizeof(unsigned char), 12, file);

    // Make sure this is a type 2 image
    if (header[2] != 2)
    {
        // Unsupported tga image type in file
        fclose(file);
        return FALSE;
    }

    // Make sure there is no color map in this image
    if (header[1] != 0)
    {
        // Unsupported color map
        fclose(file);
        return FALSE;
    }

    // Read width and height fields for the image
    short s;
    fread(&s, sizeof(short), 1, file);
    *width = s;
    fread(&s, sizeof(short), 1, file);
    *height = s;

    // Read in the bits per pixel format for this image (only support 24 and 32)
    unsigned char bpp;
    fread(&bpp, sizeof(unsigned char), 1, file);
    if (bpp != 24 && bpp != 32)
    {
        fclose(file);
        return FALSE;
    }

    // Calculate the actual number of color components and the texture data size
    int colorComponents = bpp / 8;
    int size = (*width) * (*height) * colorComponents;

    // Read past the image descriptor byte
    fseek(file, 1, SEEK_CUR);

    // Read past the image identification field, in case it exists
    if (header[0] > 0)
    {
        fseek(file, header[0], SEEK_CUR);
    }

    // Allocate space for the pixels in this image
    char* data = malloc(size);

    // Read in the texture data
    fread(data, 1, size, file);

    // Done reading in TGA file
    fclose(file);

    // Swap the first and third bytes - R (red) and B (blue) - to convert the image to RGB(A) format
    unsigned char temp;
    int i;
    for (i = 0; i < size; i += colorComponents)
    {
        temp = data[i];
        data[i] = data[i+2];
        data[i+2] = temp;
    }

    if (colorComponents == 3)
    {
        *buffer = data;
    }
    else if (colorComponents == 4)
    {
        // Convert RGBA to RGB
        int pixelCount = (*width) * (*height);
        *buffer = malloc(pixelCount * 3);
        for (i = 0; i < pixelCount; ++i)
        {
            (*buffer)[i * 3] = data[i * 4];
            (*buffer)[i * 3 + 1] = data[i * 4 + 1];
            (*buffer)[i * 3 + 2] = data[i * 4 + 2];
        }
        free(data);
    }

    return TRUE;
}

{'repo_name': 'danginsburg/opengles-book-samples', 'stars': '176', 'repo_language': 'HTML', 'file_name': 'Stencil_Test.sln', 'mime_type': 'text/plain', 'hash': -3913926713995280294, 'source_dataset': 'data'}


//
//  ASTextKitComponents.h
//  AsyncDisplayKit
//
//  Copyright (c) 2014-present, Facebook, Inc.  All rights reserved.
//  This source code is licensed under the BSD-style license found in the
//  LICENSE file in the root directory of this source tree. An additional grant
//  of patent rights can be found in the PATENTS file in the same directory.
//

#import <UIKit/UIKit.h>
#import "ASBaseDefines.h"

NS_ASSUME_NONNULL_BEGIN

@interface ASTextKitComponents : NSObject

/**
 @abstract Creates the stack of TextKit components.
 @param attributedSeedString The attributed string to seed the returned text storage with, or nil to receive an blank text storage.
 @param textContainerSize The size of the text-container. Typically, size specifies the constraining width of the layout, and FLT_MAX for height. Pass CGSizeZero if these components will be hooked up to a UITextView, which will manage the text container's size itself.
 @return An `ASTextKitComponents` containing the created components. The text view component will be nil.
 @discussion The returned components will be hooked up together, so they are ready for use as a system upon return.
 */
+ (instancetype)componentsWithAttributedSeedString:(nullable NSAttributedString *)attributedSeedString
                                 textContainerSize:(CGSize)textContainerSize;

/**
 @abstract Creates the stack of TextKit components.
 @param textStorage The NSTextStorage to use.
 @param textContainerSize The size of the text-container. Typically, size specifies the constraining width of the layout, and FLT_MAX for height. Pass CGSizeZero if these components will be hooked up to a UITextView, which will manage the text container's size itself.
 @param layoutManager The NSLayoutManager to use.
 @return An `ASTextKitComponents` containing the created components. The text view component will be nil.
 @discussion The returned components will be hooked up together, so they are ready for use as a system upon return.
 */
+ (instancetype)componentsWithTextStorage:(NSTextStorage *)textStorage
                        textContainerSize:(CGSize)textContainerSize
                            layoutManager:(NSLayoutManager *)layoutManager;

/**
 @abstract Returns the bounding size for the text view's text.
 @param constrainedWidth The constraining width to be used during text-sizing. Usually, this value should be the receiver's calculated size.
 @result A CGSize representing the bounding size for the receiver's text.
 */
- (CGSize)sizeForConstrainedWidth:(CGFloat)constrainedWidth;

@property (nonatomic, strong, readonly) NSTextStorage *textStorage;
@property (nonatomic, strong, readonly) NSTextContainer *textContainer;
@property (nonatomic, strong, readonly) NSLayoutManager *layoutManager;
@property (nullable, nonatomic, strong) UITextView *textView;

@end

NS_ASSUME_NONNULL_END

{'repo_name': 'andrewwiik/Tweaks', 'stars': '101', 'repo_language': 'Objective-C', 'file_name': 'control', 'mime_type': 'text/plain', 'hash': 7549365716292935935, 'source_dataset': 'data'}


# -*- coding: utf-8 -*-

"""
    Bimap - bidirectional mapping between code/value
"""

class BimapError(Exception):
    pass

class Bimap(object):

    """
        Bi-directional mapping between code/text.

        Initialised using:

            name:   Used for exceptions
            dict:   Dict mapping from code (numeric) to text
            error:  Error type to raise if key not found

        The class provides:

            * A 'forward' map (code->text) which is accessed through
              __getitem__ (bimap[code])
            * A 'reverse' map (code>value) which is accessed through
              __getattr__ (bimap.text)
            * A 'get' method which does a forward lookup (code->text)
              and returns a textual version of code if there is no
              explicit mapping (or default provided)

        >>> class TestError(Exception):
        ...     pass

        >>> TEST = Bimap('TEST',{1:'A', 2:'B', 3:'C'},TestError)
        >>> TEST[1]
        'A'
        >>> TEST.A
        1
        >>> TEST.X
        Traceback (most recent call last):
        ...
        TestError: TEST: Invalid reverse lookup: [X]
        >>> TEST[99]
        Traceback (most recent call last):
        ...
        TestError: TEST: Invalid forward lookup: [99]
        >>> TEST.get(99)
        '99'

    """

    def __init__(self,name,forward,error=KeyError):
        self.name = name
        self.error = error
        self.forward = forward.copy()
        self.reverse = dict([(v,k) for (k,v) in list(forward.items())])

    def get(self,k,default=None):
        try:
            return self.forward[k]
        except KeyError as e:
            return default or str(k)

    def __getitem__(self,k):
        try:
            return self.forward[k]
        except KeyError as e:
            raise self.error("%s: Invalid forward lookup: [%s]" % (self.name,k))

    def __getattr__(self,k):
        try:
            return self.reverse[k]
        except KeyError as e:
            raise self.error("%s: Invalid reverse lookup: [%s]" % (self.name,k))

if __name__ == '__main__':
    import doctest
    doctest.testmod()

{'repo_name': 'nopernik/mpDNS', 'stars': '142', 'repo_language': 'Python', 'file_name': 'node.py', 'mime_type': 'text/x-python', 'hash': -3004342637162837445, 'source_dataset': 'data'}


<div id='issue_details_<%= issue.id %>'>
      Issue #<%= issue.id %> - <%= issue.status %>

      Reported By:
      <% if issue.reporter_user  %>
        <%= issue.reporter_user.identifier_name %>
      <% else %>
        [ Anonymous ]
      <% end -%>

      <% form_for :issue, issue, :url => { :action => 'update_issue', :path => issue.id } do |f| %>
        Location:<%= f.text_field :location %><input type='submit' value='Submit'>
      <% end -%>

Behavior

      <%= simple_format issue.behavior %>

Notes

      <% if issue.system_issue_notes.length > 0 %>

          When
          Who
          Action
          Note

        <% issue.system_issue_notes.each do |note| %>

             <%= (note.entered_at || Time.now()).localize("%m/%d/%Y %H:%M".t) %>

            <%= note.entered_user ? note.entered_user.name : "[Unknown]" %>

            <%= note.action %>

            <%= sprintf("%0.2f",note.work_time) %>

            <% if note.domain_file %>
              <a href='<%= note.domain_file.url %>'><%= note.domain_file.name %>

            <% end -%>
            <%= h(note.note).gsub("\n","
") %>

        <% end -%>

      <% end -%>

Add Note

      <% remote_cms_form_for :note, @issue_note, :update => "issue_details_#{issue.id}", :url => {:action => 'add_note', :path =>  issue.id } do |f| %>
        <%= f.radio_buttons :action, [ 'note','closed','complete' ] %>
        <%= f.text_field :work_time %>
        <%= f.text_area :note, :cols => 50,:rows => 5 %>
        <%= f.filemanager_file :domain_file_id , :type => 'file' %>
        <%= f.submit_tag 'Submit' %>
      <% end -%>

<% if issue.status == 'closed' || issue.status == 'complete' %>

<% end -%>

{'repo_name': 'cykod/Webiva', 'stars': '184', 'repo_language': 'Ruby', 'file_name': 'local.conf', 'mime_type': 'text/xml', 'hash': -7403248834010466464, 'source_dataset': 'data'}


(****************************************************************************)
(*                               Liquidity                                  *)
(*                                                                          *)
(*                  Copyright (C) 2017-2020 OCamlPro SAS                    *)
(*                                                                          *)
(*                    Authors: Fabrice Le Fessant                           *)
(*                             Alain Mebsout                                *)
(*                             David Declerck                               *)
(*                             Steven De Oliveira                           *)
(*                                                                          *)
(*  This program is free software: you can redistribute it and/or modify    *)
(*  it under the terms of the GNU General Public License as published by    *)
(*  the Free Software Foundation, either version 3 of the License, or       *)
(*  (at your option) any later version.                                     *)
(*                                                                          *)
(*  This program is distributed in the hope that it will be useful,         *)
(*  but WITHOUT ANY WARRANTY; without even the implied warranty of          *)
(*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *)
(*  GNU General Public License for more details.                            *)
(*                                                                          *)
(*  You should have received a copy of the GNU General Public License       *)
(*  along with this program.  If not, see <https://www.gnu.org/licenses/>.  *)
(****************************************************************************)

open LiquidTypes

(** Generate graph representation (in dot graphviz format) from a
    decompiled symbolic evaluated Michelson contract. *)
val to_string : node_contract -> string

{'repo_name': 'OCamlPro/liquidity', 'stars': '138', 'repo_language': 'OCaml', 'file_name': 'build-tezos.ocp2-inc', 'mime_type': 'text/plain', 'hash': 8574109048507907516, 'source_dataset': 'data'}