home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
122.lha
/
Arp_v1.1
/
Demos
/
Devices.c
< prev
next >
Wrap
C/C++ Source or Header
|
1986-11-20
|
3KB
|
104 lines
/* Devices.c -- arp.library demo, uses DA lists to determine what devices
* are connected to the system. -=+SDB+=-
*
* Copyright (c) 1987, Scott Ballantyne
* Use and abuse as you please.
*
* MANX:
* cc Devices.c
* ln Devices.o -larp -lc
*
* Lattice:
* lc Devices.c
* blink lib:c.o Devices.o to Devices lib lib:arp.lib lib:lc.lib lib:amiga.lib
*/
#include <exec/types.h>
#include <libraries/arpbase.h>
#include <arpfunctions.h>
struct DirectoryEntry *DeviceList = NULL; /* List header */
#define ARG_DEVICES 1
#define ARG_DISKS 2
#define ARG_VOLUMES 3
#define ARG_ASSIGNS 4
char *CLI_Template = "DEVICES/S,DISKS/S,VOLUMES/S,ASSIGNS/S";
/* Example of a more extended help message */
/* It would be pleasant if more programs extended this sort of help */
#ifdef AZTEC_C /* Lattice doesn't do well with long strings */
char *CLI_Help =
"Displays devices connected to this system.\nYou may enter:\n\
\tDEVICES -- To display all devices (this is default)\n\
\tDISKS -- To display all diskbased devices\n\
\tVOLUMES -- To display all volumes\n\
\tASSIGNS -- To display all logical assignments\n\n\
Or you may enter any combination of the above. Note that\n\
DEVICES DISKS is the same as simply DISKS\n";
#else
char *CLI_Help = "Displays devices connected to this system:\n\
\tDEVICES -- For devices\n\
\tDISKS -- For disk devices\n\
\tVOLUMES -- for Volumes\n\
\tASSIGNS -- for logicals\n\nOr any combination of the above\n\n";
#endif
VOID main(argc, argv)
int argc;
char **argv;
{
LONGBITS WhichDevices = 0;
LONG numdevs;
register struct DirectoryEntry *dev;
if (argc < 2 ) /* set default */
WhichDevices |= DLF_DEVICES;
/* Find out which switches were used, if any */
if ( argv[ARG_DEVICES] )
WhichDevices |= DLF_DEVICES;
if ( argv[ARG_DISKS] )
WhichDevices |= ( DLF_DEVICES | DLF_DISKONLY );
if ( argv[ARG_VOLUMES] )
WhichDevices |= DLF_VOLUMES;
if ( argv[ARG_ASSIGNS] )
WhichDevices |= DLF_DIRS;
/* Now get the requested devices */
if ( (numdevs = AddDADevs( &DeviceList, WhichDevices )) == 0 )
{
Puts("No entries found");
exit(0);
}
Printf("Found %ld entries\n", numdevs);
/* Now display the name and the type of device it is. */
for ( dev = DeviceList; dev; dev = dev->de_Next)
{
Printf("%-32s", dev->de_Name);
switch (dev->de_Type)
{
case DLX_DEVICE:
Puts("Resident device");
break;
case DLX_VOLUME:
Puts("Volume [mounted]");
break;
case DLX_UNMOUNTED:
Puts("Volume [not mounted]");
break;
case DLX_ASSIGN:
Puts("Logical Assignment");
break;
default:
Puts("Encountered Device of mystery!");
}
}
FreeDAList(DeviceList);
}