home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!usc!elroy.jpl.nasa.gov!jato!jdickson
- From: jdickson@jato.jpl.nasa.gov (Jeff Dickson)
- Subject: Re: Printing the device list -- what am I doing wrong?
- Message-ID: <1992Jul29.154104.7714@jato.jpl.nasa.gov>
- Organization: Jet Propulsion Laboratory
- References: <51071@dime.cs.umass.edu>
- Date: Wed, 29 Jul 1992 15:41:04 GMT
- Lines: 52
-
- In article <51071@dime.cs.umass.edu> barrett@gleep.cs.umass.edu (Daniel Barrett) writes:
- >
- >
- > I'm trying to print the list of volumes under 2.04. The following
- >program gives me a recoverable alert 01000008. What am I doing wrong?
- >If I take out the FPuts() statements, it appears to work.
- >
- > The device names DO get printed, but they appear with extra
- >spaces in front of them, or backspace characters. Weird.
- >
- > At first, I thought maybe FPuts() within a LockDosList might be
- >illegal. So I removed them, strcpy'd the names into a big array, and did one
- >puts() after the UnLockDosList. Nope -- still a recoverable alert.
- >
- > I'm using an A3000T, 2.04, and Aztec C 5.2a. Note that Aztec
- >opens dos.library automatically with its startup code.
- >
- >#include <dos/dos.h>
- >#include <dos/dosextens.h>
- >
- >main()
- >{
- > struct DosList *dlist;
- > char *name;
- >
- > dlist = (struct DosList *)LockDosList(LDF_VOLUMES | LDF_READ);
- > if (!dlist)
- > exit(RETURN_FAIL);
- >
- > while (dlist = (struct DosList *)NextDosEntry(dlist, LDF_VOLUMES))
- > {
- > name = BADDR(dlist->dol_Name);
-
- dol_Name is a BSTR. That means that it is stored as a BPTR and the first byte
- of the string is the count of the string's length. So, for instance, "DF0"
- in BSTR form would be:
-
- 3DF0
-
- dol_Name is not null terminated and this is why the system is crashing. The
- extra characters in front of DOS names stem from the fact that you're treating
- the first byte of the string as a normal character.
-
- >
- >
- > //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- >| Dan Barrett -- Dept of Computer Science, Lederle Graduate Research Center |
- >| University of Massachusetts, Amherst, MA 01003 -- barrett@cs.umass.edu |
- > \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////////
-
- jeff
-
-