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