HDTenEightyP/NetNews huggingface dataset:
From: P0LU000 <P0LU@UNB.CA>
Subject: MicroSoft C v6.0 code prob.
Organization: The University of New Brunswick
Date: Fri, 4 Sep 1992 19:36:26 GMT

//
// File: t.c
//
//      Test out various subroutines quickly and hopefully with min fuss
//
//

void main( int argc, char *argv[] );

#include <stdio.h>
#include <dos.h>
#include <signal.h>
#include <process.h>

#include "t.h"

int get_disk_serial( unsigned char  diskno,
					 char           *ser );

int get_byte_form( unsigned char diskno,
				   long int      *i );




















A few weeks ago, some people were kind enough to assist me in
writing code that will allow a program to read the disk serial
number (for DOS 4.0 and up).

Well, I adapted the code from a Pascal routine in PC magazine
(July 1992, page 496), and this version will run.  The only
problem is that it does not print out the correct disk volume.

The program I've written up so far is included below.  Can
anyone here tell me what I'm doing wrong.  More importantly,
can anyone tell me how to do it right?

Thanx in advance...
Leslie Mills

********* Program Follows **********

/* sorry for the incredibly bad spacing.  I had a horrible time
   trying to transfer the file where I could actually post it
*/

void main( int  argc,   // these variables are not used.
     char *argv[] )     // I placed them here out of habit
{
 char ser[10];           // disk serial number
 int res;                // result of function call

 res = get_disk_serial( (unsigned char) 3, ser );
 if ( res == 0 ) {
  printf( "The serial number of drive C: is: %s\n", ser );
 } else {
  printf( "Call barfed. Big Bad Ugly Error.\n" );
 }

 return;
}

//
// I grabbed quite a bit of this procedure from:
//          PC Magazine, July 1992, page 496
// Written: 92/09/04
//
int get_disk_serial( unsigned char  diskno,
      char           ser[] )
{
 long int i;         // This will hold the function result
 char     *hexdigits = "0123456789ABCDEF";
 int      res;

 union REGS   inregs, outregs;
 struct SREGS segregs;

 inregs.h.ah = 0x69;     // DOS fcn call 69h : serial number code
 inregs.h.al = 0x00;     // read from disk, don't write!
 inregs.h.bl = diskno;   // read from disk number in diskno
 inregs.x.dx = (unsigned int) &i;       // data pointer

 res = int86x( 0x21, &inregs, &outregs, &segregs );
 if ( outregs.x.cflag ) {
  // my ambiguous way of displaying an error message
  printf( "Little Fluffy took a round, better take him to the vet.\n" );
 } else {
  printf( "Yeah!\n" );
 }

 //*- Now long int variable i should have disk serial number

printf( "Byte value of i: %lX\n\n", i );

 ser[0] = hexdigits[  i >> 28 ];
 ser[1] = hexdigits[ (i >> 24) & 0xf ];
 ser[2] = hexdigits[ (i >> 20) & 0xf ];
 ser[3] = hexdigits[ (i >> 16) & 0xf ];
 ser[4] = '-';
 ser[5] = hexdigits[ (i >> 12) & 0xf ];
 ser[6] = hexdigits[ (i >>  8) & 0xf ];
 ser[7] = hexdigits[ (i >>  4) & 0xf ];
 ser[8] = hexdigits[ i & 0xf ];
 ser[9] = '\0';

 printf( "We reached here all right...\n" );

 return( 0 );
}


Newsgroups: comp.os.msdos.programmer
From: joet@dcatlas.dot.gov (Joe Trott)
Subject: Re: Any idea why NUL is busy inside of windows?
Organization: U.S Dept. of Transportation
Date: Thu, 3 Sep 1992 20:24:11 GMT

leadfoot@bigbootay.sw.stratus.com (Mark Curtis) writes:

>I can not get MS's C7 pwb to compile inside a dos window.  It gets
>a sharing violation on the dev NUL.  NUL is used to throw away
>unwanted output.  Outside of windows all is fine, but inside a dos
>window any write accesses to NUL produce share violations.

>copy \autoexec.bat nul               inside a dos window causes A/R/F
>                                     error message.  PWB displays an
>                                     error prompt and aborts.

