[syslinux:master] dos: Work-in-progress
syslinux-bot for Shao Miller
shao.miller at yrdsb.edu.on.ca
Mon Jul 19 21:24:12 PDT 2010
Commit-ID: 1fb6b70cdacaf3ca3c069a6d96434eed3b6bc22f
Gitweb: http://syslinux.zytor.com/commit/1fb6b70cdacaf3ca3c069a6d96434eed3b6bc22f
Author: Shao Miller <shao.miller at yrdsb.edu.on.ca>
AuthorDate: Sat, 3 Jul 2010 19:06:10 -0400
Committer: Shao Miller <shao.miller at yrdsb.edu.on.ca>
CommitDate: Sat, 3 Jul 2010 19:06:10 -0400
dos: Work-in-progress
---
MCONFIG.local | 1 +
dos/Makefile | 5 +++--
dos/ctype.h | 3 +++
{com32/include => dos}/getopt.h | 7 +++++--
{com32/lib => dos}/getopt_long.c | 2 +-
dos/stdio.h | 2 ++
dos/stdlib.h | 3 +++
{com32/lib => dos}/strchr.c | 1 +
dos/string.h | 2 ++
{com32/lib => dos}/strntoumax.c | 0
dos/strtoul.c | 15 +++++++++++++++
{win32 => dos}/sysexits.h | 0
dos/syslinux.c | 21 +++++++++------------
libinstaller/syslxopt.c | 8 +++++---
14 files changed, 50 insertions(+), 20 deletions(-)
diff --git a/MCONFIG.local b/MCONFIG.local
new file mode 100644
index 0000000..f91fc16
--- /dev/null
+++ b/MCONFIG.local
@@ -0,0 +1 @@
+CFLAGS += -DDEBUG=1
diff --git a/dos/Makefile b/dos/Makefile
old mode 100644
new mode 100755
index 574b65e..3d19ff2
--- a/dos/Makefile
+++ b/dos/Makefile
@@ -28,6 +28,7 @@ INCLUDES = -include code16.h -nostdinc -iwithprefix include \
SRCS = syslinux.c \
../libinstaller/fat.c \
../libinstaller/syslxmod.c \
+ ../libinstaller/syslxopt.c \
../libinstaller/setadv.c \
../libinstaller/bootsect_bin.c \
../libinstaller/ldlinux_bin.c \
@@ -35,8 +36,8 @@ SRCS = syslinux.c \
$(wildcard ../libfat/*.c)
OBJS = header.o crt0.o $(patsubst %.c,%.o,$(notdir $(SRCS)))
LIBOBJS = int2526.o conio.o memcpy.o memset.o memmove.o skipatou.o atou.o \
- malloc.o free.o getsetsl.o \
- argv.o printf.o __divdi3.o __udivmoddi4.o
+ malloc.o free.o getopt_long.o getsetsl.o strchr.o strtoul.o \
+ strntoumax.o argv.o printf.o __divdi3.o __udivmoddi4.o
VPATH = .:../libfat:../libinstaller
diff --git a/dos/ctype.h b/dos/ctype.h
new file mode 100644
index 0000000..c0d00c0
--- /dev/null
+++ b/dos/ctype.h
@@ -0,0 +1,3 @@
+static int isspace(int c) {
+ return (c == ' ');
+}
diff --git a/com32/include/getopt.h b/dos/getopt.h
old mode 100644
new mode 100755
similarity index 61%
copy from com32/include/getopt.h
copy to dos/getopt.h
index 71c41cd..a1b74b1
--- a/com32/include/getopt.h
+++ b/dos/getopt.h
@@ -1,7 +1,7 @@
#ifndef _GETOPT_H
#define _GETOPT_H
-#include <klibc/extern.h>
+/* (Very slightly) adapted from klibc */
struct option {
const char *name;
@@ -16,7 +16,10 @@ enum {
optional_argument = 2,
};
-__extern int getopt_long(int, char *const *, const char *,
+extern char *optarg;
+extern int optind, opterr, optopt;
+
+extern int getopt_long(int, char *const *, const char *,
const struct option *, int *);
#endif /* _GETOPT_H */
diff --git a/com32/lib/getopt_long.c b/dos/getopt_long.c
old mode 100644
new mode 100755
similarity index 99%
copy from com32/lib/getopt_long.c
copy to dos/getopt_long.c
index e3d064b..1458779
--- a/com32/lib/getopt_long.c
+++ b/dos/getopt_long.c
@@ -9,9 +9,9 @@
*/
#include <stdint.h>
-#include <unistd.h>
#include <string.h>
#include <getopt.h>
+#include "mystuff.h"
char *optarg;
int optind, opterr, optopt;
diff --git a/dos/stdio.h b/dos/stdio.h
index 2c25666..c7ca25c 100644
--- a/dos/stdio.h
+++ b/dos/stdio.h
@@ -16,6 +16,8 @@ int printf(const char *fmt, ...);
#define stdout 1
#define stderr 2
+#define EOF (-1)
+
#define fprintf(x, y, ...) printf(y, ## __VA_ARGS__)
#endif /* STDIO_H */
diff --git a/dos/stdlib.h b/dos/stdlib.h
old mode 100644
new mode 100755
index 71af690..d346705
--- a/dos/stdlib.h
+++ b/dos/stdlib.h
@@ -10,4 +10,7 @@ void *malloc(size_t);
void *calloc(size_t, size_t);
void free(void *);
+extern unsigned long int strtoul(const char *nptr,
+ char **endptr, int base);
+
#endif
diff --git a/com32/lib/strchr.c b/dos/strchr.c
similarity index 89%
copy from com32/lib/strchr.c
copy to dos/strchr.c
index cd3ec78..8315311 100644
--- a/com32/lib/strchr.c
+++ b/dos/strchr.c
@@ -3,6 +3,7 @@
*/
#include <string.h>
+#include "mystuff.h"
char *strchr(const char *s, int c)
{
diff --git a/dos/string.h b/dos/string.h
index 5ee829e..f648de2 100644
--- a/dos/string.h
+++ b/dos/string.h
@@ -21,4 +21,6 @@ static inline int memcmp(const void *__m1, const void *__m2, unsigned int __n)
return rv;
}
+extern char *strchr(const char *s, int c);
+
#endif /* _STRING_H */
diff --git a/com32/lib/strntoumax.c b/dos/strntoumax.c
similarity index 100%
copy from com32/lib/strntoumax.c
copy to dos/strntoumax.c
diff --git a/dos/strtoul.c b/dos/strtoul.c
new file mode 100644
index 0000000..3be9430
--- /dev/null
+++ b/dos/strtoul.c
@@ -0,0 +1,15 @@
+/*
+ * strtoul.c
+ *
+ * strtoul() function
+ */
+
+#include <stddef.h>
+#include <inttypes.h>
+
+extern uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n);
+
+unsigned long strtoul(const char *nptr, char **endptr, int base)
+{
+ return (unsigned long) strntoumax(nptr, endptr, base, ~(size_t) 0);
+}
diff --git a/win32/sysexits.h b/dos/sysexits.h
similarity index 100%
copy from win32/sysexits.h
copy to dos/sysexits.h
diff --git a/dos/syslinux.c b/dos/syslinux.c
old mode 100644
new mode 100755
index 9574553..891980e
--- a/dos/syslinux.c
+++ b/dos/syslinux.c
@@ -18,15 +18,18 @@
*/
#include <errno.h>
+#include <getopt.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
-#include <stdarg.h>
+//#include <stdarg.h>
#include "mystuff.h"
#include "syslinux.h"
#include "libfat.h"
#include "setadv.h"
+#include "sysexits.h"
+#include "syslxopt.h"
const char *program = "syslinux"; /* Name of program */
uint16_t dos_version;
@@ -44,12 +47,6 @@ void pause(void)
# define pause() ((void)0)
#endif
-void __attribute__ ((noreturn)) usage(void)
-{
- puts("Usage: syslinux [-sfmar][-d directory] <drive>: [bootsecfile]\n");
- exit(1);
-}
-
void unlock_device(int);
void __attribute__ ((noreturn)) die(const char *msg)
@@ -617,7 +614,7 @@ int main(int argc, char *argv[])
if (**argp == '-') {
opt = *argp + 1;
if (!*opt)
- usage();
+ usage(EX_USAGE, MODE_SYSLINUX_DOSWIN);
while (*opt) {
switch (*opt) {
@@ -641,13 +638,13 @@ int main(int argc, char *argv[])
subdir = *++argp;
break;
default:
- usage();
+ usage(EX_USAGE, MODE_SYSLINUX_DOSWIN);
}
opt++;
}
} else {
if (bootsecfile)
- usage();
+ usage(EX_USAGE, MODE_SYSLINUX_DOSWIN);
else if (device)
bootsecfile = *argp;
else
@@ -656,7 +653,7 @@ int main(int argc, char *argv[])
}
if (!device)
- usage();
+ usage(EX_USAGE, MODE_SYSLINUX_DOSWIN);
/*
* Create an ADV in memory... this should be smarter.
@@ -668,7 +665,7 @@ int main(int argc, char *argv[])
*/
dev_fd = (device[0] & ~0x20) - 0x40;
if (dev_fd < 1 || dev_fd > 26 || device[1] != ':' || device[2])
- usage();
+ usage(EX_USAGE, MODE_SYSLINUX_DOSWIN);
set_lock_device(dev_fd);
diff --git a/libinstaller/syslxopt.c b/libinstaller/syslxopt.c
index e7f405a..eb00dbd 100755
--- a/libinstaller/syslxopt.c
+++ b/libinstaller/syslxopt.c
@@ -108,7 +108,10 @@ void __attribute__ ((noreturn)) usage(int rv, enum syslinux_mode mode)
" --raid -r Fall back to the next device on boot failure\n"
" --once=... %s Execute a command once upon boot\n"
" --clear-once -O Clear the boot-once command\n"
- " --reset-adv Reset auxilliary data\n"
+ " --reset-adv Reset auxilliary data\n",
+ mode == MODE_SYSLINUX ? " " : "-o");
+ /* Have to chop this roughly in half for the DOS installer for some reason */
+ fprintf(stderr,
" --menu-save= -M Set the label to select as default on the next boot\n"
" --mbr -m Install an MBR (DOS/Win32 installers only)\n"
" --active -a Mark partition as active (DOS/Win32 installers only)\n"
@@ -120,8 +123,7 @@ void __attribute__ ((noreturn)) usage(int rv, enum syslinux_mode mode)
" which includes zipdisks and LS-120 superfloppies.\n"
"\n"
" The -z option is useful for USB devices which are considered\n"
- " hard disks by some BIOSes and zipdrives by other BIOSes.\n",
- mode == MODE_SYSLINUX ? " " : "-o");
+ " hard disks by some BIOSes and zipdrives by other BIOSes.\n");
exit(rv);
}
More information about the Syslinux-commits
mailing list