[36ab7c7] | 1 | /*
|
---|
| 2 | * Copyright (c) 2008 Tim Post
|
---|
[d553f81] | 3 | * Copyright (c) 2011, Martin Sucha
|
---|
[c9f5e24f] | 4 | * All rights reserved.
|
---|
[216d6fc] | 5 | *
|
---|
[c9f5e24f] | 6 | * Redistribution and use in source and binary forms, with or without
|
---|
[36ab7c7] | 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
[c9f5e24f] | 9 | *
|
---|
[36ab7c7] | 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
[c9f5e24f] | 17 | *
|
---|
[36ab7c7] | 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
[c9f5e24f] | 28 | */
|
---|
[216d6fc] | 29 |
|
---|
| 30 | #include <stdio.h>
|
---|
| 31 | #include <stdlib.h>
|
---|
| 32 | #include <getopt.h>
|
---|
[19f857a] | 33 | #include <str.h>
|
---|
[d553f81] | 34 | #include <io/console.h>
|
---|
| 35 | #include <io/color.h>
|
---|
| 36 | #include <io/style.h>
|
---|
[3cefd70] | 37 | #include <io/keycode.h>
|
---|
[d553f81] | 38 | #include <errno.h>
|
---|
| 39 | #include <vfs/vfs.h>
|
---|
| 40 | #include <assert.h>
|
---|
[216d6fc] | 41 |
|
---|
| 42 | #include "config.h"
|
---|
| 43 | #include "util.h"
|
---|
| 44 | #include "errors.h"
|
---|
| 45 | #include "entry.h"
|
---|
| 46 | #include "cat.h"
|
---|
| 47 | #include "cmds.h"
|
---|
| 48 |
|
---|
[a000878c] | 49 | static const char *cmdname = "cat";
|
---|
[c9f5e24f] | 50 | #define CAT_VERSION "0.0.1"
|
---|
| 51 | #define CAT_DEFAULT_BUFLEN 1024
|
---|
[cc9f314] | 52 | #define CAT_FULL_FILE 0
|
---|
[c9f5e24f] | 53 |
|
---|
[d553f81] | 54 | static const char *hexchars = "0123456789abcdef";
|
---|
| 55 |
|
---|
| 56 | static bool paging_enabled = false;
|
---|
| 57 | static size_t chars_remaining = 0;
|
---|
| 58 | static size_t lines_remaining = 0;
|
---|
| 59 | static sysarg_t console_cols = 0;
|
---|
| 60 | static sysarg_t console_rows = 0;
|
---|
[3cefd70] | 61 | static bool should_quit = false;
|
---|
[a33706e] | 62 | static bool dash_represents_stdin = false;
|
---|
[0845589] | 63 | static unsigned int lineno = 0;
|
---|
| 64 | static bool number = false;
|
---|
| 65 | static bool last_char_was_newline = false;
|
---|
[216d6fc] | 66 |
|
---|
[79ae36dd] | 67 | static console_ctrl_t *console = NULL;
|
---|
| 68 |
|
---|
[3771a6e] | 69 | static struct option const long_options[] = {
|
---|
[c9f5e24f] | 70 | { "help", no_argument, 0, 'h' },
|
---|
| 71 | { "version", no_argument, 0, 'v' },
|
---|
| 72 | { "head", required_argument, 0, 'H' },
|
---|
| 73 | { "tail", required_argument, 0, 't' },
|
---|
| 74 | { "buffer", required_argument, 0, 'b' },
|
---|
| 75 | { "more", no_argument, 0, 'm' },
|
---|
[d553f81] | 76 | { "hex", no_argument, 0, 'x' },
|
---|
[a33706e] | 77 | { "stdin", no_argument, 0, 's' },
|
---|
[0845589] | 78 | { "number", no_argument, 0, 'n' },
|
---|
[216d6fc] | 79 | { 0, 0, 0, 0 }
|
---|
| 80 | };
|
---|
| 81 |
|
---|
| 82 | /* Dispays help for cat in various levels */
|
---|
[809813d] | 83 | void help_cmd_cat(unsigned int level)
|
---|
[216d6fc] | 84 | {
|
---|
[c9f5e24f] | 85 | if (level == HELP_SHORT) {
|
---|
| 86 | printf("`%s' shows the contents of files\n", cmdname);
|
---|
| 87 | } else {
|
---|
| 88 | help_cmd_cat(HELP_SHORT);
|
---|
| 89 | printf(
|
---|
[1433ecda] | 90 | "Usage: %s [options] <file1> [file2] [...]\n"
|
---|
| 91 | "Options:\n"
|
---|
| 92 | " -h, --help A short option summary\n"
|
---|
| 93 | " -v, --version Print version information and exit\n"
|
---|
| 94 | " -H, --head ## Print only the first ## bytes\n"
|
---|
| 95 | " -t, --tail ## Print only the last ## bytes\n"
|
---|
| 96 | " -b, --buffer ## Set the read buffer size to ##\n"
|
---|
| 97 | " -m, --more Pause after each screen full\n"
|
---|
| 98 | " -x, --hex Print bytes as hex values\n"
|
---|
| 99 | " -s, --stdin Treat `-' in file list as standard input\n"
|
---|
| 100 | " -n, --number Number all output lines\n"
|
---|
| 101 | "Currently, %s is under development, some options don't work.\n",
|
---|
| 102 | cmdname, cmdname);
|
---|
[c9f5e24f] | 103 | }
|
---|
| 104 |
|
---|
[809813d] | 105 | return;
|
---|
[216d6fc] | 106 | }
|
---|
| 107 |
|
---|
[193d280c] | 108 | static void waitprompt(void)
|
---|
[d553f81] | 109 | {
|
---|
[1433ecda] | 110 | console_set_pos(console, 0, console_rows - 1);
|
---|
[7c014d1] | 111 | console_set_color(console, COLOR_WHITE, COLOR_BLUE, 0);
|
---|
[a35b458] | 112 |
|
---|
[3cefd70] | 113 | printf("ENTER/SPACE/PAGE DOWN - next page, "
|
---|
[1433ecda] | 114 | "ESC/Q - quit, C - continue unpaged");
|
---|
[d553f81] | 115 | fflush(stdout);
|
---|
[a35b458] | 116 |
|
---|
[79ae36dd] | 117 | console_set_style(console, STYLE_NORMAL);
|
---|
[d553f81] | 118 | }
|
---|
| 119 |
|
---|
[193d280c] | 120 | static void waitkey(void)
|
---|
[d553f81] | 121 | {
|
---|
[07b7c48] | 122 | cons_event_t ev;
|
---|
| 123 | kbd_event_t *kev;
|
---|
[87822ce] | 124 | errno_t rc;
|
---|
[a35b458] | 125 |
|
---|
[d553f81] | 126 | while (true) {
|
---|
[87822ce] | 127 | rc = console_get_event(console, &ev);
|
---|
| 128 | if (rc != EOK)
|
---|
[d553f81] | 129 | return;
|
---|
[07b7c48] | 130 | if (ev.type == CEV_KEY && ev.ev.key.type == KEY_PRESS) {
|
---|
| 131 | kev = &ev.ev.key;
|
---|
[a35b458] | 132 |
|
---|
[07b7c48] | 133 | if (kev->key == KC_ESCAPE || kev->key == KC_Q) {
|
---|
[3cefd70] | 134 | should_quit = true;
|
---|
| 135 | return;
|
---|
| 136 | }
|
---|
[07b7c48] | 137 | if (kev->key == KC_C) {
|
---|
[3cefd70] | 138 | paging_enabled = false;
|
---|
| 139 | return;
|
---|
| 140 | }
|
---|
[07b7c48] | 141 | if (kev->key == KC_ENTER || kev->key == KC_SPACE ||
|
---|
| 142 | kev->key == KC_PAGE_DOWN) {
|
---|
[3cefd70] | 143 | return;
|
---|
| 144 | }
|
---|
[d553f81] | 145 | }
|
---|
| 146 | }
|
---|
| 147 | assert(false);
|
---|
| 148 | }
|
---|
| 149 |
|
---|
[193d280c] | 150 | static void newpage(void)
|
---|
[d553f81] | 151 | {
|
---|
[79ae36dd] | 152 | console_clear(console);
|
---|
[d553f81] | 153 | chars_remaining = console_cols;
|
---|
[79ae36dd] | 154 | lines_remaining = console_rows - 1;
|
---|
[d553f81] | 155 | }
|
---|
| 156 |
|
---|
[28a5ebd] | 157 | static void paged_char(char32_t c)
|
---|
[d553f81] | 158 | {
|
---|
[0845589] | 159 | if (last_char_was_newline && number) {
|
---|
| 160 | lineno++;
|
---|
| 161 | printf("%6u ", lineno);
|
---|
| 162 | }
|
---|
[28a5ebd] | 163 | putuchar(c);
|
---|
[0845589] | 164 | last_char_was_newline = c == '\n';
|
---|
[d553f81] | 165 | if (paging_enabled) {
|
---|
| 166 | chars_remaining--;
|
---|
| 167 | if (c == '\n' || chars_remaining == 0) {
|
---|
| 168 | chars_remaining = console_cols;
|
---|
| 169 | lines_remaining--;
|
---|
| 170 | }
|
---|
| 171 | if (lines_remaining == 0) {
|
---|
| 172 | fflush(stdout);
|
---|
| 173 | waitprompt();
|
---|
| 174 | waitkey();
|
---|
| 175 | newpage();
|
---|
| 176 | }
|
---|
| 177 | }
|
---|
| 178 | }
|
---|
| 179 |
|
---|
[cc9f314] | 180 | static unsigned int cat_file(const char *fname, size_t blen, bool hex,
|
---|
| 181 | off64_t head, off64_t tail, bool tail_first)
|
---|
[c9f5e24f] | 182 | {
|
---|
[8e3498b] | 183 | int fd, count = 0, reads = 0;
|
---|
| 184 | size_t bytes;
|
---|
[c9f5e24f] | 185 | char *buff = NULL;
|
---|
[8e3498b] | 186 | size_t i;
|
---|
[cc9f314] | 187 | size_t offset = 0, copied_bytes = 0;
|
---|
| 188 | off64_t file_size = 0, length = 0;
|
---|
[58898d1d] | 189 | aoff64_t pos = 0;
|
---|
[b7fd2a0] | 190 | errno_t rc;
|
---|
[c9f5e24f] | 191 |
|
---|
[a33706e] | 192 | bool reading_stdin = dash_represents_stdin && (str_cmp(fname, "-") == 0);
|
---|
[a35b458] | 193 |
|
---|
[a33706e] | 194 | if (reading_stdin) {
|
---|
| 195 | fd = fileno(stdin);
|
---|
| 196 | /* Allow storing the whole UTF-8 character. */
|
---|
| 197 | blen = STR_BOUNDS(1);
|
---|
[f77c1c9] | 198 | } else {
|
---|
[b7fd2a0] | 199 | errno_t rc = vfs_lookup_open(fname, WALK_REGULAR, MODE_READ, &fd);
|
---|
[f77c1c9] | 200 | if (rc != EOK) {
|
---|
| 201 | fd = -1;
|
---|
| 202 | }
|
---|
| 203 | }
|
---|
[a35b458] | 204 |
|
---|
[8bb129d] | 205 | if (fd < 0) {
|
---|
[c9f5e24f] | 206 | printf("Unable to open %s\n", fname);
|
---|
| 207 | return 1;
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | if (NULL == (buff = (char *) malloc(blen + 1))) {
|
---|
[9c4cf0d] | 211 | vfs_put(fd);
|
---|
[c9f5e24f] | 212 | printf("Unable to allocate enough memory to read %s\n",
|
---|
[58898d1d] | 213 | fname);
|
---|
[c9f5e24f] | 214 | return 1;
|
---|
| 215 | }
|
---|
| 216 |
|
---|
[cc9f314] | 217 | if (tail != CAT_FULL_FILE) {
|
---|
[39330200] | 218 | vfs_stat_t st;
|
---|
[58898d1d] | 219 |
|
---|
[23a0368] | 220 | if (vfs_stat(fd, &st) != EOK) {
|
---|
[9c4cf0d] | 221 | vfs_put(fd);
|
---|
[58898d1d] | 222 | free(buff);
|
---|
[23a0368] | 223 | printf("Unable to vfs_stat %d\n", fd);
|
---|
[58898d1d] | 224 | return 1;
|
---|
| 225 | }
|
---|
| 226 | file_size = st.size;
|
---|
[cc9f314] | 227 | if (head == CAT_FULL_FILE) {
|
---|
| 228 | head = file_size;
|
---|
| 229 | length = tail;
|
---|
| 230 | } else if (tail_first) {
|
---|
| 231 | length = head;
|
---|
| 232 | } else {
|
---|
| 233 | if (tail > head)
|
---|
| 234 | tail = head;
|
---|
| 235 | length = tail;
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | if (tail_first) {
|
---|
[58898d1d] | 239 | pos = (tail >= file_size) ? 0 : (file_size - tail);
|
---|
[cc9f314] | 240 | } else {
|
---|
[58898d1d] | 241 | pos = ((head - tail) >= file_size) ? 0 : (head - tail);
|
---|
[cc9f314] | 242 | }
|
---|
| 243 | } else
|
---|
| 244 | length = head;
|
---|
| 245 |
|
---|
[c9f5e24f] | 246 | do {
|
---|
[a33706e] | 247 | size_t bytes_to_read;
|
---|
| 248 | if (reading_stdin) {
|
---|
| 249 | bytes_to_read = 1;
|
---|
| 250 | } else {
|
---|
[e435537] | 251 | if ((length != CAT_FULL_FILE) &&
|
---|
| 252 | (length - (off64_t)count <= (off64_t)(blen - copied_bytes))) {
|
---|
[a33706e] | 253 | bytes_to_read = (size_t) (length - count);
|
---|
| 254 | } else {
|
---|
| 255 | bytes_to_read = blen - copied_bytes;
|
---|
| 256 | }
|
---|
| 257 | }
|
---|
[a35b458] | 258 |
|
---|
[8e3498b] | 259 | rc = vfs_read(fd, &pos, buff + copied_bytes, bytes_to_read,
|
---|
| 260 | &bytes);
|
---|
[cc9f314] | 261 | copied_bytes = 0;
|
---|
| 262 |
|
---|
[8e3498b] | 263 | if (rc == EOK && bytes > 0) {
|
---|
[2953f9a] | 264 | buff[bytes] = '\0';
|
---|
[d553f81] | 265 | offset = 0;
|
---|
[3cefd70] | 266 | for (i = 0; i < bytes && !should_quit; i++) {
|
---|
[d553f81] | 267 | if (hex) {
|
---|
[1433ecda] | 268 | paged_char(hexchars[((uint8_t)buff[i]) / 16]);
|
---|
| 269 | paged_char(hexchars[((uint8_t)buff[i]) % 16]);
|
---|
| 270 | paged_char(((count + i + 1) & 0xf) == 0 ? '\n' : ' ');
|
---|
| 271 | } else {
|
---|
[28a5ebd] | 272 | char32_t c = str_decode(buff, &offset, bytes);
|
---|
[d553f81] | 273 | if (c == 0) {
|
---|
[28a3e74] | 274 | /* Reached end of string */
|
---|
[d553f81] | 275 | break;
|
---|
[cc9f314] | 276 | } else if (c == U_SPECIAL && offset + 2 >= (size_t)bytes) {
|
---|
[7c3fb9b] | 277 | /*
|
---|
| 278 | * If an extended character is cut off due to the size of the buffer,
|
---|
| 279 | * we will copy it over to the next buffer so it can be read correctly.
|
---|
| 280 | */
|
---|
[cc9f314] | 281 | copied_bytes = bytes - offset + 1;
|
---|
| 282 | memcpy(buff, buff + offset - 1, copied_bytes);
|
---|
| 283 | break;
|
---|
[d553f81] | 284 | }
|
---|
| 285 | paged_char(c);
|
---|
| 286 | }
|
---|
[a35b458] | 287 |
|
---|
[d553f81] | 288 | }
|
---|
[cc9f314] | 289 | count += bytes;
|
---|
[c9f5e24f] | 290 | reads++;
|
---|
| 291 | }
|
---|
[a35b458] | 292 |
|
---|
[e435537] | 293 | if (reading_stdin)
|
---|
[a33706e] | 294 | fflush(stdout);
|
---|
[8e3498b] | 295 | } while (rc == EOK && bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE));
|
---|
[c9f5e24f] | 296 |
|
---|
[9c4cf0d] | 297 | vfs_put(fd);
|
---|
[8e3498b] | 298 | if (rc != EOK) {
|
---|
[c9f5e24f] | 299 | printf("Error reading %s\n", fname);
|
---|
| 300 | free(buff);
|
---|
| 301 | return 1;
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | free(buff);
|
---|
| 305 |
|
---|
| 306 | return 0;
|
---|
| 307 | }
|
---|
| 308 |
|
---|
[216d6fc] | 309 | /* Main entry point for cat, accepts an array of arguments */
|
---|
[809813d] | 310 | int cmd_cat(char **argv)
|
---|
[216d6fc] | 311 | {
|
---|
[cc9f314] | 312 | unsigned int argc, i, ret = 0;
|
---|
| 313 | size_t buffer = 0;
|
---|
[216d6fc] | 314 | int c, opt_ind;
|
---|
[cc9f314] | 315 | aoff64_t head = CAT_FULL_FILE, tail = CAT_FULL_FILE;
|
---|
[d553f81] | 316 | bool hex = false;
|
---|
| 317 | bool more = false;
|
---|
[cc9f314] | 318 | bool tailFirst = false;
|
---|
[d553f81] | 319 | sysarg_t rows, cols;
|
---|
[b7fd2a0] | 320 | errno_t rc;
|
---|
[a35b458] | 321 |
|
---|
[28a3e74] | 322 | /*
|
---|
| 323 | * reset global state
|
---|
| 324 | * TODO: move to structure?
|
---|
| 325 | */
|
---|
[d553f81] | 326 | paging_enabled = false;
|
---|
| 327 | chars_remaining = 0;
|
---|
| 328 | lines_remaining = 0;
|
---|
| 329 | console_cols = 0;
|
---|
| 330 | console_rows = 0;
|
---|
[3cefd70] | 331 | should_quit = false;
|
---|
[4cca9a9] | 332 | dash_represents_stdin = false;
|
---|
[79ae36dd] | 333 | console = console_init(stdin, stdout);
|
---|
[0845589] | 334 | number = false;
|
---|
| 335 | lineno = 0;
|
---|
| 336 | /* This enables printing of the first number. */
|
---|
| 337 | last_char_was_newline = true;
|
---|
| 338 |
|
---|
[43e02a6] | 339 | argc = cli_count_args(argv);
|
---|
[216d6fc] | 340 |
|
---|
[948222e4] | 341 | c = 0;
|
---|
| 342 | optreset = 1;
|
---|
| 343 | optind = 0;
|
---|
| 344 | opt_ind = 0;
|
---|
| 345 |
|
---|
| 346 | while (c != -1) {
|
---|
[4cca9a9] | 347 | c = getopt_long(argc, argv, "xhvmH:t:b:sn", long_options, &opt_ind);
|
---|
[216d6fc] | 348 | switch (c) {
|
---|
| 349 | case 'h':
|
---|
[c9f5e24f] | 350 | help_cmd_cat(HELP_LONG);
|
---|
| 351 | return CMD_SUCCESS;
|
---|
[216d6fc] | 352 | case 'v':
|
---|
[c9f5e24f] | 353 | printf("%s\n", CAT_VERSION);
|
---|
| 354 | return CMD_SUCCESS;
|
---|
| 355 | case 'H':
|
---|
[1433ecda] | 356 | if (!optarg || str_uint64_t(optarg, NULL, 10, false, &head) != EOK) {
|
---|
[1abcf1d] | 357 | puts("Invalid head size");
|
---|
[cc9f314] | 358 | return CMD_FAILURE;
|
---|
| 359 | }
|
---|
| 360 | break;
|
---|
[c9f5e24f] | 361 | case 't':
|
---|
[1433ecda] | 362 | if (!optarg || str_uint64_t(optarg, NULL, 10, false, &tail) != EOK) {
|
---|
[1abcf1d] | 363 | puts("Invalid tail size");
|
---|
[cc9f314] | 364 | return CMD_FAILURE;
|
---|
| 365 | }
|
---|
| 366 | if (head == CAT_FULL_FILE)
|
---|
| 367 | tailFirst = true;
|
---|
| 368 | break;
|
---|
[c9f5e24f] | 369 | case 'b':
|
---|
[1433ecda] | 370 | if (!optarg || str_size_t(optarg, NULL, 10, false, &buffer) != EOK) {
|
---|
[1abcf1d] | 371 | puts("Invalid buffer size");
|
---|
[cc9f314] | 372 | return CMD_FAILURE;
|
---|
| 373 | }
|
---|
[216d6fc] | 374 | break;
|
---|
[c9f5e24f] | 375 | case 'm':
|
---|
[d553f81] | 376 | more = true;
|
---|
| 377 | break;
|
---|
| 378 | case 'x':
|
---|
| 379 | hex = true;
|
---|
| 380 | break;
|
---|
[a33706e] | 381 | case 's':
|
---|
| 382 | dash_represents_stdin = true;
|
---|
| 383 | break;
|
---|
[0845589] | 384 | case 'n':
|
---|
| 385 | number = true;
|
---|
| 386 | break;
|
---|
[216d6fc] | 387 | }
|
---|
| 388 | }
|
---|
| 389 |
|
---|
[c9f5e24f] | 390 | argc -= optind;
|
---|
| 391 |
|
---|
| 392 | if (argc < 1) {
|
---|
| 393 | printf("%s - incorrect number of arguments. Try `%s --help'\n",
|
---|
[1433ecda] | 394 | cmdname, cmdname);
|
---|
[c9f5e24f] | 395 | return CMD_FAILURE;
|
---|
| 396 | }
|
---|
| 397 |
|
---|
[cc9f314] | 398 | if (buffer < 4)
|
---|
[c9f5e24f] | 399 | buffer = CAT_DEFAULT_BUFLEN;
|
---|
[a35b458] | 400 |
|
---|
[d553f81] | 401 | if (more) {
|
---|
[79ae36dd] | 402 | rc = console_get_size(console, &cols, &rows);
|
---|
[d553f81] | 403 | if (rc != EOK) {
|
---|
| 404 | printf("%s - cannot get console size\n", cmdname);
|
---|
| 405 | return CMD_FAILURE;
|
---|
| 406 | }
|
---|
| 407 | console_cols = cols;
|
---|
| 408 | console_rows = rows;
|
---|
| 409 | paging_enabled = true;
|
---|
| 410 | newpage();
|
---|
| 411 | }
|
---|
[c9f5e24f] | 412 |
|
---|
[3cefd70] | 413 | for (i = optind; argv[i] != NULL && !should_quit; i++)
|
---|
[cc9f314] | 414 | ret += cat_file(argv[i], buffer, hex, head, tail, tailFirst);
|
---|
[216d6fc] | 415 |
|
---|
[c9f5e24f] | 416 | if (ret)
|
---|
| 417 | return CMD_FAILURE;
|
---|
| 418 | else
|
---|
| 419 | return CMD_SUCCESS;
|
---|
[216d6fc] | 420 | }
|
---|