]> git.saurik.com Git - apple/libdispatch.git/blob - testing/apply_strtoull.c
libdispatch-84.5.5.tar.gz
[apple/libdispatch.git] / testing / apply_strtoull.c
1 #include <sys/types.h>
2 #include <sys/mman.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <stdint.h>
6 #include <stdbool.h>
7 #include <dispatch.h>
8 #include <unistd.h>
9 #include <fcntl.h>
10 #include <errno.h>
11 #include <string.h>
12 #include <assert.h>
13
14 int
15 main(int argc, char *argv[])
16 {
17 struct stat sb;
18 char **numbers;
19 char *map;
20 size_t i, j;
21 int r, fd;
22
23 if (argc != 2) {
24 fprintf(stderr, "usage: %s <file>\n", argv[0]);
25 exit(EXIT_FAILURE);
26 }
27
28 fd = open(argv[1], O_RDONLY);
29 assert(fd != -1);
30
31 r = fstat(fd, &sb);
32 assert(r != -1);
33
34 if (sb.st_len == 0) {
35 fprintf(stderr, "The file is zero length.\n");
36 exit(EXIT_FAILURE);
37 }
38
39 map = mmap(NULL, sb.st_len, PROT_READ, MAP_FILE, fd, 0);
40 assert(map != MAP_FAILED);
41
42 numbers = malloc(sb.st_len * sizeof(void *)); /* more than enough */
43 assert(numbers);
44
45 /* XXX finish me */
46 numbers[0] = map;
47 j = 1;
48 for (i = 0; i < sb.st_len; i++) {
49 if (map[i] == '\n') {
50 numbers[j] = map + i;
51 j++;
52 continue;
53 }
54 i++;
55 }
56 i
57 ; i < sb.st_len; i++) {
58 if (map[i]
59 }
60
61 dispatch_apply(b, cnt);
62
63 exit(EXIT_SUCCESS);
64 }