#include <stdbool.h>
#define ERROR_STATE -1
-#define SAFE_BUFFER_SIZE 255
+#define SAFE_BUFFER_SIZE 2048
#define CHECK_OUTPUT_WIDTH 42
#define MINIMAL_MODULE_WIDTH 3
#define ATTR_WIDTH 50
static void _print_module_legend()
{
- printf("\n[[node role name],[attributes list],[x,y,width,height],[node name],[states list]]\n\n");
+ printf("\n[[node],[node role name],[attributes list],[x,y,width,height],[node name],[states list][flow to node, flow from node]\n\n");
}
static void _print_atspi_states_legend()
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");
- abort();
+ attributes_string[ATTR_WIDTH - 1] = '\n';
}
_combine_strings(&result, attributes_string);
}
return result;
}
+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);
+ }
+ }
+ return ret;
+}
+
static char *_get_info(AtspiAccessible *node, int length_limit)
{
if (!node)
_truncate_string(states, length_limit);
char result[SAFE_BUFFER_SIZE];
- int ret = snprintf(result, SAFE_BUFFER_SIZE, "[[%s],[%s],[%s,%s,%s,%s],[%s],[%s]]",
- node_role_name,
- attributes,
- box_size->x,
- box_size->y,
- box_size->width,
- box_size->height,
- node_name,
- states);
+ int ret = snprintf(result, SAFE_BUFFER_SIZE, "[[%p],[%s],[%s],[%s,%s,%s,%s],[%s],[%s],[%p,%p]]",
+ node,
+ node_role_name,
+ attributes,
+ box_size->x,
+ box_size->y,
+ box_size->width,
+ box_size->height,
+ node_name,
+ states,
+ _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");
- abort();
+ result[SAFE_BUFFER_SIZE - 1] = '\n';
}
free(node_name);