OSDN Git Service

Move common code to sdp to avoid duplication
authorSzymon Janc <szymon.janc@tieto.com>
Wed, 28 Mar 2012 10:03:19 +0000 (12:03 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Wed, 28 Mar 2012 10:17:39 +0000 (13:17 +0300)
LanguageBaseAttributeIDList is set from few places and each time static
function was copied and used for that. Move this funtion to sdp code
and use that instead of copying code.

compat/sdp.c
lib/sdp.c
lib/sdp_lib.h
network/server.c
serial/proxy.c
tools/sdptool.c

index f384844..9ad8333 100644 (file)
 static sdp_record_t *record = NULL;
 static sdp_session_t *session = NULL;
 
-static void add_lang_attr(sdp_record_t *r)
-{
-       sdp_lang_attr_t base_lang;
-       sdp_list_t *langs = 0;
-
-       /* UTF-8 MIBenum (http://www.iana.org/assignments/character-sets) */
-       base_lang.code_ISO639 = (0x65 << 8) | 0x6e;
-       base_lang.encoding = 106;
-       base_lang.base_offset = SDP_PRIMARY_LANG_BASE;
-       langs = sdp_list_append(0, &base_lang);
-       sdp_set_lang_attr(r, langs);
-       sdp_list_free(langs, 0);
-}
-
 static void epox_endian_quirk(unsigned char *data, int size)
 {
        /* USAGE_PAGE (Keyboard)        05 07
@@ -448,7 +434,7 @@ int bnep_sdp_register(bdaddr_t *device, uint16_t role)
        aproto = sdp_list_append(NULL, apseq);
        sdp_set_access_protos(record, aproto);
 
-       add_lang_attr(record);
+       sdp_add_lang_attr(record);
 
        sdp_list_free(proto[0], NULL);
        sdp_list_free(proto[1], NULL);
index 97c0a08..e12bace 100644 (file)
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -4794,3 +4794,16 @@ fail:
        return -1;
 }
 
+void sdp_add_lang_attr(sdp_record_t *rec)
+{
+       sdp_lang_attr_t base_lang;
+       sdp_list_t *langs;
+
+       base_lang.code_ISO639 = (0x65 << 8) | 0x6e;
+       base_lang.encoding = 106;
+       base_lang.base_offset = SDP_PRIMARY_LANG_BASE;
+
+       langs = sdp_list_append(0, &base_lang);
+       sdp_set_lang_attr(rec, langs);
+       sdp_list_free(langs, NULL);
+}
index 433e9ef..6e1eb91 100644 (file)
@@ -624,6 +624,8 @@ void sdp_pattern_add_uuidseq(sdp_record_t *rec, sdp_list_t *seq);
 
 int sdp_send_req_w4_rsp(sdp_session_t *session, uint8_t *req, uint8_t *rsp, uint32_t reqsize, uint32_t *rspsize);
 
+void sdp_add_lang_attr(sdp_record_t *rec);
+
 #ifdef __cplusplus
 }
 #endif
index 67d81e3..987cfca 100644 (file)
@@ -110,20 +110,6 @@ static struct network_server *find_server(GSList *list, uint16_t id)
        return NULL;
 }
 
-static void add_lang_attr(sdp_record_t *r)
-{
-       sdp_lang_attr_t base_lang;
-       sdp_list_t *langs = 0;
-
-       /* UTF-8 MIBenum (http://www.iana.org/assignments/character-sets) */
-       base_lang.code_ISO639 = (0x65 << 8) | 0x6e;
-       base_lang.encoding = 106;
-       base_lang.base_offset = SDP_PRIMARY_LANG_BASE;
-       langs = sdp_list_append(0, &base_lang);
-       sdp_set_lang_attr(r, langs);
-       sdp_list_free(langs, 0);
-}
-
 static sdp_record_t *server_record_new(const char *name, uint16_t id)
 {
        sdp_list_t *svclass, *pfseq, *apseq, *root, *aproto;
@@ -232,7 +218,7 @@ static sdp_record_t *server_record_new(const char *name, uint16_t id)
        aproto = sdp_list_append(NULL, apseq);
        sdp_set_access_protos(record, aproto);
 
-       add_lang_attr(record);
+       sdp_add_lang_attr(record);
 
        sdp_attr_add_new(record, SDP_ATTR_SECURITY_DESC,
                                SDP_UINT16, &security_desc);
index 736f690..ea5c29f 100644 (file)
@@ -130,20 +130,6 @@ static void proxy_free(struct serial_proxy *prx)
        g_free(prx);
 }
 
-static void add_lang_attr(sdp_record_t *r)
-{
-       sdp_lang_attr_t base_lang;
-       sdp_list_t *langs = 0;
-
-       /* UTF-8 MIBenum (http://www.iana.org/assignments/character-sets) */
-       base_lang.code_ISO639 = (0x65 << 8) | 0x6e;
-       base_lang.encoding = 106;
-       base_lang.base_offset = SDP_PRIMARY_LANG_BASE;
-       langs = sdp_list_append(0, &base_lang);
-       sdp_set_lang_attr(r, langs);
-       sdp_list_free(langs, 0);
-}
-
 static sdp_record_t *proxy_record_new(const char *uuid128, uint8_t channel)
 {
        sdp_list_t *apseq, *aproto, *profiles, *proto[2], *root, *svclass_id;
@@ -186,7 +172,7 @@ static sdp_record_t *proxy_record_new(const char *uuid128, uint8_t channel)
        aproto = sdp_list_append(NULL, apseq);
        sdp_set_access_protos(record, aproto);
 
-       add_lang_attr(record);
+       sdp_add_lang_attr(record);
 
        sdp_set_info_attr(record, "Serial Proxy", NULL, "Serial Proxy");
 
index 1a89245..db9ac0d 100644 (file)
@@ -1148,20 +1148,6 @@ typedef struct {
        uint8_t network;
 } svc_info_t;
 
-static void add_lang_attr(sdp_record_t *r)
-{
-       sdp_lang_attr_t base_lang;
-       sdp_list_t *langs = 0;
-
-       /* UTF-8 MIBenum (http://www.iana.org/assignments/character-sets) */
-       base_lang.code_ISO639 = (0x65 << 8) | 0x6e;
-       base_lang.encoding = 106;
-       base_lang.base_offset = SDP_PRIMARY_LANG_BASE;
-       langs = sdp_list_append(0, &base_lang);
-       sdp_set_lang_attr(r, langs);
-       sdp_list_free(langs, 0);
-}
-
 static int add_sp(sdp_session_t *session, svc_info_t *si)
 {
        sdp_list_t *svclass_id, *apseq, *proto[2], *profiles, *root, *aproto;
@@ -1203,7 +1189,7 @@ static int add_sp(sdp_session_t *session, svc_info_t *si)
        aproto = sdp_list_append(0, apseq);
        sdp_set_access_protos(&record, aproto);
 
-       add_lang_attr(&record);
+       sdp_add_lang_attr(&record);
 
        sdp_set_info_attr(&record, "Serial Port", "BlueZ", "COM Port");
 
@@ -2312,7 +2298,7 @@ static int add_hid_keyb(sdp_session_t *session, svc_info_t *si)
        root = sdp_list_append(0, &root_uuid);
        sdp_set_browse_groups(&record, root);
 
-       add_lang_attr(&record);
+       sdp_add_lang_attr(&record);
 
        sdp_uuid16_create(&hidkb_uuid, HID_SVCLASS_ID);
        svclass_id = sdp_list_append(0, &hidkb_uuid);
@@ -2490,7 +2476,7 @@ static int add_hid_wiimote(sdp_session_t *session, svc_info_t *si)
        aproto = sdp_list_append(0, apseq);
        sdp_set_add_access_protos(&record, aproto);
 
-       add_lang_attr(&record);
+       sdp_add_lang_attr(&record);
 
        sdp_set_info_attr(&record, "Nintendo RVL-CNT-01",
                                        "Nintendo", "Nintendo RVL-CNT-01");