Rev 3397 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3397 | Rev 3492 | ||
---|---|---|---|
Line 57... | Line 57... | ||
57 | { "more", no_argument, 0, 'm' }, |
57 | { "more", no_argument, 0, 'm' }, |
58 | { 0, 0, 0, 0 } |
58 | { 0, 0, 0, 0 } |
59 | }; |
59 | }; |
60 | 60 | ||
61 | /* Dispays help for cat in various levels */ |
61 | /* Dispays help for cat in various levels */ |
62 | void * help_cmd_cat(unsigned int level) |
62 | void help_cmd_cat(unsigned int level) |
63 | { |
63 | { |
64 | if (level == HELP_SHORT) { |
64 | if (level == HELP_SHORT) { |
65 | printf("`%s' shows the contents of files\n", cmdname); |
65 | printf("`%s' shows the contents of files\n", cmdname); |
66 | } else { |
66 | } else { |
67 | help_cmd_cat(HELP_SHORT); |
67 | help_cmd_cat(HELP_SHORT); |
Line 76... | Line 76... | ||
76 | " -m, --more Pause after each screen full\n" |
76 | " -m, --more Pause after each screen full\n" |
77 | "Currently, %s is under development, some options don't work.\n", |
77 | "Currently, %s is under development, some options don't work.\n", |
78 | cmdname, cmdname); |
78 | cmdname, cmdname); |
79 | } |
79 | } |
80 | 80 | ||
81 | return CMD_VOID; |
81 | return; |
82 | } |
82 | } |
83 | 83 | ||
84 | static unsigned int cat_file(const char *fname, size_t blen) |
84 | static unsigned int cat_file(const char *fname, size_t blen) |
85 | { |
85 | { |
86 | int fd, bytes = 0, count = 0, reads = 0; |
86 | int fd, bytes = 0, count = 0, reads = 0; |
Line 119... | Line 119... | ||
119 | printf("Error reading %s\n", fname); |
119 | printf("Error reading %s\n", fname); |
120 | free(buff); |
120 | free(buff); |
121 | return 1; |
121 | return 1; |
122 | } |
122 | } |
123 | 123 | ||
124 | /* Debug stuff, newline not added purposefully */ |
- | |
125 | printf("** %s is a file with the size of %ld bytes\n", |
- | |
126 | fname, total); |
- | |
127 | printf( "** %d bytes were read in a buffer of %d bytes in %d reads\n", |
- | |
128 | count, blen, reads); |
- | |
129 | printf("** Read %s\n", count == total ? "Succeeded" : "Failed"); |
- | |
130 | free(buff); |
124 | free(buff); |
131 | 125 | ||
132 | return 0; |
126 | return 0; |
133 | } |
127 | } |
134 | 128 | ||
135 | /* Main entry point for cat, accepts an array of arguments */ |
129 | /* Main entry point for cat, accepts an array of arguments */ |
136 | int * cmd_cat(char **argv) |
130 | int cmd_cat(char **argv) |
137 | { |
131 | { |
138 | unsigned int argc, i, ret = 0, buffer = 0; |
132 | unsigned int argc, i, ret = 0, buffer = 0; |
139 | int c, opt_ind; |
133 | int c, opt_ind; |
140 | 134 | ||
141 | argc = cli_count_args(argv); |
135 | argc = cli_count_args(argv); |