source: buchla-68k/orig/GEMDOS/PATHS.C@ 7bf3856

Last change on this file since 7bf3856 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 3.5 KB
Line 
1/*
2 =============================================================================
3 paths.c -- show the directory paths on multiple drives
4 Version 3 -- 1989-01-17 -- D.N. Lynx Crowe
5 (c) Copyright 1989 -- D.N. Lynx Crowe
6
7 Defaults are setup to show the hard disks and any installed RAM disks.
8
9 The installation drive mask is set so that drive B: will always be
10 skipped since we don't have one on this system.
11 =============================================================================
12*/
13
14#include "ctype.h"
15#include "osbind.h"
16#include "stddefs.h"
17
18#define FIRST 'C' /* default 1st drive (upper case) */
19#define NDRIVES 24 /* default number of drives */
20
21#define DMASK 0x03FFFFFD /* installation drive mask */
22
23char buf[256]; /* directory path buffer */
24
25
26/*
27 =============================================================================
28 usage() -- print the usage message
29 =============================================================================
30*/
31
32usage()
33{
34 Cconws("\r\nusage: PATHS [first [last]]\r\n\r\n");
35
36 Cconws(" Displays the current directory path for each installed drive\r\n");
37 Cconws(" in the range \"first\" through \"last\". System defaults are:\r\n");
38 Cconws(" \"first\" = ");
39 Cconout(FIRST);
40 Cconws(" \"last\" = ");
41 Cconout(FIRST + NDRIVES - 1);
42 Cconws("\r\n\r\n");
43
44 Cconws(" Where: \"first\" and \"last\" are drive letters A..Z, and\r\n");
45 Cconws(" if specified, \"last\" must be greater than \"first\".\r\n");
46 Cconws(" If only \"first\" is specified, \"last\" defaults to \"first\"\r\n");
47}
48
49/*
50
51*/
52
53/*
54 =============================================================================
55 show the directory paths on multiple drives
56 =============================================================================
57*/
58
59main(argc, argv)
60int argc;
61char *argv[];
62{
63 register short c, drive, last;
64 register long dmap;
65 short first;
66
67 if (argc > 1) { /* process first optional argument */
68
69 c = *argv[1];
70
71 if (isascii(c) AND isalpha(c)) { /* check argument */
72
73 first = _toupper(c) - 'A';
74 last = first;
75
76 } else {
77
78 Cconws("ERROR: Invalid first argument - \"");
79 Cconws(argv[1]);
80 Cconws("\".\r\n");
81 usage();
82 Pterm(1);
83 }
84
85 } else { /* default for no arguments */
86
87 first = FIRST - 'A';
88 last = first + NDRIVES - 1;
89 }
90
91/*
92
93*/
94
95 if (argc > 2) { /* process second optional argument */
96
97 c = *argv[2];
98
99 if (isascii(c) AND isalpha(c)) { /* check argument */
100
101 last = _toupper(c) - 'A';
102
103 if (last < first) { /* check drive order */
104
105 Cconws("ERROR: Arguments out of order.\r\n");
106 usage();
107 Pterm(1);
108 }
109
110 } else {
111
112 Cconws("ERROR: Invalid 2nd argument - \"");
113 Cconws(argv[2]);
114 Cconws("\".\r\n");
115 usage();
116 Pterm(1);
117 }
118 }
119
120/*
121
122*/
123 if (argc > 3) { /* check for too many arguments */
124
125 Cconws("ERROR: Invalid number of arguments.\r\n");
126 usage();
127 Pterm(1);
128 }
129
130 dmap = Drvmap() & DMASK; /* get map of installed drives */
131
132 /* for each drive in the range first to last ... */
133
134 for (drive = first; drive < (last + 1); drive++) {
135
136 /* ... if it's installed ... */
137
138 if (dmap & (0x0000001L << drive)) {
139
140 /* ... print the current directory path */
141
142 Dgetpath(buf, 1 + drive);
143
144 if ('\0' EQ buf[0]) { /* clean up root path */
145
146 buf[0] = '\\';
147 buf[1] = '\0';
148 }
149
150 Cconout(drive + 'A');
151 Cconout(':');
152 Cconws(buf);
153 Cconws("\r\n");
154 }
155 }
156
157 Pterm(0);
158}
Note: See TracBrowser for help on using the repository browser.