blob: a4835d4f40c7a0aeb77ad959c407d89f3bffe2da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <ctype.h>
#include <errno.h>
#include "sd-device.h"
#include "device-nodes.h"
#include "libudev-util.h"
#include "string-util.h"
#include "strxcpyx.h"
#include "utf8.h"
/**
* SECTION:libudev-util
* @short_description: utils
*
* Utilities useful when dealing with devices and device node names.
*/
/**
* udev_util_encode_string:
* @str: input string to be encoded
* @str_enc: output string to store the encoded input string
* @len: maximum size of the output string, which may be
* four times as long as the input string
*
* Encode all potentially unsafe characters of a string to the
* corresponding 2 char hex value prefixed by '\x'.
*
* Returns: 0 if the entire string was copied, non-zero otherwise.
**/
_public_ int udev_util_encode_string(const char *str, char *str_enc, size_t len) {
return encode_devnode_name(str, str_enc, len);
}
|