Re-organized things a slight bit.
[reactos.git] / freeldr / freeldr / reactos / arcname.c
1 /*
2 * FreeLoader - arcname.c
3 *
4 * Copyright (C) 2001 Brian Palmer <brianp@sginet.com>
5 * Copyright (C) 2001 Eric Kohl
6 *
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.
11 *
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.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include <freeldr.h>
23 #include <rtl.h>
24
25
26 BOOL DissectArcPath(char *ArcPath, char *BootPath, PULONG BootDrive, PULONG BootPartition)
27 {
28 char *p;
29
30 if (_strnicmp(ArcPath, "multi(0)disk(0)", 15) != 0)
31 return FALSE;
32
33 p = ArcPath + 15;
34 if (_strnicmp(p, "fdisk(", 6) == 0)
35 {
36 /*
37 * floppy disk path:
38 * multi(0)disk(0)fdisk(x)\path
39 */
40 p = p + 6;
41 *BootDrive = atoi(p);
42 p = strchr(p, ')');
43 if (p == NULL)
44 return FALSE;
45 p++;
46 *BootPartition = 0;
47 }
48 else if (_strnicmp(p, "rdisk(", 6) == 0)
49 {
50 /*
51 * hard disk path:
52 * multi(0)disk(0)rdisk(x)partition(y)\path
53 */
54 p = p + 6;
55 *BootDrive = atoi(p) + 0x80;
56 p = strchr(p, ')');
57 if ((p == NULL) || (_strnicmp(p, ")partition(", 11) != 0))
58 return FALSE;
59 p = p + 11;
60 *BootPartition = atoi(p);
61 p = strchr(p, ')');
62 if ((p == NULL) || (*BootPartition == 0))
63 return FALSE;
64 p++;
65 }
66 else
67 {
68 return FALSE;
69 }
70
71 strcpy(BootPath, p);
72
73 return TRUE;
74 }