Commit 384de52d authored by Slava Monich's avatar Slava Monich

[libwspcodec] 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.

Also changed versioning a bit. Now application would be linking
against libwspcodec-X.Y.so rather than libwspcodec.so.X
parent a57ae26a
......@@ -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
......@@ -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
......@@ -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)
......
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.
......
debian/tmp/usr/lib/libwspcodec.so* usr/lib
debian/tmp/usr/lib/libwspcodec*.so* usr/lib
......@@ -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
Name: libwspcodec
Version: 2.0.0
Release: 1
Version: 2.1
Release: 0
Summary: WSP encoder and decoder library
Group: Development/Libraries
License: GPLv2
......@@ -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
......@@ -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;
}
......@@ -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,
......@@ -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 */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment