Changeset c0757e1f in mainline for uspace/app/disp/disp.c
- Timestamp:
- 2023-04-19T11:13:06Z (20 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 37087c8
- Parents:
- ec8ef12
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/disp/disp.c
rec8ef12 rc0757e1f 56 56 printf(" %s assign-dev <device> <seat>\n", NAME); 57 57 printf(" %s unassign-dev <device>\n", NAME); 58 printf(" %s list-dev <seat>\n", NAME); 58 59 } 59 60 … … 393 394 } 394 395 396 /** List dev subcommand. 397 * 398 * @param dcfg_svc Display configuration service name 399 * @param argc Number of arguments 400 * @param argv Arguments 401 * @return EOK on success or an erro code 402 */ 403 static errno_t list_dev(const char *dcfg_svc, int argc, char *argv[]) 404 { 405 dispcfg_t *dispcfg; 406 char *seat_name; 407 sysarg_t seat_id; 408 dispcfg_dev_list_t *dev_list; 409 size_t i; 410 char *svc_name; 411 table_t *table = NULL; 412 errno_t rc; 413 414 if (argc < 1) { 415 printf(NAME ": Missing arguments.\n"); 416 print_syntax(); 417 return EINVAL; 418 } 419 420 if (argc > 1) { 421 printf(NAME ": Too many arguments.\n"); 422 print_syntax(); 423 return EINVAL; 424 } 425 426 seat_name = argv[0]; 427 428 rc = dispcfg_open(dcfg_svc, NULL, NULL, &dispcfg); 429 if (rc != EOK) { 430 printf(NAME ": Failed connecting to display configuration " 431 "service: %s.\n", str_error(rc)); 432 return rc; 433 } 434 435 rc = seat_find_by_name(dispcfg, seat_name, &seat_id); 436 if (rc != EOK) { 437 printf(NAME ": Seat '%s' not found.\n", seat_name); 438 dispcfg_close(dispcfg); 439 return ENOENT; 440 } 441 442 rc = dispcfg_get_asgn_dev_list(dispcfg, seat_id, &dev_list); 443 if (rc != EOK) { 444 printf(NAME ": Failed getting seat list.\n"); 445 dispcfg_close(dispcfg); 446 return rc; 447 } 448 449 rc = table_create(&table); 450 if (rc != EOK) { 451 printf("Memory allocation failed.\n"); 452 dispcfg_free_dev_list(dev_list); 453 dispcfg_close(dispcfg); 454 return rc; 455 } 456 457 table_header_row(table); 458 table_printf(table, "Device Name\n"); 459 460 for (i = 0; i < dev_list->ndevs; i++) { 461 rc = loc_service_get_name(dev_list->devs[i], &svc_name); 462 if (rc != EOK) { 463 printf("Failed getting name of service %zu\n", 464 (size_t)dev_list->devs[i]); 465 continue; 466 } 467 468 table_printf(table, "%s\n", svc_name); 469 free(svc_name); 470 } 471 472 if (dev_list->ndevs != 0) { 473 rc = table_print_out(table, stdout); 474 if (rc != EOK) { 475 printf("Error printing table.\n"); 476 table_destroy(table); 477 dispcfg_free_dev_list(dev_list); 478 dispcfg_close(dispcfg); 479 return rc; 480 } 481 } 482 483 dispcfg_close(dispcfg); 484 return EOK; 485 } 486 395 487 int main(int argc, char *argv[]) 396 488 { … … 423 515 if (rc != EOK) 424 516 return 1; 517 } else if (str_cmp(argv[1], "list-dev") == 0) { 518 rc = list_dev(dispcfg_svc, argc - 2, argv + 2); 519 if (rc != EOK) 520 return 1; 425 521 } else { 426 522 printf(NAME ": Unknown command '%s'.\n", argv[1]);
Note:
See TracChangeset
for help on using the changeset viewer.