James Zern | 061263a | 2012-05-11 16:00:57 -0700 | [diff] [blame] | 1 | // Copyright 2012 Google Inc. All Rights Reserved. |
| 2 | // |
James Zern | d640614 | 2013-06-06 23:05:58 -0700 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license |
| 4 | // that can be found in the COPYING file in the root of the source |
| 5 | // tree. An additional intellectual property rights grant can be found |
| 6 | // in the file PATENTS. All contributing project authors may |
| 7 | // be found in the AUTHORS file in the root of the source tree. |
James Zern | 061263a | 2012-05-11 16:00:57 -0700 | [diff] [blame] | 8 | // ----------------------------------------------------------------------------- |
| 9 | // |
| 10 | // Utility functions used by the example programs. |
| 11 | // |
| 12 | |
| 13 | #ifndef WEBP_EXAMPLES_EXAMPLE_UTIL_H_ |
| 14 | #define WEBP_EXAMPLES_EXAMPLE_UTIL_H_ |
| 15 | |
| 16 | #include "webp/types.h" |
| 17 | |
James Zern | 605a712 | 2013-11-25 14:43:12 -0800 | [diff] [blame] | 18 | #ifdef __cplusplus |
James Zern | 061263a | 2012-05-11 16:00:57 -0700 | [diff] [blame] | 19 | extern "C" { |
| 20 | #endif |
| 21 | |
| 22 | // Allocates storage for entire file 'file_name' and returns contents and size |
| 23 | // in 'data' and 'data_size'. Returns 1 on success, 0 otherwise. '*data' should |
| 24 | // be deleted using free(). |
| 25 | int ExUtilReadFile(const char* const file_name, |
| 26 | const uint8_t** data, size_t* data_size); |
| 27 | |
Urvang Joshi | e9a15a3 | 2012-11-07 14:41:15 -0800 | [diff] [blame] | 28 | // Write a data segment into a file named 'file_name'. Returns true if ok. |
| 29 | int ExUtilWriteFile(const char* const file_name, |
| 30 | const uint8_t* data, size_t data_size); |
| 31 | |
James Zern | 605a712 | 2013-11-25 14:43:12 -0800 | [diff] [blame] | 32 | #ifdef __cplusplus |
James Zern | 061263a | 2012-05-11 16:00:57 -0700 | [diff] [blame] | 33 | } // extern "C" |
| 34 | #endif |
| 35 | |
| 36 | #endif // WEBP_EXAMPLES_EXAMPLE_UTIL_H_ |