Changeset 87822ce in mainline for uspace/app
- Timestamp:
- 2021-03-04T19:14:30Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d6c4d40
- Parents:
- 760a392
- Location:
- uspace/app
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cat/cat.c
r760a392 r87822ce 122 122 cons_event_t ev; 123 123 kbd_event_t *kev; 124 errno_t rc; 124 125 125 126 while (true) { 126 if (!console_get_event(console, &ev)) { 127 rc = console_get_event(console, &ev); 128 if (rc != EOK) 127 129 return; 128 }129 130 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) { 130 131 kev = &ev.ev.key; -
uspace/app/bdsh/cmds/modules/cp/cp.c
r760a392 r87822ce 146 146 { 147 147 va_list args; 148 errno_t rc; 148 149 149 150 va_start(args, message); … … 154 155 cons_event_t ev; 155 156 console_flush(con); 156 console_get_event(con, &ev); 157 rc = console_get_event(con, &ev); 158 if (rc != EOK) 159 exit(1); 157 160 if (ev.type != CEV_KEY || ev.ev.key.type != KEY_PRESS || 158 161 (ev.ev.key.mods & (KM_CTRL | KM_ALT)) != 0) { -
uspace/app/edit/edit.c
r760a392 r87822ce 251 251 252 252 while (!done) { 253 console_get_event(con, &ev); 253 rc = console_get_event(con, &ev); 254 if (rc != EOK) 255 break; 256 254 257 pane.rflags = 0; 255 258 … … 634 637 int nc; 635 638 bool done; 639 errno_t rc; 636 640 637 641 asprintf(&str, "%s: %s", prompt, init_value); … … 648 652 649 653 while (!done) { 650 console_get_event(con, &ev); 654 rc = console_get_event(con, &ev); 655 if (rc != EOK) 656 return NULL; 651 657 652 658 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) { -
uspace/app/mkbd/main.c
r760a392 r87822ce 174 174 while (true) { 175 175 cons_event_t ev; 176 bool ok= console_get_event(con, &ev);177 if ( !ok) {176 errno_t rc = console_get_event(con, &ev); 177 if (rc != EOK) { 178 178 printf("Connection with console broken: %s.\n", 179 179 str_error(errno)); -
uspace/app/modplay/modplay.c
r760a392 r87822ce 174 174 while (true) { 175 175 timeout = 0; 176 if (console_get_event_timeout(con, &event, &timeout)) 176 rc = console_get_event_timeout(con, &event, &timeout); 177 if (rc == EOK) 177 178 modplay_event(&event); 179 else if (rc != ETIMEOUT) 180 break; 181 178 182 if (quit) 179 183 break; -
uspace/app/netecho/netecho.c
r760a392 r87822ce 121 121 { 122 122 cons_event_t ev; 123 errno_t rc; 123 124 124 125 printf("Communication started. Press Ctrl-Q to quit.\n"); … … 128 129 done = false; 129 130 while (!done) { 130 console_get_event(con, &ev); 131 rc = console_get_event(con, &ev); 132 if (rc != EOK) 133 break; 134 131 135 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) 132 136 key_handle(&ev.ev.key); -
uspace/app/nterm/nterm.c
r760a392 r87822ce 130 130 done = false; 131 131 while (!done) { 132 console_get_event(con, &ev); 132 rc = console_get_event(con, &ev); 133 if (rc != EOK) 134 break; 135 133 136 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) 134 137 key_handle(&ev.ev.key); -
uspace/app/ping/ping.c
r760a392 r87822ce 196 196 while (true) { 197 197 cons_event_t ev; 198 if (!console_get_event(con, &ev)) 199 break; 198 errno_t rc; 199 rc = console_get_event(con, &ev); 200 if (rc != EOK) { 201 ping_signal_received(RECEIVED_INTERRUPT); 202 break; 203 } 200 204 201 205 if ((ev.type == CEV_KEY) && (ev.ev.key.type == KEY_PRESS) && -
uspace/app/tester/ipc/starve.c
r760a392 r87822ce 57 57 cons_event_t ev; 58 58 usec_t timeout = 0; 59 bool has_event = console_get_event_timeout(console, &ev, &timeout); 60 if (has_event && ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) { 61 TPRINTF("Key %d pressed, terminating.\n", ev.ev.key.key); 59 errno_t rc = console_get_event_timeout(console, &ev, &timeout); 60 if (rc == EOK) { 61 if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) { 62 TPRINTF("Key %d pressed, terminating.\n", ev.ev.key.key); 63 break; 64 } 65 } else if (rc != ETIMEOUT) { 66 TPRINTF("Got rc=%d, terminating.\n", rc); 62 67 break; 63 68 } -
uspace/app/tetris/scores.c
r760a392 r87822ce 126 126 cons_event_t ev; 127 127 kbd_event_t *kev; 128 errno_t rc; 128 129 129 130 clear_screen(); … … 141 142 while (true) { 142 143 console_flush(console); 143 if (!console_get_event(console, &ev)) 144 rc = console_get_event(console, &ev); 145 if (rc != EOK) 144 146 exit(1); 145 147 -
uspace/app/tetris/screen.c
r760a392 r87822ce 54 54 */ 55 55 56 #include <errno.h> 56 57 #include <stdio.h> 57 58 #include <stdlib.h> … … 340 341 { 341 342 usec_t timeout = fallrate; 343 errno_t rc; 342 344 343 345 while (timeout > 0) { 344 346 cons_event_t event; 345 347 346 if (!console_get_event_timeout(console, &event, &timeout)) 348 rc = console_get_event_timeout(console, &event, &timeout); 349 if (rc == ETIMEOUT) 347 350 break; 351 if (rc != EOK) 352 exit(1); 348 353 } 349 354 } … … 354 359 int tgetchar(void) 355 360 { 361 errno_t rc; 362 356 363 /* 357 364 * Reset timeleft to fallrate whenever it is not positive … … 376 383 cons_event_t event; 377 384 378 if (!console_get_event_timeout(console, &event, &timeleft)) { 385 rc = console_get_event_timeout(console, &event, &timeleft); 386 if (rc == ETIMEOUT) { 379 387 timeleft = 0; 380 388 return -1; 381 389 } 390 if (rc != EOK) 391 exit(1); 382 392 383 393 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) … … 394 404 { 395 405 char32_t c = 0; 406 errno_t rc; 396 407 397 408 while (c == 0) { 398 409 cons_event_t event; 399 410 400 if (!console_get_event(console, &event)) 411 rc = console_get_event(console, &event); 412 if (rc == ETIMEOUT) 401 413 return -1; 414 if (rc != EOK) 415 exit(1); 402 416 403 417 if (event.type == CEV_KEY && event.ev.key.type == KEY_PRESS) -
uspace/app/tetris/tetris.c
r760a392 r87822ce 202 202 while (true) { 203 203 int i = getchar(); 204 if (i < 0) 205 return 0; 204 206 205 207 switch (i) { -
uspace/app/top/screen.c
r760a392 r87822ce 534 534 /** Get char with timeout 535 535 * 536 * @param sec Timeout in seconds 537 * @param rch Place to store character on success 538 * @return EOK on success, ETIMEOUT on time out, EIO on other error 536 539 */ 537 int tgetchar(sec_t sec) 538 { 540 errno_t tgetchar(sec_t sec, int *rch) 541 { 542 errno_t rc; 543 539 544 /* 540 545 * Reset timeleft whenever it is not positive. … … 548 553 * update timeleft so that the next call to tgetchar() 549 554 * will not wait as long. If there is no input, 550 * make timeleft zero and return -1.555 * make timeleft zero and return ETIMEOUT. 551 556 */ 552 557 … … 557 562 558 563 warning_timeleft -= timeleft; 559 if (!console_get_event_timeout(console, &event, &timeleft)) { 564 rc = console_get_event_timeout(console, &event, &timeleft); 565 if (rc == ETIMEOUT) { 560 566 timeleft = 0; 561 return -1; 562 } 567 return ETIMEOUT; 568 } 569 570 if (rc != EOK) 571 return EIO; 572 563 573 warning_timeleft += timeleft; 564 574 … … 567 577 } 568 578 569 return (int) c; 579 *rch = (int) c; 580 return EOK; 570 581 } 571 582 -
uspace/app/top/screen.h
r760a392 r87822ce 35 35 #define TOP_SCREEN_H_ 36 36 37 #include <errno.h> 37 38 #include <io/console.h> 38 39 #include <io/verify.h> … … 47 48 _HELENOS_PRINTF_ATTRIBUTE(1, 2); 48 49 49 extern int tgetchar(sec_t);50 extern errno_t tgetchar(sec_t, int *); 50 51 51 52 #endif -
uspace/app/top/top.c
r760a392 r87822ce 583 583 data_t data_prev; 584 584 const char *ret = NULL; 585 errno_t rc; 586 int c; 585 587 586 588 screen_init(); … … 595 597 /* And paint screen until death */ 596 598 while (true) { 597 int c = tgetchar(UPDATE_INTERVAL);598 599 if ( c < 0) { /* timeout */599 rc = tgetchar(UPDATE_INTERVAL, &c); 600 601 if (rc == ETIMEOUT) { /* timeout */ 600 602 data_prev = data; 601 603 if ((ret = read_data(&data)) != NULL) { … … 608 610 609 611 c = -1; 612 } else if (rc != EOK) { 613 /* Error (e.g. communication with console lost) */ 614 goto out; 610 615 } 611 616 -
uspace/app/trace/trace.c
r760a392 r87822ce 511 511 { 512 512 cons_event_t event; 513 errno_t rc; 513 514 514 515 (void) arg; … … 522 523 fibril_mutex_unlock(&state_lock); 523 524 524 if (!console_get_event(console, &event)) 525 rc = console_get_event(console, &event); 526 if (rc != EOK) 525 527 return EINVAL; 526 528
Note:
See TracChangeset
for help on using the changeset viewer.