blob: 9f38b76b1098c9af8a61c323a2c330ffc5b68411 [file] [log] [blame]
srs5694221e0872009-08-29 15:00:31 -04001/* 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. */
3
srs5694e7b4ff92009-08-18 13:16:10 -04004#include <stdint.h>
srs5694e7b4ff92009-08-18 13:16:10 -04005#include <stdlib.h>
srs5694fed16d02010-01-27 23:03:40 -05006#include <string>
srs5694e7b4ff92009-08-18 13:16:10 -04007#include "support.h"
srs56946699b012010-02-04 00:55:30 -05008#include "guid.h"
srs5694e7b4ff92009-08-18 13:16:10 -04009
10#ifndef __PARTITION_TYPES
11#define __PARTITION_TYPES
12
srs5694e7b4ff92009-08-18 13:16:10 -040013using namespace std;
14
15// A partition type
16struct AType {
17 // I'm using a custom 16-bit extension of the original MBR 8-bit
18 // type codes, so as to permit disambiguation and use of new
19 // codes required by GPT
20 uint16_t MBRType;
srs56946699b012010-02-04 00:55:30 -050021 GUIDData GUIDType;
srs5694e321d442010-01-29 17:44:04 -050022 string name;
srs5694e7b4ff92009-08-18 13:16:10 -040023 int display; // 1 to show to users as available type, 0 not to
24 AType* next;
25}; // struct AType
26
srs56946699b012010-02-04 00:55:30 -050027class PartType : public GUIDData {
srs5694e7b4ff92009-08-18 13:16:10 -040028protected:
29 static int numInstances;
30 static AType* allTypes; // Linked list holding all the data
31 static AType* lastType; // Pointer to last entry in the list
srs56946699b012010-02-04 00:55:30 -050032 void AddAllTypes(void);
srs5694e7b4ff92009-08-18 13:16:10 -040033public:
srs56946699b012010-02-04 00:55:30 -050034 PartType(void);
35 PartType(const PartType & orig);
36 PartType(const GUIDData & orig);
37 ~PartType(void);
38
39 // Set up type information
40 int AddType(uint16_t mbrType, const char * guidData, const char * name, int toDisplay = 1);
41
srs569482f3f0b2010-09-22 10:50:24 -040042 // New assignment operators....
43 PartType & operator=(const string & orig);
44 PartType & operator=(const char * orig);
45
srs56946699b012010-02-04 00:55:30 -050046 // Assignment operators based on base class....
47 GUIDData & operator=(const GUIDData & orig) {return GUIDData::operator=(orig);}
srs56946699b012010-02-04 00:55:30 -050048
49 // New data assignment
srs5694cb76c672010-02-11 22:22:22 -050050 PartType & operator=(uint16_t ID); // Use MBR type code times 0x0100 to assign GUID
srs56946699b012010-02-04 00:55:30 -050051
52 // Retrieve transformed GUID data based on type code matches
srs56945a081752010-09-24 20:39:41 -040053 string TypeName(void) const;
54 uint16_t GetHexType() const;
srs56946699b012010-02-04 00:55:30 -050055
56 // Information relating to all type data
srs56945a081752010-09-24 20:39:41 -040057 void ShowAllTypes(void) const;
58 int Valid(uint16_t code) const;
srs5694e7b4ff92009-08-18 13:16:10 -040059};
60
61#endif