예제 #1
0
int settings_restore(settings_location location) {
    int i;
    lock();
    EEFS_ERROR err;
    DIAG(" %d\n", 0);
    int addr = SETTINGS_START_ADDRESS + location * sizeof (settings);
    for (i = 0; i < ADC_NUMBER_OF_INPUTS; i++) {
        err = eefs_object_restore(addr + i, &settings[i], sizeof (settings_t));
        DIAG("iperiod: %d", settings[i].integration_period);
        if (err != EEFS_OK) {
            DIAG("error loading settings");
            settings_set_default();
            unlock();
            return 1;
        }
    }
    actual_settings = settings;
    DIAG("");
//    err = eefs_object_restore(addr + i, &actual_settings, sizeof(settings_t*));
//    if(err != EEFS_OK){
//        actual_settings = settings;
//        DIAG("error loading actual setting");
//    }
    unlock();
    return 0;
}
예제 #2
0
/* HR 270801
 * Attach a desktop to a window
 */
global
void set_desktop_widget(XA_WINDOW *wind,
					    XA_TREE *desktop)		/* HR tree --> widget */
{
	XA_TREE *nt = xcalloc(1,sizeof(XA_TREE),103);		/* HR: use calloc */
	XA_WIDGET *wi = get_widget(wind, XAW_TOOLBAR);		/* HR */
	XA_WIDGET_LOCATION loc;

	DIAG((D_widg,nil,"set_desktop_widget(wind=%d):new@%lx\n", wind->handle, nt));

	if (!nt)
	{
		DIAG((D_widg,nil," - unable to allocate widget.\n"));
		return;
	}

	*nt = *desktop;			/* HR desktop widget.tree */

	loc.relative_type = LT;
	loc.r = wind->r;
	loc.r.y += MENU_H + 1;
	loc.r.w -= MENU_H + 1;

	wi->display = display_object_widget;
	wi->click   = click_desktop_widget;
	wi->dclick  = click_desktop_widget;
	wi->drag    = click_desktop_widget;
	wi->loc   = loc;
	wi->state = NONE;
	wi->stuff = nt;
	wi->start = 0;
}
예제 #3
0
int C2F(gendiag)(int *typ, int *n, int *k, int *dx, int *dy)
{
    static int i, iy, nn;

    nn = *n + Abs(*k);

    switch (*typ)
    {
        case 1:
            DIAG(integer1);
            break;
        case 2:
            DIAG(integer2);
            break;
        case 4:
            DIAG(int) ;
            break;
        case 11:
            DIAG(unsigned char);
            break;
        case 12:
            DIAG(unsigned short);
            break;
        case 14:
            DIAG(unsigned int);
            break;
    }
    return 0;
}
예제 #4
0
/* fut_new_itbl creates a new input table for one dimension of a grid table
 * of size 'size'.	Ifun must be a pointer to a function accepting a double
 * and returning a double, both in the range (0.0,1.0).	A pointer to the
 * newly allocated table is returned.	(If ifun is NULL, table is not
 * initialized).
 */
fut_itbl_p
	fut_new_itblEx (	PTTableType_t	tableType,
						PTDataClass_t	iClass,
						KpInt32_t		size,
						fut_ifunc_t		ifun,
						fut_calcData_p	data)
{
fut_itbl_p	itbl;
KpInt32_t	nEntries;

	if ((size <= 1) || (size > FUT_GRD_MAXDIM)) {
		DIAG("fut_new_itbl: bad grid size (%d).\n", size);
		return (FUT_NULL_ITBL);
	}
					/* allocate input table structure */
	itbl = fut_alloc_itbl ();
	if ( ! IS_ITBL(itbl)) {
		DIAG("fut_new_itbl: can't alloc input table struct.\n", 0);
		return (FUT_NULL_ITBL);
	}

	itbl->size = size;
	itbl->dataClass = iClass;

					/* allocate the table */
	if (itbl->dataClass == KCP_VARIABLE_RANGE) {
		nEntries = MF2_STD_ITBL_SIZE;
	}
	else {
		nEntries = FUT_INPTBL_ENT;
	}

	if (tableType == KCP_PT_TABLES) {
		itbl->tbl = fut_alloc_itbldat (itbl);
		if ( itbl->tbl == NULL ) {
			DIAG("fut_new_itbl: can't alloc input table array.\n", 0);
			goto ErrOut;
		}
	} else {
		itbl->refTbl = fut_alloc_imftdat (itbl, nEntries);
		if ( itbl->refTbl == NULL ) {
			DIAG("fut_new_itbl: can't alloc input table array.\n", 0);
			goto ErrOut;
		}
	}

	/* compute the input table entries */
	if ( ! fut_calc_itblEx (itbl, ifun, data) ) {
		/* Note: fut_calc_itbl prints message on error */
		goto ErrOut;
	}

	return (itbl);


ErrOut:
	fut_free_itbl (itbl);
	return (FUT_NULL_ITBL);
}
예제 #5
0
/* fut_new_gtbl creates a new grid table and optionally intializes it.
 * The input channels defined for the grid are specified in the input
 * channel mask portion of iomask.	Each input defined must have a size
 * specified in a KpInt32_t array.
 * Gfun must be a pointer to a function accepting from zero to three
 * doubles (depending on values of sx, sy, and sz) in the range (0.0,1.0)
 * and returning a fut_gtbldat_t in the range (0,FUT_GRD_MAXVAL).
 * A pointer to the newly allocated table is returned if there were no
 * errors.	(If gfun is NULL, the table is not initialized).
 */
