1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * Trivial managed buffer structure
17  */
18 
19 #ifndef ESE_REPLAY_BUFFER_H__
20 #define ESE_REPLAY_BUFFER_H__ 1
21 
22 #include <ctype.h>
23 #include <stdint.h>
24 #include <stdbool.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include <unistd.h>
29 
30 struct Buffer {
31   uint32_t len;
32   uint32_t size;
33   uint8_t *buffer;
34 };
35 
36 bool buffer_init(struct Buffer *b, uint32_t len);
37 void buffer_free(struct Buffer *b);
38 bool buffer_read_hex(struct Buffer *b, FILE *fp, bool consume_newline);
39 void buffer_dump(const struct Buffer *b, const char *prefix, const char *name,
40                  uint32_t limit, FILE *fp);
41 
42 #endif  /* ESE_REPLAY_BUFFER_H__ */
43