blob: 7efa7e1064375c05553a1950654bb58771ea0c54 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <fcntl.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include "util/map.h"
int entry_kat(int argc, char **argv) {
if (argc == 2 && strcmp(argv[1], "-h") == 0) {
fprintf(stderr, "Gebruik: kat [BESTAND]...\n"
"\n"
"Schakel BESTAND(en) aaneen naar standaard uitvoer.\n");
return 0;
}
for (int i = 1; i < argc; i++) {
const char *fname = argv[i];
struct map *map = open_map(fname);
if (map == NULL) {
return 1;
}
if (map->sb.st_size >= 0) {
for (size_t i = 0; i < (size_t)map->sb.st_size; i++) {
putchar(map->addr[i]);
}
}
close_map(map);
}
return 0;
}
|