Skip to contentSkip to conversation

Never type another DOS command!

PATCH New Clarence Dang 1 participant 1 message Sep 20, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Never type another DOS command!

Sick of trying to remember those cryptic short filenames? Sick of trying to remember the syntax of LREDIR or $_hdimage? Sick of forgetting to include the builtins in your PATH?

Ever wanted to run a DOS app without typing a _single_ DOS command?

Don't delay - try the attached patch today!

Here are the steps for success (tm):

1. Get a copy of 1.1.5.7 or CVS
2. Apply the attached patch
3. make && make install
4. Make sure "unix -c" is put at the end of your autoexec.bat (as opposed to the default, "unix -e", which tries to execute your commands literally)

Now, you can run your favourite DOS apps like this:

xdosemu "/home/clarence/games/commander keen/keen1.exe"

And it will automatically:

1. mount / if the specified program is not available from an already-redirected drive
2. "cd" to the correct directory
3. and execute the program automagically, all without _any_ typing in DOS

In the process, I "ported" over some more builtins i.e. I just cut and paste them (except for com_dossetcurrentdir()).

Also, while I was at it, I made a cosmetic change to GetRedirectionRoot() in mfs.c - maybe it's just me but returning "TRUE" for failure and "FALSE" for success is just a little bit misleading :P

Thanks go to Stas Sergeev for his help on callbacks and builtins, and Bart Oldeman for his explanation of make_unmake_dos_mangled_path() which must have changed at least 3 times during the writing of this patch :P

Enjoy!
Clarence, uncharacteristically writing an ad :)

--
KolourPaint - http://sf.net/projects/kolourpaint
LibMSWrite - http://sf.net/projects/libmswrite

"Documentation is code duplication" -- David Greenaway

src/dosext/mfs/lfn.h +10 -0
diff -ur -x'*.d' -x'*.o' 1157pr/src/dosext/mfs/lfn.h 1157/src/dosext/mfs/lfn.h
@@ -0,0 +1,10 @@
+/* 
+ * All modifications in this file to the original code are
+ * (C) Copyright 1992, ..., 2003 the "DOSEMU-Development-Team".
+ *
+ * for details see file COPYING in the DOSEMU distribution
+ */
+
+void make_unmake_dos_mangled_path(char *dest, char *fpath,
+                                         int current_drive, int alias);
+
src/dosext/mfs/lfn.c +2 -1
diff -ur -x'*.d' -x'*.o' 1157pr/src/dosext/mfs/lfn.c 1157/src/dosext/mfs/lfn.c
@@ -24,6 +24,7 @@
 #include "mfs.h"
 #include "mangle.h"
 #include "bios.h"
+#include "lfn.h"
 
 #define EOS '\0'
 #define BACKSLASH '\\'
@@ -78,7 +79,7 @@
 	  alias=1: mangle, alias=0: don't mangle
    output: dest = DOS path
 */
