[gdm] common: remove gdm_string_hex_{de,en}code()



commit bbc08d3456ce77de1eae63b6f321a9256d54d873
Author: Christian Schramm <christian h m schramm gmail com>
Date:   Fri Mar 28 09:32:15 2014 +0100

    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

 common/gdm-common.c    |  208 ------------------------------------------------
 common/gdm-common.h    |    9 --
 tests/Makefile.am      |    2 -
 tests/m-common.c       |    4 +-
 tests/s-common-utils.c |   89 --------------------
 tests/s-common-utils.h |   28 -------
 6 files changed, 1 insertions(+), 339 deletions(-)
---
diff --git a/common/gdm-common.c b/common/gdm-common.c
index 88f5419..4017313 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 50bf153..d876b66 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);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8879498..63fc198 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -21,8 +21,6 @@ m_common_SOURCES =            \
        m-common.c              \
        s-common-address.c      \
        s-common-address.h      \
-       s-common-utils.c        \
-       s-common-utils.h        \
        $(NULL)
 
 m_common_CFLAGS =              \
diff --git a/tests/m-common.c b/tests/m-common.c
index 0c03805..c5ff2f4 100644
--- a/tests/m-common.c
+++ b/tests/m-common.c
@@ -24,7 +24,6 @@
 #include <glib-object.h>
 
 #include "s-common-address.h"
-#include "s-common-utils.h"
 
 static gboolean no_fork = FALSE;
 static gboolean verbose = FALSE;
@@ -57,8 +56,7 @@ main (int argc, char **argv)
                 exit (1);
         }
 
-        r = srunner_create (suite_common_utils ());
-        srunner_add_suite (r, suite_common_address ());
+        r = srunner_create (suite_common_address ());
 
         if (no_fork) {
                 srunner_set_fork_status (r, CK_NOFORK);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]