It is hard to resist thinking that this is an act of self preservation on
the part of Windows.  Only by plugging up NUL can it prevent itself from
being sucked into the void where it belongs.

(Sorry...just got carried away for a moment...)

Seriously, do you need more file handles?  Just a wild guess...

-JTT

Newsgroups: comp.os.msdos.programmer,comp.os.msdos.misc
From: dspascha@eos.ncsu.edu (DAVID SCOTT PASCHAL)
Subject: Re: Why ms-dos is non reentrant
Originator: dspascha@c00089-100lez.eos.ncsu.edu
Reply-To: dspascha@eos.ncsu.edu (DAVID SCOTT PASCHAL)
Organization: North Carolina State University, Project Eos
Date: Tue, 1 Sep 1992 21:22:40 GMT


Hi.  There are plenty of mostly undocumented INT 21h calls that can be used to
determine if it's safe to make a DOS call from within an interrupt handler, but
there are also two function calls that can be used to get the address of the
Swappable Data Area (SDA) so that if a DOS call is being processed all you do is
swap out the SDA into your own buffer, make all the DOS calls you want, and
swap the saved data back into the SDA!  I can't remember the specifics since I
don't have any docs with me, but I know it's INT 21h function 5D06h for DOS 3.x
and function 5D0Bh for DOS 4.x and later.  However, you still have to pay
attention to "critical sections" delimited by calls to certain (sub)functions
of INT 2Ah.  The book <Undocumented DOS> by Ralf Brown, Andrew Schulman, and
others explains all about this.

Tschuess,
David Paschal
Newsgroups: comp.os.msdos.programmer,news.answers
Newsgroups: comp.os.msdos.programmer,comp.os.msdos.misc
Subject: Re: Why ms-dos is non reentrant
From: dueck@brandonu.ca
Date: 2 Sep 92 17:45:17 CST
Organization: Brandon University, Brandon, Manitoba, Canada

In article <92245.122042A10742@TRMETU.BITNET>, Pinar Aydemir <A10742@TRMETU.BITNET> writes:
> I almost hear everyday that msdos is non-reentrant.
> It is non re-entrant so dont call a dos funcion from a Interrupt Service
> Routine.
> Since It is non reentrant, bla bla bla.
> 
> I looked at some books about OS, and the definition of reentrancy is
> given as being unmodified (pure) code.So, what makes msdos non reentrant ?
> Any information  is appreciated.
> -Yasemin

That definition is not quite correct. Pure code just means that you don't
modify code on the fly.

Reentrance requires the notion of a process: code + data. The code
remains constant, but the data is different for each occurence of a process.

For example:
   x dw 0

incrax:
   mov x, ax
   add x, 1
   mov ax, x
   ret

is not re-entrant, but

incrax:
   push bp
   mov  bp,sp
   sub  sp, 2
   mov  [bp-2], ax
   add  [bp-2], 1
   mov  ax, [bp-2]
   mov	sp, bp
   ret

is re-entrant. The difference? We have to consider that an interrupt handler
can be invoked at any time (asynchronous), that it may call the incrax routine, and that
at the time of the interrupt, the CPU was executiong somewhere in incrax
(what I call a synchronous execution).

In the first example, an interrupt handler invoked asynchronously that 
calls incrax will modify location x, thereby causing an incorrect
result from the synchronous call to incrax,

An interrupt handler that calls incrax in the second example will not
clobber location x, since the data areas used by the code is specific 
to an instance of a thread of control. Thus the asynchronous execution
cannot interfere with the synchronous execution.

In the case of DOS, the state of a system call is stored in fixed locations.
A system call made from within an interrupt handler modifies the state
represented by those locations. So when the interrupt completes, and
the CPU return to the middle of an interrupted system call, the modified
state is almost always incorrect.

I hope this helps.

Gery Dueck
dueck@brandonu.ca
From: bandu@acsu.buffalo.edu (Jagath Samarabandu)
Newsgroups: comp.os.msdos.programmer
Subject: gcc (djgpp) default file mode (text vs binary) question?
Date: 25 Aug 92 17:22:03 GMT
Organization: SUNY/Buffalo Electrical Eng.

