From: Jean-Philippe Orsini Date: Mon, 7 Nov 2011 23:03:15 +0000 (+0000) Subject: removed plib X-Git-Tag: v0.8.0.5~593 X-Git-Url: https://git.wpitchoune.net/gitweb/?p=psensor.git;a=commitdiff_plain;h=b6de13fcb155c076b2a4360ba33bc29a7fdc37ec removed plib --- diff --git a/configure b/configure index 4270cac..4b3cb7c 100755 --- a/configure +++ b/configure @@ -8552,7 +8552,7 @@ fi -ac_config_files="$ac_config_files Makefile src/Makefile src/glade/Makefile src/plib/Makefile src/lib/Makefile src/unity/Makefile src/libpsensor_json/Makefile src/server/Makefile icons/hicolor/scalable/Makefile icons/hicolor/14x14/Makefile icons/hicolor/16x16/Makefile icons/hicolor/22x22/Makefile icons/hicolor/24x24/Makefile icons/hicolor/32x32/Makefile icons/hicolor/48x48/Makefile icons/hicolor/64x64/Makefile icons/ubuntu-mono-dark/status/22/Makefile icons/ubuntu-mono-light/status/22/Makefile icons/ubuntu-mono-dark/apps/22/Makefile www/Makefile po/Makefile.in tests/Makefile" +ac_config_files="$ac_config_files Makefile src/Makefile src/glade/Makefile src/lib/Makefile src/unity/Makefile src/libpsensor_json/Makefile src/server/Makefile icons/hicolor/scalable/Makefile icons/hicolor/14x14/Makefile icons/hicolor/16x16/Makefile icons/hicolor/22x22/Makefile icons/hicolor/24x24/Makefile icons/hicolor/32x32/Makefile icons/hicolor/48x48/Makefile icons/hicolor/64x64/Makefile icons/ubuntu-mono-dark/status/22/Makefile icons/ubuntu-mono-light/status/22/Makefile icons/ubuntu-mono-dark/apps/22/Makefile www/Makefile po/Makefile.in tests/Makefile" for ac_prog in help2man @@ -9385,7 +9385,6 @@ do "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "src/glade/Makefile") CONFIG_FILES="$CONFIG_FILES src/glade/Makefile" ;; - "src/plib/Makefile") CONFIG_FILES="$CONFIG_FILES src/plib/Makefile" ;; "src/lib/Makefile") CONFIG_FILES="$CONFIG_FILES src/lib/Makefile" ;; "src/unity/Makefile") CONFIG_FILES="$CONFIG_FILES src/unity/Makefile" ;; "src/libpsensor_json/Makefile") CONFIG_FILES="$CONFIG_FILES src/libpsensor_json/Makefile" ;; diff --git a/configure.ac b/configure.ac index ccce11f..d032e80 100644 --- a/configure.ac +++ b/configure.ac @@ -226,7 +226,6 @@ AC_CONFIG_FILES([ Makefile src/Makefile src/glade/Makefile - src/plib/Makefile src/lib/Makefile src/unity/Makefile src/libpsensor_json/Makefile diff --git a/po/Makefile.in b/po/Makefile.in index f901ffc..8b758af 100644 --- a/po/Makefile.in +++ b/po/Makefile.in @@ -21,7 +21,7 @@ srcdir = . top_srcdir = .. -prefix = /tmp/r +prefix = /usr/local exec_prefix = ${prefix} datarootdir = ${prefix}/share datadir = ${datarootdir} diff --git a/src/Makefile.am b/src/Makefile.am index 36e7885..2ee2568 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = plib lib unity glade +SUBDIRS = lib unity glade AM_LDFLAGS = -Wl,--as-needed @@ -22,7 +22,6 @@ AM_CPPFLAGS = -Wall -pedantic -Werror -DDEFAULT_WWW_DIR=\""$(pkgdatadir)/www"\"\ DEFS = -DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" -DLOCALEDIR=\"$(localedir)\" @DEFS@ LIBS = \ - plib/libplib.a \ lib/libpsensor.a \ $(GTK_LIBS)\ $(GCONF_LIBS)\ diff --git a/src/Makefile.in b/src/Makefile.in index 19e0634..8861f68 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -130,7 +130,7 @@ AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ distdir ETAGS = etags CTAGS = ctags -DIST_SUBDIRS = plib lib unity glade libpsensor_json server +DIST_SUBDIRS = lib unity glade libpsensor_json server DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ @@ -210,10 +210,10 @@ LIBMICROHTTPD_LIBS = @LIBMICROHTTPD_LIBS@ LIBNOTIFY_CFLAGS = @LIBNOTIFY_CFLAGS@ LIBNOTIFY_LIBS = @LIBNOTIFY_LIBS@ LIBOBJS = @LIBOBJS@ -LIBS = plib/libplib.a lib/libpsensor.a $(GTK_LIBS) $(GCONF_LIBS) \ - $(SENSORS_LIBS) $(am__append_4) $(am__append_6) \ - $(am__append_9) $(am__append_12) $(am__append_14) \ - $(am__append_16) $(am__append_18) +LIBS = lib/libpsensor.a $(GTK_LIBS) $(GCONF_LIBS) $(SENSORS_LIBS) \ + $(am__append_4) $(am__append_6) $(am__append_9) \ + $(am__append_12) $(am__append_14) $(am__append_16) \ + $(am__append_18) LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ @@ -304,7 +304,7 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -SUBDIRS = plib lib unity glade $(am__append_1) $(am__append_2) +SUBDIRS = lib unity glade $(am__append_1) $(am__append_2) AM_LDFLAGS = -Wl,--as-needed AM_CPPFLAGS = -Wall -pedantic -Werror \ -DDEFAULT_WWW_DIR=\""$(pkgdatadir)/www"\" \ diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index ef13758..48dc632 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -12,6 +12,7 @@ libpsensor_a_SOURCES = \ hdd.h hdd.c\ nvidia.h \ lmsensor.h lmsensor.c \ + p_io.h p_io.c \ url.c url.h if NVIDIA diff --git a/src/lib/Makefile.in b/src/lib/Makefile.in index 23ae2f7..fd21574 100644 --- a/src/lib/Makefile.in +++ b/src/lib/Makefile.in @@ -59,16 +59,17 @@ 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 url.c url.h nvidia.c amd.c \ - cpu.c + nvidia.h lmsensor.h lmsensor.c p_io.h p_io.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) libpsensor_a-url.$(OBJEXT) \ - $(am__objects_1) $(am__objects_2) $(am__objects_3) + libpsensor_a-lmsensor.$(OBJEXT) libpsensor_a-p_io.$(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 @@ -231,8 +232,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 url.c url.h $(am__append_1) \ - $(am__append_4) $(am__append_6) + lmsensor.h lmsensor.c p_io.h p_io.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-log.Po@am__quote@ @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-p_io.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@ @@ -396,6 +398,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-p_io.o: p_io.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsensor_a_CFLAGS) $(CFLAGS) -MT libpsensor_a-p_io.o -MD -MP -MF $(DEPDIR)/libpsensor_a-p_io.Tpo -c -o libpsensor_a-p_io.o `test -f 'p_io.c' || echo '$(srcdir)/'`p_io.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpsensor_a-p_io.Tpo $(DEPDIR)/libpsensor_a-p_io.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='p_io.c' object='libpsensor_a-p_io.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-p_io.o `test -f 'p_io.c' || echo '$(srcdir)/'`p_io.c + +libpsensor_a-p_io.obj: p_io.c +@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpsensor_a_CFLAGS) $(CFLAGS) -MT libpsensor_a-p_io.obj -MD -MP -MF $(DEPDIR)/libpsensor_a-p_io.Tpo -c -o libpsensor_a-p_io.obj `if test -f 'p_io.c'; then $(CYGPATH_W) 'p_io.c'; else $(CYGPATH_W) '$(srcdir)/p_io.c'; fi` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libpsensor_a-p_io.Tpo $(DEPDIR)/libpsensor_a-p_io.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='p_io.c' object='libpsensor_a-p_io.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-p_io.obj `if test -f 'p_io.c'; then $(CYGPATH_W) 'p_io.c'; else $(CYGPATH_W) '$(srcdir)/p_io.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 diff --git a/src/lib/p_io.c b/src/lib/p_io.c new file mode 100644 index 0000000..3af18ef --- /dev/null +++ b/src/lib/p_io.c @@ -0,0 +1,297 @@ +/* + 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 +*/ + +#include +#include +#include +#include +#include + +#include "p_io.h" + +int is_dir(const char *path) +{ + struct stat st; + + int ret = lstat(path, &st); + + if (ret == 0 && S_ISDIR(st.st_mode)) + return 1; + + return 0; +} + +int is_file(const char *path) +{ + struct stat st; + + int ret = lstat(path, &st); + + if (ret == 0 && S_ISREG(st.st_mode)) + return 1; + + return 0; +} + +char *dir_normalize(const char *dpath) +{ + char *npath; + int n; + + if (!dpath || !strlen(dpath)) + return NULL; + + npath = strdup(dpath); + + n = strlen(npath); + + if (n > 1 && npath[n - 1] == '/') + npath[n - 1] = '\0'; + + return npath; +} + +char **dir_list(const char *dpath, int (*filter) (const char *path)) +{ + struct dirent *ent; + DIR *dir; + char **paths; + int n; + + dir = opendir(dpath); + + if (!dir) + return NULL; + + n = 1; + paths = malloc(sizeof(void *)); + *paths = NULL; + + while ((ent = readdir(dir)) != NULL) { + char *fpath; + char *name = ent->d_name; + + if (!strcmp(name, ".") || !strcmp(name, "..")) + continue; + + fpath = malloc(strlen(dpath) + 1 + strlen(name) + 1); + + strcpy(fpath, dpath); + strcat(fpath, "/"); + strcat(fpath, name); + + if (!filter || filter(fpath)) { + char **npaths; + + n++; + npaths = malloc(n * sizeof(void *)); + memcpy(npaths + 1, paths, (n - 1) * sizeof(void *)); + free(paths); + paths = npaths; + *npaths = fpath; + + } else { + free(fpath); + } + } + + closedir(dir); + + return paths; +} + +void paths_free(char **paths) +{ + char **paths_cur; + + paths_cur = paths; + while (*paths_cur) { + free(*paths_cur); + + paths_cur++; + } + + free(paths); +} + +char *file_get_content(const char *fpath) +{ + long size; + + char *page; + + size = file_get_size(fpath); + + if (size == -1) { + page = NULL; + + } else if (size == 0) { + page = malloc(1); + *page = '\0'; + + } else { + FILE *fp = fopen(fpath, "rb"); + if (fp) { + page = malloc(size + 1); + if (!page || size != fread(page, 1, size, fp)) { + free(page); + return NULL; + } + + *(page + size) = '\0'; + + fclose(fp); + } else { + page = NULL; + } + } + + return page; +} + +long file_get_size(const char *path) +{ + FILE *fp; + + if (!is_file(path)) + return -1; + + fp = fopen(path, "rb"); + if (fp) { + long size; + + if (fseek(fp, 0, SEEK_END) == -1) + return -1; + + size = ftell(fp); + + fclose(fp); + + return size; + } + + return -1; +} + +#define FCOPY_BUF_SZ 4096 +static int FILE_copy(FILE *src, FILE *dst) +{ + int ret = 0; + char *buf = malloc(FCOPY_BUF_SZ); + int n; + + if (!buf) + return FILE_COPY_ERROR_ALLOC_BUFFER; + + while (!ret) { + n = fread(buf, 1, FCOPY_BUF_SZ, src); + if (n) { + if (fwrite(buf, 1, n, dst) != n) + ret = FILE_COPY_ERROR_WRITE; + } else { + if (!feof(src)) + ret = FILE_COPY_ERROR_READ; + else + break; + } + } + + free(buf); + + return ret; +} + +int +file_copy(const char *src, const char *dst) +{ + FILE *fsrc, *fdst; + int ret = 0; + + fsrc = fopen(src, "r"); + + if (fsrc) { + fdst = fopen(dst, "w+"); + + if (fdst) { + ret = FILE_copy(fsrc, fdst); + fclose(fdst); + } else { + ret = FILE_COPY_ERROR_OPEN_DST; + } + + fclose(fsrc); + } else { + ret = FILE_COPY_ERROR_OPEN_SRC; + } + + return ret; +} + +char *path_append(const char *dir, const char *path) +{ + char *ret, *ndir; + + ndir = dir_normalize(dir); + + if (!ndir && (!path || !strlen(path))) + ret = NULL; + + else if (!ndir) { + ret = strdup(path); + + } else if (!path || !strlen(path)) { + return ndir; + + } else { + ret = malloc(strlen(ndir) + 1 + strlen(path) + 1); + strcpy(ret, ndir); + strcat(ret, "/"); + strcat(ret, path); + } + + free(ndir); + + return ret; +} + +void +file_copy_print_error(int code, const char *src, const char *dst) +{ + switch (code) { + case 0: + break; + case FILE_COPY_ERROR_OPEN_SRC: + printf("File copy error: failed to open %s.\n", src); + break; + case FILE_COPY_ERROR_OPEN_DST: + printf("File copy error: failed to open %s.\n", dst); + break; + case FILE_COPY_ERROR_READ: + printf("File copy error: failed to read %s.\n", src); + break; + case FILE_COPY_ERROR_WRITE: + printf("File copy error: failed to write %s.\n", src); + break; + case FILE_COPY_ERROR_ALLOC_BUFFER: + printf("File copy error: failed to allocate buffer.\n"); + break; + default: + printf("File copy error: unknown error %d.\n", code); + } +} diff --git a/src/lib/p_io.h b/src/lib/p_io.h new file mode 100644 index 0000000..a5887d9 --- /dev/null +++ b/src/lib/p_io.h @@ -0,0 +1,71 @@ +/* + 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 +*/ + +#ifndef _P_IO_H +#define _P_IO_H + +/* Returns '1' if a given 'path' denotates a directory else returns + 0 */ +int is_dir(const char *path); + +/* Returns '1' if a given 'path' denotates a file else returns + 0 */ +int is_file(const char *path); + +/* Returns a normalized path */ +char *path_normalize(const char *dpath); + +/* Returns the null-terminated entries of a directory */ +char **dir_list(const char *dpath, int (*filter) (const char *path)); +void paths_free(char **paths); + +char *path_append(const char *dir, const char *path); + +/* + Returns the size of a file. + Returns '-1' if the size cannot be retrieved or not a file. +*/ +long file_get_size(const char *path); + +/* + Returns the content of a file. + Returns 'NULL' if the file cannot be read or failed to allocate + enough memory. + Returns an empty string if the file exists but is empty. +*/ +char *file_get_content(const char *path); + +enum file_copy_error { + FILE_COPY_ERROR_OPEN_SRC = 1, + FILE_COPY_ERROR_OPEN_DST, + FILE_COPY_ERROR_READ, + FILE_COPY_ERROR_WRITE, + FILE_COPY_ERROR_ALLOC_BUFFER +}; + +void file_copy_print_error(int code, const char *src, const char *dst); + +/* + Copy a file. + + Returns '0' if sucessfull, otherwise return the error code. +*/ +int file_copy(const char *src, const char *dst); + +#endif diff --git a/src/plib/Makefile.am b/src/plib/Makefile.am deleted file mode 100644 index a34a02e..0000000 --- a/src/plib/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ - -AM_CPPFLAGS = \ - -I$(top_srcdir)/src - -noinst_LIBRARIES = libplib.a - -libplib_a_CFLAGS = -pedantic -Wall -Werror - -libplib_a_SOURCES = \ - plib_io.h plib_io.c diff --git a/src/plib/Makefile.in b/src/plib/Makefile.in deleted file mode 100644 index a4a38f8..0000000 --- a/src/plib/Makefile.in +++ /dev/null @@ -1,495 +0,0 @@ -# Makefile.in generated by automake 1.11.1 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -subdir = src/plib -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -LIBRARIES = $(noinst_LIBRARIES) -AR = ar -ARFLAGS = cru -libplib_a_AR = $(AR) $(ARFLAGS) -libplib_a_LIBADD = -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 -am__depfiles_maybe = depfiles -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(libplib_a_SOURCES) -DIST_SOURCES = $(libplib_a_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -APPINDICATOR_CFLAGS = @APPINDICATOR_CFLAGS@ -APPINDICATOR_LIBS = @APPINDICATOR_LIBS@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CURL_CFLAGS = @CURL_CFLAGS@ -CURL_LIBS = @CURL_LIBS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -GCONF_CFLAGS = @GCONF_CFLAGS@ -GCONF_LIBS = @GCONF_LIBS@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ -GMSGFMT = @GMSGFMT@ -GMSGFMT_015 = @GMSGFMT_015@ -GREP = @GREP@ -GTK_CFLAGS = @GTK_CFLAGS@ -GTK_LIBS = @GTK_LIBS@ -GTOP_CFLAGS = @GTOP_CFLAGS@ -GTOP_LIBS = @GTOP_LIBS@ -HELP2MAN = @HELP2MAN@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -INTLLIBS = @INTLLIBS@ -INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ -JSON_CFLAGS = @JSON_CFLAGS@ -JSON_LIBS = @JSON_LIBS@ -LDFLAGS = @LDFLAGS@ -LIBATIADL_CFLAGS = @LIBATIADL_CFLAGS@ -LIBATIADL_LIBS = @LIBATIADL_LIBS@ -LIBICONV = @LIBICONV@ -LIBINTL = @LIBINTL@ -LIBMICROHTTPD_CFLAGS = @LIBMICROHTTPD_CFLAGS@ -LIBMICROHTTPD_LIBS = @LIBMICROHTTPD_LIBS@ -LIBNOTIFY_CFLAGS = @LIBNOTIFY_CFLAGS@ -LIBNOTIFY_LIBS = @LIBNOTIFY_LIBS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBICONV = @LTLIBICONV@ -LTLIBINTL = @LTLIBINTL@ -LTLIBOBJS = @LTLIBOBJS@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -MSGFMT = @MSGFMT@ -MSGFMT_015 = @MSGFMT_015@ -MSGMERGE = @MSGMERGE@ -NVIDIA_CFLAGS = @NVIDIA_CFLAGS@ -NVIDIA_LIBS = @NVIDIA_LIBS@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -PKG_CONFIG = @PKG_CONFIG@ -PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ -PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ -POSUB = @POSUB@ -RANLIB = @RANLIB@ -SENSORS_LIBS = @SENSORS_LIBS@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -UNITY_CFLAGS = @UNITY_CFLAGS@ -UNITY_LIBS = @UNITY_LIBS@ -USE_NLS = @USE_NLS@ -VERSION = @VERSION@ -X11_CFLAGS = @X11_CFLAGS@ -X11_LIBS = @X11_LIBS@ -XEXT_CFLAGS = @XEXT_CFLAGS@ -XEXT_LIBS = @XEXT_LIBS@ -XGETTEXT = @XGETTEXT@ -XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ -XMKMF = @XMKMF@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -builddir = @builddir@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/src - -noinst_LIBRARIES = libplib.a -libplib_a_CFLAGS = -pedantic -Wall -Werror -libplib_a_SOURCES = \ - plib_io.h plib_io.c - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .o .obj -$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/plib/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/plib/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(am__aclocal_m4_deps): - -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) -libplib.a: $(libplib_a_OBJECTS) $(libplib_a_DEPENDENCIES) - -rm -f libplib.a - $(libplib_a_AR) libplib.a $(libplib_a_OBJECTS) $(libplib_a_LIBADD) - $(RANLIB) libplib.a - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplib_a-plib_io.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@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 $< - -.c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@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) '$<'` - -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 -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='plib_io.c' object='libplib_a-plib_io.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-plib_io.o `test -f 'plib_io.c' || echo '$(srcdir)/'`plib_io.c - -libplib_a-plib_io.obj: plib_io.c -@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplib_a_CFLAGS) $(CFLAGS) -MT libplib_a-plib_io.obj -MD -MP -MF $(DEPDIR)/libplib_a-plib_io.Tpo -c -o libplib_a-plib_io.obj `if test -f 'plib_io.c'; then $(CYGPATH_W) 'plib_io.c'; else $(CYGPATH_W) '$(srcdir)/plib_io.c'; fi` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libplib_a-plib_io.Tpo $(DEPDIR)/libplib_a-plib_io.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='plib_io.c' object='libplib_a-plib_io.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-plib_io.obj `if test -f 'plib_io.c'; then $(CYGPATH_W) 'plib_io.c'; else $(CYGPATH_W) '$(srcdir)/plib_io.c'; fi` - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - set x; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in files) print i; }; }'`; \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(LIBRARIES) -installdirs: -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -html-am: - -info: info-am - -info-am: - -install-data-am: - -install-dvi: install-dvi-am - -install-dvi-am: - -install-exec-am: - -install-html: install-html-am - -install-html-am: - -install-info: install-info-am - -install-info-am: - -install-man: - -install-pdf: install-pdf-am - -install-pdf-am: - -install-ps: install-ps-am - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: - -.MAKE: install-am install-strip - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ - clean-noinstLIBRARIES ctags distclean distclean-compile \ - distclean-generic distclean-tags distdir dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ - uninstall-am - - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/plib/plib_io.c b/src/plib/plib_io.c deleted file mode 100644 index 1fddcc9..0000000 --- a/src/plib/plib_io.c +++ /dev/null @@ -1,297 +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 -*/ - -#include -#include -#include -#include -#include - -#include "plib_io.h" - -int is_dir(const char *path) -{ - struct stat st; - - int ret = lstat(path, &st); - - if (ret == 0 && S_ISDIR(st.st_mode)) - return 1; - - return 0; -} - -int is_file(const char *path) -{ - struct stat st; - - int ret = lstat(path, &st); - - if (ret == 0 && S_ISREG(st.st_mode)) - return 1; - - return 0; -} - -char *dir_normalize(const char *dpath) -{ - char *npath; - int n; - - if (!dpath || !strlen(dpath)) - return NULL; - - npath = strdup(dpath); - - n = strlen(npath); - - if (n > 1 && npath[n - 1] == '/') - npath[n - 1] = '\0'; - - return npath; -} - -char **dir_list(const char *dpath, int (*filter) (const char *path)) -{ - struct dirent *ent; - DIR *dir; - char **paths; - int n; - - dir = opendir(dpath); - - if (!dir) - return NULL; - - n = 1; - paths = malloc(sizeof(void *)); - *paths = NULL; - - while ((ent = readdir(dir)) != NULL) { - char *fpath; - char *name = ent->d_name; - - if (!strcmp(name, ".") || !strcmp(name, "..")) - continue; - - fpath = malloc(strlen(dpath) + 1 + strlen(name) + 1); - - strcpy(fpath, dpath); - strcat(fpath, "/"); - strcat(fpath, name); - - if (!filter || filter(fpath)) { - char **npaths; - - n++; - npaths = malloc(n * sizeof(void *)); - memcpy(npaths + 1, paths, (n - 1) * sizeof(void *)); - free(paths); - paths = npaths; - *npaths = fpath; - - } else { - free(fpath); - } - } - - closedir(dir); - - return paths; -} - -void paths_free(char **paths) -{ - char **paths_cur; - - paths_cur = paths; - while (*paths_cur) { - free(*paths_cur); - - paths_cur++; - } - - free(paths); -} - -char *file_get_content(const char *fpath) -{ - long size; - - char *page; - - size = file_get_size(fpath); - - if (size == -1) { - page = NULL; - - } else if (size == 0) { - page = malloc(1); - *page = '\0'; - - } else { - FILE *fp = fopen(fpath, "rb"); - if (fp) { - page = malloc(size + 1); - if (!page || size != fread(page, 1, size, fp)) { - free(page); - return NULL; - } - - *(page + size) = '\0'; - - fclose(fp); - } else { - page = NULL; - } - } - - return page; -} - -long file_get_size(const char *path) -{ - FILE *fp; - - if (!is_file(path)) - return -1; - - fp = fopen(path, "rb"); - if (fp) { - long size; - - if (fseek(fp, 0, SEEK_END) == -1) - return -1; - - size = ftell(fp); - - fclose(fp); - - return size; - } - - return -1; -} - -#define FCOPY_BUF_SZ 4096 -static int FILE_copy(FILE *src, FILE *dst) -{ - int ret = 0; - char *buf = malloc(FCOPY_BUF_SZ); - int n; - - if (!buf) - return FILE_COPY_ERROR_ALLOC_BUFFER; - - while (!ret) { - n = fread(buf, 1, FCOPY_BUF_SZ, src); - if (n) { - if (fwrite(buf, 1, n, dst) != n) - ret = FILE_COPY_ERROR_WRITE; - } else { - if (!feof(src)) - ret = FILE_COPY_ERROR_READ; - else - break; - } - } - - free(buf); - - return ret; -} - -int -file_copy(const char *src, const char *dst) -{ - FILE *fsrc, *fdst; - int ret = 0; - - fsrc = fopen(src, "r"); - - if (fsrc) { - fdst = fopen(dst, "w+"); - - if (fdst) { - ret = FILE_copy(fsrc, fdst); - fclose(fdst); - } else { - ret = FILE_COPY_ERROR_OPEN_DST; - } - - fclose(fsrc); - } else { - ret = FILE_COPY_ERROR_OPEN_SRC; - } - - return ret; -} - -char *path_append(const char *dir, const char *path) -{ - char *ret, *ndir; - - ndir = dir_normalize(dir); - - if (!ndir && (!path || !strlen(path))) - ret = NULL; - - else if (!ndir) { - ret = strdup(path); - - } else if (!path || !strlen(path)) { - return ndir; - - } else { - ret = malloc(strlen(ndir) + 1 + strlen(path) + 1); - strcpy(ret, ndir); - strcat(ret, "/"); - strcat(ret, path); - } - - free(ndir); - - return ret; -} - -void -file_copy_print_error(int code, const char *src, const char *dst) -{ - switch (code) { - case 0: - break; - case FILE_COPY_ERROR_OPEN_SRC: - printf("File copy error: failed to open %s.\n", src); - break; - case FILE_COPY_ERROR_OPEN_DST: - printf("File copy error: failed to open %s.\n", dst); - break; - case FILE_COPY_ERROR_READ: - printf("File copy error: failed to read %s.\n", src); - break; - case FILE_COPY_ERROR_WRITE: - printf("File copy error: failed to write %s.\n", src); - break; - case FILE_COPY_ERROR_ALLOC_BUFFER: - printf("File copy error: failed to allocate buffer.\n"); - break; - default: - printf("File copy error: unknown error %d.\n", code); - } -} diff --git a/src/plib/plib_io.h b/src/plib/plib_io.h deleted file mode 100644 index a5887d9..0000000 --- a/src/plib/plib_io.h +++ /dev/null @@ -1,71 +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 -*/ - -#ifndef _P_IO_H -#define _P_IO_H - -/* Returns '1' if a given 'path' denotates a directory else returns - 0 */ -int is_dir(const char *path); - -/* Returns '1' if a given 'path' denotates a file else returns - 0 */ -int is_file(const char *path); - -/* Returns a normalized path */ -char *path_normalize(const char *dpath); - -/* Returns the null-terminated entries of a directory */ -char **dir_list(const char *dpath, int (*filter) (const char *path)); -void paths_free(char **paths); - -char *path_append(const char *dir, const char *path); - -/* - Returns the size of a file. - Returns '-1' if the size cannot be retrieved or not a file. -*/ -long file_get_size(const char *path); - -/* - Returns the content of a file. - Returns 'NULL' if the file cannot be read or failed to allocate - enough memory. - Returns an empty string if the file exists but is empty. -*/ -char *file_get_content(const char *path); - -enum file_copy_error { - FILE_COPY_ERROR_OPEN_SRC = 1, - FILE_COPY_ERROR_OPEN_DST, - FILE_COPY_ERROR_READ, - FILE_COPY_ERROR_WRITE, - FILE_COPY_ERROR_ALLOC_BUFFER -}; - -void file_copy_print_error(int code, const char *src, const char *dst); - -/* - Copy a file. - - Returns '0' if sucessfull, otherwise return the error code. -*/ -int file_copy(const char *src, const char *dst); - -#endif diff --git a/src/server/Makefile.am b/src/server/Makefile.am index 0aab252..1ef3750 100644 --- a/src/server/Makefile.am +++ b/src/server/Makefile.am @@ -12,7 +12,6 @@ AM_CPPFLAGS = -pedantic -Wall -Werror -DDEFAULT_WWW_DIR=\""$(pkgdatadir)/www"\"\ DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ LIBS = \ - ../plib/libplib.a \ ../lib/libpsensor.a \ ../libpsensor_json/libpsensor_json.a \ $(SENSORS_LIBS) \ diff --git a/src/server/Makefile.in b/src/server/Makefile.in index 68022ad..794f6c7 100644 --- a/src/server/Makefile.in +++ b/src/server/Makefile.in @@ -147,9 +147,9 @@ LIBMICROHTTPD_LIBS = @LIBMICROHTTPD_LIBS@ LIBNOTIFY_CFLAGS = @LIBNOTIFY_CFLAGS@ LIBNOTIFY_LIBS = @LIBNOTIFY_LIBS@ LIBOBJS = @LIBOBJS@ -LIBS = ../plib/libplib.a ../lib/libpsensor.a \ - ../libpsensor_json/libpsensor_json.a $(SENSORS_LIBS) \ - $(JSON_LIBS) $(LIBMICROHTTPD_LIBS) $(am__append_2) +LIBS = ../lib/libpsensor.a ../libpsensor_json/libpsensor_json.a \ + $(SENSORS_LIBS) $(JSON_LIBS) $(LIBMICROHTTPD_LIBS) \ + $(am__append_2) LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ LTLIBOBJS = @LTLIBOBJS@ diff --git a/src/server/server.c b/src/server/server.c index e0757cf..dc1781e 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -43,7 +43,7 @@ #include "psensor_json.h" #include "url.h" -#include "plib/plib_io.h" +#include "p_io.h" #include "server.h" static const char *program_name;