예제 #1
0
static void
printEdges( DictIter* iter, char* comment )
{
    XP_UCHAR buf[32];
    iterToString( dict, edges, buf, VSIZE(buf) );
    XP_LOGF( "%s: %s", comment, buf );
}
예제 #2
0
static const XP_UCHAR*
and_util_getUserString( XW_UtilCtxt* uc, XP_U16 stringCode )
{
    XP_UCHAR* result = "";
    UTIL_CBK_HEADER("getUserString", "(I)Ljava/lang/String;" );
    int index = stringCode - 1; /* see LocalizedStrIncludes.h */
    XP_ASSERT( index < VSIZE( util->userStrings ) );

    if ( ! util->userStrings[index] ) {
        jstring jresult = (*env)->CallObjectMethod( env, util->jutil, mid, 
                                                    stringCode );
        jsize len = (*env)->GetStringUTFLength( env, jresult );
        XP_UCHAR* buf = XP_MALLOC( util->util.mpool, len + 1 );

        const char* jchars = (*env)->GetStringUTFChars( env, jresult, NULL );
        XP_MEMCPY( buf, jchars, len );
        buf[len] = '\0';
        (*env)->ReleaseStringUTFChars( env, jresult, jchars );
        deleteLocalRef( env, jresult );
        util->userStrings[index] = buf;
    }

    result = util->userStrings[index];
    UTIL_CBK_TAIL();
    return result;
}
예제 #3
0
파일: ps.c 프로젝트: syuu1228/openbsd-src
static int
pscomp(const void *v1, const void *v2)
{
	const struct kinfo_proc *kp1 = *(const struct kinfo_proc **)v1;
	const struct kinfo_proc *kp2 = *(const struct kinfo_proc **)v2;
	int i;
#define VSIZE(k) ((k)->p_vm_dsize + (k)->p_vm_ssize + (k)->p_vm_tsize)

	if (sortby == SORTCPU && (i = getpcpu(kp2) - getpcpu(kp1)) != 0)
		return (i);
	if (sortby == SORTMEM && (i = VSIZE(kp2) - VSIZE(kp1)) != 0)
		return (i);
	if ((i = kp1->p_tdev - kp2->p_tdev) == 0 &&
	    (i = kp1->p_ustart_sec - kp2->p_ustart_sec) == 0)
		i = kp1->p_ustart_usec - kp2->p_ustart_usec;
	return (i);
}
예제 #4
0
static void
and_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, XP_U16 when,
                   XWTimerProc proc, void* closure )
{
    UTIL_CBK_HEADER("setTimer", "(III)V" );

    XP_ASSERT( why < VSIZE(util->timerStorage) );
    TimerStorage* storage = &util->timerStorage[why];
    storage->proc = proc;
    storage->closure = closure;
    (*env)->CallVoidMethod( env, util->jutil, mid,
                            why, when, (int)storage );
    UTIL_CBK_TAIL();
}
예제 #5
0
void
destroyUtil( XW_UtilCtxt** utilc )
{
    AndUtil* util = (AndUtil*)*utilc;
    JNIEnv *env = *util->env;

    int ii;
    for ( ii = 0; ii < VSIZE(util->userStrings); ++ii ) {
        XP_UCHAR* ptr = util->userStrings[ii];
        if ( NULL != ptr ) {
            XP_FREE( util->util.mpool, ptr );
        }
    }

    if ( NULL != util->jutil ) {
        (*env)->DeleteGlobalRef( env, util->jutil );
    }
#ifdef XWFEATURE_DEVID
    XP_FREEP( util->util.mpool, &util->devIDStorage );
#endif
    XP_FREE( util->util.mpool, util->util.vtable );
    XP_FREE( util->util.mpool, util );
    *utilc = NULL;
}
예제 #6
0
static int get_stat(int pid, char * buffer)
{
	struct task_struct ** p = get_task(pid);
	unsigned long sigignore=0, sigcatch=0, bit=1, wchan;
	int i,tty_pgrp;
	char state;

	if (!p || !*p)
		return 0;
	if ((*p)->state < 0 || (*p)->state > 5)
		state = '.';
	else
		state = "RSDZTD"[(*p)->state];
	wchan = get_wchan(*p);
	for(i=0; i<32; ++i) {
		switch((int) (*p)->sigaction[i].sa_handler) {
		case 1: sigignore |= bit; break;
		case 0: break;
		default: sigcatch |= bit;
		} bit <<= 1;
	}
	tty_pgrp = (*p)->tty;
	if (tty_pgrp > 0 && tty_table[tty_pgrp])
		tty_pgrp = tty_table[tty_pgrp]->pgrp;
	else
		tty_pgrp = -1;
	return sprintf(buffer,"%d (%s) %c %d %d %d %d %d %u %u \
%u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d \
%d %d %d %u\n",
		pid,
		(*p)->comm,
		state,
		(*p)->p_pptr->pid,
		(*p)->pgrp,
		(*p)->session,
		(*p)->tty,
		tty_pgrp,
		(*p)->flags,
		(*p)->min_flt,
		(*p)->cmin_flt,
		(*p)->maj_flt,
		(*p)->cmaj_flt,
		(*p)->utime,
		(*p)->stime,
		(*p)->cutime,
		(*p)->cstime,
		(*p)->counter,  /* this is the kernel priority ---
				   subtract 30 in your user-level program. */
		(*p)->priority, /* this is the nice value ---
				   subtract 15 in your user-level program. */
		(*p)->timeout,
		(*p)->it_real_value,
		(*p)->start_time,
		VSIZE((*p),(*p)->kernel_stack_page),
		(*p)->rss, /* you might want to shift this left 3 */
		(*p)->rlim[RLIMIT_RSS].rlim_cur,
		(*p)->start_code,
		(*p)->end_code,
		(*p)->start_stack,
		KSTK_ESP((*p)->kernel_stack_page),
		KSTK_EIP((*p)->kernel_stack_page),
		(*p)->signal,
		(*p)->blocked,
		sigignore,
		sigcatch,
		wchan);
}
예제 #7
0
static XP_Bool
drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
{
    XP_Bool success = XP_TRUE;
    XP_Rect cellRect;
    Tile tile;
    XP_Bool isBlank, isEmpty, recent, pending = XP_FALSE;
    XWBonusType bonus;
    ModelCtxt* model = board->model;
    DictionaryCtxt* dict = model_getDictionary( model );
    XP_U16 modelCol, modelRow;

    if ( dict != NULL && getCellRect( board, col, row, &cellRect ) ) {

        /* We want to invert EITHER the current pending tiles OR the most recent
         * move.  So if the tray is visible AND there are tiles missing from it,
         * show them.  Otherwise show the most recent move.
         */
        XP_U16 selPlayer = board->selPlayer;
        XP_U16 curCount = model_getCurrentMoveCount( model, selPlayer );
        XP_Bool showPending = board->trayVisState == TRAY_REVEALED
            && curCount > 0;

        flipIf( board, col, row, &modelCol, &modelRow );

        /* This 'while' is only here so I can 'break' below */
        while ( board->trayVisState == TRAY_HIDDEN ||
                !rectContainsRect( &board->trayBounds, &cellRect ) ) {
            XP_UCHAR ch[4] = {'\0'};
            XP_S16 owner = -1;
            XP_Bool invert = XP_FALSE;
            XP_Bitmaps bitmaps;
            XP_Bitmaps* bptr = NULL;
            const XP_UCHAR* textP = NULL;
            HintAtts hintAtts;
            CellFlags flags = CELL_NONE;
            XP_Bool isOrigin;
            XP_U16 value = 0;

            isEmpty = !model_getTile( model, modelCol, modelRow, showPending,
                                        selPlayer, &tile, &isBlank,
                                        &pending, &recent );
            if ( dragDropIsBeingDragged( board, col, row, &isOrigin ) ) {
                flags |= isOrigin? CELL_DRAGSRC : CELL_DRAGCUR;
                if ( isEmpty && !isOrigin ) {
                    dragDropTileInfo( board, &tile, &isBlank );
                    //isEmpty = XP_FALSE;
                }
                showPending = pending = XP_TRUE;
            }

            if ( isEmpty ) {
                isBlank = XP_FALSE;
                flags |= CELL_ISEMPTY;
            } else if ( isBlank && skipBlanks ) {
                break;
            } else {
                Tile valTile = isBlank? dict_getBlankTile( dict ) : tile;
                value = dict_getTileValue( dict, valTile );

                if ( board->showColors ) {
                    owner = (XP_S16)model_getCellOwner( model, modelCol, 
                                                        modelRow );
                }

                invert = showPending? pending : recent;

                if ( board->showCellValues ) {
                    XP_SNPRINTF( ch, VSIZE(ch), "%d", value );
                    textP = ch;
                } else {
                    if ( dict_faceIsBitmap( dict, tile ) ) {
                        dict_getFaceBitmaps( dict, tile, &bitmaps );
                        bptr = &bitmaps;
                    }
                    textP = dict_getTileString( dict, tile );
                }
            }
            bonus = model_getSquareBonus( model, col, row );
            hintAtts = figureHintAtts( board, col, row );

            if ( (col==board->star_row) && (row==board->star_row) ) {
                flags |= CELL_ISSTAR;
            }
            if ( invert ) {
                flags |= CELL_HIGHLIGHT;
            }
            if ( isBlank ) {
                flags |= CELL_ISBLANK;
            }
#ifdef KEYBOARD_NAV
            if ( cellFocused( board, col, row ) ) {
                flags |= CELL_ISCURSOR;
            }
#endif
#ifdef XWFEATURE_CROSSHAIRS
            flags |= flagsForCrosshairs( board, col, row );
#endif

            XP_Bool androidPlaying = model_androidPlaying(model, modelCol, modelRow);
            XP_S16 nMoves = model_getNMoves(model);
            if (androidPlaying && 1 < nMoves){
                flags |= CELL_ANDROID_PLAYING;
            }

            success = draw_drawCell( board->draw, &cellRect, textP, bptr,
                                     tile, value, owner, bonus, hintAtts, 
                                     flags );

            break;
        }
    }
    return success;
} /* drawCell */