File: support.h

package info (click to toggle)
gdisk 1.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 940 kB
  • sloc: cpp: 8,692; sh: 244; makefile: 48
file content (87 lines) | stat: -rw-r--r-- 2,484 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* This program is copyright (c) 2009-2018 by Roderick W. Smith. It is distributed
  under the terms of the GNU GPL version 2, as detailed in the COPYING file. */

#include <stdint.h>
#include <stdlib.h>
#include <string>

#ifndef __GPTSUPPORT
#define __GPTSUPPORT

#define GPTFDISK_VERSION "1.0.5"

#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
// Darwin (Mac OS) & FreeBSD: disk IOCTLs are different, and there is no lseek64
#include <sys/disk.h>
#define lseek64 lseek
#endif

#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
#define DEFAULT_GPT_TYPE 0xA503
#endif

#ifdef __APPLE__
#define DEFAULT_GPT_TYPE 0xAF00
#endif

#ifdef _WIN32
#define DEFAULT_GPT_TYPE 0x0700
#endif

#ifdef __sun__
#define DEFAULT_GPT_TYPE 0xbf01
#endif

// Microsoft Visual C++ only
#if defined (_MSC_VER)
#define sscanf sscanf_s
#define strcpy strcpy_s
#define sprintf sprintf_s
#endif

// Linux only....
#ifdef __linux__
#include <linux/fs.h>
#define DEFAULT_GPT_TYPE 0x8300
#endif

#ifndef DEFAULT_GPT_TYPE
#define DEFAULT_GPT_TYPE 0x8300
#endif

// Set this as a default
#define SECTOR_SIZE UINT32_C(512)

// Signatures for Apple (APM) disks, multiplied by 0x100000000
#define APM_SIGNATURE1 UINT64_C(0x00004D5000000000)
#define APM_SIGNATURE2 UINT64_C(0x0000535400000000)

/**************************
 * Some GPT constants.... *
 **************************/

#define GPT_SIGNATURE UINT64_C(0x5452415020494645)

// Number and size of GPT entries...
#define NUM_GPT_ENTRIES 128
#define GPT_SIZE 128
#define HEADER_SIZE UINT32_C(92)
#define GPT_RESERVED 420
#define NAME_SIZE 36 // GPT allows 36 UTF-16LE code units for a name in a 128 byte partition entry

using namespace std;

string ReadString(void);
uint64_t GetNumber(uint64_t low, uint64_t high, uint64_t def, const string & prompt);
char GetYN(void);
uint64_t GetSectorNum(uint64_t low, uint64_t high, uint64_t def, uint64_t sSize, const std::string& prompt);
uint64_t IeeeToInt(string IeeeValue, uint64_t sSize, uint64_t low, uint64_t high, uint64_t def = 0);
string BytesToIeee(uint64_t size, uint32_t sectorSize);
unsigned char StrToHex(const string & input, unsigned int position);
int IsHex(string input); // Returns 1 if input can be hexadecimal number....
int IsLittleEndian(void); // Returns 1 if CPU is little-endian, 0 if it's big-endian
void ReverseBytes(void* theValue, int numBytes); // Reverses byte-order of theValue
void WinWarning(void);
string ToLower(const string& input);

#endif