return box_size;
}
-static char *_get_states(AtspiAccessible *node)
+static char *_get_states(AtspiAccessible *node, int length_limit)
{
AtspiStateSet *node_state_set = atspi_accessible_get_state_set(node);
GArray *states = atspi_state_set_get_states(node_state_set);
g_array_free(states, 0);
g_object_unref(node_state_set);
+ _truncate_string(state_string, length_limit);
+
return state_string;
}
-static char *_get_attributes(AtspiAccessible *node)
+static char *_get_attributes(AtspiAccessible *node, int length_limit)
{
- GHashTable *attributes = NULL;
- attributes = atspi_accessible_get_attributes(node, NULL);
+ GHashTable *attributes = atspi_accessible_get_attributes(node, NULL);
if (!attributes)
return NULL;
char *result = NULL;
while (g_hash_table_iter_next (&attributes_iter, &attr_key, &attr_value)) {
char attributes_string[ATTR_WIDTH];
- int ret = snprintf(attributes_string, ATTR_WIDTH, "(%s=%s)", (char*)attr_key, (char*)attr_value);
- if (ret >= ATTR_WIDTH) {
- fprintf(stderr, "_get_attributes: generated string is too long. Buffer overflow");
- attributes_string[ATTR_WIDTH - 1] = '\n';
- }
+ int ret = snprintf(attributes_string, ATTR_WIDTH, "(%s=%s)", (char *)attr_key, (char *)attr_value);
+ if (ret >= ATTR_WIDTH)
+ fprintf(stderr, "\n_get_attributes: generated string is too long. Buffer overflow\n");
+
_combine_strings(&result, attributes_string);
}
g_hash_table_unref(attributes);
+ _truncate_string(result, length_limit);
return result;
}
-static AtspiAccessible *_get_object_in_relation(AtspiAccessible * source, AtspiRelationType search_type)
+static AtspiAccessible *_get_object_in_relation(AtspiAccessible *source, AtspiRelationType search_type)
{
- GArray *relations;
- AtspiAccessible *ret = NULL;
- AtspiRelation *relation;
- AtspiRelationType type;
- int i;
- if (source) {
- relations = atspi_accessible_get_relation_set(source, NULL);
- if (relations) {
- for (i = 0; i < relations->len; i++) {
- relation = g_array_index(relations, AtspiRelation *, i);
- type = atspi_relation_get_relation_type(relation);
-
- if (type == search_type) {
- ret = atspi_relation_get_target(relation, 0);
- break;
- }
- }
- g_array_free(relations, TRUE);
+ if (source == NULL)
+ return NULL;
+
+ GArray *relations = atspi_accessible_get_relation_set(source, NULL);
+
+ if (relations == NULL)
+ return NULL;
+
+ AtspiAccessible *ret;
+ for (int i = 0; i < relations->len; ++i) {
+ AtspiRelation *relation = g_array_index(relations, AtspiRelation *, i);
+ AtspiRelationType type = atspi_relation_get_relation_type(relation);
+
+ if (type == search_type) {
+ ret = atspi_relation_get_target(relation, 0);
+ break;
}
}
+
+ g_array_free(relations, TRUE);
+
return ret;
}
char *node_name = atspi_accessible_get_name(node, NULL);
char *node_role_name = atspi_accessible_get_role_name(node, NULL);
- char *attributes = _get_attributes(node);
- _truncate_string(attributes, length_limit);
+ char *attributes = _get_attributes(node, length_limit);
Box_Size *box_size = _get_box_size(node);
- char *states = _get_states(node);
- _truncate_string(states, length_limit);
+ char *states = _get_states(node, length_limit);
char result[SAFE_BUFFER_SIZE];
int ret = snprintf(result, SAFE_BUFFER_SIZE, "[[%p],[%s],[%s],[%s,%s,%s,%s],[%s],[%s],[%p,%p]]",
_get_object_in_relation(node, ATSPI_RELATION_FLOWS_TO),
_get_object_in_relation(node, ATSPI_RELATION_FLOWS_FROM));
- if (ret >= SAFE_BUFFER_SIZE) {
- fprintf(stderr, "_get_info: generated string is too long. Buffer overflow");
- result[SAFE_BUFFER_SIZE - 1] = '\n';
- }
+ if (ret >= SAFE_BUFFER_SIZE)
+ fprintf(stderr, "\n_get_info: generated string is too long. Buffer overflow\n");
free(node_name);
free(node_role_name);
bool app_name_matched = false;
for (int i = 0; i < count; i++) {
AtspiAccessible *child = atspi_accessible_get_child_at_index(desktop, i, NULL);
- if (child) {
- char *name = atspi_accessible_get_name(child, NULL);
+ if (child == NULL)
+ break;
+
+ char *name = atspi_accessible_get_name(child, NULL);
+
+ if (!dump && !check)
+ printf("%s\n", name);
- if (!dump && !check) {
- printf("%s\n", name);
- }
+ if ((check || dump) && name && !strcmp(name, app_name)) {
+ app_name_matched = true;
- if ((check || dump) && name && !strcmp(name, app_name)) {
- app_name_matched = true;
+ _print_module_legend();
- _print_module_legend();
+ if (check)
+ _test_atspi_parent_child_relation(child, desktop, i);
- if (check)
- _test_atspi_parent_child_relation(child, desktop, i);
+ _print_atspi_tree_verify_maybe_r(0, child, check, length_limit);
- _print_atspi_tree_verify_maybe_r(0, child, check, length_limit);
+ if (first_match) {
+ free(name);
+ break;
+ } else
+ printf("\n");
- if (first_match) {
- free(name);
- break;
- } else
- printf("\n");
- }
free(name);
}
}