Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    r28a3e74 rf2d665b4  
    3939#include <io/color.h>
    4040#include <io/style.h>
    41 #include <io/keycode.h>
    4241#include <errno.h>
    4342#include <vfs/vfs.h>
     
    6362static sysarg_t console_cols = 0;
    6463static sysarg_t console_rows = 0;
    65 static bool should_quit = false;
    6664
    6765static struct option const long_options[] = {
     
    104102        console_set_pos(fphone(stdout), 0, console_rows-1);
    105103        console_set_color(fphone(stdout), COLOR_BLUE, COLOR_WHITE, 0);
    106         printf("ENTER/SPACE/PAGE DOWN - next page, "
    107                "ESC/Q - quit, C - continue unpaged");
     104        printf("Press any key to continue");
    108105        fflush(stdout);
    109106        console_set_style(fphone(stdout), STYLE_NORMAL);
     
    119116                }
    120117                if (ev.type == KEY_PRESS) {
    121                         if (ev.key == KC_ESCAPE || ev.key == KC_Q) {
    122                                 should_quit = true;
    123                                 return;
    124                         }
    125                         if (ev.key == KC_C) {
    126                                 paging_enabled = false;
    127                                 return;
    128                         }
    129                         if (ev.key == KC_ENTER || ev.key == KC_SPACE ||
    130                             ev.key == KC_PAGE_DOWN) {
    131                                 return;
    132                         }
     118                        return;
    133119                }
    134120        }
     
    164150{
    165151        int fd, bytes = 0, count = 0, reads = 0;
     152        off64_t total = 0;
    166153        char *buff = NULL;
    167154        int i;
     
    173160                return 1;
    174161        }
     162
     163        total = lseek(fd, 0, SEEK_END);
     164        lseek(fd, 0, SEEK_SET);
    175165
    176166        if (NULL == (buff = (char *) malloc(blen + 1))) {
     
    187177                        buff[bytes] = '\0';
    188178                        offset = 0;
    189                         for (i = 0; i < bytes && !should_quit; i++) {
     179                        for (i = 0; i < bytes; i++) {
    190180                                if (hex) {
    191181                                        paged_char(hexchars[((uint8_t)buff[i])/16]);
     
    195185                                        wchar_t c = str_decode(buff, &offset, bytes);
    196186                                        if (c == 0) {
    197                                                 /* Reached end of string */
     187                                                // reached end of string
    198188                                                break;
    199189                                        }
     
    204194                        reads++;
    205195                }
    206         } while (bytes > 0 && !should_quit);
     196        } while (bytes > 0);
    207197
    208198        close(fd);
     
    228218        int rc;
    229219       
    230         /*
    231          * reset global state
    232          * TODO: move to structure?
    233          */
     220        // reset global state
     221        // TODO: move to structure?
    234222        paging_enabled = false;
    235223        chars_remaining = 0;
     
    237225        console_cols = 0;
    238226        console_rows = 0;
    239         should_quit = false;
    240227
    241228        argc = cli_count_args(argv);
     
    291278        }
    292279
    293         for (i = optind; argv[i] != NULL && !should_quit; i++)
     280        for (i = optind; argv[i] != NULL; i++)
    294281                ret += cat_file(argv[i], buffer, hex);
    295282
Note: See TracChangeset for help on using the changeset viewer.