Skip to content

Commit

Permalink
[libwspcodec] Took out wsp_text_header_iter stuff
Browse files Browse the repository at this point in the history
Those functions were parsing a strange representation of textual
Content-Type like headers but the syntax they understood wasn't
HTTP compliant. This is pretty useless, has nothing to do with
WSP and doesn't belong here.

Also changed versioning a bit. Now application would be linking
against libwspcodec-X.Y.so rather than libwspcodec.so.X
  • Loading branch information
monich committed Feb 22, 2014
1 parent a57ae26 commit 384de52
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 190 deletions.
20 changes: 9 additions & 11 deletions Makefile
Expand Up @@ -16,13 +16,13 @@ all: debug release pkgconfig
#

VERSION_MAJOR = 2
VERSION_MINOR = 0
VERSION_MICRO = 0
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_MICRO)
VERSION_MINOR = 1
VERSION_RELEASE = 0
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)

LIB_SHORTCUT = libwspcodec.so
LIB_SONAME = $(LIB_SHORTCUT).$(VERSION_MAJOR)
LIB = $(LIB_SHORTCUT).$(VERSION)
LIB_SHORTCUT = libwspcodec-$(VERSION).so
LIB_SONAME = $(LIB_SHORTCUT)
LIB = $(LIB_SONAME).$(VERSION_RELEASE)