Hello All,

I'm trying to port a bunch of unix image processing programs using djgpp and
have trouble setting the default file mode to binary. 

The file 'libc.doc' that comes with the distribution says I can set the global
variable _ftype to O_TEXT or O_BINARY and it should set the default file type.
But this doesn't seem to work. 

If any of you can give me some *(help)(), I'd really appreciate it.

Thanks,

Bandu

PS: Hats off to those who toiled to port gcc (djgpp). It even beats the pants
off of Borland C++ 3.1 for my application (both code size and speed).
Newsgroups: comp.os.msdos.programmer,comp.os.msdos.misc
From: resnicks@netcom.com (Steve Resnick)
Subject: Re: Why ms-dos is non reentrant
Date: Tue, 01 Sep 92 17:13:24 GMT
Organization: What? Me organized? You should see my checkbook!

In article <BOUILLIN.92Sep1164052@node_3f5e2.ntc.nokia.com> bouillin@ntc.nokia.com writes:
>>>>>> On Tuesday, 1 Sep 1992 12:20:42 TUR, Pinar Aydemir <A10742@TRMETU.BITNET> said:
>
>> I almost hear everyday that msdos is non-reentrant.
>> It is non re-entrant so dont call a dos funcion from a Interrupt Service
>> Routine.
>> Since It is non reentrant, bla bla bla.
>
>> I looked at some books about OS, and the definition of reentrancy is
>> given as being unmodified (pure) code.So, what makes msdos non reentrant ?
>> Any information  is appreciated.
>
>msdos is reentrant because it has been designed so. When writing the
>code of a particular routine you may tell the compiler that at
>runtime, either its data segments are fixed (say a memory position) or
>re-definable (say a new memory position at each call), the latter
>routine only is called re-entrant. Note such a routine may call itself
>without any problem... provided it has an exit path (for example after
>10 times).


Claude - What you described is relocateable code. Not reentrancy.

MS-DOS consists of both. The DOS kernel (or at least certain portions)
reside at specific addresses. This code is not moveable.

Reentrant code is code that can be called either from within itself, or
code which can be interrupted and called during that interrupt procedure.

Code which operates on global or static data is, generally, non-reentrant.

For example,
/*** NON REENTRANT ***/
char foo[1234567];

char foobar(int i)
{
	foo[i] += '0';
	return foo[i];
}

/** REENTRANT **/

char foobar(char * foo, int i)
{
	foo[i] += '0';
	return foo[i];
}

