| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_ | 5 #ifndef VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_ |
| 6 #define VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_ | 6 #define VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_ |
| 7 | 7 |
| 8 #define _GNU_SOURCE | 8 #define _GNU_SOURCE |
| 9 #define _FILE_OFFSET_BITS 64 | 9 #define _FILE_OFFSET_BITS 64 |
| 10 #include <features.h> | 10 #include <features.h> |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 int IsZero(const Guid *guid); | 75 int IsZero(const Guid *guid); |
| 76 | 76 |
| 77 | 77 |
| 78 int ReadPMBR(struct drive *drive); | 78 int ReadPMBR(struct drive *drive); |
| 79 int WritePMBR(struct drive *drive); | 79 int WritePMBR(struct drive *drive); |
| 80 | 80 |
| 81 | 81 |
| 82 /* Convert possibly unterminated UTF16 string to UTF8. | 82 /* Convert possibly unterminated UTF16 string to UTF8. |
| 83 * Caller must prepare enough space for UTF8, which could be up to | 83 * Caller must prepare enough space for UTF8, which could be up to |
| 84 * twice the number of UTF16 chars plus the terminating '\0'. | 84 * twice the number of UTF16 chars plus the terminating '\0'. |
| 85 * |
| 86 * Return: CGPT_OK --- all character are converted successfully. |
| 87 * CGPT_FAILED --- convert error, i.e. output buffer is too short. |
| 85 */ | 88 */ |
| 86 void UTF16ToUTF8(const uint16_t *utf16, unsigned int maxinput, | 89 int UTF16ToUTF8(const uint16_t *utf16, unsigned int maxinput, |
| 87 uint8_t *utf8, unsigned int maxoutput); | 90 uint8_t *utf8, unsigned int maxoutput); |
| 88 /* Convert null-terminated UTF8 string to UTF16. | 91 /* Convert null-terminated UTF8 string to UTF16. |
| 89 * Caller must prepare enough space for UTF16, including a terminating 0x0000 | 92 * Caller must prepare enough space for UTF16, including a terminating 0x0000 |
| 93 * |
| 94 * Return: CGPT_OK --- all character are converted successfully. |
| 95 * CGPT_FAILED --- convert error, i.e. output buffer is too short. |
| 90 */ | 96 */ |
| 91 void UTF8ToUTF16(const uint8_t *utf8, uint16_t *utf16, unsigned int maxoutput); | 97 int UTF8ToUTF16(const uint8_t *utf8, uint16_t *utf16, unsigned int maxoutput); |
| 92 | 98 |
| 93 /* Helper functions for supported GPT types. */ | 99 /* Helper functions for supported GPT types. */ |
| 94 int ResolveType(const Guid *type, char *buf); | 100 int ResolveType(const Guid *type, char *buf); |
| 95 int SupportedType(const char *name, Guid *type); | 101 int SupportedType(const char *name, Guid *type); |
| 96 void PrintTypes(void); | 102 void PrintTypes(void); |
| 97 void EntryDetails(GptEntry *entry, uint32_t index, int raw); | 103 void EntryDetails(GptEntry *entry, uint32_t index, int raw); |
| 98 | 104 |
| 99 uint32_t GetNumberOfEntries(const GptData *gpt); | 105 uint32_t GetNumberOfEntries(const GptData *gpt); |
| 100 GptEntry *GetEntry(GptData *gpt, int secondary, uint32_t entry_index); | 106 GptEntry *GetEntry(GptData *gpt, int secondary, uint32_t entry_index); |
| 101 void SetPriority(GptData *gpt, int secondary, uint32_t entry_index, | 107 void SetPriority(GptData *gpt, int secondary, uint32_t entry_index, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 /* The standard "assert" macro goes away when NDEBUG is defined. This doesn't. | 141 /* The standard "assert" macro goes away when NDEBUG is defined. This doesn't. |
| 136 */ | 142 */ |
| 137 #define require(A) do { \ | 143 #define require(A) do { \ |
| 138 if (!(A)) { \ | 144 if (!(A)) { \ |
| 139 fprintf(stderr, "condition (%s) failed at %s:%d\n", \ | 145 fprintf(stderr, "condition (%s) failed at %s:%d\n", \ |
| 140 #A, __FILE__, __LINE__); \ | 146 #A, __FILE__, __LINE__); \ |
| 141 exit(1); } \ | 147 exit(1); } \ |
| 142 } while (0) | 148 } while (0) |
| 143 | 149 |
| 144 #endif // VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_ | 150 #endif // VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_ |
| OLD | NEW |