]> git.meshlink.io Git - catta/blobdiff - avahi-core/util.c
* strip glib from avahi-core
[catta] / avahi-core / util.c
index 514f0d9a07f3de6cedf80a2cf652c5e4dfdeac61..77632fde1221f55bb2ba235e70604c6e438f4867 100644 (file)
@@ -27,9 +27,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
+#include <ctype.h>
 
-#include <glib.h>
-
+#include <avahi-common/malloc.h>
 #include "util.h"
 
 void avahi_hexdump(const void* p, size_t size) {
@@ -72,7 +72,8 @@ char *avahi_format_mac_address(const uint8_t* mac, size_t size) {
     unsigned i;
     static const char hex[] = "0123456789abcdef";
 
-    t = r = g_new(char, size > 0 ? size*3 : 1);
+    if (!(t = r = avahi_new(char, size > 0 ? size*3 : 1)))
+        return NULL;
 
     if (size <= 0) {
         *r = 0;
@@ -91,3 +92,23 @@ char *avahi_format_mac_address(const uint8_t* mac, size_t size) {
     return r;
 }
 
+char *avahi_strdown(char *s) {
+    char *c;
+    
+    assert(s);
+
+    for (c = s; *c; c++)
+        *c = (char) tolower(*c);
+
+    return s;
+}
+
+char *avahi_strup(char *s) {
+    char *c;
+    assert(s);
+
+    for (c = s; *c; c++)
+        *c = (char) toupper(*c);
+
+    return s;
+}