(Okay, these aren't great examples, but I gotta get back to work <grin>)

-- 
------------------------------------------------------------------------------
Steve Resnick - resnicks@netcom.com steve@axebbs.kludge.com FidoNet: 1:143/105
"Sometimes you're the windshield, sometimes you're the bug." - M. Knopfler
-----------------------------------------------------------------------------
From: rjg2@ukc.ac.uk (R.J.Gibson)
Newsgroups: comp.os.msdos.programmer,comp.os.msdos.misc
Subject: Stack size changing
Date: 1 Sep 92 13:41:46 GMT
Reply-To: rjg2@ukc.ac.uk (R.J.Gibson)
Organization: Biology Lab, University of Kent at Canterbury, UK.


I have a problem which I have not been able to overcome and was
wondering if anyone out there could help.

I was sent a piece of C source which I have been unable to compile.  I
am using Boralands Turbo C ver 1.0 and the code in question is

#ifdef __TURBOC__
unsigned _stklen = 0x3fff;	/* increase stack from 4K to 16K */
#endif

I have defined __TURBOC__ but ia am getting a message saying that this
is an error "error -redeclaration of __stklen"

There is not other manual decrlartion of this in the code that I can
find.

It also coplains at 

typedef unsigned char  int8u;

but not at 

typedef unsigned long  int32u;
typedef long		int32;
typedef unsigned short int16u;
typedef short		int16;

Any ideas?

Thanks
Ro.

ps other people have compiled this code on pcs with other compilers so
it should work and I have managed it on a sun.  I am just looking for
an idea as I have no other pc compilers and would like it on the pc.

DISCLAIMER:
***********
All comments, jokes, asides, rubbish, cabbages etc are of my own
making and in no way represent the policy of the University of Kent,
or any other member of the University, nor any cat, dog, goldfish,
insect, bacteria, mineral, etc, on campus.  All flames to rjg2@ukc.ac.uk.
Newsgroups: comp.os.msdos.programmer
From: librik@cory.Berkeley.EDU (David Librik)
Subject: Re: Efficient byte/word mirroring request
Organization: University of California, at Berkeley
Date: Fri, 28 Aug 1992 07:24:24 GMT

egg@dstos3.dsto.gov.au writes:

>Does anyone know how to quickly and efficiently mirror a byte.
>ie
>    11001010 to 01010011

>the only way I know is this

>   mov  al,byte_to_shift
>   mov  cx,8
>ShiftLoop:
>   rcr  al
>   rcl  ah
>   loop ShiftLoop
>   mov  shifted_byte,ah

>There must be an easier (and smarter) way to speed this up using logical
>op's perhaps ?

>Themie Gouthas
>egg@dstos3.dsto.gov.au

This is an interesting problem.  No, I don't think there is any straightforward
logical set of operations you can do, because none of the logical ops are
too concerned with bit-order.  But we can do a lot better than the code you
have there for speed -- an assembler hint, don't use loops unless you are
held to it at gunpoint.

A good solution using your approach would be as follows:
	mov	ah,byte_to_shift
	xor	al,al		; Clear AL

	shr	ah,ah		; Get low bit of AH into carry
	adc	al,al		; Put carry into low bit of AL
	shr	ah,ah		; Get next lowest bit of AH into carry
	adc	al,al		; Put carry into low bit of AL, shift left
	shr	ah,ah		;   the rest of AL.  An ADC is equivalent
	adc	al,al		;   to an RCL, but takes 2 rather than 9 cycles
	shr	ah,ah		; Do this thing once for each bit.
	adc	al,al		; This is what macro assemblers were made for.
	shr	ah,ah
	adc	al,al
	shr	ah,ah
	adc	al,al
	shr	ah,ah
	adc	al,al
	shr	ah,ah
	adc	al,al

	mov	shifted_byte,al

A better solution, if this is an important enough operation to sacrifice 256
bytes of memory in order to massively improve speed is, to make a table:

reverse_table	label	byte
		db	00000000b
		db	10000000b
		db	01000000b
		db	11000000b
... you get the point.  Then the actual reversal code is:
		mov	al,byte_to_shift
		mov	bx,offset reverse_table
		xlatb
		mov	shifted_byte,al

Not too shabby.  Anyone with a better solution is more than welcome to
correct my code.

- David Librik                                       'Crac Cymraeg!'
  librik@cory.Berkeley.edu
From: messina@netcom.com (Tony Porczyk)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Novice question: how to boot from a bat file?
Date: 31 Aug 92 01:36:27 GMT
Organization: Messina Software

ts@uwasa.fi (Timo Salmi) writes:

>In article <adgn1#p.messina@netcom.com> messina@netcom.com (Tony Porczyk) writes:
>>begin 666 reset.com
>>1ND``CMJ[<@#'!S02Z@``__\`
>>It's not too long :-), after uudecoding it should be 17 bytes long.
>
>Yes I know it is certainly not too long, but whether just a few
>characters or hundreds of lines, please do not use this practice. 
>Here is the why:
>-From: garbo.uwasa.fi:/pc/ts/tsfaq29.zip Frequently Asked Questions

Well, not to get picky, but the uuencoded post was 1 line long, your
preaching was 5 pages long.  Talk about a waste of bandwith.

t.
Newsgroups: comp.os.msdos.programmer,comp.os.msdos.misc
From: bws@ccs.carleton.ca (Brian Sullivan)
Subject: Re: Why ms-dos is non reentrant
Organization: Carleton University
Date: Tue, 1 Sep 1992 13:23:23 GMT

In article <92245.122042A10742@TRMETU.BITNET> A10742@TRMETU.BITNET (Pinar Aydemir) writes:

>I almost hear everyday that msdos is non-reentrant.
>It is non re-entrant so dont call a dos funcion from a Interrupt Service
>Routine.
>Since It is non reentrant, bla bla bla.

>I looked at some books about OS, and the definition of reentrancy is
>given as being unmodified (pure) code.So, what makes msdos non reentrant ?
>Any information  is appreciated.
>-Yasemin

When performing a DOS call, some routines use Static data space, (rather than
allocating memory on a stack). If you interrupt a DOS call to perform the 
same function(or on fro the same family, (even if you save all the 
registers) you can still trash the original data. And after your TSR exits
DOS continues with corrupted data. 

Reentrancy is not dependent on pure code, it simply requires that a 
routine may call itself, or be interupted and called by another routine
WITHOUT SIDE EFFECTS. To wit (I always wanted to say that) each time 
the code begins, all data must be allocated on a stack (no static data 
blocks!!!!!). 
Newsgroups: comp.os.msdos.programmer
From: kennu@mits.mdata.fi (Kenneth Falck)
Subject: Re: assembler and serial ports
Organization: Microdata Oy, Helsinki, Finland
Date: Sun, 23 Aug 1992 16:40:28 GMT

In article <1992Aug22.221721.17544@tc.cornell.edu> homer@theory.TC.Cornell.EDU (Homer Smith) writes:
>     I am playing with INT 14, the serial port bios routines.
> 
>     Function 1 is supposed to write to the port and function
>2 is supposed to read from the port.  

You know, the BIOS communications functions aren't very good.
In fact, if I were you, I'd use a FOSSIL driver and check its
documentation, or alternatively write routines that access
the UART directly. (I did it once in C but got troubles with
speed; writing them in assembler should be fast enough.)

Also, in case you haven't tried, I recommend checking out
a database called HelpPC. Probably available at your local 
BBS and/or nic.funet.fi & garbo.uwasa.fi.

Sorry for not being able to help with your original problem.

-- 
kennu@mits.mdata.fi

Newsgroups: comp.os.msdos.programmer
From: Ross Ridge <ross@zooid.guild.org>
Subject: Re: Novice question: how to boot from a bat file?
Organization: ZOOiD BBS
Date: Fri, 4 Sep 1992 06:43:30 GMT

roy%cybrspc@cs.umn.edu (Roy M. Silvernail) writes:
>It means the FAQ is doing its job.  Cut the size down, and you'll soon
>see those questions popping up on the net again.

I'm seeing them anyways.

>Come to think of it, this is the first time I've ever seen anyone
>complain about getting too much information. :-)

You're kidding, right?  Ever heard of KILL files?  Or threaded news readers?  
Usenet is the perfect example of too much information.

								Ross Ridge

-- 
Ross Ridge - The Great HTMU					     l/	 //
								    [OO][oo]
ross@zooid.guild.org						    /()\/()/
uunet.ca!zooid!ross						     db	 //
From: Jon Freivald <jaf@jaflrn.UUCP>
Newsgroups: comp.os.msdos.programmer
Subject: Re: How can you set an environment variable in a program?
Keywords: variable, C
Date: Tue, 25 Aug 92 18:13:29 EDT
Organization: The Wizzard's Cave, East Meadow, NY

tyrant@Aardvark.Rain.COM (Rex Goode) writes:

> dmh@superb (Daniel Hermans) writes:
> 
> >hi,
> >i am using turbo c v2.0 to generate a temporary file name,
> >place some data in the temporary file and then close the file. the temp
> >file is then to be used on the command line of another program. both
> >programs are called within a batch file something like:
> 
> >@echo off
> 
> >program1
> >program2 < %tempfile%
> 
> >   system("set tempfile=tmpx.$$$");
> 
> >i tried using system(command) as above but the variable is not set when the
> >program exits probably because system starts a new command.com shell each
> >time
> 
> Absolutely right about the new command.com, with its own environment. That
> is what happens when you use system(). Try setenv(),
> 
> setenv("TEMPFILE=TMPX.$$$);

OK, I don't have TC 2.0, but I do have TC++ 1.0 & 2.0 -- no such critter
as "setenv()" and "putenv()" only changes the environment for the
current process -- as soon as you exit, the variable is gone...

Jon

=============================================================================
		   Jon Freivald ( jaflrn!jaf@uunet.UU.NET )
	 Nothing is impossible for the man who doesn't have to do it.
=============================================================================
Newsgroups: comp.os.msdos.programmer,news.answers
From: brown@NCoast.ORG (Stan Brown)
Subject: comp.os.msdos.programmer FAQ diff 3 of 4
Expires: Sun, 20 Sep 1992 00:24:08 GMT
Organization: Oak Road Systems, Cleveland Ohio USA
Date: Wed, 26 Aug 1992 00:24:08 GMT
Followup-To: comp.os.msdos.programmer

Archive-name: msdos-programmer-faq/diff3
Last-modified: 22 August 1992


Please see part 1 for explanations.

- 12>Last-modified: 19 July 1992
+ 12>Last-modified: 22 August 1992

+168>Q407. How can my program open more files than DOS's limit of 20?
+170>    (This is a summary of an article Ralf Brown posted on 8 August 1992.)
+172>    There are separate limits on files and file handles.  For example,
+173>    DOS opens three files but five file handles:  CON (stdin, stdout,
+174>    and stderr), AUX (stdaux), and PRN (stdprn).
+176>    The limit in FILES= in CONFIG.SYS is a system-wide limit on files
+177>    opened by all programs (including the three that DOS opens and any
+178>    opened by TSRs); each process has a limit of 20 handles (including
+179>    the five that DOS opens).  Example:  CONFIG.SYS has FILES=40.  Then
+180>    program #1 will be able to open 15 file handles.  Assuming that the
+181>    program actually does open 15 handles pointing to 15 different
+182>    files, other programs could still open a total of 22 files (40-3-15
+183>    = 22), though no one program could open more than 15 file handles.
+185>    If you're running DOS 3.3 or later, you can increase the per-process
+186>    limit of 20 file handles by a call to INT 21 function 67, Set Handle
+187>    Count.  Your program is still limited by the system-wide limit on
+188>    open files, so you may also need to increase the FILES= value in
+189>    your CONFIG.SYS file (and reboot).  The run-time library that you're
+190>    using may have a fixed-size table of file handles, so you may also
+191>    need to get source code for the module that contains the table,
+192>    increase the table size, and recompile it.

-499>    high-level languages provide a way to do this.
+525>    high-level languages provide a way to do this; for instance, in
+526>    Turbo Pascal it's Lo(DosExitCode) and the high byte gives the way
+527>    in which the child terminated.  In Microsoft C, the exit code of a
+528>    synchronous child process is the return value of the spawn-typoe
+529>    function that creates the process.

+690>Q709. What can I use to manage versions of software?
+692>    In PD1:<MSDOS.PGMUTL> at Simtel you'll find RCS55.ZIP, 388K dated 18
+693>    Dec 1991.  I haven't used it myself, but I understand this is a port
+694>    of the Unix RCS utility, but is limited to one-character extensions
+695>    on filenames (no .CPP).

-- 

Stan Brown, Oak Road Systems                      brown@Ncoast.ORG
From: dick.zeitlin%acc1bbs@ssr.com (Dick Zeitlin) 
Newsgroups: comp.os.msdos.programmer
Subject: 4DOS diversion (Was Re: A
Date: 24 Aug 92 23:26:00 GMT
Distribution: world
Organization: Advanced Computer Concepts BBS, New Rochelle, NY 914-654-1981
Reply-To: dick.zeitlin%acc1bbs@ssr.com (Dick Zeitlin) 

TS> .Seriously, because the majority of the PC users are using MsDos.  As
  > .you might recall we already had a ____prolonged____ discussion (a
  > .good one at that) on this subject last spring in this very
  > .newsgroup.

Sorry if this is bringing up an old issue, but I wasn't around last
spring.

I don't understand.  You seem to be implying a dichotomy between 4Dos
and MsDos.  I'm using MsDos, and using the 4Dos shell.  (Is it
anything else but a shell?  Just a replacement for COMMAND.COM, as far
as I know.)  I can't understand why this seems to be put in the same
category as DR-Dos, which is indeed a replacement for MsDos.

        D/

 * OLX 2.2 * Dick.Zeitlin%acc1bbs@ssr.com