ReactOS  0.4.13-dev-257-gfabbd7c
arcname.c File Reference
#include <freeldr.h>
Include dependency graph for arcname.c:

Go to the source code of this file.

Functions

BOOLEAN DissectArcPath (CHAR *ArcPath, CHAR *BootPath, UCHAR *BootDrive, ULONG *BootPartition)
 
BOOLEAN DissectArcPath2 (IN CHAR *ArcPath, OUT ULONG *x, OUT ULONG *y, OUT ULONG *z, OUT ULONG *Partition, OUT ULONG *PathSyntax)
 
VOID ConstructArcPath (PCHAR ArcPath, PCHAR SystemFolder, UCHAR Disk, ULONG Partition)
 

Function Documentation

◆ ConstructArcPath()

VOID ConstructArcPath ( PCHAR  ArcPath,
PCHAR  SystemFolder,
UCHAR  Disk,
ULONG  Partition 
)

Definition at line 157 of file arcname.c.

158 {
159  char tmp[50];
160 
161  strcpy(ArcPath, "multi(0)disk(0)");
162 
163  if (Disk < 0x80)
164  {
165  /*
166  * Floppy disk path:
167  * multi(0)disk(0)fdisk(x)\path
168  */
169  sprintf(tmp, "fdisk(%d)", (int) Disk);
170  strcat(ArcPath, tmp);
171  }
172  else
173  {
174  /*
175  * Hard disk path:
176  * multi(0)disk(0)rdisk(x)partition(y)\path
177  */
178  sprintf(tmp, "rdisk(%d)partition(%d)", (int) (Disk - 0x80), (int) Partition);
179  strcat(ArcPath, tmp);
180  }
181 
182  if (SystemFolder[0] == '\\' || SystemFolder[0] == '/')
183  {
184  strcat(ArcPath, SystemFolder);
185  }
186  else
187  {
188  strcat(ArcPath, "\\");
189  strcat(ArcPath, SystemFolder);
190  }
191 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define sprintf(buf, format,...)
Definition: sprintf.c:55
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388

Referenced by OptionMenuCustomBootReactOS().

◆ DissectArcPath()

BOOLEAN DissectArcPath ( CHAR ArcPath,
CHAR BootPath,
UCHAR BootDrive,
ULONG BootPartition 
)

Definition at line 24 of file arcname.c.

25 {
26  char *p;
27 
28  /* Detect ramdisk path */
29  if (_strnicmp(ArcPath, "ramdisk(0)", 10) == 0)
30  {
31  /* Magic value for ramdisks */
32  *BootDrive = 0x49;
33  *BootPartition = 1;
34 
35  /* Get the path */
36  p = ArcPath + 11;
37  strcpy(BootPath, p);
38  return TRUE;
39  }
40 
41  if (_strnicmp(ArcPath, "multi(0)disk(0)", 15) != 0)
42  return FALSE;
43 
44  p = ArcPath + 15;
45  if (_strnicmp(p, "fdisk(", 6) == 0)
46  {
47  /*
48  * Floppy disk path:
49  * multi(0)disk(0)fdisk(x)\path
50  */
51  p = p + 6;
52  *BootDrive = atoi(p);
53  p = strchr(p, ')');
54  if (p == NULL)
55  return FALSE;
56  p++;
57  *BootPartition = 0;
58  }
59  else if (_strnicmp(p, "cdrom(", 6) == 0)
60  {
61  /*
62  * Cdrom path:
63  * multi(0)disk(0)cdrom(x)\path
64  */
65  p = p + 6;
66  *BootDrive = atoi(p) + 0x80;
67  p = strchr(p, ')');
68  if (p == NULL)
69  return FALSE;
70  p++;
71  *BootPartition = 0xff;
72  }
73  else if (_strnicmp(p, "rdisk(", 6) == 0)
74  {
75  /*
76  * Hard disk path:
77  * multi(0)disk(0)rdisk(x)partition(y)\path
78  */
79  p = p + 6;
80  *BootDrive = atoi(p) + 0x80;
81  p = strchr(p, ')');
82  if ((p == NULL) || (_strnicmp(p, ")partition(", 11) != 0))
83  return FALSE;
84  p = p + 11;
85  *BootPartition = atoi(p);
86  p = strchr(p, ')');
87  if (p == NULL)
88  return FALSE;
89  p++;
90  }
91  else
92  {
93  return FALSE;
94  }
95 
96  strcpy(BootPath, p);
97 
98  return TRUE;
99 }
#define TRUE
Definition: types.h:120
_Check_return_ _CRTIMP int __cdecl _strnicmp(_In_reads_or_z_(_MaxCount) const char *_Str1, _In_reads_or_z_(_MaxCount) const char *_Str2, _In_ size_t _MaxCount)
smooth NULL
Definition: ftsmooth.c:416
char * strchr(const char *String, int ch)
Definition: utclib.c:501
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
GLfloat GLfloat p
Definition: glext.h:8902
char BootPath[0x100]
Definition: mach.c:35

Referenced by DiskOpen().

◆ DissectArcPath2()

BOOLEAN DissectArcPath2 ( IN CHAR ArcPath,
OUT ULONG x,
OUT ULONG y,
OUT ULONG z,
OUT ULONG Partition,
OUT ULONG PathSyntax 
)

Definition at line 103 of file arcname.c.

110 {
111  /* Detect ramdisk() */
112  if (_strnicmp(ArcPath, "ramdisk(0)", 10) == 0)
113  {
114  *x = *y = *z = 0;
115  *Partition = 1;
116  *PathSyntax = 2;
117  return TRUE;
118  }
119  /* Detect scsi()disk()rdisk()partition() */
120  else if (sscanf(ArcPath, "scsi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x, y, z, Partition) == 4)
121  {
122  *PathSyntax = 0;
123  return TRUE;
124  }
125  /* Detect scsi()cdrom()fdisk() */
126  else if (sscanf(ArcPath, "scsi(%lu)cdrom(%lu)fdisk(%lu)", x, y, z) == 3)
127  {
128  *Partition = 0;
129  *PathSyntax = 0;
130  return TRUE;
131  }
132  /* Detect multi()disk()rdisk()partition() */
133  else if (sscanf(ArcPath, "multi(%lu)disk(%lu)rdisk(%lu)partition(%lu)", x, y, z, Partition) == 4)
134  {
135  *PathSyntax = 1;
136  return TRUE;
137  }
138  /* Detect multi()disk()cdrom() */
139  else if (sscanf(ArcPath, "multi(%lu)disk(%lu)cdrom(%lu)", x, y, z) == 3)
140  {
141  *Partition = 1;
142  *PathSyntax = 1;
143  return TRUE;
144  }
145  /* Detect multi()disk()fdisk() */
146  else if (sscanf(ArcPath, "multi(%lu)disk(%lu)fdisk(%lu)", x, y, z) == 3)
147  {
148  *Partition = 1;
149  *PathSyntax = 1;
150  return TRUE;
151  }
152 
153  /* Unknown syntax */
154  return FALSE;
155 }
#define TRUE
Definition: types.h:120
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
_Check_return_ _CRTIMP int __cdecl _strnicmp(_In_reads_or_z_(_MaxCount) const char *_Str1, _In_reads_or_z_(_MaxCount) const char *_Str2, _In_ size_t _MaxCount)
GLdouble GLdouble z
Definition: glext.h:5874
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by DiskOpen().