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.
24 BOOLEAN
DissectArcPath(CHAR
*ArcPath
, CHAR
*BootPath
, UCHAR
* BootDrive
, ULONG
* BootPartition
)
28 /* Detect ramdisk path */
29 if (_strnicmp(ArcPath
, "ramdisk(0)", 10) == 0)
31 /* Magic value for ramdisks */
41 if (_strnicmp(ArcPath
, "multi(0)disk(0)", 15) != 0)
45 if (_strnicmp(p
, "fdisk(", 6) == 0)
49 * multi(0)disk(0)fdisk(x)\path
59 else if (_strnicmp(p
, "cdrom(", 6) == 0)
63 * multi(0)disk(0)cdrom(x)\path
66 *BootDrive
= atoi(p
) + 0x80;
71 *BootPartition
= 0xff;
73 else if (_strnicmp(p
, "rdisk(", 6) == 0)
77 * multi(0)disk(0)rdisk(x)partition(y)\path
80 *BootDrive
= atoi(p
) + 0x80;
82 if ((p
== NULL
) || (_strnicmp(p
, ")partition(", 11) != 0))
85 *BootPartition
= atoi(p
);
101 /* PathSyntax: scsi() = 0, multi() = 1, ramdisk() = 2 */
108 OUT ULONG
* Partition
,
109 OUT ULONG
*PathSyntax
)
111 /* Detect ramdisk() */
112 if (_strnicmp(ArcPath
, "ramdisk(0)", 10) == 0)
119 /* Detect scsi()disk()rdisk()partition() */
120 else if (sscanf(ArcPath
, "scsi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x
, y
, z
, Partition
) == 4)
125 /* Detect scsi()cdrom()fdisk() */
126 else if (sscanf(ArcPath
, "scsi(%lu)cdrom(%lu)fdisk(%lu)", x
, y
, z
) == 3)
132 /* Detect multi()disk()rdisk()partition() */
133 else if (sscanf(ArcPath
, "multi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x
, y
, z
, Partition
) == 4)
138 /* Detect multi()disk()cdrom() */
139 else if (sscanf(ArcPath
, "multi(%lu)disk(%lu)cdrom(%lu)", x
, y
, z
) == 3)
145 /* Detect multi()disk()fdisk() */
146 else if (sscanf(ArcPath
, "multi(%lu)disk(%lu)fdisk(%lu)", x
, y
, z
) == 3)
157 VOID
ConstructArcPath(PCHAR ArcPath
, PCHAR SystemFolder
, UCHAR Disk
, ULONG Partition
)
161 strcpy(ArcPath
, "multi(0)disk(0)");
167 * multi(0)disk(0)fdisk(x)\path
169 sprintf(tmp
, "fdisk(%d)", (int) Disk
);
170 strcat(ArcPath
, tmp
);
176 * multi(0)disk(0)rdisk(x)partition(y)\path
178 sprintf(tmp
, "rdisk(%d)partition(%d)", (int) (Disk
- 0x80), (int) Partition
);
179 strcat(ArcPath
, tmp
);
182 if (SystemFolder
[0] == '\\' || SystemFolder
[0] == '/')
184 strcat(ArcPath
, SystemFolder
);
188 strcat(ArcPath
, "\\");
189 strcat(ArcPath
, SystemFolder
);
194 UCHAR
ConvertArcNameToBiosDriveNumber(PCHAR ArcPath
)
197 UCHAR DriveNumber
= 0;
199 if (_strnicmp(ArcPath
, "multi(0)disk(0)", 15) != 0)
203 if (_strnicmp(p
, "fdisk(", 6) == 0)
207 * multi(0)disk(0)fdisk(x)\path
210 DriveNumber
= atoi(p
);
212 else if (_strnicmp(p
, "rdisk(", 6) == 0)
216 * multi(0)disk(0)rdisk(x)partition(y)\path
219 DriveNumber
= atoi(p
) + 0x80;