\_SB_.LNKS
     �¾ÂÁ      File not found.
     �¾ÂÁ      File not found.
     �¾ÂÁ      File not found.
     �¾ÂÁ      File not found.
  9   ˆl–Ým_J*j"Tâ€zã,ÜjbÑ¿Äƒh¹a–Ým_J*j"Tâ€zã,ÜjbÑ¿Ã      state = active
irq 12
     �À¾Ã      File not found.
     ˆÂÅƒyÐÁ¾Ã !ý    // SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright 2011 The Chromium Authors, All Rights Reserved.
 * Copyright 2008 Jon Loeliger, Freescale Semiconductor, Inc.
 *
 * util_is_printable_string contributed by
 *	Pantelis Antoniou <pantelis.antoniou AT gmail.com>
 */

#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#include <inttypes.h>

#include <errno.h>
#include <fcntl.h>
#include <unistd.h>

#include "libfdt.h"
#include "util.h"
#include "version_gen.h"

char *xstrdup(const char *s)
{
	int len = strlen(s) + 1;
	char *d = xmalloc(len);

	memcpy(d, s, len);

	return d;
}

int xavsprintf_append(char **strp, const char *fmt, va_list ap)
{
	int n, size = 0;	/* start with 128 bytes */
	char *p;
	va_list ap_copy;

	p = *strp;
	if (p)
		size = strlen(p);

	va_copy(ap_copy, ap);
	n = vsnprintf(NULL, 0, fmt, ap_copy) + 1;
	va_end(ap_copy);

	p = xrealloc(p, size + n);

	n = vsnprintf(p + size, n, fmt, ap);

	*strp = p;
	return strlen(p);
}

int xasprintf_append(char **strp, const char *fmt, ...)
{
	int n;
	va_list ap;

	va_start(ap, fmt);
	n = xavsprintf_append(strp, fmt, ap);
	va_end(ap);

	return n;
}

int xasprintf(char **strp, const char *fmt, ...)
{
	int n;
	va_list ap;

	*strp = NULL;

	va_start(ap, fmt);
	n = xavsprintf_append(strp, fmt, ap);
	va_end(ap);

	return n;
}

char *join_path(const char *path, const char *name)
{
	int lenp = strlen(path);
	int lenn = strlen(name);
	int len;
	int needslash = 1;
	char *str;

	len = lenp + lenn + 2;
	if ((lenp > 0) && (path[lenp-1] == '/')) {
		needslash = 0;
		len--;
	}

	str = xmalloc(len);
	memcpy(str, path, lenp);
	if (needslash) {
		str[lenp] = '/';
		lenp++;
	}
	memcpy(str+lenp, name, lenn+1);
	return str;
}

bool util_is_printable_string(const void *data, int len)
{
	const char *s = data;
	const char *ss, *se;

	/* zero length is not */
	if (len == 0)
		return 0;

	/* must terminate with zero */
	if (s[len - 1] != '\0')
		return 0;

	se = s + len;

	while (s < se) {
		ss = s;
		while (s < se && *s && isprint((unsigned char)*s))
			s++;

		/* not zero, or not done yet */
		if (*s != '\0' || s == ss)
			return 0;

		s++;
	}

	return 1;
}

/*
 * Parse a octal encoded character starting at index i in string s.  The
 * resulting character will be returned and the index i will be updated to
 * point at the character directly after the end of the encoding, this may be
 * the '\0' terminator of the string.
 */
static char get_oct_char(const char *s, int *i)
{
	char x[4];
	char *endx;
	long val;

	x[3] = '\0';
	strncpy(x, s + *i, 3);

	val = strtol(x, &endx, 8);

	assert(endx > x);

	(*i) += endx - x;
	return val;
}

/*
 * Parse a hexadecimal encoded character starting at index i in string s.  The
 * resulting character will be returned and the index i will be updated to
 * point at the character directly after the end of the encoding, this may be
 * the '\0' terminator of the string.
 */
static char get_hex_char(const char *s, int *i)
{
	char x[3];
	char *endx;
	long val;

	x[2] = '\0';
	strncpy(x, s + *i, 2);

	val = strtol(x, &endx, 16);
	if (!(endx  > x))
		die("\\x used with no following hex digits\n");

	(*i) += endx - x;
	return val;
}

char get_escape_char(const char *s, int *i)
{
	char	c = s[*i];
	int	j = *i + 1;
	char	val;

	switch (c) {
	case 'a':
		val = '\a';
		break;
	case 'b':
		val = '\b';
		break;
	case 't':
		val = '\t';
		break;
	case 'n':
		val = '\n';
		break;
	case 'v':
		val = '\v';
		break;
	case 'f':
		val = '\f';
		break;
	case 'r':
		val = '\r';
		break;
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
		j--; /* need to re-read the first digit as
		      * part of the octal value */
		val = get_oct_char(s, &j);
		break;