summaryrefslogtreecommitdiffstats
path: root/utils/ypr0tools/extract_section.c
diff options
context:
space:
mode:
authorLorenzo Miori <memorys60@gmail.com>2013-07-09 18:20:08 +0200
committerThomas Martitz <kugel@rockbox.org>2013-09-07 15:56:07 +0200
commitda8a6a90c33f8bf8f2cad9ff009d813b8b7fbaab (patch)
tree6cf1d0f79ca72df989c35486c81c1999cc85a116 /utils/ypr0tools/extract_section.c
parentcb27d4066a3a96cfc3758dff47c59cbadc3402ee (diff)
downloadrockbox-da8a6a90c33f8bf8f2cad9ff009d813b8b7fbaab.tar.gz
rockbox-da8a6a90c33f8bf8f2cad9ff009d813b8b7fbaab.zip
Firmware tools for Samsung YP-R0/YP-R1 (and possibly others)
They have been rewritten for being completely free and as fast as possible. Successfully extracted, patched, repacked and flashed original firmware (tested on device and it worked) Change-Id: I74d47d13f2dc3a2832a0d6821d3c2182dfd4b33b Reviewed-on: http://gerrit.rockbox.org/506 Reviewed-by: Thomas Martitz <kugel@rockbox.org> Tested-by: Thomas Martitz <kugel@rockbox.org>
Diffstat (limited to 'utils/ypr0tools/extract_section.c')
-rw-r--r--utils/ypr0tools/extract_section.c85
1 files changed, 0 insertions, 85 deletions
diff --git a/utils/ypr0tools/extract_section.c b/utils/ypr0tools/extract_section.c
deleted file mode 100644
index 8ad12bc7df..0000000000
--- a/utils/ypr0tools/extract_section.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2011 Thomas Martitz
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-/* A simple replacement program for (
- * dd if=$file1 of=$file2 bs=1 skip=$offset count=$size
- *
- * Written because byte-size operations with dd are unbearably slow.
- */
-
-void usage(void)
-{
- fprintf(stderr, "Usage: extract_section <romfile> <outfile> <offset> <byte count>\n");
- exit(1);
-}
-
-void die(const char* fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
- exit(1);
-}
-
-int main(int argc, const char* argv[])
-{
- if (argc != 5)
- usage();
-
- int ifd, ofd;
- ssize_t size = atol(argv[4]);
- long skip = atol(argv[3]);
-
- if (!size)
- die("invalid byte count\n");
-
- ifd = open(argv[1], O_RDONLY);
- if (ifd < 0)
- die("Could not open %s for reading!\n", argv[1]);
-
- ofd = open(argv[2], O_WRONLY|O_CREAT|O_TRUNC, 0666);
- if (ofd < 0)
- die("Could not create %s\n", argv[2]);
-
- void *buf = malloc(size);
- if (!buf) die("OOM\n");
-
- lseek(ifd, skip, SEEK_SET);
- lseek(ofd, 0, SEEK_SET);
- if (read(ifd, buf, size) != size)
- die("Read failed\n");
- if (write(ofd, buf, size) != size)
- die("write failed\n");
-
- close(ifd);
- close(ofd);
-
- exit(EXIT_SUCCESS);
-}