fut_gtbl_p
	fut_new_gtblEx (	PTTableType_t	tableType,
						KpInt32_t		iomask,
						fut_gfunc_t		gfun,
						fut_calcData_p	data,
						KpInt32_p		dimList)
{
fut_gtbl_p	gtbl;
KpInt32_t	imask, i, dim_size, grid_size;

					/* get input mask */
	imask = (KpInt32_t)FUT_IMASK(iomask);

					/* allocate grid table structure */
	gtbl = fut_alloc_gtbl ();
	if ( gtbl == FUT_NULL_GTBL ) {
		DIAG("fut_new_gtblA: can't alloc grid table struct.\n", 0);
		return (FUT_NULL_GTBL);
	}

	/* get sizes from dimList */
	grid_size = 1;
	for ( i=0; i<FUT_NCHAN; i++ ) {
		dim_size = (imask & FUT_BIT(i)) ? dimList[i] : 1;
		if ( dim_size <= 0 ) {
			dim_size = 1;		/* make sure > 0 */
		}
		gtbl->size[i] = (KpInt16_t)dim_size;
		grid_size *= (KpInt32_t)dim_size;
	}

					/* check for valid grid size */
	if ( grid_size <= 0 || grid_size > FUT_GRD_MAX_ENT ) {
		DIAG("fut_new_gtblA: bad grid table size (%d).\n", grid_size);
		fut_free_gtbl(gtbl);
		return (FUT_NULL_GTBL);
	}
	gtbl->tbl_size = (KpInt32_t)grid_size * (KpInt32_t)sizeof(fut_gtbldat_t);

					/* allocate grid table */
	if (tableType == KCP_PT_TABLES) {
		gtbl->refTbl = fut_alloc_gtbldat (gtbl);
	} else {
		gtbl->refTbl = fut_alloc_gmftdat (gtbl);
	}
	if ( gtbl->refTbl == NULL ) {
		DIAG("fut_new_gtblA: can't alloc grid table array.\n", 0);
		fut_free_gtbl(gtbl);
		return (FUT_NULL_GTBL);
	}

					/* compute the grid table entries */
	if ( ! fut_calc_gtblEx (gtbl, gfun, data) ) {
		fut_free_gtbl(gtbl);
		return (FUT_NULL_GTBL);
	}

	return (gtbl);
}
예제 #6
0
static int stream()
{
	unsigned iter = 0;
	int id_buf[16];
	int fp = dev->getDeviceHandle();
	int ifirst = MAXINT;
	int nbuf = 0;

	int rc = ioctl(fp, RTM_T_START_STREAM_MAX, &transfer_buffers);
	if (rc != 0){
		perror("ioctl RTM_T_START_STREAM failed");
		exit(errno);
	}

	while (iter < MAXITER){
		DIAG("CALLING read\n");
		int nread = read(fp, id_buf, NELEMS*sizeof(int));
		int ibuf;

		DIAG("	read returned %d\n", nread);

		if (nread > 0){
			for (ibuf = 0; ibuf < nread/sizeof(int); ++ibuf){
				int nwrite =  sizeof(int)*1;

				if (id_buf[ibuf] <= ifirst ){
					ifirst = id_buf[ibuf];
					if (RECYCLE == 0){
						++CYCLE;
					}else{
						if (++CYCLE >= RECYCLE){
							CYCLE=0;
						}
					}
				}
				DIAG("CALLING process\n");
				process(id_buf[ibuf], ++nbuf);
			
				dbg(2, "write [%d] %d\n", ibuf, id_buf[ibuf]);

				DIAG("CALLING write\n");
				if (write(fp, id_buf+ibuf, nwrite) != nwrite ){
					perror("write failed");
					return -1;
				}
			}
		}else{
			perror("read error");
			return nread;
		}

		iter = ++iter&MAXITER_MASK;
	}

	DIAG("all done\n");
	return 0;
}
예제 #7
0
/* fut_copy_gtbl makes an exact copy of an existing fut_gtbl_t
 */
