~ubuntu-branches/debian/lenny/network-manager/lenny

« back to all changes in this revision

Viewing changes to utils/nm-utils.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2008-07-05 15:11:33 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080705151133-rnwi7uuhda2iulug
Tags: 0.6.6-2
* debian/control
  - Add Build-Depends on pkg-config.
  - Drop obsolete Depends on iputils-arping. (Closes: #487794)
* debian/patches/09-nm_dbus_get_ap_from_object_path-mem_leak_fix.patch 
  - Fix memory leak in src/nm-dbus-net.c. (Closes: #488604)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include <glib.h>
28
28
#include "nm-utils.h"
29
29
 
30
 
gchar *nm_dbus_escape_object_path (const gchar *utf8_string)
 
30
gchar *nm_dbus_escape_object_path_item (const gchar *item)
31
31
{
32
 
        const gchar *p;
 
32
        unsigned char *p;
33
33
        gchar *object_path;
34
34
        GString *string;
35
35
 
36
 
        g_return_val_if_fail (utf8_string != NULL, NULL);       
37
 
        g_return_val_if_fail (g_utf8_validate (utf8_string, -1, NULL), NULL);
38
 
 
39
 
        string = g_string_sized_new ((strlen (utf8_string) + 1) * 6);
40
 
 
41
 
        for (p = utf8_string; *p != '\0'; p = g_utf8_next_char (p))
42
 
        {
43
 
                gunichar character;
44
 
 
45
 
                character = g_utf8_get_char (p);
46
 
 
47
 
                if (((character >= ((gunichar) 'a')) && 
48
 
                     (character <= ((gunichar) 'z'))) ||
49
 
                    ((character >= ((gunichar) 'A')) && 
50
 
                     (character <= ((gunichar) 'Z'))) ||
51
 
                    ((character >= ((gunichar) '0')) && 
52
 
                     (character <= ((gunichar) '9'))) ||
53
 
                     (character == ((gunichar) '/')))
54
 
                {
55
 
                        g_string_append_c (string, (gchar) character);
56
 
                        continue;
57
 
                }
58
 
 
59
 
                g_string_append_printf (string, "_%x_", character);
 
36
        g_return_val_if_fail (item != NULL, NULL);      
 
37
 
 
38
        string = g_string_sized_new ((strlen (item) + 1) * 6);
 
39
 
 
40
        for (p = (unsigned char *) item; *p != '\0'; p++) {
 
41
                if (((*p >= 'a') && (*p <= 'z')) ||
 
42
                    ((*p >= 'A') && (*p <= 'Z')) ||
 
43
                    ((*p >= '0') && (*p <= '9')))
 
44
                        g_string_append_c (string, *p);
 
45
                else
 
46
                        g_string_append_printf (string, "_%02x_", (unsigned char) *p);
60
47
        }
61
48
 
62
49
        object_path = string->str;
63
 
 
64
50
        g_string_free (string, FALSE);
65
 
 
66
51
        return object_path;
67
52
}
68
53