Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenarcname.c
Go to the documentation of this file.
00001 /* 00002 * FreeLoader - arcname.c 00003 * 00004 * Copyright (C) 2001 Brian Palmer <brianp@sginet.com> 00005 * Copyright (C) 2001 Eric Kohl 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License along 00018 * with this program; if not, write to the Free Software Foundation, Inc., 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00020 */ 00021 00022 #include <freeldr.h> 00023 00024 BOOLEAN DissectArcPath(CHAR *ArcPath, CHAR *BootPath, UCHAR* BootDrive, ULONG* BootPartition) 00025 { 00026 char *p; 00027 00028 // 00029 // Detect ramdisk path 00030 // 00031 if (_strnicmp(ArcPath, "ramdisk(0)", 10) == 0) 00032 { 00033 // 00034 // Magic value for ramdisks 00035 // 00036 *BootDrive = 0x49; 00037 *BootPartition = 1; 00038 00039 // 00040 // Get the path 00041 // 00042 p = ArcPath + 11; 00043 strcpy(BootPath, p); 00044 return TRUE; 00045 } 00046 00047 if (_strnicmp(ArcPath, "multi(0)disk(0)", 15) != 0) 00048 return FALSE; 00049 00050 p = ArcPath + 15; 00051 if (_strnicmp(p, "fdisk(", 6) == 0) 00052 { 00053 /* 00054 * floppy disk path: 00055 * multi(0)disk(0)fdisk(x)\path 00056 */ 00057 p = p + 6; 00058 *BootDrive = atoi(p); 00059 p = strchr(p, ')'); 00060 if (p == NULL) 00061 return FALSE; 00062 p++; 00063 *BootPartition = 0; 00064 } 00065 else if (_strnicmp(p, "cdrom(", 6) == 0) 00066 { 00067 /* 00068 * cdrom path: 00069 * multi(0)disk(0)cdrom(x)\path 00070 */ 00071 p = p + 6; 00072 *BootDrive = atoi(p) + 0x80; 00073 p = strchr(p, ')'); 00074 if (p == NULL) 00075 return FALSE; 00076 p++; 00077 *BootPartition = 0xff; 00078 } 00079 else if (_strnicmp(p, "rdisk(", 6) == 0) 00080 { 00081 /* 00082 * hard disk path: 00083 * multi(0)disk(0)rdisk(x)partition(y)\path 00084 */ 00085 p = p + 6; 00086 *BootDrive = atoi(p) + 0x80; 00087 p = strchr(p, ')'); 00088 if ((p == NULL) || (_strnicmp(p, ")partition(", 11) != 0)) 00089 return FALSE; 00090 p = p + 11; 00091 *BootPartition = atoi(p); 00092 p = strchr(p, ')'); 00093 if (p == NULL) 00094 return FALSE; 00095 p++; 00096 } 00097 else 00098 { 00099 return FALSE; 00100 } 00101 00102 strcpy(BootPath, p); 00103 00104 return TRUE; 00105 } 00106 00107 /* PathSyntax: scsi() = 0, multi() = 1, ramdisk() = 2 */ 00108 BOOLEAN 00109 DissectArcPath2( 00110 IN CHAR* ArcPath, 00111 OUT ULONG* x, 00112 OUT ULONG* y, 00113 OUT ULONG* z, 00114 OUT ULONG* Partition, 00115 OUT ULONG *PathSyntax) 00116 { 00117 /* Detect ramdisk() */ 00118 if (_strnicmp(ArcPath, "ramdisk(0)", 10) == 0) 00119 { 00120 *x = *y = *z = 0; 00121 *Partition = 1; 00122 *PathSyntax = 2; 00123 return TRUE; 00124 } 00125 /* Detect scsi()disk()rdisk()partition() */ 00126 else if (sscanf(ArcPath, "scsi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x, y, z, Partition) == 4) 00127 { 00128 *PathSyntax = 0; 00129 return TRUE; 00130 } 00131 /* Detect scsi()cdrom()fdisk() */ 00132 else if (sscanf(ArcPath, "scsi(%lu)cdrom(%lu)fdisk(%lu)", x, y, z) == 3) 00133 { 00134 *Partition = 0; 00135 *PathSyntax = 0; 00136 return TRUE; 00137 } 00138 /* Detect multi()disk()rdisk()partition() */ 00139 else if (sscanf(ArcPath, "multi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x, y, z, Partition) == 4) 00140 { 00141 *PathSyntax = 1; 00142 return TRUE; 00143 } 00144 /* Detect multi()disk()cdrom() */ 00145 else if (sscanf(ArcPath, "multi(%lu)disk(%lu)cdrom(%lu)", x, y, z) == 3) 00146 { 00147 *Partition = 1; 00148 *PathSyntax = 1; 00149 return TRUE; 00150 } 00151 /* Detect multi()disk()fdisk() */ 00152 else if (sscanf(ArcPath, "multi(%lu)disk(%lu)fdisk(%lu)", x, y, z) == 3) 00153 { 00154 *Partition = 1; 00155 *PathSyntax = 1; 00156 return TRUE; 00157 } 00158 00159 /* Unknown syntax */ 00160 return FALSE; 00161 } 00162 00163 00164 #if 0 00165 VOID ConstructArcPath(PCHAR ArcPath, PCHAR SystemFolder, UCHAR Disk, ULONG Partition) 00166 { 00167 char tmp[50]; 00168 00169 strcpy(ArcPath, "multi(0)disk(0)"); 00170 00171 if (Disk < 0x80) 00172 { 00173 /* 00174 * floppy disk path: 00175 * multi(0)disk(0)fdisk(x)\path 00176 */ 00177 sprintf(tmp, "fdisk(%d)", (int) Disk); 00178 strcat(ArcPath, tmp); 00179 } 00180 else 00181 { 00182 /* 00183 * hard disk path: 00184 * multi(0)disk(0)rdisk(x)partition(y)\path 00185 */ 00186 sprintf(tmp, "rdisk(%d)partition(%d)", (int) (Disk - 0x80), (int) Partition); 00187 strcat(ArcPath, tmp); 00188 } 00189 00190 if (SystemFolder[0] == '\\' || SystemFolder[0] == '/') 00191 { 00192 strcat(ArcPath, SystemFolder); 00193 } 00194 else 00195 { 00196 strcat(ArcPath, "\\"); 00197 strcat(ArcPath, SystemFolder); 00198 } 00199 } 00200 00201 UCHAR ConvertArcNameToBiosDriveNumber(PCHAR ArcPath) 00202 { 00203 char * p; 00204 UCHAR DriveNumber = 0; 00205 00206 if (_strnicmp(ArcPath, "multi(0)disk(0)", 15) != 0) 00207 return 0; 00208 00209 p = ArcPath + 15; 00210 if (_strnicmp(p, "fdisk(", 6) == 0) 00211 { 00212 /* 00213 * floppy disk path: 00214 * multi(0)disk(0)fdisk(x)\path 00215 */ 00216 p = p + 6; 00217 DriveNumber = atoi(p); 00218 } 00219 else if (_strnicmp(p, "rdisk(", 6) == 0) 00220 { 00221 /* 00222 * hard disk path: 00223 * multi(0)disk(0)rdisk(x)partition(y)\path 00224 */ 00225 p = p + 6; 00226 DriveNumber = atoi(p) + 0x80; 00227 } 00228 00229 return DriveNumber; 00230 } 00231 #endif Generated on Mon May 28 2012 04:19:00 for ReactOS by
1.7.6.1
|