#
# Sources
Expand Down Expand Up @@ -124,7 +124,7 @@ $(RELEASE_BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -c $(RELEASE_CFLAGS) -MF"$(@:%.o=%.d)" $< -o $@

$(PKGCONFIG): libwspcodec.pc.in
sed -e 's/\[version\]/'$(VERSION)/g $< >> $@
sed -e 's/\[version\]/'$(VERSION)/g $< > $@

#
# Install
Expand All @@ -142,13 +142,11 @@ INSTALL_LIB_DIR = $(DESTDIR)/usr/lib
INSTALL_INCLUDE_DIR = $(DESTDIR)/usr/include/libwspcodec/wspcodec
INSTALL_PKGCONFIG_DIR = $(DESTDIR)/usr/lib/pkgconfig

INSTALL_ALIAS1 = $(INSTALL_LIB_DIR)/$(LIB_SONAME)
INSTALL_ALIAS2 = $(INSTALL_LIB_DIR)/$(LIB_SHORTCUT)
INSTALL_ALIAS = $(INSTALL_LIB_DIR)/$(LIB_SHORTCUT)

install: $(INSTALL_LIB_DIR)
$(INSTALL_FILES) $(RELEASE_LIB) $(INSTALL_LIB_DIR)
ln -sf $(LIB) $(INSTALL_ALIAS1)
ln -sf $(LIB) $(INSTALL_ALIAS2)
ln -sf $(LIB) $(INSTALL_ALIAS)

install-dev: install $(INSTALL_INCLUDE_DIR) $(INSTALL_PKGCONFIG_DIR)
$(INSTALL_FILES) $(SRC_DIR)/wsputil.h $(INSTALL_INCLUDE_DIR)
Expand Down
10 changes: 10 additions & 0 deletions debian/changelog
@@ -1,3 +1,13 @@
libwspcodec (2.1.0) unstable; urgency=low

* Took out wsp_text_header_iter stuff.
Those functions were parsing a strange representation of textual
Content-Type like headers but the syntax they understood wasn't
HTTP compliant. This is pretty useless, has nothing to do with
WSP and doesn't belong here.

-- Slava Monich <slava.monich@jolla.com> Fri, 21 Feb 2014 16:36:45 +0200

libwspcodec (2.0.0) unstable; urgency=low

* Made content type field configurable.
Expand Down
2 changes: 1 addition & 1 deletion debian/libwspcodec.install
@@ -1 +1 @@
debian/tmp/usr/lib/libwspcodec.so* usr/lib
debian/tmp/usr/lib/libwspcodec*.so* usr/lib
2 changes: 1 addition & 1 deletion libwspcodec.pc.in
Expand Up @@ -5,5 +5,5 @@ Name: libwspcodec
Description: WSP encoder and decoder library
Version: [version]
Requires: glib-2.0
Libs: -L${libdir} -lwspcodec
Libs: -L${libdir} -lwspcodec-[version]
Cflags: -I${includedir} -I${includedir}/wspcodec
8 changes: 4 additions & 4 deletions rpm/libwspcodec.spec
@@ -1,6 +1,6 @@
Name: libwspcodec
Version: 2.0.0
Release: 1
Version: 2.1
Release: 0
Summary: WSP encoder and decoder library
Group: Development/Libraries
License: GPLv2
Expand Down Expand Up @@ -38,11 +38,11 @@ make install-dev DESTDIR=%{buildroot}

%files
%defattr(-,root,root,-)
%{_libdir}/%{name}.so.*
%{_libdir}/%{name}*.so.*

%files devel
%defattr(-,root,root,-)
%{_libdir}/%{name}.so
%{_libdir}/%{name}-2.1.so
%{_libdir}/pkgconfig/libwspcodec.pc
%{_includedir}/libwspcodec/wspcodec/wsputil.h
%{_includedir}/libwspcodec/wspcodec/wspcodec.h
158 changes: 0 additions & 158 deletions wspcodec/wsputil.c
Expand Up @@ -1147,161 +1147,3 @@ gboolean wsp_parameter_iter_next(struct wsp_parameter_iter *pi,

return TRUE;
}

static const char *decode_token(char *buf, gboolean accept_quotes,
unsigned int *out_consumed,
char *out_terminator)
{
unsigned int pos = 0;
unsigned int start;
unsigned int end;
char *endp;
char terminator = '\0';

/* Skip leading space */
while (buf[pos] == ' ' || buf[pos] == '\t')
pos += 1;

if (buf[pos] == '\0')
return NULL;

start = pos;

if (buf[pos] == '"') {
if (accept_quotes == FALSE)
return NULL;

pos += 1;
start = pos;

endp = strchr(buf + pos, '"');
if (endp == NULL)
return NULL;

pos = endp - buf;
end = pos;
pos += 1;
} else {
endp = strpbrk(buf + pos, sep_chars);

if (endp == NULL)
pos = strlen(buf);
else
pos = endp - buf;

end = pos;
}

while (buf[pos] == ' ' || buf[pos] == '\t')
pos += 1;

if (buf[pos] != '\0') {
terminator = buf[pos];
pos += 1;
}

buf[end] = '\0';

if (strpbrk(buf + start, ctl_chars) != NULL)
return NULL;

*out_consumed = pos;
*out_terminator = terminator;

return buf + start;
}

gboolean wsp_text_header_iter_init(struct wsp_text_header_iter *iter,
const char *hdr)
{
unsigned int len = strlen(hdr);
char terminator;
unsigned int consumed;
const char *key;
const char *value;

if (len > MAX_TEXT_HEADER_SIZE)
return FALSE;

memcpy(iter->hdr, hdr, len);
iter->hdr[len] = '\0';
iter->pos = 0;
iter->key = NULL;
iter->value = NULL;

key = decode_token(iter->hdr, FALSE, &consumed, &terminator);
if (key == NULL)
return FALSE;

if (terminator != ':')
return FALSE;

len = consumed;

value = decode_token(iter->hdr + len, TRUE, &consumed, &terminator);
if (value == NULL)
return FALSE;

if (terminator != '\0' && terminator != ';')
return FALSE;

len += consumed;

iter->key = key;
iter->value = value;
iter->pos = len;

return TRUE;
}

gboolean wsp_text_header_iter_param_next(struct wsp_text_header_iter *iter)
{
unsigned int pos = iter->pos;
char terminator;
unsigned int consumed;
const char *key;
const char *value;

key = decode_token(iter->hdr + pos, FALSE, &consumed, &terminator);
if (key == NULL)
return FALSE;

/* Empty value */
if (terminator == ';' || terminator == '\0') {
iter->key = key;
iter->value = NULL;
iter->pos += consumed;

return TRUE;
}

if (terminator != '=')
return FALSE;

pos += consumed;

value = decode_token(iter->hdr + pos, TRUE, &consumed, &terminator);
if (value == NULL)
return FALSE;

if (terminator != '\0' && terminator != ';')
return FALSE;

pos += consumed;

iter->key = key;
iter->value = value;
iter->pos = pos;

return TRUE;
}

const char *wsp_text_header_iter_get_key(struct wsp_text_header_iter *iter)
{
return iter->key;
}

const char *wsp_text_header_iter_get_value(struct wsp_text_header_iter *iter)
{
return iter->value;
}
15 changes: 0 additions & 15 deletions wspcodec/wsputil.h
Expand Up @@ -132,15 +132,6 @@ struct wsp_parameter_iter {
unsigned int pos;
};

#define MAX_TEXT_HEADER_SIZE 4096

struct wsp_text_header_iter {
char hdr[MAX_TEXT_HEADER_SIZE + 1];
unsigned int pos;
const char *key;
const char *value;
};

gboolean wsp_decode_uintvar(const unsigned char *pdu, unsigned int len,
unsigned int *out_len, unsigned int *consumed);
gboolean wsp_decode_integer(const unsigned char *pdu, unsigned int len,
Expand Down Expand Up @@ -210,10 +201,4 @@ void wsp_parameter_iter_init(struct wsp_parameter_iter *pi,
gboolean wsp_parameter_iter_next(struct wsp_parameter_iter *pi,
struct wsp_parameter *out_param);

gboolean wsp_text_header_iter_init(struct wsp_text_header_iter *iter,
const char *hdr);
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 384de52

Please sign in to comment.