Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: cgpt/cgpt.h

Issue 5025003: The right implementation of CGPT label conversion between UTF8 and UTF16. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: Fixed per code review opinion. Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | cgpt/cgpt_common.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 void GuidToStr(const Guid *guid, char *str, unsigned int buflen); 74 void GuidToStr(const Guid *guid, char *str, unsigned int buflen);
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 byte length of UTF16 string 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);
91
88 /* Convert null-terminated UTF8 string to UTF16. 92 /* Convert null-terminated UTF8 string to UTF16.
89 * Caller must prepare enough space for UTF16, including a terminating 0x0000 93 * Caller must prepare enough space for UTF16, which is the byte length of UTF8
94 * plus the terminating 0x0000.
95 *
96 * Return: CGPT_OK --- all character are converted successfully.
97 * CGPT_FAILED --- convert error, i.e. output buffer is too short.
90 */ 98 */
91 void UTF8ToUTF16(const uint8_t *utf8, uint16_t *utf16, unsigned int maxoutput); 99 int UTF8ToUTF16(const uint8_t *utf8, uint16_t *utf16, unsigned int maxoutput);
92 100
93 /* Helper functions for supported GPT types. */ 101 /* Helper functions for supported GPT types. */
94 int ResolveType(const Guid *type, char *buf); 102 int ResolveType(const Guid *type, char *buf);
95 int SupportedType(const char *name, Guid *type); 103 int SupportedType(const char *name, Guid *type);
96 void PrintTypes(void); 104 void PrintTypes(void);
97 void EntryDetails(GptEntry *entry, uint32_t index, int raw); 105 void EntryDetails(GptEntry *entry, uint32_t index, int raw);
98 106
99 uint32_t GetNumberOfEntries(const GptData *gpt); 107 uint32_t GetNumberOfEntries(const GptData *gpt);
100 GptEntry *GetEntry(GptData *gpt, int secondary, uint32_t entry_index); 108 GptEntry *GetEntry(GptData *gpt, int secondary, uint32_t entry_index);
101 void SetPriority(GptData *gpt, int secondary, uint32_t entry_index, 109 void SetPriority(GptData *gpt, int secondary, uint32_t entry_index,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 /* The standard "assert" macro goes away when NDEBUG is defined. This doesn't. 143 /* The standard "assert" macro goes away when NDEBUG is defined. This doesn't.
136 */ 144 */
137 #define require(A) do { \ 145 #define require(A) do { \
138 if (!(A)) { \ 146 if (!(A)) { \
139 fprintf(stderr, "condition (%s) failed at %s:%d\n", \ 147 fprintf(stderr, "condition (%s) failed at %s:%d\n", \
140 #A, __FILE__, __LINE__); \ 148 #A, __FILE__, __LINE__); \
141 exit(1); } \ 149 exit(1); } \
142 } while (0) 150 } while (0)
143 151
144 #endif // VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_ 152 #endif // VBOOT_REFERENCE_UTILITY_CGPT_CGPT_H_
OLDNEW
« no previous file with comments | « no previous file | cgpt/cgpt_common.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698