All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Collin R. Mulliner" <collin@betaversion.net>
To: bluez-devel@lists.sourceforge.net
Subject: Re: [Bluez-devel] sdp seq of raw data
Date: Thu, 01 Dec 2005 03:50:00 -0800	[thread overview]
Message-ID: <1133437800.1037.40.camel@panic> (raw)
In-Reply-To: <1133436800.1190.62.camel@blade>

[-- Attachment #1: Type: text/plain, Size: 526 bytes --]

Hi Marcel,

here are the patches, one for include/sdp_lib.h and one src/for sdp.c.
It adds two new functions but stais backward compatible.

... Collin

PS: it's 4am and I need to go to sleep :-(

On Thu, 2005-12-01 at 12:33 +0100, Marcel Holtmann wrote:
> Hi Collin,
> 
> > Do you accept a patch for this?
> 
> yes :)
> 
> Regards
> 
> Marcel

--
Collin R. Mulliner <collin@betaversion.net>
BETAVERSiON Systems [www.betaversion.net]
info/pgp: finger collin@betaversion.net
Blessed are the Geeks, for they internet the earth!

[-- Attachment #2: bluez_libs_raw_data_src --]
[-- Type: text/plain, Size: 1921 bytes --]

--- bluez-libs-2.22/src/sdp.c	2005-10-29 16:04:28.000000000 -0700
+++ bluez-libs-2.22_new/src/sdp.c	2005-12-01 03:30:05.000000000 -0800
@@ -346,6 +346,11 @@
 
 sdp_data_t *sdp_data_alloc(uint8_t dtd, const void *value)
 {
+	return(sdp_data_alloc_leng(dtd, value, 0));
+}
+
+sdp_data_t *sdp_data_alloc_leng(uint8_t dtd, const void *value, uint32_t leng)
+{
 	sdp_data_t *seq;
 	int len = 0;
 	sdp_data_t *d = (sdp_data_t *) malloc(sizeof(sdp_data_t));
@@ -420,14 +425,15 @@
 		if (!value)
 			goto out_error;
 
-		len = strlen(value);
-		d->unitSize += len;
+		len = leng ? leng : strlen(value);
+		d->unitSize = len - 1;
 		if (len <= USHRT_MAX) {
 			d->val.str = (char *) malloc(len + 1);
 			if (!d->val.str)
 				goto out_error;
 
-			strcpy(d->val.str, value);
+			if (leng) memcpy(d->val.str, value, leng);
+			else strcpy(d->val.str, value);
 			if (len <= UCHAR_MAX) {
 				d->unitSize += sizeof(uint8_t);
 				if (dtd != SDP_URL_STR8 && dtd != SDP_TEXT_STR8) {
@@ -491,6 +497,29 @@
 	return seq;
 }
 
+sdp_data_t *sdp_seq_alloc_leng(void **dtds, void **values, int *leng, int len)
+{
+	sdp_data_t *curr = NULL, *seq = NULL;
+	int i;
+
+	for (i = 0; i < len; i++) {
+		sdp_data_t *data;
+		uint8_t dtd = *(uint8_t *)dtds[i];
+		if (dtd >= SDP_SEQ8 && dtd <= SDP_ALT32)
+			data = (sdp_data_t *)values[i];
+		else
+			data = sdp_data_alloc_leng(dtd, values[i], leng[i]);
+		if (!data)
+			return NULL;
+		if (curr)
+			curr->next = data;
+		else
+			seq = data;
+		curr = data;
+	}
+	return sdp_data_alloc_leng(SDP_SEQ8, seq, leng[i]);
+}
+
 sdp_data_t *sdp_seq_alloc(void **dtds, void **values, int len)
 {
 	sdp_data_t *curr = NULL, *seq = NULL;
@@ -681,7 +710,8 @@
 	case SDP_URL_STR16:
 	case SDP_URL_STR32:
 		src = (unsigned char *)d->val.str;
-		data_size = strlen(d->val.str);
+		//data_size = strlen(d->val.str);
+		data_size = d->unitSize;
 		sdp_set_seq_len(seqp, data_size);
 		break;
 	case SDP_SEQ8:

[-- Attachment #3: bluez_libs_raw_data_inc --]
[-- Type: text/plain, Size: 744 bytes --]

--- bluez-libs-2.22/include/sdp_lib.h	2005-10-29 16:04:28.000000000 -0700
+++ bluez-libs-2.22_new/include/sdp_lib.h	2005-12-01 02:21:16.000000000 -0800
@@ -102,10 +102,12 @@
  * Basic sdp data functions
  */
 sdp_data_t *sdp_data_alloc(uint8_t dtd, const void *value);
+sdp_data_t *sdp_data_alloc_leng(uint8_t dtd, const void *value, uint32_t leng);
 void sdp_data_free(sdp_data_t *data);
 sdp_data_t *sdp_data_get(const sdp_record_t *rec, uint16_t attr_id);
 
 sdp_data_t *sdp_seq_alloc(void **dtds, void **values, int len);
+sdp_data_t *sdp_seq_alloc_leng(void **dtds, void **values, int *leng, int len);
 sdp_data_t *sdp_seq_append(sdp_data_t *seq, sdp_data_t *data);
 
 int sdp_attr_add(sdp_record_t *rec, uint16_t attr, sdp_data_t *data);

  reply	other threads:[~2005-12-01 11:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-01  9:39 [Bluez-devel] sdp seq of raw data Collin R. Mulliner
2005-12-01  9:55 ` Marcel Holtmann
2005-12-01 10:03   ` Collin R. Mulliner
2005-12-01 10:46     ` Marcel Holtmann
2005-12-01 11:23       ` Collin R. Mulliner
2005-12-01 11:33         ` Marcel Holtmann
2005-12-01 11:50           ` Collin R. Mulliner [this message]
2005-12-02 19:42             ` Marcel Holtmann
2005-12-02 19:53               ` Steven Singer
2005-12-02 20:06                 ` Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1133437800.1037.40.camel@panic \
    --to=collin@betaversion.net \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.