summaryrefslogtreecommitdiff
path: root/msdos/README.msdos
blob: 2d6a276b7858b7bfb82a4f74e906dab68a5e6a07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
		   Notes on the MS-DOS Perl port

			Diomidis Spinellis
			 (dds@cc.ic.ac.uk)

[0. First copy the files in the msdos directory into the parent
directory--law]

1.  Compiling.

     Perl has been compiled under MS-DOS using the Microsoft
C  compiler  version 5.1.  Before compiling install dir.h as
<sys/dir.h>.  You will need a Unix-like make  program  (e.g.
pdmake) and something like yacc (e.g. bison).  You could get
away by running yacc and dry running make on  a  Unix  host,
but  I  haven't tried it.  Compilation takes 12 minutes on a
20MHz 386 machine (together with formating the  manual),  so
you  will probably need something to do in the meantime. The
executable is 272k and the top level directory needs 1M  for
sources  and  about the same ammount for the object code and
the executables.

     The makefile will compile glob for you which  you  will
need  to  place somewhere in your path so that perl globbing
will work correctly.  I have not tried all the tests or  the
examples,  nor the awk and sed to Perl translators.  You are
on your own with them.  In the eg directory I have  included
an  example  program  that uses ioctl to display the charac-
teristics of the storage devices of the system.

2.  Using MS-DOS Perl

     The MS-DOS version of perl has most of the  functional-
ity of the Unix version.  Functions that can not be provided
under  MS-DOS  like  sockets,  password  and  host  database
access,  fork  and wait have been ommited and will terminate
with a fatal error.  Care has been taken  to  implement  the
rest.   In particular directory access, redirection (includ-
ing pipes, but excluding the pipe function),  system,  ioctl
and sleep have been provided.

[Files currently can be edited in-place provided you are cre-
ating  a  backup.   However, if the backup coincidentally has 
the same name as the original, or  if  the  resulting  backup 
filename  is invalid, then the file will probably be trashed.
For example, don't do

	perl -i~ script makefile
	perl -i.bak script file.dat

because  (1)  MS-DOS treats "makefile~" and "makefile" as the
same filename, and (2) "file.dat.bak" is an invalid filename.
The  files  "makefile"  and  "file.dat" will probably be lost 
forever.  Moral of the story:   Don't  use  in-place  editing 
under MS-DOS. --rjc]

2.1.  Interface to the MS-DOS ioctl system call.

     The function code of the  ioctl  function  (the  second
argument) is encoded as follows:

- The lowest nibble of the function code goes to AL.
- The two middle nibbles go to CL.
- The high nibble goes to CH.

     The return code is -1 in the case of an  error  and  if
successful:

- for functions AL = 00, 09, 0a the value of the register DX
- for functions AL = 02 - 08, 0e the value of the register AX
- for functions AL = 01, 0b - 0f the number 0.

     See the perl manual for instruction on how  to  distin-
guish between the return value and the success of ioctl.

     Some ioctl functions need a number as the  first  argu-
ment.   Provided  that  no  other files have been opened the
number  can  be   obtained   if   ioctl   is   called   with
@fdnum[number]  as  the  first  argument after executing the
following code:

        @fdnum = ("STDIN", "STDOUT", "STDERR");
        $maxdrives = 15;
        for ($i = 3; $i < $maxdrives; $i++) {
                open("FD$i", "nul");
                @fdnum[$i - 1] = "FD$i";
        }

2.2.  Binary file access

     Files are opened in text mode by default.   This  means
that  CR LF pairs are translated to LF.  If binary access is
needed the `binary'  function  should  be  used.   There  is
currently  no  way to reverse the effect of the binary func-
tion.  If that is needed close and reopen the file.

2.3.  Interpreter startup.

     The effect of the Unix #!/bin/perl interpreter  startup
can  be  obtained  under  MS-DOS by giving the script a .bat
extension and using the following lines on its begining:

        @REM=("
        @perl %0.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
        @end ") if 0 ;

(Note that you will probably want an absolute path name in
front of %0.bat).

				March 1990

				Diomidis Spinellis <dds@cc.ic.ac.uk>
				Myrsinis 1
				GR-145 62 Kifissia
				Greece