From: Jean-Philippe Orsini Date: Mon, 7 Nov 2011 22:53:54 +0000 (+0000) Subject: moved url.c to lib X-Git-Tag: v0.8.0.5~594 X-Git-Url: https://git.wpitchoune.net/gitweb/?p=psensor.git;a=commitdiff_plain;h=d2d694aef88fbdada5f2bf1bc9681e7014a06b87 moved url.c to lib --- diff --git a/po/Makefile.in b/po/Makefile.in index 8b758af..f901ffc 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -21,7 +21,7 @@ srcdir = . top_srcdir = .. -prefix = /usr/local +prefix = /tmp/r exec_prefix = ${prefix} datarootdir = ${prefix}/share datadir = ${datarootdir} diff --git a/src/Makefile.am b/src/Makefile.am index 8a1c982..36e7885 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -75,7 +75,7 @@ endif if CURL if JSON -psensor_SOURCES += rsensor.h rsensor.c plib/url.c plib/url.h +psensor_SOURCES += rsensor.h rsensor.c LIBS += $(CURL_LIBS) $(JSON_LIBS) AM_CPPFLAGS += $(CURL_CFLAGS) $(JSON_CFLAGS) endif diff --git a/src/Makefile.in b/src/Makefile.in index 925eb81..19e0634 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -51,7 +51,7 @@ bin_PROGRAMS = psensor$(EXEEXT) @LIBATIADL_TRUE@am__append_14 = $(LIBATIADL_LIBS) @UNITY_TRUE@am__append_15 = $(UNITY_CFLAGS) @UNITY_TRUE@am__append_16 = unity/libpsensor_unity.a $(UNITY_LIBS) -@CURL_TRUE@@JSON_TRUE@am__append_17 = rsensor.h rsensor.c plib/url.c plib/url.h +@CURL_TRUE@@JSON_TRUE@am__append_17 = rsensor.h rsensor.c @CURL_TRUE@@JSON_TRUE@am__append_18 = $(CURL_LIBS) $(JSON_LIBS) @CURL_TRUE@@JSON_TRUE@am__append_19 = $(CURL_CFLAGS) $(JSON_CFLAGS) subdir = src @@ -71,11 +71,10 @@ am__psensor_SOURCES_DIST = compat.h cfg.h cfg.c graph.h graph.c main.c \ ui.h ui.c ui_color.h ui_color.c ui_graph.h ui_graph.c \ ui_pref.h ui_pref.c ui_sensorlist.h ui_sensorlist.c \ ui_sensorpref.h ui_sensorpref.c ui_notify.h ui_notify.c \ - ui_appindicator.h ui_appindicator.c rsensor.h rsensor.c \ - plib/url.c plib/url.h + ui_appindicator.h ui_appindicator.c rsensor.h rsensor.c @LIBNOTIFY_TRUE@am__objects_1 = ui_notify.$(OBJEXT) @APPINDICATOR_TRUE@am__objects_2 = ui_appindicator.$(OBJEXT) -@CURL_TRUE@@JSON_TRUE@am__objects_3 = rsensor.$(OBJEXT) url.$(OBJEXT) +@CURL_TRUE@@JSON_TRUE@am__objects_3 = rsensor.$(OBJEXT) am_psensor_OBJECTS = cfg.$(OBJEXT) graph.$(OBJEXT) main.$(OBJEXT) \ ui.$(OBJEXT) ui_color.$(OBJEXT) ui_graph.$(OBJEXT) \ ui_pref.$(OBJEXT) ui_sensorlist.$(OBJEXT) \ @@ -414,7 +413,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_pref.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_sensorlist.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_sensorpref.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/url.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -429,20 +427,6 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -url.o: plib/url.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT url.o -MD -MP -MF $(DEPDIR)/url.Tpo -c -o url.o `test -f 'plib/url.c' || echo '$(srcdir)/'`plib/url.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/url.Tpo $(DEPDIR)/url.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='plib/url.c' object='url.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o url.o `test -f 'plib/url.c' || echo '$(srcdir)/'`plib/url.c - -url.obj: plib/url.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT url.obj -MD -MP -MF $(DEPDIR)/url.Tpo -c -o url.obj `if test -f 'plib/url.c'; then $(CYGPATH_W) 'plib/url.c'; else $(CYGPATH_W) '$(srcdir)/plib/url.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/url.Tpo $(DEPDIR)/url.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='plib/url.c' object='url.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o url.obj `if test -f 'plib/url.c'; then $(CYGPATH_W) 'plib/url.c'; else $(CYGPATH_W) '$(srcdir)/plib/url.c'; fi` install-man1: $(dist_man_MANS) @$(NORMAL_INSTALL) test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 7348b6c..ef13758 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -11,7 +11,8 @@ libpsensor_a_SOURCES = \ psensor.h psensor.c\ hdd.h hdd.c\ nvidia.h \ - lmsensor.h lmsensor.c + lmsensor.h lmsensor.c \ + url.c url.h if NVIDIA libpsensor_a_SOURCES += nvidia.c diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in index 61f517f..23ae2f7 100644 --- a/src/lib/Makefile.in +++ b/src/lib/Makefile.in @@ -59,15 +59,16 @@ libpsensor_a_AR = $(AR) $(ARFLAGS) libpsensor_a_LIBADD = am__libpsensor_a_SOURCES_DIST = amd.h cpu.h measure.h measure.c \ color.h color.c log.h log.c psensor.h psensor.c hdd.h hdd.c \ - nvidia.h lmsensor.h lmsensor.c nvidia.c amd.c cpu.c + nvidia.h lmsensor.h lmsensor.c url.c url.h nvidia.c amd.c \ + cpu.c @NVIDIA_TRUE@am__objects_1 = libpsensor_a-nvidia.$(OBJEXT) @LIBATIADL_TRUE@am__objects_2 = libpsensor_a-amd.$(OBJEXT) @GTOP_TRUE@am__objects_3 = libpsensor_a-cpu.$(OBJEXT) am_libpsensor_a_OBJECTS = libpsensor_a-measure.$(OBJEXT) \ libpsensor_a-color.$(OBJEXT) libpsensor_a-log.$(OBJEXT) \ libpsensor_a-psensor.$(OBJEXT) libpsensor_a-hdd.$(OBJEXT) \ - libpsensor_a-lmsensor.$(OBJEXT) $(am__objects_1) \ - $(am__objects_2) $(am__objects_3) + libpsensor_a-lmsensor.$(OBJEXT) libpsensor_a-url.$(OBJEXT) \ + $(am__objects_1) $(am__objects_2) $(am__objects_3) libpsensor_a_OBJECTS = $(am_libpsensor_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -230,8 +231,8 @@ noinst_LIBRARIES = libpsensor.a libpsensor_a_CFLAGS = -Wall -Werror $(am__append_5) libpsensor_a_SOURCES = amd.h cpu.h measure.h measure.c color.h color.c \ log.h log.c psensor.h psensor.c hdd.h hdd.c nvidia.h \ - lmsensor.h lmsensor.c $(am__append_1) $(am__append_4) \ - $(am__append_6) + lmsensor.h lmsensor.c url.c url.h $(am__append_1) \ + $(am__append_4) $(am__append_6) AM_CPPFLAGS = $(am__append_3) $(am__append_8) EXTRA_DIST = $(libpsensor_a_SOURCES) \ amd.c \ @@ -295,6 +296,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsensor_a-measure.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsensor_a-nvidia.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsensor_a-psensor.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libpsensor_a-url.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -394,6 +396,20 @@ libpsensor_a-lmsensor.obj: lmsensor.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsensor_a_CFLAGS) $(CFLAGS) -c -o libpsensor_a-lmsensor.obj `if test -f 'lmsensor.c'; then $(CYGPATH_W) 'lmsensor.c'; else $(CYGPATH_W) '$(srcdir)/lmsensor.c'; fi` +libpsensor_a-url.o: url.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsensor_a_CFLAGS) $(CFLAGS) -MT libpsensor_a-url.o -MD -MP -MF $(DEPDIR)/libpsensor_a-url.Tpo -c -o libpsensor_a-url.o `test -f 'url.c' || echo '$(srcdir)/'`url.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpsensor_a-url.Tpo $(DEPDIR)/libpsensor_a-url.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='url.c' object='libpsensor_a-url.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsensor_a_CFLAGS) $(CFLAGS) -c -o libpsensor_a-url.o `test -f 'url.c' || echo '$(srcdir)/'`url.c + +libpsensor_a-url.obj: url.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsensor_a_CFLAGS) $(CFLAGS) -MT libpsensor_a-url.obj -MD -MP -MF $(DEPDIR)/libpsensor_a-url.Tpo -c -o libpsensor_a-url.obj `if test -f 'url.c'; then $(CYGPATH_W) 'url.c'; else $(CYGPATH_W) '$(srcdir)/url.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpsensor_a-url.Tpo $(DEPDIR)/libpsensor_a-url.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='url.c' object='libpsensor_a-url.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsensor_a_CFLAGS) $(CFLAGS) -c -o libpsensor_a-url.obj `if test -f 'url.c'; then $(CYGPATH_W) 'url.c'; else $(CYGPATH_W) '$(srcdir)/url.c'; fi` + libpsensor_a-nvidia.o: nvidia.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsensor_a_CFLAGS) $(CFLAGS) -MT libpsensor_a-nvidia.o -MD -MP -MF $(DEPDIR)/libpsensor_a-nvidia.Tpo -c -o libpsensor_a-nvidia.o `test -f 'nvidia.c' || echo '$(srcdir)/'`nvidia.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpsensor_a-nvidia.Tpo $(DEPDIR)/libpsensor_a-nvidia.Po diff --git a/src/lib/url.c b/src/lib/url.c new file mode 100644 index 0000000..b06cd4c --- /dev/null +++ b/src/lib/url.c @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2010-2011 jeanfi@gmail.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +/* + * Part of the following code is based on: + * http://www.geekhideout.com/urlcode.shtml + */ +#include "url.h" + +#include +#include +#include + +char *url_normalize(const char *url) +{ + int n = strlen(url); + char *ret = strdup(url); + + if (url[n - 1] == '/') + ret[n - 1] = '\0'; + + return ret; +} + +static char to_hex(char code) +{ + static char hex[] = "0123456789abcdef"; + return hex[code & 0x0f]; +} + +/* + * Returns a url-encoded version of str. + */ +char *url_encode(const char *str) +{ + char *c, *buf, *pbuf; + + buf = malloc(strlen(str) * 3 + 1); + pbuf = buf; + + c = (char *)str; + + while (*c) { + + if (isalnum(*c) || + *c == '.' || *c == '_' || *c == '-' || *c == '~') + *pbuf++ = *c; + else { + *pbuf++ = '%'; + *pbuf++ = to_hex(*c >> 4); + *pbuf++ = to_hex(*c & 0x0f); + } + c++; + } + *pbuf = '\0'; + + return buf; +} diff --git a/src/lib/url.h b/src/lib/url.h new file mode 100644 index 0000000..bdc1fd1 --- /dev/null +++ b/src/lib/url.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2010 jeanfi@gmail.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA +*/ + +#ifndef _PLIB_URL_H_ +#define _PLIB_URL_H_ + +char *url_encode(const char *str); +char *url_normalize(const char *url); + +#endif diff --git a/src/plib/Makefile.am b/src/plib/Makefile.am index c626da0..a34a02e 100644 --- a/src/plib/Makefile.am +++ b/src/plib/Makefile.am @@ -7,5 +7,4 @@ noinst_LIBRARIES = libplib.a libplib_a_CFLAGS = -pedantic -Wall -Werror libplib_a_SOURCES = \ - url.c url.h \ plib_io.h plib_io.c diff --git a/src/plib/Makefile.in b/src/plib/Makefile.in index 302a5e1..a4a38f8 100644 --- a/src/plib/Makefile.in +++ b/src/plib/Makefile.in @@ -49,8 +49,7 @@ AR = ar ARFLAGS = cru libplib_a_AR = $(AR) $(ARFLAGS) libplib_a_LIBADD = -am_libplib_a_OBJECTS = libplib_a-url.$(OBJEXT) \ - libplib_a-plib_io.$(OBJEXT) +am_libplib_a_OBJECTS = libplib_a-plib_io.$(OBJEXT) libplib_a_OBJECTS = $(am_libplib_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -215,7 +214,6 @@ AM_CPPFLAGS = \ noinst_LIBRARIES = libplib.a libplib_a_CFLAGS = -pedantic -Wall -Werror libplib_a_SOURCES = \ - url.c url.h \ plib_io.h plib_io.c all: all-am @@ -267,7 +265,6 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplib_a-plib_io.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplib_a-url.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -283,20 +280,6 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` -libplib_a-url.o: url.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplib_a_CFLAGS) $(CFLAGS) -MT libplib_a-url.o -MD -MP -MF $(DEPDIR)/libplib_a-url.Tpo -c -o libplib_a-url.o `test -f 'url.c' || echo '$(srcdir)/'`url.c -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libplib_a-url.Tpo $(DEPDIR)/libplib_a-url.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='url.c' object='libplib_a-url.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplib_a_CFLAGS) $(CFLAGS) -c -o libplib_a-url.o `test -f 'url.c' || echo '$(srcdir)/'`url.c - -libplib_a-url.obj: url.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplib_a_CFLAGS) $(CFLAGS) -MT libplib_a-url.obj -MD -MP -MF $(DEPDIR)/libplib_a-url.Tpo -c -o libplib_a-url.obj `if test -f 'url.c'; then $(CYGPATH_W) 'url.c'; else $(CYGPATH_W) '$(srcdir)/url.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libplib_a-url.Tpo $(DEPDIR)/libplib_a-url.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='url.c' object='libplib_a-url.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplib_a_CFLAGS) $(CFLAGS) -c -o libplib_a-url.obj `if test -f 'url.c'; then $(CYGPATH_W) 'url.c'; else $(CYGPATH_W) '$(srcdir)/url.c'; fi` - libplib_a-plib_io.o: plib_io.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplib_a_CFLAGS) $(CFLAGS) -MT libplib_a-plib_io.o -MD -MP -MF $(DEPDIR)/libplib_a-plib_io.Tpo -c -o libplib_a-plib_io.o `test -f 'plib_io.c' || echo '$(srcdir)/'`plib_io.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libplib_a-plib_io.Tpo $(DEPDIR)/libplib_a-plib_io.Po diff --git a/src/plib/url.c b/src/plib/url.c deleted file mode 100644 index 975a204..0000000 --- a/src/plib/url.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2010-2011 jeanfi@gmail.com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -/* - * Part of the following code is based on: - * http://www.geekhideout.com/urlcode.shtml - */ -#include "plib/url.h" - -#include -#include -#include - -char *url_normalize(const char *url) -{ - int n = strlen(url); - char *ret = strdup(url); - - if (url[n - 1] == '/') - ret[n - 1] = '\0'; - - return ret; -} - -static char to_hex(char code) -{ - static char hex[] = "0123456789abcdef"; - return hex[code & 0x0f]; -} - -/* - * Returns a url-encoded version of str. - */ -char *url_encode(const char *str) -{ - char *c, *buf, *pbuf; - - buf = malloc(strlen(str) * 3 + 1); - pbuf = buf; - - c = (char *)str; - - while (*c) { - - if (isalnum(*c) || - *c == '.' || *c == '_' || *c == '-' || *c == '~') - *pbuf++ = *c; - else { - *pbuf++ = '%'; - *pbuf++ = to_hex(*c >> 4); - *pbuf++ = to_hex(*c & 0x0f); - } - c++; - } - *pbuf = '\0'; - - return buf; -} diff --git a/src/plib/url.h b/src/plib/url.h deleted file mode 100644 index bdc1fd1..0000000 --- a/src/plib/url.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright (C) 2010 jeanfi@gmail.com - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA -*/ - -#ifndef _PLIB_URL_H_ -#define _PLIB_URL_H_ - -char *url_encode(const char *str); -char *url_normalize(const char *url); - -#endif diff --git a/src/rsensor.c b/src/rsensor.c index 8b3eb12..052afa1 100644 --- a/src/rsensor.c +++ b/src/rsensor.c @@ -21,7 +21,7 @@ #include #define _(str) gettext(str) -#include "plib/url.h" +#include "url.h" #include "server/server.h" #include diff --git a/src/server/server.c b/src/server/server.c index 6509dcd..e0757cf 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -42,7 +42,7 @@ #endif #include "psensor_json.h" -#include "plib/url.h" +#include "url.h" #include "plib/plib_io.h" #include "server.h"