srs5694 | 221e087 | 2009-08-29 15:00:31 -0400 | [diff] [blame] | 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. */ |
| 3 | |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 4 | #include <stdint.h> |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 5 | #include <stdlib.h> |
srs5694 | fed16d0 | 2010-01-27 23:03:40 -0500 | [diff] [blame] | 6 | #include <string> |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 7 | #include "support.h" |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 8 | #include "guid.h" |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 9 | |
| 10 | #ifndef __PARTITION_TYPES |
| 11 | #define __PARTITION_TYPES |
| 12 | |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 13 | using namespace std; |
| 14 | |
| 15 | // A partition type |
| 16 | struct 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; |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 21 | GUIDData GUIDType; |
srs5694 | e321d44 | 2010-01-29 17:44:04 -0500 | [diff] [blame] | 22 | string name; |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 23 | int display; // 1 to show to users as available type, 0 not to |
| 24 | AType* next; |
| 25 | }; // struct AType |
| 26 | |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 27 | class PartType : public GUIDData { |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 28 | protected: |
| 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 |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 32 | void AddAllTypes(void); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 33 | public: |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 34 | 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 | |
srs5694 | 82f3f0b | 2010-09-22 10:50:24 -0400 | [diff] [blame^] | 42 | // New assignment operators.... |
| 43 | PartType & operator=(const string & orig); |
| 44 | PartType & operator=(const char * orig); |
| 45 | |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 46 | // Assignment operators based on base class.... |
| 47 | GUIDData & operator=(const GUIDData & orig) {return GUIDData::operator=(orig);} |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 48 | |
| 49 | // New data assignment |
srs5694 | cb76c67 | 2010-02-11 22:22:22 -0500 | [diff] [blame] | 50 | PartType & operator=(uint16_t ID); // Use MBR type code times 0x0100 to assign GUID |
srs5694 | 6699b01 | 2010-02-04 00:55:30 -0500 | [diff] [blame] | 51 | |
| 52 | // Retrieve transformed GUID data based on type code matches |
| 53 | string TypeName(void); |
| 54 | uint16_t GetHexType(); |
| 55 | |
| 56 | // Information relating to all type data |
| 57 | void ShowAllTypes(void); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 58 | int Valid(uint16_t); |
srs5694 | e7b4ff9 | 2009-08-18 13:16:10 -0400 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | #endif |