static void node_image(xml_data_node *node, messtest_command_type_t command) { xml_attribute_node *attr_node; const char *s2; int preload, device_type; memset(&new_command, 0, sizeof(new_command)); new_command.command_type = command; /* 'preload' attribute */ attr_node = xml_get_attribute(node, "preload"); preload = attr_node ? atoi(attr_node->value) : 0; if (preload) new_command.command_type += 2; /* 'filename' attribute */ attr_node = xml_get_attribute(node, "filename"); new_command.u.image_args.filename = attr_node ? attr_node->value : NULL; /* 'type' attribute */ attr_node = xml_get_attribute(node, "type"); if (!attr_node) { error_missingattribute("type"); return; } s2 = attr_node->value; device_type = device_typeid(s2); if (device_type < 0) { error_baddevicetype(s2); return; } new_command.u.image_args.device_type = device_type; /* 'slot' attribute */ attr_node = xml_get_attribute(node, "slot"); new_command.u.image_args.device_slot = attr_node ? atoi(attr_node->value) : 0; /* 'format' attribute */ format_index = 0; attr_node = xml_get_attribute(node, "format"); new_command.u.image_args.format = attr_node ? attr_node->value : NULL; /* 'tag' attribute */ attr_node = xml_get_attribute(node, "tag"); new_command.u.image_args.device_tag = attr_node ? attr_node->value : NULL; if (!append_command()) { error_outofmemory(); return; } }
static void node_imageverify(xml_data_node *node) { xml_attribute_node *attr_node; const char *s; iodevice_t device_type; void *new_buffer; mess_pile pile; /* <imageverify> - verifies that an image contains specific data */ memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_VERIFY_IMAGE; /* 'type' attribute */ attr_node = xml_get_attribute(node, "type"); s = attr_node ? attr_node->value : NULL; if (!s) { error_missingattribute("type"); return; } device_type = device_typeid(s); if (device_type < 0) { error_baddevicetype(s); return; } new_command.u.verify_args.device_type = device_type; pile_init(&pile); messtest_get_data(node, &pile); new_buffer = pool_malloc(&command_pool, pile_size(&pile)); memcpy(new_buffer, pile_getptr(&pile), pile_size(&pile)); new_command.u.verify_args.verify_data = new_buffer; new_command.u.verify_args.verify_data_size = pile_size(&pile); pile_delete(&pile); if (!append_command()) { error_outofmemory(); return; } }
static int get_device_identity_tags(xml_data_node *node, messtest_device_identity *ident) { xml_attribute_node *attr_node; const char *s2; /* clear out the result */ memset(ident, 0, sizeof(*ident)); /* 'type' attribute */ attr_node = xml_get_attribute(node, "type"); if (attr_node != NULL) { s2 = attr_node->value; ident->type = device_config_image_interface::device_typeid(s2); if (ident->type <= IO_UNKNOWN) { error_baddevicetype(s2); return FALSE; } } else { /* the device type was unspecified */ ident->type = IO_UNKNOWN; } /* 'slot' attribute */ attr_node = xml_get_attribute(node, "slot"); ident->slot = (attr_node != NULL) ? atoi(attr_node->value) : 0; /* 'tag' attribute */ attr_node = xml_get_attribute(node, "tag"); ident->tag = (attr_node != NULL) ? attr_node->value : NULL; return TRUE; }