/* helpers for test_encode_devnode_name */ static char *do_encode_string(const char *in) { size_t out_len = strlen(in) * 4 + 1; char *out = malloc(out_len); assert_se(out); assert_se(encode_devnode_name(in, out, out_len) >= 0); puts(out); return out; }
/** * 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); }