libarmutils  1.4
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups
file_buffer.h
1 /*******************************************************************************
2 *
3 * COPYRIGHT (C) 2017 Battelle Memorial Institute. All Rights Reserved.
4 *
5 ********************************************************************************
6 *
7 * Author:
8 * name: Brian Ermold
9 * phone: (509) 375-2277
10 * email: brian.ermold@pnl.gov
11 *
12 ********************************************************************************
13 *
14 * REPOSITORY INFORMATION:
15 * $Revision:$
16 * $Author:$
17 * $Date:$
18 *
19 ********************************************************************************
20 *
21 * NOTE: DOXYGEN is used to generate documentation for this file.
22 *
23 *******************************************************************************/
24 
25 /** @file_buffer.h
26 * File Buffer Header.
27 */
28 
29 #ifndef _FILE_BUFFER_H
30 #define _FILE_BUFFER_H
31 
32 #include <sys/stat.h>
33 
34 /**
35  * @defgroup ARMUTILS_FILE_BUFFER File Buffer
36  */
37 /*@{*/
38 
39 /** FileBuffer Structure. */
40 typedef struct FileBuffer {
41 
42  const char *full_path; /**< full path to the file */
43  struct stat *stats; /**< file stats */
44  size_t length; /**< size of the file in bytes */
45  char *data; /**< in memory copy of the file */
46  size_t data_nalloced; /**< allocated length of data buffer */
47 
48  /* used by file_buffer_split_lines() */
49 
50  char **lines; /**< array of line pointers created by
51  file_buffer_split_lines() */
52  size_t nlines; /**< number of lines */
53  size_t lines_nalloced; /**< allocated length of lines array */
54 
55 } FileBuffer;
56 
60  FileBuffer *fbuf,
61  const char *full_path,
62  char **data);
63 
65  FileBuffer *fbuf,
66  int *nlines,
67  char ***lines);
68 
69 /*@}*/
70 
71 #endif /* _FILE_BUFFER_H */