Exemple #1
0
int main(int argc, char *argv[])
{
	struct option longopts[] = {
		{ "version", no_argument, NULL,	'v' },
		{ "help", no_argument, NULL, 'h' },
		{ 0, 0, 0, 0 }
	};
	int c = 0;

	/* Parse command-line options */
	while ((c = getopt_long(argc, argv, "vh", longopts, NULL)) > -1) {
		switch (c) {
		case 'h':
			display_usage(stdout);
			return EXIT_SUCCESS;
		case 'v':
			display_version();
			return EXIT_SUCCESS;
		default:
			/* Unknown option */
			display_usage(stderr);
			return EXIT_FAILURE;
		}
	}
	/* Start the wm */
	if (leaf_init() != ERR_NONE)
		return leaf_exit(EXIT_FAILURE);
	if (leaf_run() != ERR_NONE)
		return leaf_exit(EXIT_FAILURE);

	return leaf_exit(EXIT_SUCCESS);
}
Exemple #2
0
bool_t problem_alloc(problem_t *p, leaf_t *root, var_t *var) {
    leaf_t *leaf = NULL;
    bool_t result = TRUE;
    size_t i = 0;

    if (root->n_children > 0) {
        for (; i < root->n_children ; i++)
            result = result && problem_alloc(p, root->children[i], var);
    } else {
		printf("%lu ; \n", var->name);
		leaf = leaf_init(var->def->set[var->name - 1], NULL, var->name);
		if (leaf == NULL)
			exit(EXIT_FAILURE);

		if (constraint_check(p->n_constraints, p->constraints, root, var->name, var->def->set[var->name - 1])) {
			leaf_append(root, leaf);
			leaf->ancestor = root;
		} else {
			leaf_free(leaf);
		}

		if (root->n_children == 0)
			result = FALSE;
    }

    return result;
}