util.h (c1144d29f405ce1f4e6ede6482beb3d0d09750c6) util.h (f858927fd6ce394a7f431153d44ad0a09e8f49a1)
1#ifndef UTIL_H
2#define UTIL_H
3
4#include <stdarg.h>
5#include <stdbool.h>
6#include <getopt.h>
7
8/*

--- 84 unchanged lines hidden (view full) ---

93 */
94char get_escape_char(const char *s, int *i);
95
96/**
97 * Read a device tree file into a buffer. This will report any errors on
98 * stderr.
99 *
100 * @param filename The filename to read, or - for stdin
1#ifndef UTIL_H
2#define UTIL_H
3
4#include <stdarg.h>
5#include <stdbool.h>
6#include <getopt.h>
7
8/*

--- 84 unchanged lines hidden (view full) ---

93 */
94char get_escape_char(const char *s, int *i);
95
96/**
97 * Read a device tree file into a buffer. This will report any errors on
98 * stderr.
99 *
100 * @param filename The filename to read, or - for stdin
101 * @param len If non-NULL, the amount of data we managed to read
101 * @return Pointer to allocated buffer containing fdt, or NULL on error
102 */
102 * @return Pointer to allocated buffer containing fdt, or NULL on error
103 */
103char *utilfdt_read(const char *filename);
104char *utilfdt_read(const char *filename, size_t *len);
104
105/**
105
106/**
106 * Like utilfdt_read(), but also passes back the size of the file read.
107 *
108 * @param len If non-NULL, the amount of data we managed to read
109 */
110char *utilfdt_read_len(const char *filename, off_t *len);
111
112/**
113 * Read a device tree file into a buffer. Does not report errors, but only
114 * returns them. The value returned can be passed to strerror() to obtain
115 * an error message for the user.
116 *
117 * @param filename The filename to read, or - for stdin
118 * @param buffp Returns pointer to buffer containing fdt
107 * Read a device tree file into a buffer. Does not report errors, but only
108 * returns them. The value returned can be passed to strerror() to obtain
109 * an error message for the user.
110 *
111 * @param filename The filename to read, or - for stdin
112 * @param buffp Returns pointer to buffer containing fdt
113 * @param len If non-NULL, the amount of data we managed to read
119 * @return 0 if ok, else an errno value representing the error
120 */
114 * @return 0 if ok, else an errno value representing the error
115 */
121int utilfdt_read_err(const char *filename, char **buffp);
116int utilfdt_read_err(const char *filename, char **buffp, size_t *len);
122
123/**
117
118/**
124 * Like utilfdt_read_err(), but also passes back the size of the file read.
125 *
126 * @param len If non-NULL, the amount of data we managed to read
127 */
128int utilfdt_read_err_len(const char *filename, char **buffp, off_t *len);
129
130/**
131 * Write a device tree buffer to a file. This will report any errors on
132 * stderr.
133 *
134 * @param filename The filename to write, or - for stdout
135 * @param blob Poiner to buffer containing fdt
136 * @return 0 if ok, -1 on error
137 */
138int utilfdt_write(const char *filename, const void *blob);

--- 128 unchanged lines hidden ---
119 * Write a device tree buffer to a file. This will report any errors on
120 * stderr.
121 *
122 * @param filename The filename to write, or - for stdout
123 * @param blob Poiner to buffer containing fdt
124 * @return 0 if ok, -1 on error
125 */
126int utilfdt_write(const char *filename, const void *blob);

--- 128 unchanged lines hidden ---