fut_gtbl_p
	fut_copy_gtbl (fut_gtbl_p gtbl)
{
fut_gtbl_p		new_gtbl;
KpInt32_t		gsize;
KpHandle_t		h;

				/* check for valid gtbl */
	if ( ! IS_GTBL(gtbl) ) {
		return (FUT_NULL_GTBL);
	}

	new_gtbl = fut_alloc_gtbl ();	/* allocate the new gtbl structure */
	if ( new_gtbl == FUT_NULL_GTBL ) {
		DIAG("fut_copy_gtbl: can't alloc grid table struct.\n", 0);
		return (FUT_NULL_GTBL);
	}

	h = new_gtbl->handle;	/* save handle before copying over old gtbl */

	*new_gtbl = *gtbl;		/* copy entire struct except reference count */

	new_gtbl->handle = h;
	new_gtbl->ref = 0;		/* first reference */

	if (gtbl->tbl != NULL) {	/* copy fixed gtbl data */
		gsize = gtbl->tbl_size / (KpInt32_t)sizeof(fut_gtbldat_t);
		new_gtbl->tbl = fut_alloc_gtbldat (new_gtbl);
		if ( new_gtbl->tbl == NULL ) {
			DIAG("fut_copy_gtbl: can't alloc grid table array.\n", 0);
			goto ErrOut;
		}
		new_gtbl->tblHandle = getHandleFromPtr((KpGenericPtr_t)new_gtbl->tbl);

		/* copy the table entries */
		KpMemCpy (new_gtbl->tbl, gtbl->tbl, gtbl->tbl_size);
	}

	if (gtbl->refTbl != NULL) {	/* copy reference gtbl data */
		new_gtbl->refTbl = fut_alloc_gmftdat (new_gtbl);
		if (new_gtbl->refTbl == NULL ) {
			DIAG("fut_copy_gtbl: can't alloc ref grid table array.\n", 0);
			goto ErrOut;
		}

		/* copy the table entries */
		KpMemCpy (new_gtbl->refTbl, gtbl->refTbl, gtbl->tbl_size);
	}

	return (new_gtbl);
	

ErrOut:
	fut_free_gtbl (new_gtbl);
	return (FUT_NULL_GTBL);
}
예제 #8
0
/* fut_copy_otbl makes an exact copy of an existing fut_otbl_t
 */
