diff options
author | Christian Schramm <christian.h.m.schramm@gmail.com> | 2014-03-28 09:32:15 +0100 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2014-04-07 10:04:36 -0400 |
commit | bbc08d3456ce77de1eae63b6f321a9256d54d873 (patch) | |
tree | b8f9f5c6176a2e4c62f1eca3fb3e7aa6d745206c /common | |
parent | af384da3c72efee40dcba48bb0e3e2ad6a08f6e4 (diff) | |
download | gdm-bbc08d3456ce77de1eae63b6f321a9256d54d873.tar.gz |
common: remove gdm_string_hex_{de,en}code()
These functions are unused, so there's no reason to
keep them around.
This commit removes those functions and corresponding test code.
https://bugzilla.gnome.org/show_bug.cgi?id=727183
Diffstat (limited to 'common')
-rw-r--r-- | common/gdm-common.c | 208 | ||||
-rw-r--r-- | common/gdm-common.h | 9 |
2 files changed, 0 insertions, 217 deletions
diff --git a/common/gdm-common.c b/common/gdm-common.c index 88f5419b..4017313b 100644 --- a/common/gdm-common.c +++ b/common/gdm-common.c @@ -211,214 +211,6 @@ gdm_signal_pid (int pid, return status; } -/* hex conversion adapted from D-Bus */ -/** - * Appends a two-character hex digit to a string, where the hex digit - * has the value of the given byte. - * - * @param str the string - * @param byte the byte - */ -static void -_gdm_string_append_byte_as_hex (GString *str, - int byte) -{ - const char hexdigits[16] = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'a', 'b', 'c', 'd', 'e', 'f' - }; - - str = g_string_append_c (str, hexdigits[(byte >> 4)]); - - str = g_string_append_c (str, hexdigits[(byte & 0x0f)]); -} - -/** - * Encodes a string in hex, the way MD5 and SHA-1 are usually - * encoded. (Each byte is two hex digits.) - * - * @param source the string to encode - * @param start byte index to start encoding - * @param dest string where encoded data should be placed - * @param insert_at where to place encoded data - * @returns #TRUE if encoding was successful, #FALSE if no memory etc. - */ -gboolean -gdm_string_hex_encode (const GString *source, - int start, - GString *dest, - int insert_at) -{ - GString *result; - const unsigned char *p; - const unsigned char *end; - gboolean retval; - - g_return_val_if_fail (source != NULL, FALSE); - g_return_val_if_fail (dest != NULL, FALSE); - g_return_val_if_fail (source != dest, FALSE); - g_return_val_if_fail (start >= 0, FALSE); - g_return_val_if_fail (dest >= 0, FALSE); - g_assert (start <= source->len); - - result = g_string_new (NULL); - - retval = FALSE; - - p = (const unsigned char*) source->str; - end = p + source->len; - p += start; - - while (p != end) { - _gdm_string_append_byte_as_hex (result, *p); - ++p; - } - - dest = g_string_insert (dest, insert_at, result->str); - - retval = TRUE; - - g_string_free (result, TRUE); - - return retval; -} - -/** - * Decodes a string from hex encoding. - * - * @param source the string to decode - * @param start byte index to start decode - * @param end_return return location of the end of the hex data, or #NULL - * @param dest string where decoded data should be placed - * @param insert_at where to place decoded data - * @returns #TRUE if decoding was successful, #FALSE if no memory. - */ -gboolean -gdm_string_hex_decode (const GString *source, - int start, - int *end_return, - GString *dest, - int insert_at) -{ - GString *result; - const unsigned char *p; - const unsigned char *end; - gboolean retval; - gboolean high_bits; - - g_return_val_if_fail (source != NULL, FALSE); - g_return_val_if_fail (dest != NULL, FALSE); - g_return_val_if_fail (source != dest, FALSE); - g_return_val_if_fail (start >= 0, FALSE); - g_return_val_if_fail (dest >= 0, FALSE); - - g_assert (start <= source->len); - - result = g_string_new (NULL); - - retval = FALSE; - - high_bits = TRUE; - p = (const unsigned char*) source->str; - end = p + source->len; - p += start; - - while (p != end) { - unsigned int val; - - switch (*p) { - case '0': - val = 0; - break; - case '1': - val = 1; - break; - case '2': - val = 2; - break; - case '3': - val = 3; - break; - case '4': - val = 4; - break; - case '5': - val = 5; - break; - case '6': - val = 6; - break; - case '7': - val = 7; - break; - case '8': - val = 8; - break; - case '9': - val = 9; - break; - case 'a': - case 'A': - val = 10; - break; - case 'b': - case 'B': - val = 11; - break; - case 'c': - case 'C': - val = 12; - break; - case 'd': - case 'D': - val = 13; - break; - case 'e': - case 'E': - val = 14; - break; - case 'f': - case 'F': - val = 15; - break; - default: - goto done; - } - - if (high_bits) { - result = g_string_append_c (result, val << 4); - } else { - int len; - unsigned char b; - - len = result->len; - - b = result->str[len - 1]; - - b |= val; - - result->str[len - 1] = b; - } - - high_bits = !high_bits; - - ++p; - } - - done: - dest = g_string_insert (dest, insert_at, result->str); - - if (end_return) { - *end_return = p - (const unsigned char*) source->str; - } - - retval = TRUE; - - g_string_free (result, TRUE); - - return retval; -} - static gboolean _fd_is_character_device (int fd) { diff --git a/common/gdm-common.h b/common/gdm-common.h index 50bf1538..d876b66e 100644 --- a/common/gdm-common.h +++ b/common/gdm-common.h @@ -53,15 +53,6 @@ gboolean gdm_clear_close_on_exec_flag (int fd); const char * gdm_make_temp_dir (char *template); -gboolean gdm_string_hex_encode (const GString *source, - int start, - GString *dest, - int insert_at); -gboolean gdm_string_hex_decode (const GString *source, - int start, - int *end_return, - GString *dest, - int insert_at); char *gdm_generate_random_bytes (gsize size, GError **error); gboolean gdm_goto_login_session (GError **error); |