1 /* This program is copyright (c) 2009 by Roderick W. Smith. It is distributed
2 under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
11 #define GPTFDISK_VERSION "0.8.5"
13 #if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
14 // Darwin (Mac OS) & FreeBSD: disk IOCTLs are different, and there is no lseek64
19 #if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
20 #define DEFAULT_TYPE 0xA503
24 #define DEFAULT_TYPE 0xAF00
28 #define DEFAULT_TYPE 0x0700
31 // Microsoft Visual C++ only
32 #if defined (_MSC_VER)
33 #define sscanf sscanf_s
34 #define strcpy strcpy_s
35 #define sprintf sprintf_s
41 #define DEFAULT_TYPE 0x8300
45 #define DEFAULT_TYPE 0x8300
48 // Set this as a default
49 #define SECTOR_SIZE UINT32_C(512)
51 // Signatures for Apple (APM) disks, multiplied by 0x100000000
52 #define APM_SIGNATURE1 UINT64_C(0x00004D5000000000)
53 #define APM_SIGNATURE2 UINT64_C(0x0000535400000000)
55 /**************************
56 * Some GPT constants.... *
57 **************************/
59 #define GPT_SIGNATURE UINT64_C(0x5452415020494645)
61 // Number and size of GPT entries...
62 #define NUM_GPT_ENTRIES 128
64 #define HEADER_SIZE UINT32_C(92)
65 #define GPT_RESERVED 420
70 string ReadString(void);
71 int GetNumber(int low, int high, int def, const string & prompt);
73 uint64_t GetSectorNum(uint64_t low, uint64_t high, uint64_t def, uint64_t sSize, const std::string& prompt);
74 uint64_t IeeeToInt(string IeeeValue, uint64_t sSize, uint64_t low, uint64_t high, uint64_t def = 0);
75 string BytesToIeee(uint64_t size, uint32_t sectorSize);
76 unsigned char StrToHex(const string & input, unsigned int position);
77 int IsHex(string input); // Returns 1 if input can be hexadecimal number....
78 int IsLittleEndian(void); // Returns 1 if CPU is little-endian, 0 if it's big-endian
79 void ReverseBytes(void* theValue, int numBytes); // Reverses byte-order of theValue
80 void WinWarning(void);