Example #1
0
GNode *
_gcr_subject_public_key_load (GckObject *key,
                              GCancellable *cancellable,
                              GError **error)
{
	GckBuilder builder = GCK_BUILDER_INIT;
	GckAttributes *attributes;
	GNode *asn;

	g_return_val_if_fail (GCK_IS_OBJECT (key), NULL);
	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
	g_return_val_if_fail (error == NULL || *error == NULL, NULL);

	lookup_attributes (key, &builder);

	if (!check_attributes (&builder)) {
		if (!load_attributes (key, &builder, cancellable, error)) {
			gck_builder_clear (&builder);
			return NULL;
		}
	}

	attributes = gck_builder_end (&builder);
	asn = _gcr_subject_public_key_for_attributes (attributes);
	if (asn == NULL) {
		g_set_error_literal (error, GCK_ERROR, CKR_TEMPLATE_INCONSISTENT,
		                     _("Couldn't build public key"));
	}

	gck_attributes_unref (attributes);
	return asn;
}
Example #2
0
bool Object::load_nodes(TiXmlNode *node)
{
    int result = true;

    if (node->Type() == TiXmlNode::TINYXML_ELEMENT) {
        if (strcmp(node->Value(), "object") == 0) {
            result = load_object_attributes(node->ToElement());
        }
        else if (strcmp(node->Value(), "string") == 0) {
            load_strings(node->ToElement());
        }
        else {
            load_attributes(node->ToElement());
        }
    }

    for (TiXmlNode *child = node->FirstChild();
             child != 0;
             child = child->NextSibling()) {
        if (!load_nodes(child)) {
            result = false;
        }
    }

    return result;
}
Example #3
0
/*
in :
    - path is the path to the file that contains examples
    - ex is a pointer on the non-allocated yet tab of examples used to create the tree
    - n_ex is a pointer on the ex tab length
    - attr is a pointer on a tab, same than ex
    - n_attr is same than n_ex
out :
    - nothing
*/
void get_datas_from_file(const string path, struct example_t **ex, int *n_ex, struct attribute_t **attr, int *n_attr)
{
    int i, j;
    string buffer;
    FILE *f = fopen(path, "r");

    /*if parameters aren't correct, then*/
    if(ex == NULL || attr == NULL || n_ex == NULL || n_attr == NULL)
        /*leave function*/
        return;

    if(f != NULL)
    {
        /*first, find attributes*/
        while(fgets(buffer, sizeof(buffer), f) != NULL && strstr(buffer, "#attributes") == NULL);
        /*then read and load the set*/
        load_attributes(f, attr, n_attr);
        /*now find the examples*/
        while(fgets(buffer, sizeof(buffer), f) != NULL && strstr(buffer, "#examples") == NULL);

        /*and then load them*/
        fscanf(f, "%d\n", n_ex);
        *ex = malloc(sizeof(**ex) * *n_ex);
        for(i = 0; i < *n_ex; ++i)
        {
            (*ex)[i].l_tab = *n_attr;
            (*ex)[i].tab_values = malloc(sizeof(*(*ex)[i].tab_values) * *n_attr);
            for(j = 0; j < *n_attr; ++j)
                fscanf(f, "%s ", (*ex)[i].tab_values[j]);
            fscanf(f, "%s\n", (*ex)[i].property);
        }
    }
}
Example #4
0
static void
thread_key_attributes (GSimpleAsyncResult *res,
                       GObject *object,
                       GCancellable *cancellable)
{
	LoadClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
	GError *error = NULL;

	if (!load_attributes (closure->object, &closure->builder, cancellable, &error))
		g_simple_async_result_take_error (res, error);
}
Example #5
0
bool Object::load_nodes(TiXmlNode *node)
{
    int result = true;

    if (node->Type() == TiXmlNode::TINYXML_ELEMENT) {
        if (strcmp(node->Value(), "object") == 0) {
            result = load_object_attributes(node->ToElement());
        }
        else if (strcmp(node->Value(), "string") == 0) {
            load_strings(node->ToElement());
        }
        else if (strcmp(node->Value(), "weak_parts") == 0) {
            m_weak_parts.push_back(new CollisionParts(node->ToElement()));
        }
        else if (strcmp(node->Value(), "weak_part") == 0) {
            if (m_weak_parts.size()) {
                CollisionParts *parts = m_weak_parts.back();
                parts->add_parts(node->ToElement());
             }
        }
        else if (strcmp(node->Value(), "shielded_parts") == 0) {
            m_shielded_parts.push_back(new CollisionParts(node->ToElement()));
        }
        else if (strcmp(node->Value(), "shielded_part") == 0) {
            if (m_shielded_parts.size()) {
                CollisionParts *parts = m_shielded_parts.back();
                parts->add_parts(node->ToElement());
             }
        }
        else {
            load_attributes(node->ToElement());
        }
    }

    for (TiXmlNode *child = node->FirstChild();
             child != 0;
             child = child->NextSibling()) {
        if (!load_nodes(child)) {
            result = false;
        }
    }

    return result;
}
Example #6
0
/*
in :
    - path is the path of the file where datas lie (a *.NEL file)
    - attributes is a pointer on the future tab that will contain the attributes and their values
    - n_attr is explicit
out :
    - the tree that has been loaded grom the file in <path>
*/
struct node_t *load_tree(const string path, struct attribute_t **attributes, int *n_attr)
{
    string buffer;
    struct node_t *ret;
    FILE *f = fopen(path, "r");
    if(f == NULL)
        return NULL;


    while(fgets(buffer, sizeof(buffer), f) != NULL)
    {
        /*on each read line, load the right part of it.*/
        if(strstr(buffer, "#attributes") != NULL)
            load_attributes(f, attributes, n_attr);
        else if(strstr(buffer, "#tree"))
            ret = load_tree_tab(f, 0);
    }
    free(f);
    return ret;
}