2 * FreeLoader - arcname.c
4 * Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
5 * Copyright (C) 2001 Eric Kohl
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 OUT PCSTR
* Path OPTIONAL
,
28 OUT PUCHAR DriveNumber
,
29 OUT PULONG PartitionNumber
)
33 /* Detect ramdisk path */
34 if (_strnicmp(ArcPath
, "ramdisk(0)", 10) == 0)
36 /* Magic value for ramdisks */
40 /* Get the path (optional) */
49 /* NOTE: We are currently limited when handling multi()disk() paths!! */
50 if (_strnicmp(ArcPath
, "multi(0)disk(0)", 15) != 0)
54 if (_strnicmp(p
, "fdisk(", 6) == 0)
58 * multi(0)disk(0)fdisk(x)\path
61 *DriveNumber
= atoi(p
);
68 else if (_strnicmp(p
, "cdrom(", 6) == 0)
72 * multi(0)disk(0)cdrom(x)\path
75 *DriveNumber
= atoi(p
) + 0x80;
80 *PartitionNumber
= 0xff;
82 else if (_strnicmp(p
, "rdisk(", 6) == 0)
86 * multi(0)disk(0)rdisk(x)[partition(y)][\path]
89 *DriveNumber
= atoi(p
) + 0x80;
94 /* The partition is optional */
95 if (_strnicmp(p
, "partition(", 10) == 0)
98 *PartitionNumber
= atoi(p
);
106 *PartitionNumber
= 0;
114 /* Get the path (optional) */
121 /* PathSyntax: scsi() = 0, multi() = 1, ramdisk() = 2 */
128 OUT PULONG Partition
,
129 OUT PULONG PathSyntax
)
131 /* Detect ramdisk() */
132 if (_strnicmp(ArcPath
, "ramdisk(0)", 10) == 0)
139 /* Detect scsi()disk()rdisk()partition() */
140 else if (sscanf(ArcPath
, "scsi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x
, y
, z
, Partition
) == 4)
145 /* Detect scsi()cdrom()fdisk() */
146 else if (sscanf(ArcPath
, "scsi(%lu)cdrom(%lu)fdisk(%lu)", x
, y
, z
) == 3)
152 /* Detect multi()disk()rdisk()partition() */
153 else if (sscanf(ArcPath
, "multi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x
, y
, z
, Partition
) == 4)
158 /* Detect multi()disk()cdrom() */
159 else if (sscanf(ArcPath
, "multi(%lu)disk(%lu)cdrom(%lu)", x
, y
, z
) == 3)
165 /* Detect multi()disk()fdisk() */
166 else if (sscanf(ArcPath
, "multi(%lu)disk(%lu)fdisk(%lu)", x
, y
, z
) == 3)
177 VOID
ConstructArcPath(PCHAR ArcPath
, PCHAR SystemFolder
, UCHAR Disk
, ULONG Partition
)
181 strcpy(ArcPath
, "multi(0)disk(0)");
187 * multi(0)disk(0)fdisk(x)\path
189 sprintf(tmp
, "fdisk(%d)", (int) Disk
);
190 strcat(ArcPath
, tmp
);
196 * multi(0)disk(0)rdisk(x)partition(y)\path
198 sprintf(tmp
, "rdisk(%d)partition(%d)", (int) (Disk
- 0x80), (int) Partition
);
199 strcat(ArcPath
, tmp
);
202 if (SystemFolder
[0] == '\\' || SystemFolder
[0] == '/')
204 strcat(ArcPath
, SystemFolder
);
208 strcat(ArcPath
, "\\");
209 strcat(ArcPath
, SystemFolder
);
214 UCHAR
ConvertArcNameToBiosDriveNumber(PCHAR ArcPath
)
217 UCHAR DriveNumber
= 0;
219 if (_strnicmp(ArcPath
, "multi(0)disk(0)", 15) != 0)
223 if (_strnicmp(p
, "fdisk(", 6) == 0)
227 * multi(0)disk(0)fdisk(x)\path
230 DriveNumber
= atoi(p
);
232 else if (_strnicmp(p
, "rdisk(", 6) == 0)
236 * multi(0)disk(0)rdisk(x)partition(y)\path
239 DriveNumber
= atoi(p
) + 0x80;