2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2008-08-27 22:02:41 +02:00
|
|
|
|
2015-10-24 22:58:24 +02:00
|
|
|
#include "device-nodes.h"
|
2018-11-16 03:44:17 +01:00
|
|
|
#include "libudev-util.h"
|
2008-08-27 22:02:41 +02:00
|
|
|
|
2011-10-06 01:10:59 +02:00
|
|
|
/**
|
|
|
|
* SECTION:libudev-util
|
|
|
|
* @short_description: utils
|
2012-04-20 03:25:36 +02:00
|
|
|
*
|
|
|
|
* Utilities useful when dealing with devices and device node names.
|
2011-10-06 01:10:59 +02:00
|
|
|
*/
|
|
|
|
|
2008-11-05 21:49:52 +01:00
|
|
|
/**
|
2011-10-06 01:10:59 +02:00
|
|
|
* udev_util_encode_string:
|
2008-11-05 21:49:52 +01:00
|
|
|
* @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
|
2011-10-06 01:10:59 +02:00
|
|
|
* corresponding 2 char hex value prefixed by '\x'.
|
2008-11-05 21:49:52 +01:00
|
|
|
*
|
|
|
|
* Returns: 0 if the entire string was copied, non-zero otherwise.
|
|
|
|
**/
|
2018-08-22 12:51:32 +02:00
|
|
|
_public_ int udev_util_encode_string(const char *str, char *str_enc, size_t len) {
|
2013-09-18 18:12:04 +02:00
|
|
|
return encode_devnode_name(str, str_enc, len);
|
2008-11-05 21:49:52 +01:00
|
|
|
}
|