diff options
author | James <> | 2015-11-04 11:49:21 +0000 |
---|---|---|
committer | James <> | 2015-11-04 11:49:21 +0000 |
commit | 716ca530e1c4515d8683c9d5be3d56b301758b66 (patch) | |
tree | 700eb5bcc1a462a5f21dcec15ce7c97ecfefa772 /tools/firmware-utils/src/mkdcs932.c | |
download | trunk-47381-716ca530e1c4515d8683c9d5be3d56b301758b66.tar.gz trunk-47381-716ca530e1c4515d8683c9d5be3d56b301758b66.tar.bz2 trunk-47381-716ca530e1c4515d8683c9d5be3d56b301758b66.zip |
Diffstat (limited to 'tools/firmware-utils/src/mkdcs932.c')
-rw-r--r-- | tools/firmware-utils/src/mkdcs932.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/firmware-utils/src/mkdcs932.c b/tools/firmware-utils/src/mkdcs932.c new file mode 100644 index 0000000..28c67aa --- /dev/null +++ b/tools/firmware-utils/src/mkdcs932.c @@ -0,0 +1,39 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License, + * version 2 as published by the Free Software Foundation. + * + * (C) John Crispin <blogic@openwrt.org> + */ + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdint.h> +#include <unistd.h> +#include <errno.h> + +int main(int argc, char **argv) +{ + uint32_t t = 0, sum = 0x55aa55aa; + int fd; + + if ((argc != 2) || ((fd = open(argv[1], O_RDWR)) == -1)) { + fprintf(stderr, "Usage: %s input_file\n", *argv); + return -EINVAL; + } + + lseek(fd, -4, SEEK_END); + write(fd, &t, 4); + lseek(fd, 0, SEEK_SET); + + while (read(fd, &t, 4) > 0) + sum -= t; + + lseek(fd, -4, SEEK_END); + write(fd, &sum, 4); + close(fd); + + return 0; +} |