Skip to content

Commit

Permalink
[libwspcodec] Repackaging + content type fix
Browse files Browse the repository at this point in the history
Moved the sources to wspcodec directory so that it resembles the
layout of the installed include files. Makes it easier to build
something that references libwspcodec without installing the devel
package.

Made content type field configurable. This resolves the conflict
between WSP Content-Type and X-Mms-Report-Allowed (both are 0x11)

Bumped version to 2.0.0 because this update is not backward compatible.
  • Loading branch information
monich committed Jan 21, 2014
1 parent 719b9e7 commit 7c04f50
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 18 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Expand Up @@ -2,6 +2,14 @@
build
debian/*.log
debian/*substvars
debian/libwspcodec
debian/libwspcodec-dev
debian/libwspcodec.postinst.debhelper
debian/libwspcodec.postrm.debhelper
debian/files
debian/tmp
documentation.list
installroot
libwspcodec.ncb
libwspcodec.opt
RPMS
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -15,7 +15,7 @@ all: debug release pkgconfig
# Library version
#

VERSION_MAJOR = 1
VERSION_MAJOR = 2
VERSION_MINOR = 0
VERSION_MICRO = 0
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_MICRO)
Expand All @@ -34,7 +34,7 @@ SRC = wsputil.c
# Directories
#

SRC_DIR = src
SRC_DIR = wspcodec
BUILD_DIR = build
DEBUG_BUILD_DIR = $(BUILD_DIR)/debug
RELEASE_BUILD_DIR = $(BUILD_DIR)/release
Expand Down
14 changes: 14 additions & 0 deletions debian/changelog
@@ -1,3 +1,17 @@
libwspcodec (2.0.0) unstable; urgency=low

* Made content type field configurable.
This resolves conflict between WSP Content-Type and X-Mms-Report-Allowed
headers (both are equal 0x11)

-- Slava Monich <slava.monich@jolla.com> Thu, 26 Dec 2013 00:27:57 +0200

libwspcodec (1.0.1) unstable; urgency=low

* Repackaged the sources, no API changes.

-- Slava Monich <slava.monich@jolla.com> Thu, 26 Dec 2013 00:27:57 +0200

libwspcodec (1.0.0) unstable; urgency=low

* Initial release
Expand Down
1 change: 1 addition & 0 deletions debian/compat
@@ -0,0 +1 @@
5
4 changes: 2 additions & 2 deletions debian/control
Expand Up @@ -8,11 +8,11 @@ Standards-Version: 3.8.4
Package: libwspcodec
Section: libs
Architecture: any
Depends: libglib2.0-bin (>= 2.0)
Depends: libglib2.0-bin (>= 2.32), ${shlibs:Depends}, ${misc:Depends}
Description: WSP encoder and decoder library

Package: libwspcodec-dev
Section: libdevel
Architecture: any
Depends: libwspcodec (= ${binary:Version})
Depends: libwspcodec (= ${binary:Version}), libglib2.0-dev (>= 2.32), ${misc:Depends}
Description: Development files for libwspcodec
4 changes: 2 additions & 2 deletions debian/libwspcodec-dev.install
@@ -1,3 +1,3 @@
src/wspcodec.h usr/include/libwspcodec/wspcodec
src/wsputil.h usr/include/libwspcodec/wspcodec
wspcodec/wspcodec.h usr/include/libwspcodec/wspcodec
wspcodec/wsputil.h usr/include/libwspcodec/wspcodec
build/libwspcodec.pc usr/lib/pkgconfig
1 change: 1 addition & 0 deletions debian/libwspcodec.install
@@ -0,0 +1 @@
debian/tmp/usr/lib/libwspcodec.so* usr/lib
104 changes: 104 additions & 0 deletions libwspcodec.dsp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rpm/libwspcodec.spec
@@ -1,5 +1,5 @@
Name: libwspcodec
Version: 1.0.0
Version: 2.0.0
Release: 1
Summary: WSP encoder and decoder library
Group: Development/Libraries
Expand Down
File renamed without changes.
23 changes: 12 additions & 11 deletions src/wsputil.c → wspcodec/wsputil.c
Expand Up @@ -528,18 +528,13 @@ gboolean wsp_decode_application_id(struct wsp_header_iter *iter,
}

static inline gboolean is_content_type_header(const unsigned char *pdu,
unsigned char code_page,
unsigned int flags)
struct wsp_header_iter *iter)
{
/* Check for MMS Content-Type header */
if (flags & WSP_HEADER_ITER_FLAG_DETECT_MMS_MULTIPART)
if (code_page == 1 && *pdu == 0x84)
/* Check for Content-Type header */
if (iter->flags & WSP_HEADER_ITER_FLAG_DETECT_MULTIPART)
if (iter->code_page == 1 && *pdu == iter->content_type_header)
return TRUE;

/* Check for WSP default Content-Type header */
if (code_page == 1 && *pdu == 0x91)
return TRUE;

return FALSE;
}

Expand Down Expand Up @@ -639,6 +634,12 @@ void wsp_header_iter_init(struct wsp_header_iter *iter,
iter->max = len;
iter->code_page = 1;
iter->flags = flags;
if (flags & WSP_HEADER_ITER_FLAG_DETECT_MMS_MULTIPART) {
iter->flags |= WSP_HEADER_ITER_FLAG_DETECT_MULTIPART;
iter->content_type_header = 0x84;
} else {
iter->content_type_header = 0x91;
}
}

gboolean wsp_header_iter_next(struct wsp_header_iter *iter)
Expand Down Expand Up @@ -687,7 +688,7 @@ gboolean wsp_header_iter_next(struct wsp_header_iter *iter)
return FALSE;

if (*pdu >= 0x80) {
if (is_content_type_header(pdu, iter->code_page, iter->flags))
if (is_content_type_header(pdu, iter))
return FALSE;

header = WSP_HEADER_TYPE_WELL_KNOWN;
Expand Down Expand Up @@ -742,7 +743,7 @@ gboolean wsp_header_iter_is_multipart(struct wsp_header_iter *iter)
{
const unsigned char *pdu = iter->pdu + iter->pos;

return is_content_type_header(pdu, iter->code_page, iter->flags);
return is_content_type_header(pdu, iter);
}

enum wsp_header_type wsp_header_iter_get_hdr_type(struct wsp_header_iter *iter)
Expand Down
7 changes: 7 additions & 0 deletions src/wsputil.h → wspcodec/wsputil.h
Expand Up @@ -19,9 +19,13 @@
*
*/

#ifndef WSPUTIL_H
#define WSPUTIL_H

enum wsp_header_iter_flag {
WSP_HEADER_ITER_FLAG_REJECT_CP = 0x1,
WSP_HEADER_ITER_FLAG_DETECT_MMS_MULTIPART = 0x2,
WSP_HEADER_ITER_FLAG_DETECT_MULTIPART = 0x4,
};

enum wsp_header_type {
Expand Down Expand Up @@ -97,6 +101,7 @@ struct wsp_header_iter {
unsigned int pos;
unsigned int flags;
unsigned char code_page;
unsigned char content_type_header;

enum wsp_header_type header_type;
const void *header;
Expand Down Expand Up @@ -210,3 +215,5 @@ gboolean wsp_text_header_iter_init(struct wsp_text_header_iter *iter,
gboolean wsp_text_header_iter_param_next(struct wsp_text_header_iter *iter);
const char *wsp_text_header_iter_get_key(struct wsp_text_header_iter *iter);
const char *wsp_text_header_iter_get_value(struct wsp_text_header_iter *iter);

#endif /* WSPUTIL_H */

0 comments on commit 7c04f50

Please sign in to comment.