Exemple #1
0
int addItem(struct keyval *head, const char *name, const char *value, int noDupe)
{
    struct keyval *item;

    assert(head);
    assert(name);
    assert(value);

    if (noDupe) {
        item = head->next;
        while (item != head) {
            if (!strcmp(item->value, value) && !strcmp(item->key, name))
                return 1;
            item = item->next;
        }
    }

    item = malloc(sizeof(struct keyval));

    if (!item) {
        fprintf(stderr, "Error allocating keyval\n");
        return 2;
    }

#ifdef USE_TREE
    item->key   = (char *)text_get(tree_ctx,name);
    item->value = (char *)text_get(tree_ctx,value);
#else
    item->key   = strdup(name);
    item->value = strdup(value);
#endif
    item->has_column=0;


#if 1
    /* Add to head */
    item->next = head->next;
    item->prev = head;
    head->next->prev = item;
    head->next = item;
#else
    /* Add to tail */
    item->prev = head->prev;
    item->next = head;
    head->prev->next = item;
    head->prev = item;
#endif
    return 0;
}
Exemple #2
0
int thread_call_intern(Thread *t, Module *module, RA_Proc p_idx)
{
	const Segments *seg = &module->seg;
	const RMDProcedure *p = ptbl_get(seg, p_idx);
	if(alloc_frame(t, p) || save_procedure(t, p))
		return -1;
	t->pc.byte = text_get(seg, p->addr);
	t->procs->module = module;
	return 0;
}
Exemple #3
0
/*
 * given x,y,x label, and y label will return new xyGrid
 */
xyGrid xyGrid_get(uint16_t x, uint16_t y, char* xStr, uint8_t* xinitLevel, uint8_t xlevelID,
				char* yStr, uint8_t* yinitLevel, uint8_t ylevelID)
{
	xyGrid grid;
	grid.xlevel=xinitLevel;
	grid.ylevel=yinitLevel;
	grid.xlevelID=xlevelID;
	grid.ylevelID=ylevelID;
	grid.bgnd=rect_get(x,y,230,228,BLACK_16BIT);
	grid.leftEdge=rect_get(x-9,y,8,237,g_backgroundColor);
	grid.rightEdge=rect_get(x+grid.bgnd.width+1,y,9,237,g_backgroundColor);
	grid.bottomEdge=rect_get(x,y+grid.bgnd.height+1,grid.bgnd.width,12,g_backgroundColor);
	grid.dot=circle_get(x,y+grid.bgnd.height,5,WHITE_16BIT);
	grid.xlabel=text_get(x, y-16, xStr, grid.bgnd.width/2,
			15, WHITE_16BIT,WHITE_16BIT, g_backgroundColor,0,0);
	grid.ylabel=text_get(x+grid.bgnd.width/2, y-16, yStr, grid.bgnd.width/2,
			15, WHITE_16BIT,WHITE_16BIT, g_backgroundColor,0,0);

	xyGrid_updateDotPos(&grid);
	return grid;
}
Exemple #4
0
/*
 * initializes a new slider at point (x,y) with label lbl
 *
 * returns initialized slider
 */
slider slider_get(uint16_t x, uint16_t y, char *str, uint8_t *initLevel, uint8_t levelID)
{
	slider sldr;
	sldr.level=initLevel;
	sldr.levelID=levelID;
	sldr.bgnd=rect_get(x,y,100,228,GREEN_16BIT);
	sldr.label=text_get(x,y-15,str,sldr.bgnd.width,14,WHITE_16BIT,WHITE_16BIT,g_backgroundColor,0,0);
	sldr.track=rect_get(sldr.bgnd.x+45,sldr.bgnd.y+15,10,200, RED_16BIT);
	sldr.slide=rect_get(sldr.bgnd.x+10,0,80,30,BLACK_16BIT);
	sldr.bottomEdge=rect_get(x,y+sldr.bgnd.height,sldr.bgnd.width,12,g_backgroundColor);
	slider_updateSlidePos(&sldr);
	return sldr;
}
Exemple #5
0
int thread_init(Thread *t, struct Module *m, Symbol *proc)
{
	const Segments *seg = &m->seg;
	RA_Export exp_idx = module_exp_get_obligatory(m, proc, 0);

	const RMDExport *exp = exp_get(seg, exp_idx);
	const RMDProcedure *ptbl_ent = ptbl_get(seg, exp->idx);
	t->pc.byte = text_get(seg, ptbl_ent->addr);

	t->vars = t->vstack;
	t->vars_end = t->vars + sizeof t->vstack / sizeof t->vstack[0] - 1;

	/* Create first stack frame manually as if startup code
	   calls function @proc. There is only 'exit' instruction
	   in startup code, so we do not need all fields */
	t->pstack[0].retaddr = startup_code;
	t->pstack[0].proc = ptbl_ent;
	t->pstack[0].module = m;
	t->procs = t->pstack;
	t->procs_end = t->procs + sizeof t->pstack / sizeof t->pstack[0] - 1;
	return 0;
}
Exemple #6
0
void updateItem(struct keyval *head, const char *name, const char *value)
{
    struct keyval *item;

    if (!head) 
        return;

    item = head->next;
    while(item != head) {
        if (!strcmp(item->key, name)) {
#ifdef USE_TREE
            text_release(tree_ctx, item->value);
            item->value = (char *)text_get(tree_ctx,value);
#else
            free(item->value);
            item->value = strdup(value);
#endif
            return;
        }
        item = item->next;
    }
    addItem(head, name, value, 0);
}