Ejemplo n.º 1
0
void tdlg::on_tsSpin_editingFinished()
{
    if(bedit[0])
    {
        bedit[0] = false;
        buser = true;
        checkval(&Tusr[0], Tmin[0], Tmax[0]);
        ui->tsSpin->setValue(nint(Tusr[0]));
    }
}
Ejemplo n.º 2
0
awkfloat setfval(register cell *vp, awkfloat f)
{
	dprintf("setfval: %lo %g\n", (long)vp, f);
	checkval(vp);
	if (vp == recloc)
		error(FATAL, "can't set $0");
	vp->tval &= ~STR;	/* mark string invalid */
	vp->tval |= NUM;	/* mark number ok */
	if ((vp->tval & FLD) && isnull(vp->nval))
		donerec = 0;
	return(vp->fval = f);
}
Ejemplo n.º 3
0
char *setsval(register cell *vp, const char *s)
{
	dprintf("setsval: %lo %s\n", (long)vp, s);
	checkval(vp);
	if (vp == recloc)
		error(FATAL, "can't set $0");
	vp->tval &= ~NUM;
	vp->tval |= STR;
	if ((vp->tval & FLD) && isnull(vp->nval))
		donerec = 0;
	if (!(vp->tval&FLD))
		strfree(vp->sval);
	vp->tval &= ~FLD;
	return(vp->sval = tostring(s));
}
Ejemplo n.º 4
0
char *getsval(register cell *vp)
{
	char s[100];

	if (vp->sval == record && donerec == 0)
		recbld();
	dprintf("getsval: %lo", (long)vp);
	checkval(vp);
	if ((vp->tval & STR) == 0) {
		if (!(vp->tval&FLD))
			strfree(vp->sval);
		if ((long long)vp->fval==vp->fval)
			(void)snprintf(s, sizeof s, "%.20g", vp->fval);
		else
			(void)snprintf(s, sizeof s, *OFMT, vp->fval);
		vp->sval = tostring(s);
		vp->tval &= ~FLD;
		vp->tval |= STR;
	}
	dprintf("  %s\n", vp->sval);
	return(vp->sval);
}
Ejemplo n.º 5
0
awkfloat getfval(register cell *vp)
{

	if (vp->sval == record && donerec == 0)
		recbld();
	dprintf("getfval: %lo", (long)vp);
	checkval(vp);
	if ((vp->tval & NUM) == 0) {
		/* the problem is to make non-numeric things */
		/* have unlikely numeric variables, so that */
		/* $1 == $2 comparisons sort of make sense when */
		/* one or the other is numeric */
		if (isanumber(vp->sval)) {
			vp->fval = atof(vp->sval);
			if (!(vp->tval & CON))	/* don't change type of a constant */
				vp->tval |= NUM;
		}
		else
			vp->fval = 0.0;	/* not a very good idea */
	}
	dprintf("  %g\n", vp->fval);
	return(vp->fval);
}
Ejemplo n.º 6
0
int main(int argc, char **argv)
{
	int ret = -1, i;
	char buf[1024], path[PATH_MAX];
	struct stat sb;

	char *dev_allow[] = {
		"c *:* m",
		"b *:* m",
		"c 1:3 rwm",
		"c 1:5 rwm",
		"c 1:7 rwm",
		"c 5:0 rwm",
		"c 5:2 rwm",
		"c 1:8 rwm",
		"c 1:9 rwm",
		"c 136:* rwm",
		"c 10:229 rwm",
	};

	test_init(argc, argv);

	if (mount_and_add("devices", cgname, "devices.deny", "a") < 0)
		goto out;

	/* need to allow /dev/null for restore */
	sprintf(path, "%s/devices/%s/devices.allow", dirname, cgname);
	for (i = 0; i < ARRAY_SIZE(dev_allow); i++) {
		if (write_value(path, dev_allow[i]) < 0)
			goto out;
	}

	if (mount_and_add("memory", cgname, "memory.limit_in_bytes", "268435456") < 0)
		goto out;

	test_daemon();
	test_waitsig();

	buf[0] = 0;
	for (i = 0; i < ARRAY_SIZE(dev_allow); i++) {
		strcat(buf, dev_allow[i]);
		strcat(buf, "\n");
	}

	sprintf(path, "%s/devices/%s/devices.list", dirname, cgname);
	if (!checkval(path, buf)) {
		fail();
		goto out;
	}

	sprintf(path, "%s/memory/%s/memory.limit_in_bytes", dirname, cgname);
	if (!checkval(path, "268435456\n")) {
		fail();
		goto out;
	}

	sprintf(path, "%s/devices/%s/special_prop_check", dirname, cgname);
	if (stat(path, &sb) < 0) {
		fail("special_prop_check doesn't exist?");
		goto out;
	}

	if (!S_ISDIR(sb.st_mode)) {
		fail("special_prop_check not a directory?");
		goto out;
	}

	pass();
	ret = 0;
out:
	sprintf(path, "%s/devices/%s/special_prop_check", dirname, cgname);
	rmdir(path);

	sprintf(path, "%s/devices/%s", dirname, cgname);
	rmdir(path);
	sprintf(path, "%s/devices", dirname);
	umount(path);

	sprintf(path, "%s/memory/%s", dirname, cgname);
	rmdir(path);
	sprintf(path, "%s/memory", dirname);
	umount(path);

	return ret;
}
Ejemplo n.º 7
0
static int block(void)
{
    if (stop) return 0;

    if (accept(number)) {
        ordernum = numvalue;
    } else {
        ordernum = 0;
    }

    if (accept(info)) {
        expect(ident);
        strncpy(name_long, strvalue, sizeof(name_long)-1);
        expect(ident);
        strncpy(name_short, strvalue, sizeof(name_short)-1);
        expect(number);
        competitors_min = numvalue;
        expect(number);
        competitors_max = numvalue;
        expect(eol);
        return 1;
    }

    if (accept(svg)) {
        if (accept(page)) {
            expect(number);
            pagenum = numvalue;
        }
        expect(eol);
        return 1;
    }

    if (accept(ident)) {
        match_t *m = get_match_or_create(strvalue);
        m->ordernum = ordernum;
        m->number = linenum;
        m->page = pagenum;
        expect(colon);
        player();
        m->c1 = compvalue;
        player();
        m->c2 = compvalue;
        expect(eol);
        return 1;
    }

    if (accept(b3)) {
        char buf[64];
        match_t *m[3];
        int i;
        checkval((num_best_of_three_pairs < NUM_BEST_OF_3_PAIRS), 
                 "Too many best of three pools, max = %d", NUM_BEST_OF_3_PAIRS);
        expect(ident);
        best_of_three_pairs[num_best_of_three_pairs].name = get_sym(strvalue);
        for (i = 0; i < 3; i++) {
            snprintf(buf, sizeof(buf), "%s_%d", strvalue, i+1);
            m[i] = get_match_or_create(buf);
            m[i]->ordernum = ordernum;
            m[i]->number = linenum;
            m[i]->page = pagenum;
            best_of_three_pairs[num_best_of_three_pairs].matches[i] = get_sym(buf);
        }
        expect(colon);
        player();
        m[0]->c1 = m[1]->c1 = m[2]->c1 = compvalue;
        player();
        m[0]->c2 = m[1]->c2 = m[2]->c2 = compvalue;
        expect(eol);
        num_best_of_three_pairs++;
        return 1;
    }

    if (accept(rr)) {
        round_robin_t *pool = &round_robin_pools[num_round_robin_pools];
        competitor_t c[20];
        int num_players = 0, i, j;
        char buf[64];
        checkval((num_round_robin_pools < NUM_ROUND_ROBIN_POOLS), 
                 "Too many round robin pools, max = %d", NUM_ROUND_ROBIN_POOLS);
        expect(ident);
        pool->name = get_sym(strvalue);
        /*
        match_t *m1 = get_match(strvalue);
        m1->ordernum = ordernum;
        m1->number = linenum;
        m1->page = pagenum;
        m1->type = rr;
        */
        expect(colon);
        while (player()) {
            c[num_players++] = compvalue;
            pool->competitors[pool->num_competitors++] = compvalue;
        }
        // Create round robin matches
        for (i = 0; i < num_players-1; i++) {
            for (j = i+1; j < num_players; j++) {
                checkval((pool->num_rr_matches < NUM_RR_MATCHES), 
                         "Too many round robin matches, max = %d", NUM_RR_MATCHES);

                sprintf(buf, "%s_%d_%d", round_robin_pools[num_round_robin_pools].name->name, i, j);
                match_t *m = get_match_or_create(buf);
                m->ordernum = ordernum;
                m->number = linenum;
                m->page = pagenum;
                m->c1 = c[i];
                m->c2 = c[j];
                pool->rr_matches[pool->num_rr_matches++] = get_sym(buf);
            }
        }
        expect(eol);
        num_round_robin_pools++;
        return 1;
    }

    if (accept(ko)) {
        int num_players = 0;
        char buf[64];
        expect(ident);
        sym_t *name = get_sym(strvalue), *reference = NULL;
        expect(colon);
        int i = 1, n, lev = 1;
        while (player()) {
            checkval((num_matches < NUM_CUSTOM_MATCHES), 
                     "Too many matches, max = %d", NUM_CUSTOM_MATCHES);

            sprintf(buf, "%s_%d_%d", name->name, lev, i);
            match_t *m = get_match_or_create(buf);
            if (i == 1) reference = get_sym(buf);
            else {
                m->reference = reference;
                //m->x = 0.0; m->y = y_shift*(i - 1);
            }
            m->ordernum = ordernum;
            m->number = linenum;
            m->page = pagenum;
            m->c1 = compvalue;
            if (!player()) {
                fprintf(stderr, "Line %d: missing player\n", linenum);
                return 1;
            }
            m->c2 = compvalue;
            m->flags |= FLAG_LONG_NAME;
            num_players += 2;
            i++;
        }
        // Create knock out matches
        for (n = num_players/4; n >= 1; n = n/2) {
            lev++;
            for (i = 0; i < n; i++) {
                if (n == 1)
                    sprintf(buf, "%s", name->name);
                else
                    sprintf(buf, "%s_%d_%d", name->name, lev, i+1);
                match_t *m = get_match_or_create(buf), *m1, *m2;

                if (n == 1) m->flags |= FLAG_LAST;

                m->ordernum = ordernum;
                m->number = linenum;
                m->page = pagenum;

                sprintf(buf, "%s_%d_%d", name->name, lev-1, 2*i+1);
                m->c1.match = get_sym(buf);
                m->c1.pos = 1;

                sprintf(buf, "%s_%d_%d", name->name, lev-1, 2*i+2);
                m->c2.match = get_sym(buf);
                m->c2.pos = 1;

                checkval((num_matches < NUM_CUSTOM_MATCHES-1), 
                         "Too many matches, max = %d", NUM_CUSTOM_MATCHES);
                m1 = get_match_or_create(m->c1.match->name);
                m2 = get_match_or_create(m->c2.match->name);
                if (m1 && m2) {
                    m->reference = reference;
                    //m->x = x_shift*(lev-1); 
                    m->y = (m1->y + m2->y)/2;
                    m->y1 = m1->y - m->y;
                    m->y2 = m2->y - m->y;
                }
            }
        } 
        expect(eol);
        return 1;
    }

    if (accept(order)) {
        while (player()) {
            checkval((num_ord < NUM_CUSTOM_MATCHES), 
                     "Too many matches in order, max = %d", NUM_CUSTOM_MATCHES);
            match_order[num_ord].first = compvalue;
            expect(dash);
            if (player()) {
                match_order[num_ord++].second = compvalue;
            }
        }
         
        expect(eol);
        return 1;
    }

    if (accept(pos)) {
        int posval = numvalue-1;
        checkval((posval >= 0 && posval < NUM_CUST_POS), 
                 "Wrong position number, values 1-%d are valid", NUM_CUST_POS);

        expect(ident);
        sym_t *s = get_sym(strvalue);
        positions[posval].match = s;
        expect(dot);
        expect(number);
        positions[posval].pos = numvalue;
        positions[posval].page = pagenum;
        if (accept(number)) {
            positions[posval].real_contest_pos = numvalue;
        }
        expect(eol);
        return 1;
    }

    if (accept(group)) {
        int grpval = numvalue-1;
        checkval((grpval >= 0 && grpval < NUM_GROUPS), "Wrong group index, 1-%d are valid", NUM_GROUPS);
        if (accept(rr)) {
            groups_type = 1;
        }
        groups[grpval].num_competitors = 0;
        while (player()) {
            if (compvalue.comp)
                groups[grpval].competitors[groups[grpval].num_competitors++] = compvalue.comp;
        }        
        if (grpval+1 > num_groups) num_groups = grpval+1;
        group_set = 1;
        expect(eol);
        return 1;
    }

    accept(eol);
    return 1;
}