Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
util.c File Reference
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include "libfdt.h"
#include "util.h"

Go to the source code of this file.

Functions

charxstrdup (const char *s)
 
charjoin_path (const char *path, const char *name)
 
int util_is_printable_string (const void *data, int len)
 
char get_escape_char (const char *s, int *i)
 
int utilfdt_read_err (const char *filename, char **buffp)
 
charutilfdt_read (const char *filename)
 
int utilfdt_write_err (const char *filename, const void *blob)
 
int utilfdt_write (const char *filename, const void *blob)
 
int utilfdt_decode_type (const char *fmt, int *type, int *size)
 

Function Documentation

char get_escape_char ( const char s,
int i 
)

Definition at line 142 of file util.c.

char* join_path ( const char path,
const char name 
)

Definition at line 48 of file util.c.

int util_is_printable_string ( const void data,
int  len 
)

Check a string of a given length to see if it is all printable and has a valid terminator.

Parameters
dataThe string to check
lenThe string length including terminator
Returns
1 if a valid printable string, 0 if not

Definition at line 72 of file util.c.

int utilfdt_decode_type ( const char fmt,
int type,
int size 
)

Decode a data type string. The purpose of this string

The string consists of an optional character followed by the type: Modifier characters: hh or b 1 byte h 2 byte l 4 byte, default

Type character: s string i signed integer u unsigned integer x hex

TODO: Implement ll modifier (8 bytes) TODO: Implement o type (octal)

Parameters
fmtFormat string to process
typeReturns type found(s/d/u/x), or 0 if none
sizeReturns size found(1,2,4,8) or 4 if none
Returns
0 if ok, -1 on error (no type given, or other invalid format)

Definition at line 295 of file util.c.

char* utilfdt_read ( const char filename)

Read a device tree file into a buffer. This will report any errors on stderr.

Parameters
filenameThe filename to read, or - for stdin
Returns
Pointer to allocated buffer containing fdt, or NULL on error

Definition at line 238 of file util.c.

int utilfdt_read_err ( const char filename,
char **  buffp 
)

Read a device tree file into a buffer. Does not report errors, but only returns them. The value returned can be passed to strerror() to obtain an error message for the user.

Parameters
filenameThe filename to read, or - for stdin
buffpReturns pointer to buffer containing fdt
Returns
0 if ok, else an errno value representing the error

Definition at line 194 of file util.c.

int utilfdt_write ( const char filename,
const void blob 
)

Write a device tree buffer to a file. This will report any errors on stderr.

Parameters
filenameThe filename to write, or - for stdout
blobPoiner to buffer containing fdt
Returns
0 if ok, -1 on error

Definition at line 284 of file util.c.

int utilfdt_write_err ( const char filename,
const void blob 
)

Write a device tree buffer to a file. Does not report errors, but only returns them. The value returned can be passed to strerror() to obtain an error message for the user.

Parameters
filenameThe filename to write, or - for stdout
blobPoiner to buffer containing fdt
Returns
0 if ok, else an errno value representing the error

Definition at line 252 of file util.c.

char* xstrdup ( const char s)

Definition at line 38 of file util.c.