fut_otbl_p
	fut_copy_otbl (fut_otbl_p otbl)
{
fut_otbl_p		new_otbl;
KpHandle_t		h;

	/* check for valid otbl */
	if ( ! IS_OTBL(otbl) ) {
		return (FUT_NULL_OTBL);
	}

	/* allocate the new otbl structure */
	new_otbl = fut_alloc_otbl ();
	if ( new_otbl == FUT_NULL_OTBL ) {
		DIAG("fut_copy_otbl: can't alloc output table struct.\n", 0);
		return (FUT_NULL_OTBL);
	}

	h = new_otbl->handle;	/* save handle before copying over old otbl */

	*new_otbl = *otbl;		/* copy entire struct except reference count */

	new_otbl->handle = h;
	new_otbl->ref = 0;		/* first reference */

	if (otbl->tbl != NULL) {	/* copy fixed otbl data */
		new_otbl->tbl = fut_alloc_otbldat (new_otbl);
		if ( new_otbl->tbl == NULL ) {
			DIAG("fut_copy_otbl: can't alloc output table array.\n", 0);
			goto ErrOut;
		}
		new_otbl->tblHandle = getHandleFromPtr((KpGenericPtr_t)new_otbl->tbl);

		/* copy the table entries */
		KpMemCpy (new_otbl->tbl, otbl->tbl, FUT_OUTTBL_ENT * sizeof (fut_otbldat_t));
	}

	if (otbl->refTbl != NULL) {	/* copy reference otbl data */
		new_otbl->refTbl = fut_alloc_omftdat (new_otbl, new_otbl->refTblEntries);
		if (new_otbl->refTbl == NULL ) {
			DIAG("fut_copy_otbl: can't alloc output table array.\n", 0);
			goto ErrOut;
		}

		/* copy the table entries */
		KpMemCpy (new_otbl->refTbl, otbl->refTbl, new_otbl->refTblEntries * sizeof (mf2_tbldat_t));
	}

	return (new_otbl);
	

ErrOut:
	fut_free_otbl (new_otbl);
	return (FUT_NULL_OTBL);
}
예제 #9
0
bool validate(int M, vector<string>& nodes, int T, vector<string>& tags) {
    if (M != nodes.size()) {
        DIAG("ERROR: Specified node count is not same as actual node count !" << endl);
        return false;
    }
    if (T * M != tags.size()) {
        DIAG("ERROR: Specified total tag count is not same as expected tag count, NodeCount * TagCount !" << endl);
        return false;
    }
    return true;
    
}
예제 #10
0
double system_read_input(system_flags_t* flag)
{
    if(xSemaphoreTake(syslock, 1000) == pdFALSE){
        DIAG("Cannot obtain sysmutex");
        return 0;
    }
    /* get lock before doing a measurement. It guarantees that no settings changes
     * are done while using the adc. */
    double value, temperature;
    *flag = 0;
    if(is_temp_mode){
        temperature = tmp245_read_temp_double();
        value = temperature;
    } else{
        value = gain * adc_read_value(channel, (int*)flag) + offset;
        if(resln == ADC_RESOLUTION_6_5){
            if(fabs(value - acc_value) <= wn_delta){
                acc_value = acc_value + (value - acc_value)/RESLN_6_5_FILTER_SIZE;
                value = acc_value;
            }else{
                *flag |= SYS_FLAG_FILTER_OUT_WINDOW;
                acc_value = value;
            }
        }
    }
    /* release semaphore when done. */
    xSemaphoreGive(syslock);
    assert(!isnan(value));
    assert(!isinf(value));
    return value;
}
예제 #11
0
파일: symbol.c 프로젝트: richteer/cs445
bool stab_types_eq(struct stab *st, size_t a, size_t b) {
    // todo: when cache in place, just check a == b
    struct stab_type *at = STAB_TYPE(st, a), *bt = STAB_TYPE(st, b);
    if (at->ty.tag != bt->ty.tag) {
        return false;
    } else {
        switch (at->ty.tag) {
            case TYPE_BOOLEAN:
            case TYPE_CHAR:
            case TYPE_INTEGER:
            case TYPE_REAL:
            case TYPE_STRING:
                return true;
            case TYPE_ARRAY:
                return (at->ty.array.upper == bt->ty.array.upper
                    &&  at->ty.array.lower == bt->ty.array.lower
                    &&  at->ty.array.elt_type == bt->ty.array.elt_type);
            case TYPE_FUNCTION:
            case TYPE_RECORD:
                return a == b;
            case TYPE_POINTER:
                return stab_types_eq(st, at->ty.pointer, bt->ty.pointer);

            case TYPE_REF:
            default:
                DIAG("bad type for comparison!\n");
                abort();
        }
    }
}
예제 #12
0
void pointersize(int size)
{
	if (prm_nasm && skipsize)
		return;
/*	if (needpointer)
*/		switch (size) {		
			case 10:
				fprintf(outputFile,"TBYTE ");
				break;
			case 8:                      
       	fprintf(outputFile,"QWORD ");
				break;
			case 6:
				if (!uses_float) {
					fprintf(outputFile,"FWORD ");
					break;
				}
			case 4:                      
				fprintf(outputFile,"DWORD ");
				break;
			case 2:
				fprintf(outputFile,"WORD ");
				break;
			case 1:
				fprintf(outputFile,"BYTE ");
				break;
			default:
				DIAG("Bad pointer");
		}	
		if (!prm_nasm)
			fprintf(outputFile,"PTR ");
}
예제 #13
0
global
void *form_save(int d, RECT r, void *area)
{
	MFDB Mscreen={0};
	MFDB Mpreserve;
	G_i pnt[8];
	
	r.x-=d, r.y-=d, r.w+=2*d, r.h+=2*d;

	rtopxy(pnt, &r);
	ritopxy(pnt+4,0,0,r.w,r.h);
DIAG((D_menu,nil,"form_save %d/%d,%d/%d\n",r.x,r.y,r.w,r.h));
	Mpreserve.fd_w = r.w;
	Mpreserve.fd_h = r.h;
	Mpreserve.fd_wdwidth = (r.w + 15) / 16;
	Mpreserve.fd_nplanes = screen.planes;
	Mpreserve.fd_stand = 0;

	if (area == nil)
		area = xmalloc(calc_back(&r,screen.planes),210);

	if (area)
	{
		Mpreserve.fd_addr = area;
		vro_cpyfm(C.vh, S_ONLY, pnt, &Mscreen, &Mpreserve);
	}
	return area;
}
예제 #14
0
int seg_number_of_tribs(int r, int c, SEGMENT *streams, SEGMENT *dirs)
{

    int trib = 0;
    int i, j;
    int streams_cell = 0;
    int dirs_cell = 0;

    for (i = 1; i < 9; ++i) {
	if (NOT_IN_REGION(i))
	    continue;

	j = DIAG(i);

	Segment_get(streams, &streams_cell, NR(i), NC(i));
	Segment_get(dirs, &dirs_cell, NR(i), NC(i));

	if (streams_cell && dirs_cell == j)
	    trib++;
    }

    if (trib > 5)
	G_fatal_error(_("Error finding nodes. "
                        "Stream and direction maps probably do not match."));
    if (trib > 3)
	G_warning(_("Stream network may be too dense"));

    return trib;
}
예제 #15
0
int seg_trib_nums(int r, int c, SEGMENT *streams, SEGMENT *dirs)
{				/* calculate number of tributaries */

    int trib_num = 0;
    int i, j;
    int next_r, next_c;
    int streams_cell, streams_next_cell, dirs_next_cell;

    Segment_get(streams, &streams_cell, r, c);
    for (i = 1; i < 9; ++i) {
	if (NOT_IN_REGION(i))
	    continue;

	j = DIAG(i);
	next_r = NR(i);
	next_c = NC(i);

	Segment_get(streams, &streams_next_cell, next_r, next_c);
	Segment_get(dirs, &dirs_next_cell, next_r, next_c);

	if (streams_next_cell > 0 && dirs_next_cell == j)
	    trib_num++;
    }

    if (trib_num > 1)
	for (i = 1; i < 9; ++i) {
	    if (NOT_IN_REGION(i))
		continue;

	    j = DIAG(i);
	    next_r = NR(i);
	    next_c = NC(i);

	    Segment_get(streams, &streams_next_cell, next_r, next_c);
	    Segment_get(dirs, &dirs_next_cell, next_r, next_c);

	    if (streams_next_cell == streams_cell && dirs_next_cell == j)
		trib_num--;
	}

    if (trib_num > 5)
	G_fatal_error(_("Error finding inits. Stream and direction maps probably do not match"));
    if (trib_num > 3)
	G_warning(_("Stream network may be too dense"));

    return trib_num;
}				/* end trib_num */
예제 #16
0
void putlen(int l)
/*
 *      append the length field to an instruction.
 */
{ 
	if (l!= 10 && l != 8 && l != 6 && l != 4 && l != 1 && l != 2 && l != 0)
     DIAG("illegal length field.");
}
예제 #17
0
bool validate(int N, int L, int M, int S) {
    if (N == 0) {
        DIAG("ERROR: N cannot be 0 !" << endl);
        return false;
    }
    if (L == 0) {
        DIAG("ERROR: L cannot be 0 !" << endl);
        return false;
    }
    if (M == 0) {
        DIAG("ERROR: M cannot be 0 !" << endl);
        return false;
    }
    if (S == 0 && L != 1) {
        DIAG("ERROR: S cannot be 0 if L is not 1 !" << endl);
        return false;
    }
    if (S >= M) {
        DIAG("ERROR: Slave number should be less then number of nodes !" << endl);
        return false;
    }
    if (S * M > N * (L - 1) ) {
        DIAG("ERROR: Slave number is too large. S * M cannot exceed N * (L - 1) !" << endl);
        return false;
    }
    if (L > S + 1) {
        DIAG("ERROR: Number of copies L cannot be larger than (S + 1) !" << endl);
        return false;
    }
    return true;
}
예제 #18
0
파일: symbol.c 프로젝트: richteer/cs445
static size_t stab_resolve_complex_type(struct stab *st, char *name, struct ast_type *ty) {
    struct stab_type *t = M(struct stab_type);
    t->defn = NULL;
    t->name = name;
    t->ty.tag = ty->tag;
    t->magic = 0;

    switch (ty->tag) {
        case TYPE_POINTER:
            t->ty.pointer = stab_resolve_type(st, strdup(name), ty->pointer);
            t->size = ABI_POINTER_SIZE; // XHAZARD
            t->align = ABI_POINTER_ALIGN; // XHAZARD
            break;

        case TYPE_RECORD:
            t->ty.record.fields = list_empty(CB free_stab_record_field);

            LFOREACH(struct ast_record_field *field, ty->record)
                // todo: check that field name is unique
                list_add(t->ty.record.fields, YOLO stab_record_field(field->name, stab_resolve_type(st, strdup(field->name), field->type)));
            ENDLFOREACH;

            break;

        case TYPE_ARRAY:
            t->ty.array.lower = atoi(ty->array.lower);
            t->ty.array.upper = atoi(ty->array.upper);
            t->ty.array.elt_type = stab_resolve_type(st, strdup("<array elts>"), ty->array.elt_type);
            t->size = STAB_TYPE(st, t->ty.array.elt_type)->size * (t->ty.array.upper - t->ty.array.lower);
            break;

        case TYPE_FUNCTION:
            t->ty.func.type = ty->func.type;
            t->ty.func.retty = stab_resolve_type(st, strdup("<func ret>"), ty->func.retty);
            t->ty.func.args = list_empty(CB dummy_free);
            t->ty.func.ret_assigned = false;
            t->magic = 0;

            LFOREACH(struct ast_decls *decl, ty->func.args)
                LFOREACH(char *name, decl->names)
                    size_t id = stab_resolve_type(st, strdup(name), decl->type);
                    list_add(t->ty.func.args, YOLO stab_add_var(st, strdup(name), id, NULL, NULL, false));
                ENDLFOREACH;
            ENDLFOREACH;

            t->size = ABI_CLOSURE_SIZE; // XHAZARD
            t->align = ABI_CLOSURE_ALIGN; // XHAZARD
            break;

        default:
            DIAG("resolve_complex_type given simple type!\n");
            abort();
            return -1;
    }

    return ptrvec_push(st->types, YOLO t);
}
예제 #19
0
static void process(int ibuf, int nbuf){
	if (VERBOSE){
		fprintf(stderr, "%02d\n", ibuf);
	}

	char buf[80];

	
	sprintf(buf, "%s/%06d/", OUTROOT, CYCLE);
	mkdir(buf, 0777);
	sprintf(buf, "%s/%06d/%d.%02d", OUTROOT, CYCLE, dev->getDevnum(), ibuf);

	if (NO_OVERWRITE){
		struct stat stat_buf;
		int rc = stat(buf, &stat_buf);
		DIAG("stat:rc %d errno %d\n", rc, errno);
		if (rc == 0){
			err("OVERRUN: NO_OVERWRITE SET and \"%s\" exists",
					buf);
			exit(1);
		}else if (errno != ENOENT){
			err("OVERRUN: NO_OVERWRITE SET and \"%s\" exists",
					buf);
			perror("buf");
			exit(errno);
		}else{
			;	/* ENOENT - that's good! */
		}
	}
	int outfp = open(buf, O_MODE, PERM);

	if (outfp == -1){
		perror(buf);
		_exit(errno);
	}
	write(outfp, dev->getHostBufferMapping(ibuf), maxlen);

	strcat(buf, ".id");
	int out_meta = open(buf, O_MODE, PERM);
	write_meta(out_meta, ibuf, nbuf);

	close(out_meta);		
	close(outfp);		/* close data last - we monitor this one */

	if (PUT_DATA){
		char *cp = strstr(buf, ".id");
		if (cp){
			*cp = '\0';
		}
	}
	puts(buf);

	if (USLEEP){
		usleep(USLEEP);
	}
}
예제 #20
0
/* HR 021101: new function to make the code orthogonal.
*/
static
G_i *transform_icon_bitmap(XA_CLIENT *client, CICONBLK *icon, G_i *map, long len, int planes)
{
	MFDB src, dst;
	G_i *new_data = map, *tmp = nil;
	long icon_len = len * planes,
	     new_len = len * screen.planes;

DIAG((D_s,client,"icon_len %ld, new_len %ld\n", icon_len, new_len));

	if (planes < screen.planes)
	{
		DIAG((D_x,client,"XA_calloc 3 %ld\n", new_len));
		new_data = XA_calloc(&client->base, 1, new_len, 3, client->rsct);		/* HR: and put in a list. */
		if (new_data == nil)					/* HR 021101: check */
			return map;
		memcpy(new_data, map, icon_len);
	}

	src.fd_w = icon->monoblk.ic.w;			/* Transform MFDB's */
	src.fd_h = icon->monoblk.ic.h;
	src.fd_wdwidth = (src.fd_w + 15) / 16;		/* HR: round up */
	src.fd_stand = 1;
	src.fd_r1 = src.fd_r2 = src.fd_r3 = 0;
	src.fd_nplanes = screen.planes;			/* HR */
	dst = src;

	dst.fd_addr = new_data;
	dst.fd_stand = 0;

	DIAG((D_x,client,"XA_calloc %d*%ld\n", 1, new_len));
	tmp = XA_calloc(nil, 1, new_len, 0, 0);
	if (tmp)								/* HR 021101: check */
	{
		memcpy(tmp, new_data, new_len);
		src.fd_addr = tmp;
		transform_gem_bitmap_data(src, dst, planes, screen.planes);
/*		vr_trnfm( C.vh, &src, &dst );  */
		free(tmp);
	}

	return new_data;
}
예제 #21
0
/* fut_new_otbl creates a new output table for one channel of a fut.
 * Ofun must be a pointer to a function accepting a fut_gtbldat_t in the
 * range (0,FUT_GRD_MAXVAL) and returning a fut_otbldat_t in the same
 * interval.	A pointer to the newly allocated table is returned.
 * (If ofun is NULL, table is not intialized!).
 */
