OpenWrt – Blame information for rev 4

Subversion Repositories:
Rev:
Rev Author Line No. Line
4 office 1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License,
4 * version 2 as published by the Free Software Foundation.
5 *
6 * (C) John Crispin <blogic@openwrt.org>
7 */
8  
9 #include <sys/types.h>
10 #include <sys/stat.h>
11 #include <fcntl.h>
12 #include <stdio.h>
13 #include <stdint.h>
14 #include <unistd.h>
15 #include <errno.h>
16  
17 int main(int argc, char **argv)
18 {
19 uint32_t t = 0, sum = 0x55aa55aa;
20 int fd;
21  
22 if ((argc != 2) || ((fd = open(argv[1], O_RDWR)) == -1)) {
23 fprintf(stderr, "Usage: %s input_file\n", *argv);
24 return -EINVAL;
25 }
26  
27 lseek(fd, -4, SEEK_END);
28 write(fd, &t, 4);
29 lseek(fd, 0, SEEK_SET);
30  
31 while (read(fd, &t, 4) > 0)
32 sum -= t;
33  
34 lseek(fd, -4, SEEK_END);
35 write(fd, &sum, 4);
36 close(fd);
37  
38 return 0;
39 }