-static void make_unmake_dos_mangled_path(char *dest, char *fpath,
+void make_unmake_dos_mangled_path(char *dest, char *fpath,
 					 int current_drive, int alias)
 {
 	char *src;
src/dosext/mfs/mfs.c +3 -15
diff -ur -x'*.d' -x'*.o' 1157pr/src/dosext/mfs/mfs.c 1157/src/dosext/mfs/mfs.c
@@ -264,18 +264,6 @@
 #define SFT_FDEVICE 0x0080
 #define SFT_FEOF 0x0040
 
-/* #define MAX_PATH_LENGTH 57 */
-/* 2001/01/05 Manfred Scherer
- * With the value 57 I can create pathlength until 54.
- * In native DOS I can create pathlength until 63.
- * With the value 66 it should be possible to create
- * paths with length 63.
- * I've tested it on my own system, and I found the value 66
- * is right for me.
- */
-
-#define MAX_PATH_LENGTH 66
-
 struct file_fd
 {
   char *name;
@@ -2417,12 +2405,12 @@
 int
 GetRedirectionRoot(int dsk, char **resourceName,int *ro_flag)
 {
-  if (!drives[dsk].root) return (TRUE);
+  if (!drives[dsk].root) return 1;
   *resourceName = malloc(MAXPATHLEN + 1);
-  if (*resourceName == NULL) return (TRUE);
+  if (*resourceName == NULL) return 1;
   strcpy(*resourceName, drives[dsk].root );
   *ro_flag=drives[dsk].read_only;
-  return (FALSE);
+  return 0;
 
 }
 
src/dosext/mfs/mfs.h +14 -2
diff -ur -x'*.d' -x'*.o' 1157pr/src/dosext/mfs/mfs.h 1157/src/dosext/mfs/mfs.h
@@ -14,7 +14,6 @@
 #include <sys/stat.h>
 #include <dirent.h>
 
-#ifdef DOSEMU
 /* definitions to make mach emu code compatible with dosemu */
 #include "emu.h"
 
@@ -67,7 +66,6 @@
 #define SETHIGH(x,y) 	(*(x) = (*(x) & ~0xff00) | ((MASK8(y))<<8))
 #define SETLOW(x,y) 	(*(x) = (*(x) & ~0xff) | (MASK8(y)))
 #define SETWORD(x,y)	(*(x) = (*(x) & ~0xffff) | (MASK16(y)))
-#endif
 
 /*
  * Copyright (c) 1991 Carnegie Mellon University
@@ -471,6 +469,20 @@
 #define CANCEL_REDIRECTION 4
 #define EXTENDED_GET_REDIRECTION 5
 
+
+/* #define MAX_PATH_LENGTH 57 */
+/* 2001/01/05 Manfred Scherer
+ * With the value 57 I can create pathlength until 54.
+ * In native DOS I can create pathlength until 63.
+ * With the value 66 it should be possible to create
+ * paths with length 63.
+ * I've tested it on my own system, and I found the value 66
+ * is right for me.
+ */
+
+#define MAX_PATH_LENGTH 66
+
+
 extern int build_ufs_path_(char *ufs, const char *path, int drive,
                            int lowercase);
 extern boolean_t find_file(char *fpath, struct stat *st, int drive);
src/plugin/commands/builtins.c +31 -0
diff -ur -x'*.d' -x'*.o' 1157pr/src/plugin/commands/builtins.c 1157/src/plugin/commands/builtins.c
@@ -377,6 +377,37 @@
    return(argcx);
 }
 
+int com_dosgetdrive(void)
+{
+        HI(ax) = 0x19;
+        call_msdos();    /* call MSDOS */
+        return LO(ax);  /* 0=A, 1=B, ... */
+}
+
+int com_dossetdrive(int drive)
+{
+        HI(ax) = 0x0e;
+        LO(dx) = drive; /* 0=A, 1=B, ... */
+        call_msdos();    /* call MSDOS */
+        return LO(ax);  /* number of available logical drives */
+}
+
+int com_dossetcurrentdir(char *path)
+{
+        /*struct com_starter_seg  *ctcb = owntcb->params;*/
+        char *s = com_strdup(path);
+
+        com_errno = 8;
+        if (!s) return -1;
+        HI(ax) = 0x3b;
+        LWORD(ds) = FP_SEG32 (s) /*COM_SEG*/;
+        LWORD(edx) = FP_OFF32 (s) /*COM_OFFS_OF(s)*/;
+        call_msdos();    /* call MSDOS */
+        com_strfree(s);
+        if (LWORD(eflags) & CF) return -1;
+        return 0;
+}
+
 struct REGPACK regs_to_regpack(struct vm86_regs *regs)
 {
 	struct REGPACK regpack;
src/plugin/commands/builtins.h +3 -0
diff -ur -x'*.d' -x'*.o' 1157pr/src/plugin/commands/builtins.h 1157/src/plugin/commands/builtins.h
@@ -63,6 +63,9 @@
 char * com_strdup(char *s);
 unsigned short get_dos_ver(void);
 void com_strfree(char *s);
+int com_dosgetdrive(void);
+int com_dossetdrive(int drive);
+int com_dossetcurrentdir(char *path);
 void com_intr(int intno, struct REGPACK *regpack);
 int com_int86x(int intno, union com_REGS *inregs,
 		union com_REGS *outregs, struct SREGS *segregs);
src/plugin/commands/unix.c +195 -15

259 lines not on this page · raw message

src/plugin/coopthreads/coopthreads.c +0 -31
diff -ur -x'*.d' -x'*.o' 1157pr/src/plugin/coopthreads/coopthreads.c 1157/src/plugin/coopthreads/coopthreads.c
@@ -994,21 +994,6 @@
 	return 0;
 }
 
-int com_dosgetdrive(void)
-{
-	HI(ax) = 0x19;
-	call_msdos();    /* call MSDOS */
-	return LO(ax);	/* 0=A, 1=B, ... */
-}
-
-int com_dossetdrive(int drive)
-{
-	HI(ax) = 0x0e;
-	LO(dx) = drive;	/* 0=A, 1=B, ... */
-	call_msdos();    /* call MSDOS */
-	return LO(ax);	/* number of available logical drives */
-}
-
 int com_dosgetcurrentdir(int drive, char *buf)
 {
 	struct com_starter_seg  *ctcb = owntcb->params;
@@ -1031,22 +1016,6 @@
 	return 0;
 }
 
-int com_dossetcurrentdir(char *path)
-{
-	struct com_starter_seg  *ctcb = owntcb->params;
-	char *s = com_strdup(path);
-
-	com_errno = 8;
-	if (!s) return -1;
-	HI(ax) = 0x3b;
-	LWORD(ds) = COM_SEG;
-	LWORD(edx) = COM_OFFS_OF(s);
-	call_msdos();    /* call MSDOS */
-	com_strfree(s);
-	if (LWORD(eflags) & CF) return -1;
-	return 0;
-}
-
 int com_dosgetsetfilestamp(int fd, int ftime)
 {
 	if (ftime) {