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) */
47 /* NOTE: We are currently limited when handling multi()disk() paths!! */
48 if (_strnicmp(ArcPath
, "multi(0)disk(0)", 15) != 0)
52 if (_strnicmp(p
, "fdisk(", 6) == 0)
56 * multi(0)disk(0)fdisk(x)\path
59 *DriveNumber
= atoi(p
);
66 else if (_strnicmp(p
, "cdrom(", 6) == 0)
70 * multi(0)disk(0)cdrom(x)\path
73 *DriveNumber
= atoi(p
) + 0x80;
78 *PartitionNumber
= 0xff;
80 else if (_strnicmp(p
, "rdisk(", 6) == 0)
84 * multi(0)disk(0)rdisk(x)[partition(y)][\path]
87 *DriveNumber
= atoi(p
) + 0x80;
92 /* The partition is optional */
93 if (_strnicmp(p
, "partition(", 10) == 0)
96 *PartitionNumber
= atoi(p
);
104 *PartitionNumber
= 0;
112 /* Get the path (optional) */
119 /* PathSyntax: scsi() = 0, multi() = 1, ramdisk() = 2 */
126 OUT PULONG Partition
,
127 OUT PULONG PathSyntax
)
129 /* Detect ramdisk() */
130 if (_strnicmp(ArcPath
, "ramdisk(0)", 10) == 0)
137 /* Detect scsi()disk()rdisk()partition() */
138 else if (sscanf(ArcPath
, "scsi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x
, y
, z
, Partition
) == 4)
143 /* Detect scsi()cdrom()fdisk() */
144 else if (sscanf(ArcPath
, "scsi(%lu)cdrom(%lu)fdisk(%lu)", x
, y
, z
) == 3)
150 /* Detect multi()disk()rdisk()partition() */
151 else if (sscanf(ArcPath
, "multi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x
, y
, z
, Partition
) == 4)
156 /* Detect multi()disk()cdrom() */
157 else if (sscanf(ArcPath
, "multi(%lu)disk(%lu)cdrom(%lu)", x
, y
, z
) == 3)
163 /* Detect multi()disk()fdisk() */
164 else if (sscanf(ArcPath
, "multi(%lu)disk(%lu)fdisk(%lu)", x
, y
, z
) == 3)
175 VOID
ConstructArcPath(PCHAR ArcPath
, PCHAR SystemFolder
, UCHAR Disk
, ULONG Partition
)
179 strcpy(ArcPath
, "multi(0)disk(0)");
185 * multi(0)disk(0)fdisk(x)\path
187 sprintf(tmp
, "fdisk(%d)", (int) Disk
);
188 strcat(ArcPath
, tmp
);
194 * multi(0)disk(0)rdisk(x)partition(y)\path
196 sprintf(tmp
, "rdisk(%d)partition(%d)", (int) (Disk
- 0x80), (int) Partition
);
197 strcat(ArcPath
, tmp
);
200 if (SystemFolder
[0] == '\\' || SystemFolder
[0] == '/')
202 strcat(ArcPath
, SystemFolder
);
206 strcat(ArcPath
, "\\");
207 strcat(ArcPath
, SystemFolder
);
212 UCHAR
ConvertArcNameToBiosDriveNumber(PCHAR ArcPath
)
215 UCHAR DriveNumber
= 0;
217 if (_strnicmp(ArcPath
, "multi(0)disk(0)", 15) != 0)
221 if (_strnicmp(p
, "fdisk(", 6) == 0)
225 * multi(0)disk(0)fdisk(x)\path
228 DriveNumber
= atoi(p
);
230 else if (_strnicmp(p
, "rdisk(", 6) == 0)
234 * multi(0)disk(0)rdisk(x)partition(y)\path
237 DriveNumber
= atoi(p
) + 0x80;