fut_otbl_p
	fut_new_otblEx (	PTTableType_t	tableType,
						PTDataClass_t	oClass,
						fut_ofunc_t		ofun,
						fut_calcData_p	data)
{
fut_otbl_p	otbl;

					/* allocate output table structure */
	otbl = fut_alloc_otbl();
	if ( otbl == FUT_NULL_OTBL ) {
		DIAG("fut_new_otbl: can't alloc output table struct.\n", 0);
		return (FUT_NULL_OTBL);
	}

	otbl->dataClass = oClass;

					/* allocate the table */
	if (tableType == KCP_PT_TABLES) {
		otbl->tbl = fut_alloc_otbldat (otbl);
		if ( otbl->tbl == NULL ) {
			DIAG("fut_new_otbl: can't alloc output table array.\n", 0);
			fut_free_otbl (otbl);
			return (FUT_NULL_OTBL);
		}
	} else {
		otbl->refTbl = fut_alloc_omftdat (otbl, FUT_OUTTBL_ENT);
		if ( otbl->refTbl == NULL ) {
			DIAG("fut_new_otbl: can't alloc output table array.\n", 0);
			fut_free_otbl (otbl);
			return (FUT_NULL_OTBL);
		}
	}

					/* compute the output table entries */
	if ( ! fut_calc_otblEx (otbl, ofun, data) ) {
		fut_free_otbl (otbl);
		return (FUT_NULL_OTBL);
	}

	return (otbl);
}
예제 #22
0
void
ptyflush(void)
{
	int n;

	if ((n = pfrontp - pbackp) > 0) {
		DIAG(TD_REPORT | TD_PTYDATA,
		    output_data("td: ptyflush %d chars\r\n", n));
		DIAG(TD_PTYDATA, printdata("pd", pbackp, n));
		n = write(pty, pbackp, n);
	}
	if (n < 0) {
		if (errno == EWOULDBLOCK || errno == EINTR)
			return;
		cleanup(0);
	}
	pbackp += n;
	if (pbackp == pfrontp)
		pbackp = pfrontp = ptyobuf;
}
예제 #23
0
static void
EventLoop (void)
{
    EventType	event;
    SDWord	timeout;
    UInt32	timer_next;
    Word	error;

    do
    {
        timeout = evtWaitForever;
        timer_next = 0;
        if (needRedisplay)
            timeout = 0;
        else if (game.timer_running)
        {
            UInt32  now = TimGetTicks ();
            int	    sec = (now - game.timer_start) / sysTicksPerSecond;

            timer_next = ((sec + 1) * sysTicksPerSecond + game.timer_start);
            timeout = timer_next - now;
        }
        EvtGetEvent (&event, timeout);
        DIAG (("Event %d\n", event.eType));
        if (timer_next && TimGetTicks () <= timer_next)
            DamageCount ();
        if (needRedisplay && event.eType == nilEvent)
            FrmUpdateForm (mainForm, frmRedrawUpdateCode);
        if (event.eType == nilEvent)
            continue;

        /* Give the system a chance to handle the event. */
        if (! SysHandleEvent (&event))
        {
            if (!MenuHandleEvent (0, &event, &error))
            {
                /* Give the application a chance to handle the event. */
                if (!ApplicationHandleEvent (&event))
                {
                    /* Let the form object provide default handling of the event. */
                    FrmDispatchEvent (&event);
                }
            }
        }
    }
    while (event.eType != appStopEvent);
    // ** SPECIAL NOTE **
    // In order for the Emulator to exit
    // cleanly when the File|Quit menu option is
    // selected, the running application
    // must exit.  The emulator will generate an
    // ÒappStopEventÓ when Quit is selected.
}
예제 #24
0
void send_dont(int option, int init) {
    if (init) {
        if ((do_dont_resp[option] == 0 && his_state_is_wont(option)) ||
                his_want_state_is_wont(option))
            return;
        set_his_want_state_wont(option);
        do_dont_resp[option]++;
    }
    netoprintf((char *) dont, option);

    DIAG(TD_OPTIONS, printoption("td: send dont", option));
}
예제 #25
0
void send_wont(int option, int init) {
    if (init) {
        if ((will_wont_resp[option] == 0 && my_state_is_wont(option)) ||
                my_want_state_is_wont(option))
            return;
        set_my_want_state_wont(option);
        will_wont_resp[option]++;
    }
    netoprintf((char *)wont, option);

    DIAG(TD_OPTIONS, printoption("td: send wont", option));
}
예제 #26
0
int ram_trib_nums(int r, int c, CELL ** streams, CELL ** dirs)
{				/* calculate number of tributaries */

    int trib_num = 0;
    int i, j;
    int next_r, next_c;

    for (i = 1; i < 9; ++i) {
	if (NOT_IN_REGION(i))
	    continue;

	j = DIAG(i);
	next_r = NR(i);
	next_c = NC(i);

	if (streams[next_r][next_c] > 0 && dirs[next_r][next_c] == j)
	    trib_num++;
    }

    if (trib_num > 1)
	for (i = 1; i < 9; ++i) {
	    if (NOT_IN_REGION(i))
		continue;

	    j = DIAG(i);
	    next_r = NR(i);
	    next_c = NC(i);

	    if (streams[next_r][next_c] == streams[r][c] &&
		dirs[next_r][next_c] == j)
		trib_num--;
	}

    if (trib_num > 5)
	G_fatal_error(_("Error finding inits. Stream and direction maps probably do not match"));
    if (trib_num > 3)
	G_warning(_("Stream network may be too dense"));

    return trib_num;
}				/* end trib_num */
예제 #27
0
파일: symbol.c 프로젝트: richteer/cs445
void stab_print_type(struct stab *st, size_t t, int indent) {
    struct stab_type *ty = STAB_TYPE(st, t);
    INDENT; DEBUG("<id %ld> ", t);
    INDENT;
    switch (ty->ty.tag) {
        case TYPE_BOOLEAN:
            DIAG("boolean\n");
            break;
        case TYPE_CHAR:
            DIAG("char\n");
            break;
        case TYPE_INTEGER:
            DIAG("integer\n");
            break;
        case TYPE_REAL:
            DIAG("real\n");
            break;
        case TYPE_STRING:
            DIAG("string\n");
            break;
        case TYPE_ARRAY:
            DIAG("array `%s`\n", ty->name);
            break;
        case TYPE_FUNCTION:
            DIAG("%s %s\n", ty->ty.func.type == SUB_PROCEDURE ? "procedure" : "function", ty->name);
            break;
        case TYPE_RECORD:
            DIAG("record `%s`\n", ty->name);
            break;
        case TYPE_POINTER:
            DIAG("pointer to `%s`\n", ty->name);
            break;
        case TYPE_VOID:
            DIAG("void\n");
            break;
        case TYPE_REF:
        default:
            abort();
    }
}
예제 #28
0
static Boolean
MainFormHandleEvent(EventPtr event)
{
    Boolean handled = false;
    int	    x, y;

    switch (event->eType) {
    case frmUpdateEvent:
        if (event->data.frmUpdate.formID == mainForm)
        {
            DIAG (("Call Redisplay\n"));
            Redisplay ();
            handled = true;
        }
        break;
    case frmOpenEvent:
        if (event->data.frmOpen.formID == mainForm)
        {
            FrmDrawForm (mainFrm);
            DamageBoard ();
        }
        break;
    case penDownEvent:
        if (PenLocation (event->screenX, event->screenY, &x, &y))
        {
            pen_down = true;
            pen_down_x = x;
            pen_down_y = y;
            handled = true;
        }
        break;
    case penUpEvent:
        if (pen_down &&
                PenLocation (event->screenX, event->screenY, &x, &y))
        {
            HandleBoardPen (pen_down_x, pen_down_y, x, y);
            handled = true;
        }
        pen_down = false;
        break;
    case keyDownEvent:
        RicochetKeyHandleEvent (event);
        break;
    case menuEvent:
        RicochetMenuHandleEvent (event);
        break;
    default:
        break;
    }
    return handled;
}
예제 #29
0
void putconst(ENODE *offset)
/*
 *      put a constant to the outputFile file.
 */
{       switch( offset->nodetype )
                {
								case en_autoreg:
                case en_autocon:
                case en_icon:
                case en_lcon:
                case en_iucon:
                case en_lucon:
                case en_ccon:
								case en_absacon:
                        fprintf(outputFile,"0%lXH",offset->v.i);
                        break;
								case en_rcon:
								case en_fcon:
								case en_lrcon:
												fprintf(outputFile,"%f",offset->v.f);
												break;
                case en_labcon:
                case en_nalabcon:
/*												if (!prm_nasm && !prm_flat)
													fprintf(outputFile,"CS:");
*/                        fprintf(outputFile,"L_%d",offset->v.i);
                        break;
								case en_napccon:
                case en_nacon:
                        fprintf(outputFile,"%s",offset->v.p[0]);
                        break;
                case en_add:
                        putconst(offset->v.p[0]);
                        fprintf(outputFile,"+");
                        putconst(offset->v.p[1]);
                        break;
                case en_sub:
                        putconst(offset->v.p[0]);
                        fprintf(outputFile,"-");
                        putconst(offset->v.p[1]);
                        break;
                case en_uminus:
                        fprintf(outputFile,"-");
                        putconst(offset->v.p[0]);
                        break;
                default:
                        DIAG("illegal constant node.");
                        break;
                }
}
예제 #30
0
파일: distance_calc.c 프로젝트: caomw/grass
int seg_fill_basins(OUTLET outlet, SEGMENT * distance, SEGMENT * dirs)
{
    /* fill empty spaces with zeros but leave -1 as a markers of NULL */
    int r, c, i, j;
    int next_r, next_c;
    double stop, val;
    POINT n_cell;
    CELL dirs_cell;
    DCELL distance_cell;

    tail = 0;
    head = -1;
    r = outlet.r;
    c = outlet.c;
    val = 1;
    stop = 0;

    Segment_put(distance, &stop, r, c);

    while (tail != head) {

	for (i = 1; i < 9; ++i) {
	    if (NOT_IN_REGION(i))
		continue;	/* out of border */

	    j = DIAG(i);
	    next_r = NR(i);
	    next_c = NC(i);

	    Segment_get(dirs, &dirs_cell, next_r, next_c);

	    if (dirs_cell == j) {	/* countributing cell */

		Segment_get(distance, &distance_cell, next_r, next_c);
		distance_cell = (distance_cell == stop) ? stop : val;
		Segment_put(distance, &distance_cell, next_r, next_c);
		n_cell.r = next_r;
		n_cell.c = next_c;
		fifo_insert(n_cell);

	    }
	}			/* end for i... */

	n_cell = fifo_return_del();
	r = n_cell.r;
	c = n_cell.c;
    }

    return 0;
}