OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium 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 COURGETTE_COURGETTE_H_ | 5 #ifndef COURGETTE_COURGETTE_H_ |
6 #define COURGETTE_COURGETTE_H_ | 6 #define COURGETTE_COURGETTE_H_ |
7 | 7 |
8 #include <stddef.h> // Required to define size_t on GCC | 8 #include <stddef.h> // Required to define size_t on GCC |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // to |output|. | 70 // to |output|. |
71 // Returns C_OK unless something went wrong. | 71 // Returns C_OK unless something went wrong. |
72 Status ApplyEnsemblePatch(SourceStream* old, SourceStream* patch, | 72 Status ApplyEnsemblePatch(SourceStream* old, SourceStream* patch, |
73 SinkStream* output); | 73 SinkStream* output); |
74 | 74 |
75 // Applies the patch in |patch_file_name| to the bytes in |old_file_name| and | 75 // Applies the patch in |patch_file_name| to the bytes in |old_file_name| and |
76 // writes the transformed ensemble to |new_file_name|. | 76 // writes the transformed ensemble to |new_file_name|. |
77 // Returns C_OK unless something went wrong. | 77 // Returns C_OK unless something went wrong. |
78 // This function first validates that the patch file has a proper header, so the | 78 // This function first validates that the patch file has a proper header, so the |
79 // function can be used to 'try' a patch. | 79 // function can be used to 'try' a patch. |
80 | |
81 Status ApplyEnsemblePatch(const FilePath::CharType* old_file_name, | 80 Status ApplyEnsemblePatch(const FilePath::CharType* old_file_name, |
82 const FilePath::CharType* patch_file_name, | 81 const FilePath::CharType* patch_file_name, |
83 const FilePath::CharType* new_file_name); | 82 const FilePath::CharType* new_file_name); |
84 | 83 |
85 // Generates a patch that will transform the bytes in |old| into the bytes in | 84 // Generates a patch that will transform the bytes in |old| into the bytes in |
86 // |target|. | 85 // |target|. |
87 // Returns C_OK unless something when wrong (unexpected). | 86 // Returns C_OK unless something when wrong (unexpected). |
88 Status GenerateEnsemblePatch(SourceStream* old, SourceStream* target, | 87 Status GenerateEnsemblePatch(SourceStream* old, SourceStream* target, |
89 SinkStream* patch); | 88 SinkStream* patch); |
90 | 89 |
(...skipping 14 matching lines...) Expand all Loading... |
105 // Returns C_OK if successful, otherwise returns an error status and sets | 104 // Returns C_OK if successful, otherwise returns an error status and sets |
106 // |*output| to NULL. | 105 // |*output| to NULL. |
107 Status ParseDetectedExecutable(const void* buffer, size_t length, | 106 Status ParseDetectedExecutable(const void* buffer, size_t length, |
108 AssemblyProgram** output); | 107 AssemblyProgram** output); |
109 | 108 |
110 // Converts |program| into encoded form, returning it as |*output|. | 109 // Converts |program| into encoded form, returning it as |*output|. |
111 // Returns C_OK if succeeded, otherwise returns an error status and | 110 // Returns C_OK if succeeded, otherwise returns an error status and |
112 // sets |*output| to NULL | 111 // sets |*output| to NULL |
113 Status Encode(AssemblyProgram* program, EncodedProgram** output); | 112 Status Encode(AssemblyProgram* program, EncodedProgram** output); |
114 | 113 |
115 | |
116 // Serializes |encoded| into the stream set. | 114 // Serializes |encoded| into the stream set. |
117 // Returns C_OK if succeeded, otherwise returns an error status. | 115 // Returns C_OK if succeeded, otherwise returns an error status. |
118 Status WriteEncodedProgram(EncodedProgram* encoded, SinkStreamSet* sink); | 116 Status WriteEncodedProgram(EncodedProgram* encoded, SinkStreamSet* sink); |
119 | 117 |
120 // Assembles |encoded|, emitting the bytes into |buffer|. | 118 // Assembles |encoded|, emitting the bytes into |buffer|. |
121 // Returns C_OK if succeeded, otherwise returns an error status and leaves | 119 // Returns C_OK if succeeded, otherwise returns an error status and leaves |
122 // |buffer| in an undefined state. | 120 // |buffer| in an undefined state. |
123 Status Assemble(EncodedProgram* encoded, SinkStream* buffer); | 121 Status Assemble(EncodedProgram* encoded, SinkStream* buffer); |
124 | 122 |
125 // Deserializes program from the stream set. | 123 // Deserializes program from the stream set. |
126 // Returns C_OK if succeeded, otherwise returns an error status and | 124 // Returns C_OK if succeeded, otherwise returns an error status and |
127 // sets |*output| to NULL | 125 // sets |*output| to NULL |
128 Status ReadEncodedProgram(SourceStreamSet* source, EncodedProgram** output); | 126 Status ReadEncodedProgram(SourceStreamSet* source, EncodedProgram** output); |
129 | 127 |
130 // Used to free an AssemblyProgram returned by other APIs. | 128 // Used to free an AssemblyProgram returned by other APIs. |
131 void DeleteAssemblyProgram(AssemblyProgram* program); | 129 void DeleteAssemblyProgram(AssemblyProgram* program); |
132 | 130 |
133 // Used to free an EncodedProgram returned by other APIs. | 131 // Used to free an EncodedProgram returned by other APIs. |
134 void DeleteEncodedProgram(EncodedProgram* encoded); | 132 void DeleteEncodedProgram(EncodedProgram* encoded); |
135 | 133 |
136 // Adjusts |program| to look more like |model|. | 134 // Adjusts |program| to look more like |model|. |
137 // | 135 // |
138 Status Adjust(const AssemblyProgram& model, AssemblyProgram *program); | 136 Status Adjust(const AssemblyProgram& model, AssemblyProgram *program); |
139 | 137 |
140 } // namespace courgette | 138 } // namespace courgette |
141 #endif // COURGETTE_COURGETTE_H_ | 139 #endif // COURGETTE_COURGETTE_H_ |
OLD | NEW |