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
)
29 // Detect ramdisk path
31 if (_strnicmp(ArcPath
, "ramdisk(0)", 10) == 0)
34 // Magic value for ramdisks
47 if (_strnicmp(ArcPath
, "multi(0)disk(0)", 15) != 0)
51 if (_strnicmp(p
, "fdisk(", 6) == 0)
55 * multi(0)disk(0)fdisk(x)\path
65 else if (_strnicmp(p
, "cdrom(", 6) == 0)
69 * multi(0)disk(0)cdrom(x)\path
72 *BootDrive
= atoi(p
) + 0x80;
77 *BootPartition
= 0xff;
79 else if (_strnicmp(p
, "rdisk(", 6) == 0)
83 * multi(0)disk(0)rdisk(x)partition(y)\path
86 *BootDrive
= atoi(p
) + 0x80;
88 if ((p
== NULL
) || (_strnicmp(p
, ")partition(", 11) != 0))
91 *BootPartition
= atoi(p
);
107 /* PathSyntax: scsi() = 0, multi() = 1, ramdisk() = 2 */
114 OUT ULONG
* Partition
,
115 OUT ULONG
*PathSyntax
)
117 /* Detect ramdisk() */
118 if (_strnicmp(ArcPath
, "ramdisk(0)", 10) == 0)
125 /* Detect scsi()disk()rdisk()partition() */
126 else if (sscanf(ArcPath
, "scsi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x
, y
, z
, Partition
) == 4)
131 /* Detect scsi()cdrom()fdisk() */
132 else if (sscanf(ArcPath
, "scsi(%lu)cdrom(%lu)fdisk(%lu)", x
, y
, z
) == 3)
138 /* Detect multi()disk()rdisk()partition() */
139 else if (sscanf(ArcPath
, "multi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x
, y
, z
, Partition
) == 4)
144 /* Detect multi()disk()cdrom() */
145 else if (sscanf(ArcPath
, "multi(%lu)disk(%lu)cdrom(%lu)", x
, y
, z
) == 3)
151 /* Detect multi()disk()fdisk() */
152 else if (sscanf(ArcPath
, "multi(%lu)disk(%lu)fdisk(%lu)", x
, y
, z
) == 3)
163 VOID
ConstructArcPath(PCHAR ArcPath
, PCHAR SystemFolder
, UCHAR Disk
, ULONG Partition
)
167 strcpy(ArcPath
, "multi(0)disk(0)");
173 * multi(0)disk(0)fdisk(x)\path
175 sprintf(tmp
, "fdisk(%d)", (int) Disk
);
176 strcat(ArcPath
, tmp
);
182 * multi(0)disk(0)rdisk(x)partition(y)\path
184 sprintf(tmp
, "rdisk(%d)partition(%d)", (int) (Disk
- 0x80), (int) Partition
);
185 strcat(ArcPath
, tmp
);
188 if (SystemFolder
[0] == '\\' || SystemFolder
[0] == '/')
190 strcat(ArcPath
, SystemFolder
);
194 strcat(ArcPath
, "\\");
195 strcat(ArcPath
, SystemFolder
);
200 UCHAR
ConvertArcNameToBiosDriveNumber(PCHAR ArcPath
)
203 UCHAR DriveNumber
= 0;
205 if (_strnicmp(ArcPath
, "multi(0)disk(0)", 15) != 0)
209 if (_strnicmp(p
, "fdisk(", 6) == 0)
213 * multi(0)disk(0)fdisk(x)\path
216 DriveNumber
= atoi(p
);
218 else if (_strnicmp(p
, "rdisk(", 6) == 0)
222 * multi(0)disk(0)rdisk(x)partition(y)\path
225 DriveNumber
= atoi(p
) + 0x80;