ReactOS  0.4.14-dev-49-gfb4591c
drivemap.c File Reference
#include <freeldr.h>
#include <debug.h>
Include dependency graph for drivemap.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (DISK)
 
BOOLEAN DriveMapIsValidDriveString (PCSTR DriveString)
 
UCHAR DriveMapGetBiosDriveNumber (PCSTR DeviceName)
 

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( DISK  )

◆ DriveMapGetBiosDriveNumber()

UCHAR DriveMapGetBiosDriveNumber ( PCSTR  DeviceName)

Definition at line 66 of file drivemap.c.

67 {
68  UCHAR BiosDriveNumber = 0;
69 
70  TRACE("DriveMapGetBiosDriveNumber(%s)\n", DeviceName);
71 
72  // If they passed in a number string then just
73  // convert it to decimal and return it
74  if (DeviceName[0] >= '0' && DeviceName[0] <= '9')
75  {
76  return (UCHAR)strtoul(DeviceName, NULL, 0);
77  }
78 
79  // Convert the drive number string into a number
80  // 'hd1' = 1
81  BiosDriveNumber = atoi(&DeviceName[2]);
82 
83  // If it's a hard disk then set the high bit
84  if ((DeviceName[0] == 'h' || DeviceName[0] == 'H') &&
85  (DeviceName[1] == 'd' || DeviceName[1] == 'D'))
86  {
87  BiosDriveNumber |= 0x80;
88  }
89 
90  return BiosDriveNumber;
91 }
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
WCHAR DeviceName[]
Definition: adapter.cpp:21
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned char UCHAR
Definition: xmlstorage.h:181
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)

◆ DriveMapIsValidDriveString()

BOOLEAN DriveMapIsValidDriveString ( PCSTR  DriveString)

Definition at line 34 of file drivemap.c.

35 {
36  ULONG Index;
37 
38  // Now verify that the user has given us appropriate strings
39  if ((strlen(DriveString) < 3) ||
40  ((DriveString[0] != 'f') && (DriveString[0] != 'F') &&
41  (DriveString[0] != 'h') && (DriveString[0] != 'H')) ||
42  ((DriveString[1] != 'd') && (DriveString[1] != 'D')))
43  {
44  return FALSE;
45  }
46 
47  // Now verify that the user has given us appropriate numbers
48  // Make sure that only numeric characters were given
49  for (Index = 2; Index < strlen(DriveString); Index++)
50  {
51  if (DriveString[Index] < '0' || DriveString[Index] > '9')
52  {
53  return FALSE;
54  }
55  }
56 
57  // Now make sure that they are not outrageous values (i.e. hd90874)
58  if ((atoi(&DriveString[2]) < 0) || (atoi(&DriveString[2]) > 0xff))
59  {
60  return FALSE;
61  }
62 
63  return TRUE;
64 }
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static const UCHAR Index[8]
Definition: usbohci.c:18
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
unsigned int ULONG
Definition: retypes.h:1