libinput-debug-tablet.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. /*
  2. * Copyright © 2019 Red Hat, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. */
  23. #include "config.h"
  24. #include <assert.h>
  25. #include <errno.h>
  26. #include <fcntl.h>
  27. #include <getopt.h>
  28. #include <inttypes.h>
  29. #include <libevdev/libevdev.h>
  30. #include <libinput.h>
  31. #include <poll.h>
  32. #include <signal.h>
  33. #include <stdio.h>
  34. #include <string.h>
  35. #include <sys/ioctl.h>
  36. #include <unistd.h>
  37. #include "util-files.h"
  38. #include "util-input-event.h"
  39. #include "util-macros.h"
  40. #include "util-strings.h"
  41. #include "libinput-util.h"
  42. #include "shared.h"
  43. static volatile sig_atomic_t stop = 0;
  44. static struct tools_options options;
  45. static int termwidth = 78;
  46. struct context {
  47. struct libinput *libinput;
  48. struct libinput_device *device;
  49. struct libinput_tablet_tool *tool;
  50. struct libevdev *evdev;
  51. /* fd[0] ... libinput fd
  52. fd[1] ... libevdev fd */
  53. struct pollfd fds[2];
  54. /* libinput device state */
  55. bool tip_is_down;
  56. double x, y;
  57. double x_norm, y_norm;
  58. double tx, ty;
  59. double dist, pressure;
  60. double rotation, slider;
  61. unsigned int buttons_down[32];
  62. unsigned int evdev_buttons_down[32];
  63. /* libevdev device state */
  64. struct {
  65. int x, y, z;
  66. int tilt_x, tilt_y;
  67. int distance, pressure;
  68. } abs;
  69. };
  70. LIBINPUT_ATTRIBUTE_PRINTF(1, 2)
  71. static void
  72. print_line(const char *format, ...)
  73. {
  74. char buf[256];
  75. va_list args;
  76. va_start(args, format);
  77. vsnprintf(buf, sizeof(buf), format, args);
  78. va_end(args);
  79. printf(ANSI_CLEAR_LINE "%s\n", buf);
  80. }
  81. static void
  82. print_buttons(struct context *ctx, unsigned int *buttons, size_t sz)
  83. {
  84. _autostrvfree_ char **strv = NULL;
  85. for (size_t i = 0; i < sz; i++) {
  86. if (buttons[i] == 0)
  87. continue;
  88. strv = strv_append_printf(
  89. strv,
  90. "%s",
  91. libevdev_event_code_get_name(EV_KEY, buttons[i]));
  92. }
  93. _autofree_ char *btnstr = strv_join(strv, " ");
  94. print_line(" buttons: %s", btnstr ? btnstr : "");
  95. }
  96. static void
  97. print_bar(const char *header, double value, double normalized)
  98. {
  99. char empty[termwidth];
  100. bool oob = false;
  101. /* the bar is minimum 10 chars, otherwise 78 or whatever fits.
  102. 32 is the manually-added up length of the prefix + [|] */
  103. const int width = max(10, min(78, termwidth - 32));
  104. int left_pad, right_pad;
  105. memset(empty, '-', sizeof empty);
  106. if (normalized < 0.0 || normalized > 1.0) {
  107. normalized = min(max(normalized, 0.0), 1.0);
  108. oob = true;
  109. }
  110. left_pad = width * normalized + 0.5;
  111. right_pad = width - left_pad;
  112. printf("\r %s%-16s %8.2f [%.*s|%.*s]%s\n",
  113. oob ? ANSI_RED : "",
  114. header,
  115. value,
  116. left_pad,
  117. empty,
  118. right_pad,
  119. empty,
  120. oob ? ANSI_NORMAL : "");
  121. }
  122. static double
  123. normalize(struct libevdev *evdev, int code, int value)
  124. {
  125. const struct input_absinfo *abs;
  126. if (!evdev)
  127. return 0.0;
  128. abs = libevdev_get_abs_info(evdev, code);
  129. if (!abs)
  130. return 0.0;
  131. return 1.0 * (value - abs->minimum) / absinfo_range(abs);
  132. }
  133. static int
  134. print_state(struct context *ctx)
  135. {
  136. const char *tool_str;
  137. double w, h;
  138. int lines_printed = 0;
  139. if (!ctx->device) {
  140. print_line(ANSI_RED "No device connected" ANSI_NORMAL);
  141. lines_printed++;
  142. } else {
  143. libinput_device_get_size(ctx->device, &w, &h);
  144. print_line("Device: %s (%s)",
  145. libinput_device_get_name(ctx->device),
  146. libinput_device_get_sysname(ctx->device));
  147. lines_printed++;
  148. }
  149. if (!ctx->tool) {
  150. print_line(ANSI_RED "No tool in proximity " ANSI_NORMAL);
  151. lines_printed++;
  152. } else {
  153. switch (libinput_tablet_tool_get_type(ctx->tool)) {
  154. case LIBINPUT_TABLET_TOOL_TYPE_PEN:
  155. tool_str = "pen";
  156. break;
  157. case LIBINPUT_TABLET_TOOL_TYPE_ERASER:
  158. tool_str = "eraser";
  159. break;
  160. case LIBINPUT_TABLET_TOOL_TYPE_BRUSH:
  161. tool_str = "brush";
  162. break;
  163. case LIBINPUT_TABLET_TOOL_TYPE_PENCIL:
  164. tool_str = "pencil";
  165. break;
  166. case LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH:
  167. tool_str = "airbrush";
  168. break;
  169. case LIBINPUT_TABLET_TOOL_TYPE_MOUSE:
  170. tool_str = "mouse";
  171. break;
  172. case LIBINPUT_TABLET_TOOL_TYPE_LENS:
  173. tool_str = "lens";
  174. break;
  175. case LIBINPUT_TABLET_TOOL_TYPE_TOTEM:
  176. tool_str = "totem";
  177. break;
  178. default:
  179. abort();
  180. }
  181. const char *tool_name = libinput_tablet_tool_get_name(ctx->tool);
  182. if (!tool_name)
  183. tool_name = "<unnamed>";
  184. printf("\rTool: '%s' %s serial %#" PRIx64 ", id %#" PRIx64 "\n",
  185. tool_name,
  186. tool_str,
  187. libinput_tablet_tool_get_serial(ctx->tool),
  188. libinput_tablet_tool_get_tool_id(ctx->tool));
  189. lines_printed++;
  190. }
  191. printf("libinput:\n");
  192. print_line("tip: %s", ctx->tip_is_down ? "down" : "up");
  193. print_bar("x:", ctx->x, ctx->x_norm);
  194. print_bar("y:", ctx->y, ctx->y_norm);
  195. print_bar("tilt x:", ctx->tx, (ctx->tx + 90) / 180);
  196. print_bar("tilt y:", ctx->ty, (ctx->ty + 90) / 180);
  197. print_bar("dist:", ctx->dist, ctx->dist);
  198. print_bar("pressure:", ctx->pressure, ctx->pressure);
  199. print_bar("rotation:", ctx->rotation, ctx->rotation / 360.0);
  200. print_bar("slider:", ctx->slider, (ctx->slider + 1.0) / 2.0);
  201. print_buttons(ctx, ctx->buttons_down, ARRAY_LENGTH(ctx->buttons_down));
  202. lines_printed += 11;
  203. printf("evdev:\n");
  204. print_bar("ABS_X:", ctx->abs.x, normalize(ctx->evdev, ABS_X, ctx->abs.x));
  205. print_bar("ABS_Y:", ctx->abs.y, normalize(ctx->evdev, ABS_Y, ctx->abs.y));
  206. print_bar("ABS_Z:", ctx->abs.z, normalize(ctx->evdev, ABS_Z, ctx->abs.z));
  207. print_bar("ABS_TILT_X:",
  208. ctx->abs.tilt_x,
  209. normalize(ctx->evdev, ABS_TILT_X, ctx->abs.tilt_x));
  210. print_bar("ABS_TILT_Y:",
  211. ctx->abs.tilt_y,
  212. normalize(ctx->evdev, ABS_TILT_Y, ctx->abs.tilt_y));
  213. print_bar("ABS_DISTANCE:",
  214. ctx->abs.distance,
  215. normalize(ctx->evdev, ABS_DISTANCE, ctx->abs.distance));
  216. print_bar("ABS_PRESSURE:",
  217. ctx->abs.pressure,
  218. normalize(ctx->evdev, ABS_PRESSURE, ctx->abs.pressure));
  219. print_buttons(ctx,
  220. ctx->evdev_buttons_down,
  221. ARRAY_LENGTH(ctx->evdev_buttons_down));
  222. lines_printed += 9;
  223. return lines_printed;
  224. }
  225. static void
  226. handle_device_added(struct context *ctx, struct libinput_event *ev)
  227. {
  228. struct libinput_device *device = libinput_event_get_device(ev);
  229. if (ctx->device)
  230. return;
  231. if (!libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TABLET_TOOL))
  232. return;
  233. ctx->device = libinput_device_ref(device);
  234. _unref_(udev_device) *udev_device = libinput_device_get_udev_device(device);
  235. if (!udev_device)
  236. return;
  237. const char *devnode = udev_device_get_devnode(udev_device);
  238. if (devnode) {
  239. _cleanup_(xclose) int fd =
  240. open(devnode, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
  241. if (fd == -1)
  242. return;
  243. if (libevdev_new_from_fd(fd, &ctx->evdev) != 0) {
  244. return;
  245. }
  246. ctx->fds[1].fd = steal_fd(&fd);
  247. }
  248. }
  249. static void
  250. handle_device_removed(struct context *ctx, struct libinput_event *ev)
  251. {
  252. struct libinput_device *device = libinput_event_get_device(ev);
  253. if (ctx->device != device)
  254. return;
  255. libinput_device_unref(ctx->device);
  256. ctx->device = NULL;
  257. libevdev_free(ctx->evdev);
  258. ctx->evdev = NULL;
  259. xclose(&ctx->fds[1].fd);
  260. }
  261. static void
  262. update_tablet_axes(struct context *ctx, struct libinput_event_tablet_tool *t)
  263. {
  264. ctx->x = libinput_event_tablet_tool_get_x(t);
  265. ctx->y = libinput_event_tablet_tool_get_y(t);
  266. ctx->x_norm = libinput_event_tablet_tool_get_x_transformed(t, 1.0);
  267. ctx->y_norm = libinput_event_tablet_tool_get_y_transformed(t, 1.0);
  268. ctx->tx = libinput_event_tablet_tool_get_tilt_x(t);
  269. ctx->ty = libinput_event_tablet_tool_get_tilt_y(t);
  270. ctx->dist = libinput_event_tablet_tool_get_distance(t);
  271. ctx->pressure = libinput_event_tablet_tool_get_pressure(t);
  272. ctx->rotation = libinput_event_tablet_tool_get_rotation(t);
  273. ctx->slider = libinput_event_tablet_tool_get_slider_position(t);
  274. }
  275. static void
  276. handle_tablet_button_event(struct context *ctx, struct libinput_event *ev)
  277. {
  278. struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
  279. unsigned int button = libinput_event_tablet_tool_get_button(t);
  280. enum libinput_button_state state =
  281. libinput_event_tablet_tool_get_button_state(t);
  282. ARRAY_FOR_EACH(ctx->buttons_down, btn) {
  283. if (state == LIBINPUT_BUTTON_STATE_PRESSED) {
  284. if (*btn == 0) {
  285. *btn = button;
  286. break;
  287. }
  288. } else {
  289. if (*btn == button) {
  290. *btn = 0;
  291. break;
  292. }
  293. }
  294. }
  295. }
  296. static void
  297. handle_tablet_axis_event(struct context *ctx, struct libinput_event *ev)
  298. {
  299. struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
  300. update_tablet_axes(ctx, t);
  301. }
  302. static void
  303. handle_tablet_proximity_event(struct context *ctx, struct libinput_event *ev)
  304. {
  305. struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
  306. struct libinput_tablet_tool *tool = libinput_event_tablet_tool_get_tool(t);
  307. if (ctx->tool) {
  308. libinput_tablet_tool_unref(ctx->tool);
  309. ctx->tool = NULL;
  310. }
  311. if (libinput_event_tablet_tool_get_proximity_state(t) ==
  312. LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN)
  313. ctx->tool = libinput_tablet_tool_ref(tool);
  314. }
  315. static void
  316. handle_tablet_tip_event(struct context *ctx, struct libinput_event *ev)
  317. {
  318. struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
  319. ctx->tip_is_down = libinput_event_tablet_tool_get_tip_state(t) ==
  320. LIBINPUT_TABLET_TOOL_TIP_DOWN;
  321. }
  322. static void
  323. handle_libinput_events(struct context *ctx)
  324. {
  325. struct libinput *li = ctx->libinput;
  326. struct libinput_event *ev;
  327. libinput_dispatch(li);
  328. while ((ev = libinput_get_event(li))) {
  329. switch (libinput_event_get_type(ev)) {
  330. case LIBINPUT_EVENT_NONE:
  331. abort();
  332. case LIBINPUT_EVENT_DEVICE_ADDED:
  333. handle_device_added(ctx, ev);
  334. tools_device_apply_config(libinput_event_get_device(ev),
  335. &options);
  336. break;
  337. case LIBINPUT_EVENT_DEVICE_REMOVED:
  338. handle_device_removed(ctx, ev);
  339. break;
  340. case LIBINPUT_EVENT_TABLET_TOOL_BUTTON:
  341. handle_tablet_button_event(ctx, ev);
  342. break;
  343. case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
  344. handle_tablet_axis_event(ctx, ev);
  345. break;
  346. case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY: {
  347. struct libinput_event_tablet_tool *tev =
  348. libinput_event_get_tablet_tool_event(ev);
  349. struct libinput_tablet_tool *tool =
  350. libinput_event_tablet_tool_get_tool(tev);
  351. tools_tablet_tool_apply_config(tool, &options);
  352. handle_tablet_proximity_event(ctx, ev);
  353. break;
  354. }
  355. case LIBINPUT_EVENT_TABLET_TOOL_TIP:
  356. handle_tablet_tip_event(ctx, ev);
  357. break;
  358. default:
  359. break;
  360. }
  361. libinput_event_destroy(ev);
  362. }
  363. }
  364. static void
  365. handle_libevdev_events(struct context *ctx)
  366. {
  367. struct libevdev *evdev = ctx->evdev;
  368. struct input_event event;
  369. #define evbit(_t, _c) (((_t) << 16) | (_c))
  370. if (!evdev)
  371. return;
  372. while (libevdev_next_event(evdev, LIBEVDEV_READ_FLAG_NORMAL, &event) ==
  373. LIBEVDEV_READ_STATUS_SUCCESS) {
  374. switch (evbit(event.type, event.code)) {
  375. case evbit(EV_KEY, BTN_TOOL_PEN):
  376. case evbit(EV_KEY, BTN_TOOL_RUBBER):
  377. case evbit(EV_KEY, BTN_TOOL_BRUSH):
  378. case evbit(EV_KEY, BTN_TOOL_PENCIL):
  379. case evbit(EV_KEY, BTN_TOOL_AIRBRUSH):
  380. case evbit(EV_KEY, BTN_TOOL_MOUSE):
  381. case evbit(EV_KEY, BTN_TOOL_LENS):
  382. ctx->evdev_buttons_down[event.code - BTN_TOOL_PEN] =
  383. event.value ? event.code : 0;
  384. break;
  385. /* above tools should be mutually exclusive but let's leave
  386. * enough space */
  387. case evbit(EV_KEY, BTN_TOUCH):
  388. ctx->evdev_buttons_down[7] = event.value ? event.code : 0;
  389. break;
  390. case evbit(EV_KEY, BTN_STYLUS):
  391. ctx->evdev_buttons_down[8] = event.value ? event.code : 0;
  392. break;
  393. case evbit(EV_KEY, BTN_STYLUS2):
  394. ctx->evdev_buttons_down[9] = event.value ? event.code : 0;
  395. break;
  396. case evbit(EV_KEY, BTN_STYLUS3):
  397. ctx->evdev_buttons_down[10] = event.value ? event.code : 0;
  398. break;
  399. case evbit(EV_ABS, ABS_X):
  400. ctx->abs.x = event.value;
  401. break;
  402. case evbit(EV_ABS, ABS_Y):
  403. ctx->abs.y = event.value;
  404. break;
  405. case evbit(EV_ABS, ABS_Z):
  406. ctx->abs.z = event.value;
  407. break;
  408. case evbit(EV_ABS, ABS_PRESSURE):
  409. ctx->abs.pressure = event.value;
  410. break;
  411. case evbit(EV_ABS, ABS_TILT_X):
  412. ctx->abs.tilt_x = event.value;
  413. break;
  414. case evbit(EV_ABS, ABS_TILT_Y):
  415. ctx->abs.tilt_y = event.value;
  416. break;
  417. case evbit(EV_ABS, ABS_DISTANCE):
  418. ctx->abs.distance = event.value;
  419. break;
  420. }
  421. }
  422. }
  423. static void
  424. sighandler(int signal, siginfo_t *siginfo, void *userdata)
  425. {
  426. stop = 1;
  427. }
  428. static void
  429. mainloop(struct context *ctx)
  430. {
  431. unsigned int lines_printed = 20;
  432. ctx->fds[0].fd = libinput_get_fd(ctx->libinput);
  433. /* pre-load the lines */
  434. for (unsigned int i = 0; i < lines_printed; i++)
  435. printf("\n");
  436. do {
  437. handle_libinput_events(ctx);
  438. handle_libevdev_events(ctx);
  439. printf(ANSI_LEFT, 1000);
  440. printf(ANSI_UP, lines_printed);
  441. lines_printed = print_state(ctx);
  442. } while (!stop && poll(ctx->fds, 2, -1) > -1);
  443. printf("\n");
  444. }
  445. static void
  446. usage(void)
  447. {
  448. printf("Usage: libinput debug-tablet [options] [--udev <seat>|--device /dev/input/event0]\n");
  449. }
  450. static void
  451. init_context(struct context *ctx)
  452. {
  453. memset(ctx, 0, sizeof *ctx);
  454. ctx->fds[0].fd = -1; /* libinput fd */
  455. ctx->fds[0].events = POLLIN;
  456. ctx->fds[0].revents = 0;
  457. ctx->fds[1].fd = -1; /* libevdev fd */
  458. ctx->fds[1].events = POLLIN;
  459. ctx->fds[1].revents = 0;
  460. }
  461. int
  462. main(int argc, char **argv)
  463. {
  464. struct context ctx;
  465. struct libinput *li;
  466. enum tools_backend backend = BACKEND_NONE;
  467. const char *seat_or_device[2] = { "seat0", NULL };
  468. struct sigaction act;
  469. bool grab = false;
  470. init_context(&ctx);
  471. tools_init_options(&options);
  472. while (1) {
  473. int c;
  474. int option_index = 0;
  475. enum {
  476. OPT_DEVICE = 1,
  477. OPT_UDEV,
  478. };
  479. static struct option opts[] = {
  480. CONFIGURATION_OPTIONS,
  481. { "help", no_argument, 0, 'h' },
  482. { "device", required_argument, 0, OPT_DEVICE },
  483. { "udev", required_argument, 0, OPT_UDEV },
  484. { 0, 0, 0, 0 }
  485. };
  486. c = getopt_long(argc, argv, "h", opts, &option_index);
  487. if (c == -1)
  488. break;
  489. switch (c) {
  490. case '?':
  491. exit(EXIT_INVALID_USAGE);
  492. break;
  493. case 'h':
  494. usage();
  495. exit(EXIT_SUCCESS);
  496. break;
  497. case OPT_DEVICE:
  498. backend = BACKEND_DEVICE;
  499. seat_or_device[0] = optarg;
  500. break;
  501. case OPT_UDEV:
  502. backend = BACKEND_UDEV;
  503. seat_or_device[0] = optarg;
  504. break;
  505. default:
  506. if (tools_parse_option(c, optarg, &options) != 0) {
  507. usage();
  508. return EXIT_INVALID_USAGE;
  509. }
  510. break;
  511. }
  512. }
  513. if (optind < argc) {
  514. if (optind < argc - 1 || backend != BACKEND_NONE) {
  515. usage();
  516. return EXIT_INVALID_USAGE;
  517. }
  518. backend = BACKEND_DEVICE;
  519. seat_or_device[0] = argv[optind];
  520. } else if (backend == BACKEND_NONE) {
  521. backend = BACKEND_UDEV;
  522. }
  523. memset(&act, 0, sizeof(act));
  524. act.sa_sigaction = sighandler;
  525. act.sa_flags = SA_SIGINFO;
  526. if (sigaction(SIGINT, &act, NULL) == -1) {
  527. fprintf(stderr,
  528. "Failed to set up signal handling (%s)\n",
  529. strerror(errno));
  530. return EXIT_FAILURE;
  531. }
  532. bool with_plugins = (options.plugins == 1);
  533. li = tools_open_backend(backend,
  534. seat_or_device,
  535. false,
  536. &grab,
  537. with_plugins,
  538. steal(&options.plugin_paths));
  539. if (!li)
  540. return EXIT_FAILURE;
  541. struct winsize w;
  542. if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1)
  543. termwidth = w.ws_col;
  544. ctx.libinput = li;
  545. mainloop(&ctx);
  546. libinput_unref(li);
  547. return EXIT_SUCCESS;
  548. }