diff --git a/Makefile.am b/Makefile.am index 911f707..e768b53 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ AUTOMAKE_OPTIONS = 1.10 foreign subdir-objects ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = build-aux compat doc examples m4 src win32 +SUBDIRS = build-aux compat doc examples m4 src dist_doc_DATA = COPYING NEWS README @@ -12,10 +12,7 @@ EXTRA_DIST = \ CLEANFILES = core *.core *~ .*~ -.PHONY: regen-win32 snapshot - -regen-win32: - cd win32; ${MAKE} regen-win32 +.PHONY: snapshot snapshot: ${MAKE} distcheck distdir=${PACKAGE}-snapshot-`date +'%Y%m%d'` diff --git a/NEWS b/NEWS index 6e66601..be89615 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +Changes in X.X.X, released on XXXX-XX-XX: + + * Windows is no longer actively supported. + + * Certain legacy UNIX systems are no longer actively supported. + + + Changes in 0.6.0, released on 2015-01-18: * This release contains a SECURITY FIX for a command injection vulnerability diff --git a/configure.ac b/configure.ac index e7be528..d7157a3 100644 --- a/configure.ac +++ b/configure.ac @@ -212,20 +212,14 @@ AC_CHECK_FUNCS([ \ gettimeofday \ nl_langinfo \ pclose \ - _pclose \ popen \ - _popen \ random \ setlocale \ snprintf \ - _snprintf \ srandomdev \ stat \ - _stat \ strncasecmp \ - strnicmp \ strtoll \ - _strtoi64 \ ]) AC_REPLACE_FUNCS([ \ @@ -275,8 +269,6 @@ AC_CONFIG_FILES([ m4/Makefile src/Makefile src/ezstream-file.sh - win32/Makefile - win32/shout/Makefile ]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index 54daecf..f7db845 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -6,7 +6,6 @@ bin_SCRIPTS = ezstream-file.sh ezstream_SOURCES = \ configfile.c \ ezstream.c \ - local_basename.c \ metadata.c \ playlist.c \ util.c \ @@ -20,7 +19,6 @@ AM_LDFLAGS = @EZ_LDFLAGS@ EXTRA_DIST = \ configfile.h \ ezstream.h \ - local_basename.h \ metadata.h \ playlist.h \ util.h \ diff --git a/src/ezstream.c b/src/ezstream.c index c7c684f..a5a4247 100644 --- a/src/ezstream.c +++ b/src/ezstream.c @@ -33,8 +33,6 @@ #include "util.h" #include "xalloc.h" -#include "local_basename.h" - #define STREAM_DONE 0 #define STREAM_CONT 1 #define STREAM_SKIP 2 @@ -584,9 +582,6 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag, if (isStdin != NULL) *isStdin = 1; -#ifdef WIN32 - _setmode(_fileno(stdin), _O_BINARY); -#endif filep = stdin; return (filep); } @@ -657,9 +652,6 @@ openResource(shout_t *shout, const char *fileName, int *popenFlag, printf("\n"); } else { *popenFlag = 1; -#ifdef WIN32 - _setmode(_fileno(filep), _O_BINARY ); -#endif } xfree(pCommandString); @@ -827,7 +819,7 @@ sendStream(shout_t *shout, FILE *filepstream, const char *fileName, if (!isStdin && playlistMode) { if (pezConfig->fileNameIsProgram) { char *tmp = xstrdup(pezConfig->fileName); - printf(" [%s]", local_basename(tmp)); + printf(" [%s]", basename(tmp)); xfree(tmp); } else printf(" [%4lu/%-4lu]", @@ -1068,7 +1060,7 @@ getProgname(const char *argv0) if (argv0 == NULL) return ((char *)"ezstream"); - p = strrchr(argv0, path_separators[0]); + p = strrchr(argv0, '/'); if (p == NULL) p = (char *)argv0; else diff --git a/src/ezstream.h b/src/ezstream.h index 3e6d192..d498004 100644 --- a/src/ezstream.h +++ b/src/ezstream.h @@ -35,6 +35,9 @@ #include #include #include +#if defined(HAVE_LIBGEN_H) && !defined(__linux__) +# include +#endif /* HAVE_LIBGEN_H && !__linux__ */ #include #ifdef HAVE_PATHS_H # include @@ -52,50 +55,11 @@ #endif /* !STDIN_FILENO */ #ifndef _PATH_DEVNULL -# ifdef WIN32 -# define _PATH_DEVNULL "nul" -# else /* WIN32 */ -# define _PATH_DEVNULL "/dev/null" -# endif /* WIN32 */ +# define _PATH_DEVNULL "/dev/null" #endif /* !_PATH_DEVNULL */ #ifndef PATH_MAX # define PATH_MAX 256 #endif /* !PATH_MAX */ -#if !defined(HAVE_PCLOSE) && defined(HAVE__PCLOSE) -# define pclose _pclose -#endif /* !HAVE_PCLOSE && HAVE__PCLOSE */ -#if !defined(HAVE_POPEN) && defined(HAVE__POPEN) -# define popen _popen -#endif /* !HAVE_POPEN && HAVE__POPEN */ -#if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF) -# define snprintf _snprintf -#endif /* !HAVE_SNPRINTF && HAVE__SNPRINTF */ -#if !defined(HAVE_STAT) && defined(HAVE__STAT) -# define stat _stat -#endif /* !HAVE_STAT && HAVE__STAT */ -#if !defined(HAVE_STRNCASECMP) && defined(HAVE_STRNICMP) -# define strncasecmp strnicmp -#endif /* !HAVE_STRNCASECMP && HAVE_STRNICMP */ -#if !defined(HAVE_STRTOLL) && defined(HAVE__STRTOI64) -# define strtoll _strtoi64 -#endif /* !HAVE_STRTOLL && HAVE__STRTOI64 */ - -#ifndef S_IRGRP -# define S_IRGRP 0 -# define S_IWGRP 0 -# define S_IXGRP 0 -#endif /* !S_IRGRP */ -#ifndef S_IROTH -# define S_IROTH 0 -# define S_IWOTH 0 -# define S_IXOTH 0 -#endif /* !S_IROTH */ - -#ifdef WIN32 -# include -# define sleep(a) Sleep((a) * 1000) -#endif /* WIN32 */ - #endif /* __EZSTREAM_H__ */ diff --git a/src/local_basename.c b/src/local_basename.c deleted file mode 100644 index e27c82e..0000000 --- a/src/local_basename.c +++ /dev/null @@ -1,107 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#ifdef HAVE_SYS_TYPES_H -# include -#endif /* HAVE_SYS_TYPES_H */ - -#include -#if defined(HAVE_LIBGEN_H) && !defined(__linux__) -# include -#endif /* HAVE_LIBGEN_H && !__linux__ */ -#include -#include - -#include "local_basename.h" - -#ifndef PATH_SEPARATORS -# define PATH_SEPARATORS "/" -#endif /* !PATH_SEPARATORS */ - -const char *path_separators = PATH_SEPARATORS; - -char * local_basename(const char *); - -static inline int - is_separator(int); - -static inline int -is_separator(int c) -{ - const char *cp; - - for (cp = path_separators; '\0' != *cp; cp++) { - if (*cp == c) - return (1); - } - - return (0); -} - -/* - * Modified basename() implementation from OpenBSD, based on: - * $OpenBSD: src/lib/libc/gen/basename.c,v 1.15 2013/09/30 12:02:32 millert Exp $ - */ -/* - * Copyright (c) 1997, 2004 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -char * -local_basename(const char *path) -{ -#ifdef HAVE_BASENAME - return (basename(path)); -#else /* HAVE_BASENAME */ - static char bname[PATH_MAX]; - size_t len; - const char *startp, *endp; - - if (path == NULL || *path == '\0') { - bname[0] = '.'; - bname[1] = '\0'; - return (bname); - } - - /* Strip any trailing path separators */ - endp = path + strlen(path) - 1; - while (endp > path && is_separator(*endp)) - endp--; - - /* - * All path separators become a single one; pick the first in the - * list as the default. - */ - if (endp == path && is_separator(*endp)) { - bname[0] = path_separators[0]; - bname[1] = '\0'; - return (bname); - } - - /* Find the start of the base */ - startp = endp; - while (startp > path && !is_separator(*(startp - 1))) - startp--; - - len = endp - startp + 1; - if (len >= sizeof(bname)) { - errno = ENAMETOOLONG; - return (NULL); - } - memcpy(bname, startp, len); - bname[len] = '\0'; - - return (bname); -#endif /* HAVE_BASENAME */ -} diff --git a/src/local_basename.h b/src/local_basename.h deleted file mode 100644 index 3f0dd94..0000000 --- a/src/local_basename.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __LOCAL_BASENAME_H__ -#define __LOCAL_BASENAME_H__ - -extern const char *path_separators; - -char * local_basename(const char *); - -#endif /* __LOCAL_BASENAME_H__ */ diff --git a/src/metadata.c b/src/metadata.c index 5da6635..19a1548 100644 --- a/src/metadata.c +++ b/src/metadata.c @@ -34,8 +34,6 @@ #include "util.h" #include "xalloc.h" -#include "local_basename.h" - /* Usually defined in . */ #ifndef S_IEXEC # define S_IEXEC S_IXUSR @@ -307,7 +305,7 @@ metadata_get_name(const char *file) abort(); } - if ((p1 = local_basename(filename)) == NULL) { + if ((p1 = basename(filename)) == NULL) { printf("%s: Internal error: basename() failed with '%s'\n", __progname, filename); exit(1); diff --git a/src/util.c b/src/util.c index 52f170c..9ed92e7 100644 --- a/src/util.c +++ b/src/util.c @@ -223,21 +223,15 @@ stream_setup(const char *host, unsigned short port, const char *mount) char * CHARtoUTF8(const char *in_str, int mode) { -#ifndef WIN32 char *codeset; -# if defined(HAVE_NL_LANGINFO) && defined(HAVE_SETLOCALE) && defined(CODESET) +#if defined(HAVE_NL_LANGINFO) && defined(HAVE_SETLOCALE) && defined(CODESET) setlocale(LC_CTYPE, ""); codeset = nl_langinfo((nl_item)CODESET); setlocale(LC_CTYPE, "C"); -# else - codeset = (char *)""; -# endif /* HAVE_NL_LANGINFO && HAVE_SETLOCALE && CODESET */ #else - char codeset[24]; - - snprintf(codeset, sizeof(codeset), "CP%u", GetACP()); -#endif /* !WIN32 */ + codeset = (char *)""; +#endif /* HAVE_NL_LANGINFO && HAVE_SETLOCALE && CODESET */ return (iconvert(in_str, codeset, "UTF-8", mode)); } @@ -245,21 +239,15 @@ CHARtoUTF8(const char *in_str, int mode) char * UTF8toCHAR(const char *in_str, int mode) { -#ifndef WIN32 char *codeset; -# if defined(HAVE_NL_LANGINFO) && defined(HAVE_SETLOCALE) && defined(CODESET) +#if defined(HAVE_NL_LANGINFO) && defined(HAVE_SETLOCALE) && defined(CODESET) setlocale(LC_CTYPE, ""); codeset = nl_langinfo((nl_item)CODESET); setlocale(LC_CTYPE, "C"); -# else - codeset = (char *)""; -# endif /* HAVE_NL_LANGINFO && HAVE_SETLOCALE && CODESET */ #else - char codeset[24]; - - snprintf(codeset, sizeof(codeset), "CP%u", GetACP()); -#endif /* !WIN32 */ + codeset = (char *)""; +#endif /* HAVE_NL_LANGINFO && HAVE_SETLOCALE && CODESET */ return (iconvert(in_str, "UTF-8", codeset, mode)); } @@ -373,32 +361,10 @@ ez_gettimeofday(void *tp_arg) #ifdef HAVE_GETTIMEOFDAY ret = gettimeofday(tp, NULL); #else /* HAVE_GETTIMEOFDAY */ -# ifdef WIN32 - /* - * Idea for this way of implementing gettimeofday()-like functionality - * on Windows taken from cURL, (C) 1998 - 2007 Daniel Steinberg, et al. - * http://curl.haxx.se/docs/copyright.html - */ - SYSTEMTIME st; - struct tm tm; - - GetLocalTime(&st); - tm.tm_sec = st.wSecond; - tm.tm_min = st.wMinute; - tm.tm_hour = st.wHour; - tm.tm_mday = st.wDay; - tm.tm_mon = st.wMonth - 1; - tm.tm_year = st.wYear - 1900; - tm.tm_isdst = -1; - tp->tv_sec = (long)mktime(&tm); - tp->tv_usec = st.wMilliseconds * 1000; - ret = 0; -# else /* WIN32 */ /* Fallback to time(): */ tp->tv_sec = (long)time(NULL); tp->tv_usec = 0; ret = 0; -# endif /* WIN32 */ #endif /* HAVE_GETTIMEOFDAY */ return (ret); diff --git a/src/xalloc.c b/src/xalloc.c index 9f06de7..644f108 100644 --- a/src/xalloc.c +++ b/src/xalloc.c @@ -191,64 +191,18 @@ _xalloc_vasprintf(char **str_p, const char *fmt, va_list ap, size_t *strsiz) va_list ap_local; *str_p = NULL; -#ifndef WIN32 -# ifndef HAVE_BROKEN_VSNPRINTF - - /* MODERN UNIX */ va_copy(ap_local, ap); *strsiz = vsnprintf(NULL, (size_t)0, fmt, ap_local) + 1; va_end(ap_local); -# ifdef HAVE_ASPRINTF +#ifdef HAVE_ASPRINTF if ((ret = vasprintf(str_p, fmt, ap)) == -1) *str_p = NULL; -# else +#else if ((*str_p = real_calloc(*strsiz, sizeof(char))) == NULL) return (-1); ret = vsnprintf(*str_p, *strsiz, fmt, ap); -# endif /* HAVE_ASPRINTF */ -# else - - /* ANCIENT UNIX */ - - { - char *buf = NULL; - - *strsiz = 4; - for (;;) { - char *tbuf; - int pret; - - if ((tbuf = real_realloc(buf, *strsiz)) == NULL) { - real_free(buf); - return (-1); - } - buf = tbuf; - va_copy(ap_local, ap); - pret = vsnprintf(buf, *strsiz, fmt, ap_local); - va_end(ap_local); - if (pret > 0 && pret < (int)*strsiz) - break; - if ((int)(*strsiz *= 2) < 0) { - real_free(buf); - return (-1); - } - } - ret = vsnprintf(buf, *strsiz, fmt, ap); - *str_p = buf; - } -# endif /* !HAVE_BROKEN_VSNPRINTF */ -#else - - /* WINDOWS */ - - va_copy(ap_local, ap); - *strsiz = _vscprintf(fmt, ap_local) + 1; - va_end(ap_local); - if ((*str_p = real_calloc(*strsiz, sizeof(char))) == NULL) - return (-1); - ret = _vsnprintf(*str_p, *strsiz, fmt, ap); -#endif /* !WIN32 */ +#endif /* HAVE_ASPRINTF */ return (ret); } diff --git a/win32/Makefile.am b/win32/Makefile.am deleted file mode 100644 index 35f6653..0000000 --- a/win32/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -AUTOMAKE_OPTIONS = 1.10 foreign subdir-objects - -SUBDIRS = shout - -EXTRA_DIST = \ - README.win32 config.h compat.h \ - ezstream.sln ezstream.vcproj \ - libflac.vcproj libogg.vcproj libshout.vcproj libspeex.vcproj \ - libtheora.vcproj libvorbis.vcproj libvorbisfile.vcproj libz.vcproj \ - taglib.vcproj taglib_c.vcproj \ - tfile.cpp - -CLEANFILES = core *.core *~ .*~ ezstream.1.pdf - -do_subst = sed -e 's,!!EXAMPLES_DIR!!,${PACKAGE_TARNAME}-${PACKAGE_VERSION}-win32/examples,g' - -.PHONY: regen-win32 - -regen-win32: Makefile - $(do_subst) < $(top_srcdir)/doc/ezstream.1.in | nroff -Tps -mandoc - | ps2pdf - ezstream.1.pdf diff --git a/win32/README.win32 b/win32/README.win32 deleted file mode 100644 index 33783b6..0000000 --- a/win32/README.win32 +++ /dev/null @@ -1,90 +0,0 @@ -README.win32 - Information about the binary Ezstream distribution for Windows -============================================================================= - - - -1. .ZIP Archive Contents ------------------------- - - -| File | Description | -+======================================================================+ -| \COPYING.txt | License for using, modifying and | -| | distributing Ezstream. | -+-----------------------+----------------------------------------------+ -| \README.txt | This file. | -+-----------------------+----------------------------------------------+ -| \ezstream.1.pdf | The ezstream manual in PDF format. | -+-----------------------+----------------------------------------------+ -| \ezstream.exe | The ezstream executable file. | -+-----------------------+----------------------------------------------+ -| \ezstream-X.Y.Z.zip | The ezstream source distribution, from which | -| | ezstream.exe was built. | -+-----------------------+----------------------------------------------+ -| \examples\*.xml | Ezstream example configuration files. | -+-----------------------+----------------------------------------------+ -| \examples\*.sh | Example playlist and metadata scripts, for | -| | demonstrational purposes (these are shell | -| | scripts.) | -+-----------------------+----------------------------------------------+ - - - -2. Installation ---------------- - - -As of version 0.3.0, ezstream no longer comes with an installer. If you have a -previous version of ezstream installed, you might want to simply uninstall it. - -The ezstream.exe file can be run from any location. To install it, simply copy -it to a location of your choosing. To make it available anywhere on the -system, add the installation folder to your PATH environment variable. - -If it doesn't start, e.g. running - > ezstream.exe -h -does not show the command line help, the Microsoft Visual C++ 2008 runtime -libraries are missing. Download and install vcredist_x86.exe, which can be -easily found on www.microsoft.com via - http://www.google.com/search?q=vc+2008+redist - - - -3. Limited functionality ------------------------- - - -A few useful features are missing in the Windows version of ezstream: - * Runtime control via signals is not possible. - * Some useful external utilities (encoders, decoders) may not be available on - Windows. - - - -4. Source code --------------- - - -Ezstream uses: - * zlib (http://www.zlib.net/, BSD-like license) - * libiconv (https://www.gnu.org/software/libiconv/, LGPL) - * libxml2 (http://xmlsoft.org/, BSD-like license) - * libogg, libvorbis, libvorbisfile (http://www.vorbis.com/, BSD-like license) - * libFLAC (https://xiph.org/flac/, BSD-like license) - * libtheora (http://www.theora.org/, BSD-like license) - * libshout (http://www.icecast.org, LGPL) - * TagLib (https://taglib.github.io/, LGPL) - -These libraries are statically linked into the ezstream.exe file. - -Ezstream itself is licensed under the GPL version 2 (see COPYING.txt for -details.) - - - -5. Support ----------- - - -For information on how to report issues with ezstream, please visit the -ezstream home page at http://www.icecast.org/ezstream.php diff --git a/win32/compat.h b/win32/compat.h deleted file mode 100644 index 38d37ec..0000000 --- a/win32/compat.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __WIN32_COMPAT_H__ -#define __WIN32_COMPAT_H__ - -/* #define WIN32_LEAN_AND_MEAN */ -#include -#include -#include -#include - -#define inline __inline - -#define va_copy(dst, src) memcpy(&(dst), &(src), sizeof(va_list)) - -#define PATH_SEPARATORS "\\/" - -#ifndef ssize_t -# define ssize_t long -#endif /* !ssize_t */ - -#endif /* __WIN32_COMPAT_H__ */ diff --git a/win32/config.h b/win32/config.h deleted file mode 100644 index 781abc0..0000000 --- a/win32/config.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef __WIN32_CONFIG_H__ -#define __WIN32_CONFIG_H__ - -#define PACKAGE_STRING "ezstream 0.6.0" - -#define HAVE_SYS_TYPES_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_LOCALE_H 1 - -#define HAVE_STAT 1 -#define HAVE__PCLOSE 1 -#define HAVE__POPEN 1 -#define HAVE__SNPRINTF 1 -#define HAVE__STRTOI64 1 - -#define HAVE_ICONV 1 -#define HAVE_TAGLIB 1 -#define ICONV_CONST - -#include - -#endif /* __WIN32_CONFIG_H__ */ diff --git a/win32/ezstream.sln b/win32/ezstream.sln deleted file mode 100644 index 7dcca1d..0000000 --- a/win32/ezstream.sln +++ /dev/null @@ -1,111 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ezstream", "ezstream.vcproj", "{43809192-0B8F-4AFE-85E6-C54E265CFB75}" - ProjectSection(ProjectDependencies) = postProject - {0A70BF55-FCF6-4DD8-A455-8233666A60E1} = {0A70BF55-FCF6-4DD8-A455-8233666A60E1} - {1ACB165E-8C63-4B44-A4EB-791EFA8FA0A5} = {1ACB165E-8C63-4B44-A4EB-791EFA8FA0A5} - {29A3AE75-E9A8-4A43-BADB-A4EF0972BD5B} = {29A3AE75-E9A8-4A43-BADB-A4EF0972BD5B} - {8FB7BDB7-B66C-4D45-A03D-2FD46AAB1B08} = {8FB7BDB7-B66C-4D45-A03D-2FD46AAB1B08} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libogg", "libogg.vcproj", "{60A624C8-EEFF-4083-A02E-1A4F6B56CE4F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbis", "libvorbis.vcproj", "{5CC6CF7F-35F8-41D4-AB87-F8173EFF390D}" - ProjectSection(ProjectDependencies) = postProject - {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F} = {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbisfile", "libvorbisfile.vcproj", "{8FB7BDB7-B66C-4D45-A03D-2FD46AAB1B08}" - ProjectSection(ProjectDependencies) = postProject - {5CC6CF7F-35F8-41D4-AB87-F8173EFF390D} = {5CC6CF7F-35F8-41D4-AB87-F8173EFF390D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libflac", "libflac.vcproj", "{3B517561-45A7-4189-B149-6EA03369255D}" - ProjectSection(ProjectDependencies) = postProject - {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F} = {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtheora", "libtheora.vcproj", "{140F1A87-BAE3-4DBD-9221-D0918A63646F}" - ProjectSection(ProjectDependencies) = postProject - {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F} = {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspeex", "libspeex.vcproj", "{6EC28559-BD88-4C63-AD91-A406FED1B363}" - ProjectSection(ProjectDependencies) = postProject - {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F} = {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libshout", "libshout.vcproj", "{29A3AE75-E9A8-4A43-BADB-A4EF0972BD5B}" - ProjectSection(ProjectDependencies) = postProject - {6EC28559-BD88-4C63-AD91-A406FED1B363} = {6EC28559-BD88-4C63-AD91-A406FED1B363} - {3B517561-45A7-4189-B149-6EA03369255D} = {3B517561-45A7-4189-B149-6EA03369255D} - {5CC6CF7F-35F8-41D4-AB87-F8173EFF390D} = {5CC6CF7F-35F8-41D4-AB87-F8173EFF390D} - {140F1A87-BAE3-4DBD-9221-D0918A63646F} = {140F1A87-BAE3-4DBD-9221-D0918A63646F} - {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F} = {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libz", "libz.vcproj", "{1ACB165E-8C63-4B44-A4EB-791EFA8FA0A5}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "taglib", "taglib.vcproj", "{B1A6316C-A73A-4B34-A428-E967A698CA37}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "taglib_c", "taglib_c.vcproj", "{0A70BF55-FCF6-4DD8-A455-8233666A60E1}" - ProjectSection(ProjectDependencies) = postProject - {B1A6316C-A73A-4B34-A428-E967A698CA37} = {B1A6316C-A73A-4B34-A428-E967A698CA37} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {43809192-0B8F-4AFE-85E6-C54E265CFB75}.Debug|Win32.ActiveCfg = Debug|Win32 - {43809192-0B8F-4AFE-85E6-C54E265CFB75}.Debug|Win32.Build.0 = Debug|Win32 - {43809192-0B8F-4AFE-85E6-C54E265CFB75}.Release|Win32.ActiveCfg = Release|Win32 - {43809192-0B8F-4AFE-85E6-C54E265CFB75}.Release|Win32.Build.0 = Release|Win32 - {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F}.Debug|Win32.ActiveCfg = Debug|Win32 - {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F}.Debug|Win32.Build.0 = Debug|Win32 - {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F}.Release|Win32.ActiveCfg = Release|Win32 - {60A624C8-EEFF-4083-A02E-1A4F6B56CE4F}.Release|Win32.Build.0 = Release|Win32 - {5CC6CF7F-35F8-41D4-AB87-F8173EFF390D}.Debug|Win32.ActiveCfg = Debug|Win32 - {5CC6CF7F-35F8-41D4-AB87-F8173EFF390D}.Debug|Win32.Build.0 = Debug|Win32 - {5CC6CF7F-35F8-41D4-AB87-F8173EFF390D}.Release|Win32.ActiveCfg = Release|Win32 - {5CC6CF7F-35F8-41D4-AB87-F8173EFF390D}.Release|Win32.Build.0 = Release|Win32 - {8FB7BDB7-B66C-4D45-A03D-2FD46AAB1B08}.Debug|Win32.ActiveCfg = Debug|Win32 - {8FB7BDB7-B66C-4D45-A03D-2FD46AAB1B08}.Debug|Win32.Build.0 = Debug|Win32 - {8FB7BDB7-B66C-4D45-A03D-2FD46AAB1B08}.Release|Win32.ActiveCfg = Release|Win32 - {8FB7BDB7-B66C-4D45-A03D-2FD46AAB1B08}.Release|Win32.Build.0 = Release|Win32 - {3B517561-45A7-4189-B149-6EA03369255D}.Debug|Win32.ActiveCfg = Debug|Win32 - {3B517561-45A7-4189-B149-6EA03369255D}.Debug|Win32.Build.0 = Debug|Win32 - {3B517561-45A7-4189-B149-6EA03369255D}.Release|Win32.ActiveCfg = Release|Win32 - {3B517561-45A7-4189-B149-6EA03369255D}.Release|Win32.Build.0 = Release|Win32 - {140F1A87-BAE3-4DBD-9221-D0918A63646F}.Debug|Win32.ActiveCfg = Debug|Win32 - {140F1A87-BAE3-4DBD-9221-D0918A63646F}.Debug|Win32.Build.0 = Debug|Win32 - {140F1A87-BAE3-4DBD-9221-D0918A63646F}.Release|Win32.ActiveCfg = Release|Win32 - {140F1A87-BAE3-4DBD-9221-D0918A63646F}.Release|Win32.Build.0 = Release|Win32 - {6EC28559-BD88-4C63-AD91-A406FED1B363}.Debug|Win32.ActiveCfg = Debug|Win32 - {6EC28559-BD88-4C63-AD91-A406FED1B363}.Debug|Win32.Build.0 = Debug|Win32 - {6EC28559-BD88-4C63-AD91-A406FED1B363}.Release|Win32.ActiveCfg = Release|Win32 - {6EC28559-BD88-4C63-AD91-A406FED1B363}.Release|Win32.Build.0 = Release|Win32 - {29A3AE75-E9A8-4A43-BADB-A4EF0972BD5B}.Debug|Win32.ActiveCfg = Debug|Win32 - {29A3AE75-E9A8-4A43-BADB-A4EF0972BD5B}.Debug|Win32.Build.0 = Debug|Win32 - {29A3AE75-E9A8-4A43-BADB-A4EF0972BD5B}.Release|Win32.ActiveCfg = Release|Win32 - {29A3AE75-E9A8-4A43-BADB-A4EF0972BD5B}.Release|Win32.Build.0 = Release|Win32 - {1ACB165E-8C63-4B44-A4EB-791EFA8FA0A5}.Debug|Win32.ActiveCfg = Debug|Win32 - {1ACB165E-8C63-4B44-A4EB-791EFA8FA0A5}.Debug|Win32.Build.0 = Debug|Win32 - {1ACB165E-8C63-4B44-A4EB-791EFA8FA0A5}.Release|Win32.ActiveCfg = Release|Win32 - {1ACB165E-8C63-4B44-A4EB-791EFA8FA0A5}.Release|Win32.Build.0 = Release|Win32 - {B1A6316C-A73A-4B34-A428-E967A698CA37}.Debug|Win32.ActiveCfg = Debug|Win32 - {B1A6316C-A73A-4B34-A428-E967A698CA37}.Debug|Win32.Build.0 = Debug|Win32 - {B1A6316C-A73A-4B34-A428-E967A698CA37}.Release|Win32.ActiveCfg = Release|Win32 - {B1A6316C-A73A-4B34-A428-E967A698CA37}.Release|Win32.Build.0 = Release|Win32 - {0A70BF55-FCF6-4DD8-A455-8233666A60E1}.Debug|Win32.ActiveCfg = Debug|Win32 - {0A70BF55-FCF6-4DD8-A455-8233666A60E1}.Debug|Win32.Build.0 = Debug|Win32 - {0A70BF55-FCF6-4DD8-A455-8233666A60E1}.Release|Win32.ActiveCfg = Release|Win32 - {0A70BF55-FCF6-4DD8-A455-8233666A60E1}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/win32/ezstream.vcproj b/win32/ezstream.vcproj deleted file mode 100644 index 7ed2a60..0000000 --- a/win32/ezstream.vcproj +++ /dev/null @@ -1,296 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win32/libflac.vcproj b/win32/libflac.vcproj deleted file mode 100644 index 457b702..0000000 --- a/win32/libflac.vcproj +++ /dev/null @@ -1,411 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win32/libogg.vcproj b/win32/libogg.vcproj deleted file mode 100644 index 04c3980..0000000 --- a/win32/libogg.vcproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win32/libshout.vcproj b/win32/libshout.vcproj deleted file mode 100644 index b2e8a99..0000000 --- a/win32/libshout.vcproj +++ /dev/null @@ -1,322 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win32/libspeex.vcproj b/win32/libspeex.vcproj deleted file mode 100644 index 3266932..0000000 --- a/win32/libspeex.vcproj +++ /dev/null @@ -1,392 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win32/libtheora.vcproj b/win32/libtheora.vcproj deleted file mode 100644 index d4def7f..0000000 --- a/win32/libtheora.vcproj +++ /dev/null @@ -1,504 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win32/libvorbis.vcproj b/win32/libvorbis.vcproj deleted file mode 100644 index 9cd471c..0000000 --- a/win32/libvorbis.vcproj +++ /dev/null @@ -1,474 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win32/libvorbisfile.vcproj b/win32/libvorbisfile.vcproj deleted file mode 100644 index c5f8858..0000000 --- a/win32/libvorbisfile.vcproj +++ /dev/null @@ -1,202 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win32/libz.vcproj b/win32/libz.vcproj deleted file mode 100644 index b8e4495..0000000 --- a/win32/libz.vcproj +++ /dev/null @@ -1,280 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win32/shout/Makefile.am b/win32/shout/Makefile.am deleted file mode 100644 index 28108ec..0000000 --- a/win32/shout/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -AUTOMAKE_OPTIONS = 1.10 foreign subdir-objects - -EXTRA_DIST = shout.h - -CLEANFILES = *~ core *.core diff --git a/win32/shout/shout.h b/win32/shout/shout.h deleted file mode 100644 index 814063a..0000000 --- a/win32/shout/shout.h +++ /dev/null @@ -1,209 +0,0 @@ -/* shout.h - * - * API for libshout, the streaming library for icecast - * - * Copyright (C) 2002-2003 the Icecast team - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __LIBSHOUT_SHOUT_H__ -#define __LIBSHOUT_SHOUT_H__ - -#define VERSION "2.2.2" -#define LIBSHOUT_MAJOR 2 -#define LIBSHOUT_MINOR 2 -#define LIBSHOUT_MICRO 2 - -#include -#ifdef WIN32 -#include -#endif - -#define SHOUTERR_SUCCESS (0) -#define SHOUTERR_INSANE (-1) -#define SHOUTERR_NOCONNECT (-2) -#define SHOUTERR_NOLOGIN (-3) -#define SHOUTERR_SOCKET (-4) -#define SHOUTERR_MALLOC (-5) -#define SHOUTERR_METADATA (-6) -#define SHOUTERR_CONNECTED (-7) -#define SHOUTERR_UNCONNECTED (-8) -#define SHOUTERR_UNSUPPORTED (-9) - -#define SHOUTERR_BUSY (-10) - -#define SHOUT_FORMAT_OGG (0) -#define SHOUT_FORMAT_MP3 (1) -/* backward-compatibility alias */ -#define SHOUT_FORMAT_VORBIS SHOUT_FORMAT_OGG - -#define SHOUT_PROTOCOL_HTTP (0) -#define SHOUT_PROTOCOL_XAUDIOCAST (1) -#define SHOUT_PROTOCOL_ICY (2) - -#define SHOUT_AI_BITRATE "bitrate" -#define SHOUT_AI_SAMPLERATE "samplerate" -#define SHOUT_AI_CHANNELS "channels" -#define SHOUT_AI_QUALITY "quality" - -typedef struct shout shout_t; -typedef struct _util_dict shout_metadata_t; - -#ifdef __cplusplus -extern "C" { -#endif - -/* initializes the shout library. Must be called before anything else */ -void shout_init(void); - -/* shuts down the shout library, deallocating any global storage. Don't call - * anything afterwards */ -void shout_shutdown(void); - -/* returns a static version string. Non-null parameters will be set to the - * value of the library major, minor, and patch levels, respectively */ -const char *shout_version(int *major, int *minor, int *patch); - -/* Allocates and sets up a new shout_t. Returns NULL if it can't get enough - * memory. The returns shout_t must be disposed of with shout_free. */ -shout_t *shout_new(void); - -/* Free all memory allocated by a shout_t */ -void shout_free(shout_t *self); - -/* Returns a statically allocated string describing the last shout error - * to occur. Only valid until the next libshout call on this shout_t */ -const char *shout_get_error(shout_t *self); - -/* Return the error code (e.g. SHOUTERR_SOCKET) for this shout instance */ -int shout_get_errno(shout_t *self); - -/* returns SHOUTERR_CONNECTED or SHOUTERR_UNCONNECTED */ -int shout_get_connected(shout_t *self); - -/* Parameter manipulation functions. libshout makes copies of all parameters, - * the caller may free its copies after giving them to libshout. May return - * SHOUTERR_MALLOC */ - -int shout_set_host(shout_t *self, const char *host); -const char *shout_get_host(shout_t *self); - -int shout_set_port(shout_t *self, unsigned short port); -unsigned short shout_get_port(shout_t *self); - -int shout_set_password(shout_t *, const char *password); -const char *shout_get_password(shout_t *self); - -int shout_set_mount(shout_t *self, const char *mount); -const char *shout_get_mount(shout_t *self); - -int shout_set_name(shout_t *self, const char *name); -const char *shout_get_name(shout_t *self); - -int shout_set_url(shout_t *self, const char *url); -const char *shout_get_url(shout_t *self); - -int shout_set_genre(shout_t *self, const char *genre); -const char *shout_get_genre(shout_t *self); - -int shout_set_user(shout_t *self, const char *username); -const char *shout_get_user(shout_t *self); - -int shout_set_agent(shout_t *self, const char *username); -const char *shout_get_agent(shout_t *self); - -int shout_set_description(shout_t *self, const char *description); -const char *shout_get_description(shout_t *self); - -int shout_set_dumpfile(shout_t *self, const char *dumpfile); -const char *shout_get_dumpfile(shout_t *self); - -int shout_set_audio_info(shout_t *self, const char *name, const char *value); -const char *shout_get_audio_info(shout_t *self, const char *name); - -int shout_set_public(shout_t *self, unsigned int make_public); -unsigned int shout_get_public(shout_t *self); - -/* takes a SHOUT_FORMAT_xxxx argument */ -int shout_set_format(shout_t *self, unsigned int format); -unsigned int shout_get_format(shout_t *self); - -/* takes a SHOUT_PROTOCOL_xxxxx argument */ -int shout_set_protocol(shout_t *self, unsigned int protocol); -unsigned int shout_get_protocol(shout_t *self); - -/* Instructs libshout to use nonblocking I/O. Must be called before - * shout_open (no switching back and forth midstream at the moment). */ -int shout_set_nonblocking(shout_t* self, unsigned int nonblocking); -unsigned int shout_get_nonblocking(shout_t *self); - -/* Opens a connection to the server. All parameters must already be set */ -int shout_open(shout_t *self); - -/* Closes a connection to the server */ -int shout_close(shout_t *self); - -/* Send data to the server, parsing it for format specific timing info */ -int shout_send(shout_t *self, const unsigned char *data, size_t len); - -/* Send unparsed data to the server. Do not use this unless you know - * what you are doing. - * Returns the number of bytes written, or < 0 on error. - */ -ssize_t shout_send_raw(shout_t *self, const unsigned char *data, size_t len); - -/* return the number of bytes currently on the write queue (only makes sense in - * nonblocking mode). */ -ssize_t shout_queuelen(shout_t *self); - -/* Puts caller to sleep until it is time to send more data to the server */ -void shout_sync(shout_t *self); - -/* Amount of time in ms caller should wait before sending again */ -int shout_delay(shout_t *self); - -/* Sets MP3 metadata. - * Returns: - * SHOUTERR_SUCCESS - * SHOUTERR_UNSUPPORTED if format isn't MP3 - * SHOUTERR_MALLOC - * SHOUTERR_INSANE - * SHOUTERR_NOCONNECT - * SHOUTERR_SOCKET - */ -int shout_set_metadata(shout_t *self, shout_metadata_t *metadata); - -/* Allocates a new metadata structure. Must be freed by shout_metadata_free. */ -shout_metadata_t *shout_metadata_new(void); - -/* Free resources allocated by shout_metadata_t */ -void shout_metadata_free(shout_metadata_t *self); - -/* Add a parameter to the metadata structure. - * Returns: - * SHOUTERR_SUCCESS on success - * SHOUTERR_INSANE if self isn't a valid shout_metadata_t* or name is null - * SHOUTERR_MALLOC if memory can't be allocated */ -int shout_metadata_add(shout_metadata_t *self, const char *name, const char *value); - -#ifdef __cplusplus -} -#endif - -/* --- Compiled features --- */ - -#define SHOUT_THREADSAFE 0 - -#endif /* __LIBSHOUT_SHOUT_H__ */ diff --git a/win32/taglib.vcproj b/win32/taglib.vcproj deleted file mode 100644 index 17bb2fe..0000000 --- a/win32/taglib.vcproj +++ /dev/null @@ -1,588 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win32/taglib_c.vcproj b/win32/taglib_c.vcproj deleted file mode 100644 index 104f561..0000000 --- a/win32/taglib_c.vcproj +++ /dev/null @@ -1,194 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/win32/tfile.cpp b/win32/tfile.cpp deleted file mode 100644 index 9add593..0000000 --- a/win32/tfile.cpp +++ /dev/null @@ -1,511 +0,0 @@ -/*************************************************************************** - copyright : (C) 2002, 2003 by Scott Wheeler - email : wheeler@kde.org - ***************************************************************************/ - -/*************************************************************************** - * This library is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Lesser General Public License version * - * 2.1 as published by the Free Software Foundation. * - * * - * This library 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 * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with this library; if not, write to the Free Software * - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * - * USA * - ***************************************************************************/ - -#include "tfile.h" -#include "tstring.h" -#include "tdebug.h" - -#ifdef WIN32 -# include -# define ftruncate _chsize -#endif /* WIN32 */ -#include -#include -#ifdef HAVE_UNISTD_H -# include -#endif /* HAVE_UNISTD_H */ - -#if !defined(R_OK) || !defined(W_OK) -# undef R_OK -# undef W_OK -# define R_OK 4 -# define W_OK 2 -#endif /* !R_OK || !W_OK */ - -using namespace TagLib; - -class File::FilePrivate -{ -public: - FilePrivate(const char *fileName) : - file(0), - name(fileName), - readOnly(true), - valid(true), - size(0) - {} - - ~FilePrivate() - { - free((void *)name); - } - - FILE *file; - const char *name; - bool readOnly; - bool valid; - ulong size; - static const uint bufferSize = 1024; -}; - -//////////////////////////////////////////////////////////////////////////////// -// public members -//////////////////////////////////////////////////////////////////////////////// - -File::File(const char *file) -{ - d = new FilePrivate(::strdup(file)); - - d->readOnly = !isWritable(file); - d->file = fopen(file, d->readOnly ? "r" : "r+"); - - if(!d->file) - debug("Could not open file " + String(file)); -} - -File::~File() -{ - if(d->file) - fclose(d->file); - delete d; -} - -const char *File::name() const -{ - return d->name; -} - -ByteVector File::readBlock(ulong length) -{ - if(!d->file) { - debug("File::readBlock() -- Invalid File"); - return ByteVector::null; - } - - if(length > FilePrivate::bufferSize && - length > ulong(File::length())) - { - length = File::length(); - } - - ByteVector v(static_cast(length)); - const int count = fread(v.data(), sizeof(char), length, d->file); - v.resize(count); - return v; -} - -void File::writeBlock(const ByteVector &data) -{ - if(!d->file) - return; - - if(d->readOnly) { - debug("File::writeBlock() -- attempted to write to a file that is not writable"); - return; - } - - fwrite(data.data(), sizeof(char), data.size(), d->file); -} - -long File::find(const ByteVector &pattern, long fromOffset, const ByteVector &before) -{ - if(!d->file || pattern.size() > d->bufferSize) - return -1; - - // The position in the file that the current buffer starts at. - - long bufferOffset = fromOffset; - ByteVector buffer; - - // These variables are used to keep track of a partial match that happens at - // the end of a buffer. - - int previousPartialMatch = -1; - int beforePreviousPartialMatch = -1; - - // Save the location of the current read pointer. We will restore the - // position using seek() before all returns. - - long originalPosition = tell(); - - // Start the search at the offset. - - seek(fromOffset); - - // This loop is the crux of the find method. There are three cases that we - // want to account for: - // - // (1) The previously searched buffer contained a partial match of the search - // pattern and we want to see if the next one starts with the remainder of - // that pattern. - // - // (2) The search pattern is wholly contained within the current buffer. - // - // (3) The current buffer ends with a partial match of the pattern. We will - // note this for use in the next itteration, where we will check for the rest - // of the pattern. - // - // All three of these are done in two steps. First we check for the pattern - // and do things appropriately if a match (or partial match) is found. We - // then check for "before". The order is important because it gives priority - // to "real" matches. - - for(buffer = readBlock(d->bufferSize); buffer.size() > 0; buffer = readBlock(d->bufferSize)) { - - // (1) previous partial match - - if(previousPartialMatch >= 0 && int(d->bufferSize) > previousPartialMatch) { - const int patternOffset = (d->bufferSize - previousPartialMatch); - if(buffer.containsAt(pattern, 0, patternOffset)) { - seek(originalPosition); - return bufferOffset - d->bufferSize + previousPartialMatch; - } - } - - if(!before.isNull() && beforePreviousPartialMatch >= 0 && int(d->bufferSize) > beforePreviousPartialMatch) { - const int beforeOffset = (d->bufferSize - beforePreviousPartialMatch); - if(buffer.containsAt(before, 0, beforeOffset)) { - seek(originalPosition); - return -1; - } - } - - // (2) pattern contained in current buffer - - long location = buffer.find(pattern); - if(location >= 0) { - seek(originalPosition); - return bufferOffset + location; - } - - if(!before.isNull() && buffer.find(before) >= 0) { - seek(originalPosition); - return -1; - } - - // (3) partial match - - previousPartialMatch = buffer.endsWithPartialMatch(pattern); - - if(!before.isNull()) - beforePreviousPartialMatch = buffer.endsWithPartialMatch(before); - - bufferOffset += d->bufferSize; - } - - // Since we hit the end of the file, reset the status before continuing. - - clear(); - - seek(originalPosition); - - return -1; -} - - -long File::rfind(const ByteVector &pattern, long fromOffset, const ByteVector &before) -{ - if(!d->file || pattern.size() > d->bufferSize) - return -1; - - // The position in the file that the current buffer starts at. - - ByteVector buffer; - - // These variables are used to keep track of a partial match that happens at - // the end of a buffer. - - /* - int previousPartialMatch = -1; - int beforePreviousPartialMatch = -1; - */ - - // Save the location of the current read pointer. We will restore the - // position using seek() before all returns. - - long originalPosition = tell(); - - // Start the search at the offset. - - long bufferOffset; - if(fromOffset == 0) { - seek(-1 * int(d->bufferSize), End); - bufferOffset = tell(); - } - else { - seek(fromOffset + -1 * int(d->bufferSize), Beginning); - bufferOffset = tell(); - } - - // See the notes in find() for an explanation of this algorithm. - - for(buffer = readBlock(d->bufferSize); buffer.size() > 0; buffer = readBlock(d->bufferSize)) { - - // TODO: (1) previous partial match - - // (2) pattern contained in current buffer - - long location = buffer.rfind(pattern); - if(location >= 0) { - seek(originalPosition); - return bufferOffset + location; - } - - if(!before.isNull() && buffer.find(before) >= 0) { - seek(originalPosition); - return -1; - } - - // TODO: (3) partial match - - bufferOffset -= d->bufferSize; - seek(bufferOffset); - } - - // Since we hit the end of the file, reset the status before continuing. - - clear(); - - seek(originalPosition); - - return -1; -} - -void File::insert(const ByteVector &data, ulong start, ulong replace) -{ - if(!d->file) - return; - - if(data.size() == replace) { - seek(start); - writeBlock(data); - return; - } - else if(data.size() < replace) { - seek(start); - writeBlock(data); - removeBlock(start + data.size(), replace - data.size()); - return; - } - - // Woohoo! Faster (about 20%) than id3lib at last. I had to get hardcore - // and avoid TagLib's high level API for rendering just copying parts of - // the file that don't contain tag data. - // - // Now I'll explain the steps in this ugliness: - - // First, make sure that we're working with a buffer that is longer than - // the *differnce* in the tag sizes. We want to avoid overwriting parts - // that aren't yet in memory, so this is necessary. - - ulong bufferLength = bufferSize(); - while(data.size() - replace > bufferLength) - bufferLength += bufferSize(); - - // Set where to start the reading and writing. - - long readPosition = start + replace; - long writePosition = start; - - ByteVector buffer; - ByteVector aboutToOverwrite(static_cast(bufferLength)); - - // This is basically a special case of the loop below. Here we're just - // doing the same steps as below, but since we aren't using the same buffer - // size -- instead we're using the tag size -- this has to be handled as a - // special case. We're also using File::writeBlock() just for the tag. - // That's a bit slower than using char *'s so, we're only doing it here. - - seek(readPosition); - int bytesRead = fread(aboutToOverwrite.data(), sizeof(char), bufferLength, d->file); - readPosition += bufferLength; - - seek(writePosition); - writeBlock(data); - writePosition += data.size(); - - buffer = aboutToOverwrite; - - // Ok, here's the main loop. We want to loop until the read fails, which - // means that we hit the end of the file. - - while(bytesRead != 0) { - - // Seek to the current read position and read the data that we're about - // to overwrite. Appropriately increment the readPosition. - - seek(readPosition); - bytesRead = fread(aboutToOverwrite.data(), sizeof(char), bufferLength, d->file); - aboutToOverwrite.resize(bytesRead); - readPosition += bufferLength; - - // Check to see if we just read the last block. We need to call clear() - // if we did so that the last write succeeds. - - if(ulong(bytesRead) < bufferLength) - clear(); - - // Seek to the write position and write our buffer. Increment the - // writePosition. - - seek(writePosition); - fwrite(buffer.data(), sizeof(char), bufferLength, d->file); - writePosition += bufferLength; - - // Make the current buffer the data that we read in the beginning. - - buffer = aboutToOverwrite; - - // Again, we need this for the last write. We don't want to write garbage - // at the end of our file, so we need to set the buffer size to the amount - // that we actually read. - - bufferLength = bytesRead; - } -} - -void File::removeBlock(ulong start, ulong length) -{ - if(!d->file) - return; - - ulong bufferLength = bufferSize(); - - long readPosition = start + length; - long writePosition = start; - - ByteVector buffer(static_cast(bufferLength)); - - ulong bytesRead = true; - - while(bytesRead != 0) { - seek(readPosition); - bytesRead = fread(buffer.data(), sizeof(char), bufferLength, d->file); - buffer.resize(bytesRead); - readPosition += bytesRead; - - // Check to see if we just read the last block. We need to call clear() - // if we did so that the last write succeeds. - - if(bytesRead < bufferLength) - clear(); - - seek(writePosition); - fwrite(buffer.data(), sizeof(char), bytesRead, d->file); - writePosition += bytesRead; - } - truncate(writePosition); -} - -bool File::readOnly() const -{ - return d->readOnly; -} - -bool File::isReadable(const char *file) -{ - return access(file, R_OK) == 0; -} - -bool File::isOpen() const -{ - return d->file; -} - -bool File::isValid() const -{ - return d->file && d->valid; -} - -void File::seek(long offset, Position p) -{ - if(!d->file) { - debug("File::seek() -- trying to seek in a file that isn't opened."); - return; - } - - switch(p) { - case Beginning: - fseek(d->file, offset, SEEK_SET); - break; - case Current: - fseek(d->file, offset, SEEK_CUR); - break; - case End: - fseek(d->file, offset, SEEK_END); - break; - } -} - -void File::clear() -{ - clearerr(d->file); -} - -long File::tell() const -{ - return ftell(d->file); -} - -long File::length() -{ - // Do some caching in case we do multiple calls. - - if(d->size > 0) - return d->size; - - if(!d->file) - return 0; - - long curpos = tell(); - - seek(0, End); - long endpos = tell(); - - seek(curpos, Beginning); - - d->size = endpos; - return endpos; -} - -bool File::isWritable(const char *file) -{ - return access(file, W_OK) == 0; -} - -//////////////////////////////////////////////////////////////////////////////// -// protected members -//////////////////////////////////////////////////////////////////////////////// - -void File::setValid(bool valid) -{ - d->valid = valid; -} - -void File::truncate(long length) -{ - ftruncate(fileno(d->file), length); -} - -TagLib::uint File::bufferSize() -{ - return FilePrivate::bufferSize; -}