home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / amiga / programm / 11781 < prev    next >
Encoding:
Text File  |  1992-07-29  |  2.1 KB  |  63 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!usc!elroy.jpl.nasa.gov!jato!jdickson
  3. From: jdickson@jato.jpl.nasa.gov (Jeff Dickson)
  4. Subject: Re: Printing the device list -- what am I doing wrong?
  5. Message-ID: <1992Jul29.154104.7714@jato.jpl.nasa.gov>
  6. Organization: Jet Propulsion Laboratory
  7. References: <51071@dime.cs.umass.edu>
  8. Date: Wed, 29 Jul 1992 15:41:04 GMT
  9. Lines: 52
  10.  
  11. In article <51071@dime.cs.umass.edu> barrett@gleep.cs.umass.edu (Daniel Barrett) writes:
  12. >
  13. >
  14. >    I'm trying to print the list of volumes under 2.04.  The following
  15. >program gives me a recoverable alert 01000008.  What am I doing wrong?
  16. >If I take out the FPuts() statements, it appears to work.
  17. >
  18. >    The device names DO get printed, but they appear with extra
  19. >spaces in front of them, or backspace characters.  Weird.
  20. >
  21. >    At first, I thought maybe FPuts() within a LockDosList might be
  22. >illegal.  So I removed them, strcpy'd the names into a big array, and did one
  23. >puts() after the UnLockDosList.  Nope -- still a recoverable alert.
  24. >
  25. >    I'm using an A3000T, 2.04, and Aztec C 5.2a.  Note that Aztec
  26. >opens dos.library automatically with its startup code.
  27. >
  28. >#include <dos/dos.h>
  29. >#include <dos/dosextens.h>
  30. >
  31. >main()
  32. >{
  33. >    struct DosList *dlist;
  34. >    char *name;
  35. >
  36. >    dlist = (struct DosList *)LockDosList(LDF_VOLUMES | LDF_READ);
  37. >    if (!dlist)
  38. >        exit(RETURN_FAIL);
  39. >
  40. >    while (dlist = (struct DosList *)NextDosEntry(dlist, LDF_VOLUMES))
  41. >    {
  42. >        name = BADDR(dlist->dol_Name);
  43.  
  44. dol_Name is a BSTR. That means that it is stored as a BPTR and the first byte
  45. of the string is the count of the string's length. So, for instance, "DF0"
  46. in BSTR form would be:
  47.  
  48.         3DF0
  49.  
  50. dol_Name is not null terminated and this is why the system is crashing. The 
  51. extra characters in front of DOS names stem from the fact that you're treating 
  52. the first byte of the string as a normal character.
  53.  
  54. >
  55. >
  56. > //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  57. >| Dan Barrett -- Dept of Computer Science, Lederle Graduate Research Center |
  58. >| University of Massachusetts, Amherst, MA  01003  --  barrett@cs.umass.edu |
  59. > \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////////
  60.  
  61. jeff
  62.  
  63.