1 #include "atspi/atspi.h"
11 #define ERROR_STATE -1
12 #define SAFE_BUFFER_SIZE 2048
13 #define CHECK_OUTPUT_WIDTH 42
14 #define MINIMAL_MODULE_WIDTH 3
16 #define NUMBER_WIDTH 6
17 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
23 #define RELATION_TABLE_COLUMN_COUNT 7
24 #define ATTRIBUTE_TABLE_COLUMN_COUNT 3
25 #define RELATION_TABLE_COLUMN_WIDTH 20
26 #define ATTRIBUTE_TABLE_BASE_COLUMN_WIDTH 20
29 static unsigned indent_width = 2;
30 static int module_name_limit = -1;
32 static const char* atspi_state_names[] = {
33 [ATSPI_STATE_INVALID] = "INVALID",
34 [ATSPI_STATE_ACTIVE] = "ACTIVE",
35 [ATSPI_STATE_ARMED] = "ARMED",
36 [ATSPI_STATE_BUSY] = "BUSY",
37 [ATSPI_STATE_CHECKED] = "CHECKED",
38 [ATSPI_STATE_COLLAPSED] = "COLLAPSED",
39 [ATSPI_STATE_DEFUNCT] = "DEFUNCT",
40 [ATSPI_STATE_EDITABLE] = "EDITABLE",
41 [ATSPI_STATE_ENABLED] = "ENABLED",
42 [ATSPI_STATE_EXPANDABLE] = "EXPANDABLE",
43 [ATSPI_STATE_EXPANDED] = "EXPANDED",
44 [ATSPI_STATE_FOCUSABLE] = "FOCUSABLE",
45 [ATSPI_STATE_FOCUSED] = "FOCUSED",
46 [ATSPI_STATE_HAS_TOOLTIP] = "HAS_TOOLTIP",
47 [ATSPI_STATE_HORIZONTAL] = "HORIZONTAL",
48 [ATSPI_STATE_ICONIFIED] = "ICONIFIED",
49 [ATSPI_STATE_MULTI_LINE] = "MULTI_LINE",
50 [ATSPI_STATE_MULTISELECTABLE] = "MULTISELECTABLE",
51 [ATSPI_STATE_OPAQUE] = "OPAQUE",
52 [ATSPI_STATE_PRESSED] = "PRESSED",
53 [ATSPI_STATE_RESIZABLE] = "RESIZABLE",
54 [ATSPI_STATE_SELECTABLE] = "SELECTABLE",
55 [ATSPI_STATE_SELECTED] = "SELECTED",
56 [ATSPI_STATE_SENSITIVE] = "SENSITIVE",
57 [ATSPI_STATE_SHOWING] = "SHOWING",
58 [ATSPI_STATE_SINGLE_LINE] = "SINGLE_LINE",
59 [ATSPI_STATE_STALE] = "STALE",
60 [ATSPI_STATE_TRANSIENT] = "TRANSIENT",
61 [ATSPI_STATE_VERTICAL] = "VERTICAL",
62 [ATSPI_STATE_VISIBLE] = "VISIBLE",
63 [ATSPI_STATE_MANAGES_DESCENDANTS] = "MANAGES_DESCENDANTS",
64 [ATSPI_STATE_INDETERMINATE] = "INDETERMINATE",
65 [ATSPI_STATE_REQUIRED] = "REQUIRED",
66 [ATSPI_STATE_TRUNCATED] = "TRUNCATED",
67 [ATSPI_STATE_ANIMATED] = "ANIMATED",
68 [ATSPI_STATE_INVALID_ENTRY] = "INVALID_ENTRY",
69 [ATSPI_STATE_SUPPORTS_AUTOCOMPLETION] = "SUPPORTS_AUTOCOMPLETION",
70 [ATSPI_STATE_SELECTABLE_TEXT] = "SELECTABLE_TEXT",
71 [ATSPI_STATE_IS_DEFAULT] = "IS_DEFAULT",
72 [ATSPI_STATE_VISITED] = "VISITED",
73 [ATSPI_STATE_CHECKABLE] = "CHECKABLE",
74 [ATSPI_STATE_MODAL] = "MODAL",
75 [ATSPI_STATE_HIGHLIGHTED] = "HIGHLIGHTED",
76 [ATSPI_STATE_HIGHLIGHTABLE] = "HIGHLIGHTABLE",
77 [ATSPI_STATE_HAS_POPUP] = "HAS_POPUP",
78 [ATSPI_STATE_READ_ONLY] = "READ_ONLY",
79 [ATSPI_STATE_LAST_DEFINED] = "LAST_DEFINED"
82 typedef struct _Box_Size {
89 static char *_multiply_string(char c, unsigned number)
91 char *result = (char *)calloc(1, number + 1);
96 memset(result, c, number);
101 static void _print_module_legend()
103 printf("\n[[node],[node role name],[attributes list],[x,y,width,height],[node name],[states list][relations]\n\n");
106 static void _print_atspi_states_legend()
108 _print_module_legend();
110 int array_len = ARRAY_SIZE(atspi_state_names);
111 int line_count = (array_len + COLUMN_NO - 1)/COLUMN_NO;
112 for (int line_idx = 0; line_idx < line_count; line_idx++) {
113 if ((line_idx < line_count - 1) || (array_len % COLUMN_NO == 0)) {
114 printf("[%d]\t%-24s[%d]\t%-24s[%d]\t%s\n",
115 line_idx * COLUMN_NO,
116 atspi_state_names[line_idx * COLUMN_NO],
117 (line_idx * COLUMN_NO) + 1,
118 atspi_state_names[(line_idx * COLUMN_NO) + 1],
119 (line_idx * COLUMN_NO) + 2,
120 atspi_state_names[(line_idx * COLUMN_NO) + 2]);
121 } else if (array_len % COLUMN_NO == 2) {
122 printf("[%d]\t%-24s[%d]\t%s\n",
123 line_idx * COLUMN_NO,
124 atspi_state_names[line_idx * COLUMN_NO],
125 (line_idx * COLUMN_NO) + 1,
126 atspi_state_names[(line_idx * COLUMN_NO) + 1]);
128 printf("[%d]\t%s\n", line_idx * COLUMN_NO, atspi_state_names[line_idx * COLUMN_NO]);
133 static void _set_indent(int indent_size)
135 if (indent_size < 0) {
136 fprintf(stderr, "WARNING: Invalid indent size. Default value retained.\n");
140 indent_width = indent_size;
143 static void _set_module_length_limit(int limit)
145 if (limit < MINIMAL_MODULE_WIDTH) {
146 fprintf(stderr, "WARNING: Invalid maximum field size. Default value retained.\n");
150 module_name_limit = limit;
153 static int _int_sort_function(gconstpointer a, gconstpointer b)
155 int int_a = GPOINTER_TO_INT (a);
156 int int_b = GPOINTER_TO_INT (b);
158 return int_a - int_b;
161 static void _truncate_string(char *string, int length_limit)
163 if (length_limit < MINIMAL_MODULE_WIDTH || !string)
166 int len = strlen(string);
168 if (len > length_limit)
169 memcpy(string + length_limit - 3, "...", 4);
172 static size_t _combine_strings(char **destination, const char *source)
174 if (!source || !*source || !destination)
177 size_t old_len = *destination ? strlen(*destination) : 0;
178 size_t source_len = strlen(source);
179 size_t len = old_len + source_len;
180 char *buf = realloc(*destination, (len + 1) * sizeof(char));
183 fprintf(stderr, "_combine_strings: allocation failed");
187 memcpy(buf + old_len, source, source_len + 1);
194 static Box_Size *_get_box_size(AtspiAccessible *node)
196 Box_Size *box_size = (Box_Size *)malloc(sizeof(Box_Size));
197 if (box_size == NULL)
205 AtspiComponent *component = atspi_accessible_get_component_iface(node);
206 AtspiRect *extent = component ? atspi_component_get_extents(component, ATSPI_COORD_TYPE_SCREEN, NULL) : NULL;
208 if (extent == NULL) {
209 _combine_strings(&x, "_");
210 _combine_strings(&y, "_");
211 _combine_strings(&width, "_");
212 _combine_strings(&height, "_");
214 char temp_buff[NUMBER_WIDTH];
216 snprintf(temp_buff, NUMBER_WIDTH, "%d", extent->x);
217 _combine_strings(&x, temp_buff);
219 snprintf(temp_buff, NUMBER_WIDTH, "%d", extent->y);
220 _combine_strings(&y, temp_buff);
222 snprintf(temp_buff, NUMBER_WIDTH, "%d", extent->width);
223 _combine_strings(&width, temp_buff);
225 snprintf(temp_buff, NUMBER_WIDTH, "%d", extent->height);
226 _combine_strings(&height, temp_buff);
228 g_object_unref(component);
234 box_size->width = width;
235 box_size->height = height;
240 static char *_get_states(AtspiAccessible *node, int length_limit)
242 AtspiStateSet *node_state_set = atspi_accessible_get_state_set(node);
243 GArray *states = atspi_state_set_get_states(node_state_set);
244 if (!states) return NULL;
245 g_array_sort(states, _int_sort_function);
247 AtspiStateType state_type;
248 char *state_string = NULL;
250 for (int i = 0; i < states->len; i++) {
251 state_type = g_array_index(states, AtspiStateType, i);
253 char node_state_str[8];
254 snprintf(node_state_str, 8, "(%d)", state_type);
255 _combine_strings(&state_string, node_state_str);
258 g_array_free(states, 0);
259 g_object_unref(node_state_set);
261 _truncate_string(state_string, length_limit);
266 static char *_get_attributes(AtspiAccessible *node, int length_limit, bool *attributes_are_too_long)
268 GHashTable *attributes = atspi_accessible_get_attributes(node, NULL);
273 GHashTableIter attributes_iter;
276 g_hash_table_iter_init (&attributes_iter, attributes);
278 while (g_hash_table_iter_next (&attributes_iter, &attr_key, &attr_value)) {
279 char attributes_string[SAFE_BUFFER_SIZE];
280 int ret = snprintf(attributes_string, SAFE_BUFFER_SIZE, "(%s=%s)", (char *)attr_key, (char *)attr_value);
281 if (ret >= SAFE_BUFFER_SIZE)
282 fprintf(stderr, "\n%s, %s %d: generated string is too long. Buffer overflow\n", __FILE__, __FUNCTION__, __LINE__);
284 _combine_strings(&result, attributes_string);
286 g_hash_table_unref(attributes);
288 int real_truncate_size = (length_limit < ATTR_WIDTH && length_limit > MINIMAL_MODULE_WIDTH) ? length_limit : ATTR_WIDTH;
289 if (result && attributes_are_too_long && strlen(result) > real_truncate_size)
290 *attributes_are_too_long = true;
292 _truncate_string(result, real_truncate_size);
296 static char *_get_info(AtspiAccessible *node, int length_limit, bool *attributes_are_too_long, bool *app_has_relations)
301 char *node_name = atspi_accessible_get_name(node, NULL);
302 char *node_role_name = atspi_accessible_get_role_name(node, NULL);
303 char *unique_id = atspi_accessible_get_unique_id(node, NULL);
304 char *path = atspi_accessible_get_path(node, NULL);
305 unsigned long long eo_ptr = 0;
306 sscanf(path, "%llu", &eo_ptr);
308 char *attributes = _get_attributes(node, length_limit, attributes_are_too_long);
309 Box_Size *box_size = _get_box_size(node);
310 char *states = _get_states(node, length_limit);
312 GArray *relations = atspi_accessible_get_relation_set(node, NULL);
313 bool current_node_has_relations = (relations && relations->len);
315 char result[SAFE_BUFFER_SIZE];
316 int ret = snprintf(result, SAFE_BUFFER_SIZE, "[[%s(%p)],[%s],[%s],[%s,%s,%s,%s],[%s],[%s],[%s]]",
317 unique_id, (uintptr_t)eo_ptr,
326 current_node_has_relations ? "*" : "");
328 if (ret >= SAFE_BUFFER_SIZE)
329 fprintf(stderr, "\n%s, %s %d: generated string is too long. Buffer overflow\n", __FILE__, __FUNCTION__, __LINE__);
331 if (current_node_has_relations)
332 *app_has_relations = true;
335 free(node_role_name);
340 free(box_size->width);
341 free(box_size->height);
345 g_array_free(relations, TRUE);
347 return g_strdup(result);
350 static void _test_atspi_parent_child_relation(AtspiAccessible *obj, AtspiAccessible *parent_candidate, int parent_candidate_index)
352 int parent_index = atspi_accessible_get_index_in_parent(obj, NULL);
353 AtspiAccessible *parent = atspi_accessible_get_parent(obj, NULL);
355 char output[CHECK_OUTPUT_WIDTH];
356 if (parent_index != parent_candidate_index || parent_candidate != parent) {
357 char parent_status[NUMBER_WIDTH];
360 strncpy(parent_status, "_", NUMBER_WIDTH);
362 snprintf(parent_status, NUMBER_WIDTH, "%d", parent_index);
364 char *parent_unique_id = atspi_accessible_get_unique_id(parent, NULL);
365 char *parent_candidate_unique_id = atspi_accessible_get_unique_id(parent_candidate, NULL);
366 snprintf(output, CHECK_OUTPUT_WIDTH, "[FAIL<%d,%s><%s,%s>]", parent_candidate_index, parent_status,
367 parent_candidate_unique_id, parent_unique_id);
368 free(parent_unique_id);
369 free(parent_candidate_unique_id);
372 snprintf(output, CHECK_OUTPUT_WIDTH, "[OK]");
375 printf("%-*s\t", CHECK_OUTPUT_WIDTH, output);
378 static int _print_atspi_tree_verify_maybe_r(int indent_number, AtspiAccessible *object, bool check_integrity, int length_limit,
379 bool *attributes_are_too_long, bool *app_has_relations)
381 char *indent = _multiply_string(' ', indent_number*indent_width);
382 if (indent != NULL) {
383 printf("%s", indent);
387 char *node_info = _get_info(object, length_limit, attributes_are_too_long, app_has_relations);
388 if (node_info != NULL) {
389 printf("%s\n", node_info);
393 int count = atspi_accessible_get_child_count(object, NULL);
394 for (int i = 0; i < count; i++) {
395 AtspiAccessible *child = atspi_accessible_get_child_at_index(object, i, NULL);
398 _test_atspi_parent_child_relation(child, object, i);
400 _print_atspi_tree_verify_maybe_r(indent_number + 1, child, check_integrity, length_limit, attributes_are_too_long, app_has_relations);
408 printf("AT-SPI2-CORE-UTIL\n\n");
409 printf("USAGE: at_spi2_tool [OPTION] [PARAMETER] ...\n\n");
410 printf("OPTION LIST:\n");
411 printf("-h, --help\t\tshow this message\n");
412 printf("-v, --version\t\tshow actual version of tool\n");
413 printf("-g, --show-legend\tprint AT-SPI state legend\n");
414 printf("-l, --list-apps\t\tlist all applications of desktop\n");
415 printf("-a, --at-spi-client <true|false>\tenable/disable org.a11y.Status.IsEnabled property\n");
416 printf("-s, --sleep <N>\tsleep N seconds\n");
417 printf("-d, --tree-dump\t\tdump tree for selected application\n");
418 printf("-c, --tree-check\tcheck tree for selected application\n");
419 printf("-f, --first-match\tperform dump or check only for first matching application\n");
420 printf("-i, --indent\t\tset indentation size, default value stands at 2\n");
421 printf("-t, --truncate\t\tset maximum single field size, default value stands at 30\n");
422 printf("\nEXAMPLE:\n");
423 printf("\tat_spi2_tool -i3 -d quickpanel\n");
424 printf("\t show AT-SPI tree for node \"quickpanel\" using three-space indentation\n");
425 printf("\tat_spi2_tool -i1 -c starter\n");
426 printf("\t show AT-SPI tree with integrity test for node \"starter\" using one-space indentation\n");
429 void _print_version()
431 printf("AT-SPI2-CORE-UTIL v%s\n", VERSION);
434 static void _print_horizontal_line_in_relations_table() {
435 for (int i = 0; i < RELATION_TABLE_COLUMN_COUNT; i++) {
436 for (int j = 0; j < RELATION_TABLE_COLUMN_WIDTH; j++)
443 static char *_get_unique_id_of_object_in_relation(AtspiRelation *relation) {
447 gint last_index = atspi_relation_get_n_targets(relation) - 1;
448 AtspiAccessible *target = atspi_relation_get_target(relation, last_index);
449 return atspi_accessible_get_unique_id(target, NULL);
452 static void _print_relations_for_object(AtspiAccessible *node) {
453 GArray *relations = atspi_accessible_get_relation_set(node, NULL);
457 if (!relations->len) {
458 g_array_free(relations, FALSE);
462 char **table = calloc(RELATION_TABLE_COLUMN_COUNT, sizeof(char *));
464 fprintf(stderr, "Calloc failed. Can't alloc memory for object relations string\n");
468 table[0] = atspi_accessible_get_unique_id(node, NULL);
469 for (int i = 0; i < relations->len; i++) {
470 AtspiRelation *relation = g_array_index(relations, AtspiRelation *, i);
471 AtspiRelationType type = atspi_relation_get_relation_type(relation);
474 case ATSPI_RELATION_CONTROLLER_FOR: idx = 1; break;
475 case ATSPI_RELATION_CONTROLLED_BY: idx = 2; break;
476 case ATSPI_RELATION_FLOWS_TO: idx = 3; break;
477 case ATSPI_RELATION_FLOWS_FROM: idx = 4; break;
478 case ATSPI_RELATION_DESCRIBED_BY: idx = 5; break;
483 table[idx] = _get_unique_id_of_object_in_relation(relation);
486 snprintf(buf, sizeof(buf), " [%d]", type);
487 _combine_strings(&table[RELATION_TABLE_COLUMN_COUNT - 1], buf);
491 for (int i = 0; i < RELATION_TABLE_COLUMN_COUNT; i++) {
492 printf("%*s|", RELATION_TABLE_COLUMN_WIDTH, table[i] ? table[i] : "");
498 _print_horizontal_line_in_relations_table();
499 g_array_free(relations, TRUE);
502 typedef void (*print_information_about_object_function)(AtspiAccessible *);
504 static void _iterate_over_tree(print_information_about_object_function func, AtspiAccessible *node) {
507 int count = atspi_accessible_get_child_count(node, NULL);
508 for (int i = 0; i < count; i++) {
509 AtspiAccessible *child = atspi_accessible_get_child_at_index(node, i, NULL);
511 _iterate_over_tree(func, child);
515 static void _print_relations_for_objects_in_tree(AtspiAccessible *node) {
516 _iterate_over_tree(_print_relations_for_object, node);
519 static void _print_header_for_relation_table() {
520 char *table[] = {"OBJECT", "CONTROLLER_FOR", "CONTROLLED_BY", "FLOWS_TO", "FLOWS_FROM", "DESCRIBED_BY", "OTHER RELATION [ID]"};
521 assert(ARRAY_SIZE(table) == RELATION_TABLE_COLUMN_COUNT);
523 _print_horizontal_line_in_relations_table();
525 for (int i = 0; i < RELATION_TABLE_COLUMN_COUNT; i++)
526 printf("%*s|", RELATION_TABLE_COLUMN_WIDTH , table[i]);
529 _print_horizontal_line_in_relations_table();
532 static void _print_relations_table(AtspiAccessible *node) {
533 printf("\nRELATIONS TABLE\n");
534 _print_header_for_relation_table();
535 _print_relations_for_objects_in_tree(node);
538 static void _print_horizontal_line_in_attributes_table() {
540 for (int i = 0; i < ATTRIBUTE_TABLE_COLUMN_COUNT; i++) {
541 if (i == ATTRIBUTE_TABLE_COLUMN_COUNT - 1)
543 for (int j = 0; j < ATTRIBUTE_TABLE_BASE_COLUMN_WIDTH * size_factor; j++)
550 static void _print_attributes_for_object(AtspiAccessible *node) {
551 GHashTable *attributes = atspi_accessible_get_attributes(node, NULL);
556 char *unique_id = atspi_accessible_get_unique_id(node, NULL);
557 GHashTableIter attributes_iter;
561 g_hash_table_iter_init (&attributes_iter, attributes);
562 while (g_hash_table_iter_next (&attributes_iter, &attr_key, &attr_value)) {
563 printf("%*s|", ATTRIBUTE_TABLE_BASE_COLUMN_WIDTH, unique_id ? unique_id : "");
564 printf("%*s|", ATTRIBUTE_TABLE_BASE_COLUMN_WIDTH, attr_key ? (char *) attr_key : "");
565 printf("%*s|\n", ATTRIBUTE_TABLE_BASE_COLUMN_WIDTH * 4, attr_value ? (char *) attr_value : "");
568 if (g_hash_table_size (attributes))
569 _print_horizontal_line_in_attributes_table();
571 g_hash_table_unref(attributes);
575 static void _print_attributes_for_objects_in_tree(AtspiAccessible *node) {
576 _iterate_over_tree(_print_attributes_for_object, node);
579 static void _print_header_for_attributes_table() {
580 char *table[] = {"OBJECT", "ATTRIBUTE KEY", "ATTRIBUTE VALUE"};
581 assert(ARRAY_SIZE(table) == ATTRIBUTE_TABLE_COLUMN_COUNT);
583 _print_horizontal_line_in_attributes_table();
586 for (int i = 0; i < ATTRIBUTE_TABLE_COLUMN_COUNT; i++) {
587 if (i == ATTRIBUTE_TABLE_COLUMN_COUNT - 1)
589 printf("%*s|", ATTRIBUTE_TABLE_BASE_COLUMN_WIDTH * size_factor , table[i]);
593 _print_horizontal_line_in_attributes_table();
596 static void _print_attributes_table(AtspiAccessible *node) {
597 printf("\nATTRIBUTES TABLE\n");
598 _print_header_for_attributes_table();
599 _print_attributes_for_objects_in_tree(node);
602 static void _atspi_tree_traverse(const char *app_name, bool dump, bool check, bool first_match, int length_limit)
605 AtspiAccessible *desktop = atspi_get_desktop(0);
607 fprintf(stderr, "atspi_get_desktop failed\n");
611 int count = atspi_accessible_get_child_count(desktop, NULL);
612 bool app_name_matched = false;
614 for (int i = 0; i < count; i++) {
615 AtspiAccessible *child = atspi_accessible_get_child_at_index(desktop, i, NULL);
617 fprintf(stderr, "\n%s, %s %d: Null application occured. Results may be misleading.\n", __FILE__, __FUNCTION__, __LINE__);
621 char *name = atspi_accessible_get_name(child, NULL);
622 bool attributes_are_too_long = false;
623 bool app_has_relations = false;
626 printf("%s\n", name);
628 if ((check || dump) && name && !strcmp(name, app_name)) {
629 app_name_matched = true;
631 _print_module_legend();
634 _test_atspi_parent_child_relation(child, desktop, i);
636 _print_atspi_tree_verify_maybe_r(0, child, check, length_limit, &attributes_are_too_long, &app_has_relations);
638 if (app_has_relations)
639 _print_relations_table(child);
641 if (attributes_are_too_long)
642 _print_attributes_table(child);
655 if (!app_name_matched && (dump || check))
656 fprintf(stderr, "There is no application with name: %s. Try again.\n", app_name);
658 g_object_unref(desktop);
661 static void _at_spi_client_enable(gboolean enabled)
663 static GDBusProxy *proxy = NULL; //we keep proxy (dbus connection) until program exits
665 GError *error = NULL;
666 GDBusProxyFlags flags = G_DBUS_PROXY_FLAGS_NONE;
670 proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
672 NULL, /* GDBusInterfaceInfo */
675 "org.freedesktop.DBus.Properties",
676 NULL, /* GCancellable */
679 fprintf(stderr, "Failed to create proxy object for '/org/a11y/bus': %s\n", error->message);
685 result = g_dbus_proxy_call_sync(proxy,
687 g_variant_new ("(ssv)", "org.a11y.Status", "IsEnabled", g_variant_new_boolean(enabled)),
688 G_DBUS_CALL_FLAGS_NONE,
693 g_variant_unref(result);
696 fprintf(stderr, "Fail to call org.freedesktop.DBus.Properties.Set: %s\n", error->message);
701 static void _run_command(int argc, char *argv[])
703 struct option long_options[] = {
704 {"help", no_argument, 0, 'h'},
705 {"version", no_argument, 0, 'v'},
706 {"show-legend", no_argument, 0, 'g'},
707 {"list-apps", no_argument, 0, 'l'},
708 {"at-spi-client", no_argument, 0, 'a'},
709 {"sleep", required_argument, 0, 's'},
710 {"tree-dump", required_argument, 0, 'd'},
711 {"tree-check", required_argument, 0, 'c'},
712 {"first-match", no_argument, 0, 'f'},
713 {"indent", required_argument, 0, 'i'},
714 {"truncate", required_argument, 0, 't'},
718 int option_index = 0;
719 bool traverse_flags[FLAG_NO] = {false};
720 char *app_name = NULL;
721 gboolean enable_at_spi_client;
724 command = getopt_long(argc, argv, "hvgla:s:d:c:ft:i:", long_options, &option_index);
726 if (command == ERROR_STATE)
739 _print_atspi_states_legend();
743 _atspi_tree_traverse(NULL, false, false, false, module_name_limit);
747 enable_at_spi_client = TRUE;
748 if (optarg[0] == 'f' || optarg[0] == '0')
749 enable_at_spi_client = FALSE;
751 _at_spi_client_enable(enable_at_spi_client);
759 traverse_flags[DUMP] = true;
764 traverse_flags[CHECK] = true;
769 traverse_flags[FIRST_MATCH] = true;
773 _set_indent(atoi(optarg));
777 _set_module_length_limit(atoi(optarg));
781 fprintf(stderr, "Invalid parameter. Use: \"--help\"\n");
789 if (traverse_flags[DUMP] || traverse_flags[CHECK])
790 _atspi_tree_traverse(app_name, traverse_flags[DUMP], traverse_flags[CHECK], traverse_flags[FIRST_MATCH], module_name_limit);
793 int main(int argc, char *argv[])
796 printf("Arguments required. Type %s --help.\n", argv[0]);
800 int result = atspi_init();
803 fprintf(stderr, "Unable to initilize AT-SPI infrastructure, atspi_init failed\n");
807 _run_command(argc, argv);