Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/azatoth/minidlna.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Maggard <jmaggard@users.sourceforce.net>2011-09-17 03:39:57 +0400
committerJustin Maggard <jmaggard@users.sourceforce.net>2011-09-17 03:39:57 +0400
commitb81ff08b0ce5b99768f04c17002005bad5e20c07 (patch)
tree4cba796c6de01aeb93251589bfe21fe5288cfcaa
parent44f26df01df3ad565be9b9aa7df918f4b2bbeb5e (diff)
* Add support for other operating systems (kFreeBSD, FreeBSD, and OSX for now).
* Switch to autoconf from genconfig.sh.
-rw-r--r--AUTHORS1
-rw-r--r--COPYING (renamed from LICENCE)0
-rw-r--r--ChangeLog0
-rw-r--r--INSTALL375
-rw-r--r--Makefile135
-rw-r--r--Makefile.am53
-rw-r--r--NEWS4
-rw-r--r--albumart.c1
-rwxr-xr-xautogen.sh36
-rw-r--r--config.h.in481
-rw-r--r--configure.ac556
-rw-r--r--daemonize.c4
-rwxr-xr-xgenconfig.sh215
-rw-r--r--getifaddr.c205
-rw-r--r--image_utils.c11
-rw-r--r--inotify.c6
-rw-r--r--inotify.h3
-rw-r--r--metadata.c103
-rw-r--r--minidlna.c14
-rw-r--r--options.c15
-rw-r--r--playlist.c6
-rw-r--r--scanner.c73
-rw-r--r--sendfile.h53
-rw-r--r--tagutils/misc.c5
-rw-r--r--tagutils/tagutils-asf.h4
-rw-r--r--tagutils/tagutils-misc.c8
-rw-r--r--tagutils/tagutils-mp3.c9
-rw-r--r--tagutils/tagutils.c2
-rw-r--r--tagutils/tagutils.h1
-rw-r--r--tivo_beacon.c3
-rw-r--r--tivo_commands.c1
-rw-r--r--tivo_utils.c3
-rw-r--r--upnpdescgen.c2
-rw-r--r--upnpevents.c9
-rw-r--r--upnpglobalvars.c2
-rw-r--r--upnphttp.c22
-rw-r--r--upnphttp.h4
-rw-r--r--upnpsoap.c2
-rw-r--r--utils.c7
-rw-r--r--uuid.c53
40 files changed, 1953 insertions, 534 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..0d8f56f
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Justin Maggard <jmaggard@users.sourceforge.net>
diff --git a/LICENCE b/COPYING
index 7df8a85..7df8a85 100644
--- a/LICENCE
+++ b/COPYING
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ChangeLog
diff --git a/INSTALL b/INSTALL
index b3bbd16..2194fe0 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,19 +1,376 @@
-MiniDLNA project.
-(c) 2009 Justin Maggard
-Parts (c) 2006-2008 Thomas Bernard
-Homepage : http://sourceforge.net/projects/minidlna/
+Installation Instructions
+*************************
-Prerequisites :
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved. This file is offered as-is,
+without warranty of any kind.
+
+Prerequisites
+==================
- libexif
- libjpeg
- libid3tag
- libFLAC
- libvorbis
-- sqlite3
+- libsqlite3
- libavformat (the ffmpeg libraries)
-- libuuid
-To Build and install :
+Basic Installation
+==================
+
+ Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package. Some packages provide this
+`INSTALL' file but do not implement all of the features documented
+below. The lack of an optional feature in a given package is not
+necessarily a bug. More recommendations for GNU packages can be found
+in *note Makefile Conventions: (standards)Makefile Conventions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+ The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system.
+
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package, generally using the just-built uninstalled binaries.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation. When installing into a prefix owned by root, it is
+ recommended that the package be configured and built as a regular
+ user, and only the `make install' phase executed with root
+ privileges.
+
+ 5. Optionally, type `make installcheck' to repeat any self-tests, but
+ this time using the binaries in their final installed location.
+ This target does not install anything. Running this target as a
+ regular user, particularly if the prior `make install' required
+ root privileges, verifies that the installation completed
+ correctly.
+
+ 6. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+ 7. Often, you can also type `make uninstall' to remove the installed
+ files again. In practice, not all packages have tested that
+ uninstallation works correctly, even though it is required by the
+ GNU Coding Standards.
+
+ 8. Some packages, particularly those that use Automake, provide `make
+ distcheck', which can by used by developers to test that all other
+ targets like `make install' and `make uninstall' work correctly.
+ This target is generally not run by end users.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you can use GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'. This
+is known as a "VPATH" build.
+
+ With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory. After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+ On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor. Like
+this:
+
+ ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CPP="gcc -E" CXXCPP="g++ -E"
+
+ This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+ By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
+absolute file name.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them. In general, the
+default for these options is expressed in terms of `${prefix}', so that
+specifying just `--prefix' will affect all of the other directory
+specifications that were not explicitly provided.
+
+ The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+ The first method involves providing an override variable for each
+affected directory. For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'. Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated. The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+ The second method involves providing the `DESTDIR' variable. For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names. The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters. On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+ Some packages offer the ability to configure how verbose the
+execution of `make' will be. For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
+Particular systems
+==================
+
+ On HP-UX, the default C compiler is not ANSI C compatible. If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+ ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+ On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file. The option `-nodtk' can be used as
+a workaround. If GNU CC is not installed, it is therefore recommended
+to try
+
+ ./configure CC="cc"
+
+and if that doesn't work, try
+
+ ./configure CC="cc -nodtk"
+
+ On Solaris, don't put `/usr/ucb' early in your `PATH'. This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+ On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'. It is recommended to use the following options:
+
+ ./configure --prefix=/boot/common
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on. Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS
+ KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+ Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
+
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+ Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+ Print a summary of the options unique to this package's
+ `configure', and exit. The `short' variant lists options used
+ only in the top level, while the `recursive' variant lists options
+ also present in any nested packages.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+ Use DIR as the installation prefix. *note Installation Names::
+ for more details, including other options available for fine-tuning
+ the installation locations.
+
+`--no-create'
+`-n'
+ Run the configure checks, but stop before creating any output
+ files.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
-- Just run make, and hope it works. :)
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 17b6668..0000000
--- a/Makefile
+++ /dev/null
@@ -1,135 +0,0 @@
-# $Id$
-# MiniDLNA project
-# http://sourceforge.net/projects/minidlna/
-# (c) 2008-2009 Justin Maggard
-# for use with GNU Make
-# To install use :
-# $ DESTDIR=/dummyinstalldir make install
-# or :
-# $ INSTALLPREFIX=/usr/local make install
-# or :
-# $ make install
-#
-#CFLAGS = -Wall -O -D_GNU_SOURCE -g -DDEBUG
-#CFLAGS = -Wall -g -Os -D_GNU_SOURCE
-CFLAGS = -Wall -g -O3 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 \
- -I/usr/include/ffmpeg \
- -I/usr/include/libavutil -I/usr/include/libavcodec -I/usr/include/libavformat \
- -I/usr/include/ffmpeg/libavutil -I/usr/include/ffmpeg/libavcodec -I/usr/include/ffmpeg/libavformat
-#STATIC_LINKING: CFLAGS += -DSTATIC
-#STATIC_LINKING: LDFLAGS = -static
-CC = gcc
-RM = rm -f
-INSTALL = install
-
-INSTALLPREFIX ?= $(DESTDIR)/usr
-SBININSTALLDIR = $(INSTALLPREFIX)/sbin
-ETCINSTALLDIR = $(DESTDIR)/etc
-
-BASEOBJS = minidlna.o upnphttp.o upnpdescgen.o upnpsoap.o \
- upnpreplyparse.o minixml.o \
- getifaddr.o daemonize.o upnpglobalvars.o \
- options.o minissdp.o uuid.o upnpevents.o \
- sql.o utils.o metadata.o scanner.o inotify.o \
- tivo_utils.o tivo_beacon.o tivo_commands.o \
- tagutils/textutils.o tagutils/misc.o tagutils/tagutils.o \
- playlist.o image_utils.o albumart.o log.o
-
-ALLOBJS = $(BASEOBJS) $(LNXOBJS)
-
-LIBS = -lpthread -lexif -ljpeg -lsqlite3 -lavformat -lavutil -lavcodec -lid3tag -lFLAC -logg -lvorbis
-#STATIC_LINKING: LIBS = -lvorbis -logg -lm -lsqlite3 -lpthread -lexif -ljpeg -lFLAC -lm -lid3tag -lz -lavformat -lavutil -lavcodec -lm
-
-TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o
-
-EXECUTABLES = minidlna testupnpdescgen
-
-.PHONY: all clean distclean install depend
-
-all: $(EXECUTABLES)
-
-clean:
- $(RM) $(ALLOBJS)
- $(RM) $(EXECUTABLES)
- $(RM) testupnpdescgen.o
-
-distclean: clean
- $(RM) config.h
-
-install: minidlna
- $(INSTALL) -d $(SBININSTALLDIR)
- $(INSTALL) minidlna $(SBININSTALLDIR)
-
-install-conf:
- $(INSTALL) -d $(ETCINSTALLDIR)
- $(INSTALL) --mode=0644 minidlna.conf $(ETCINSTALLDIR)
-
-minidlna: $(BASEOBJS) $(LNXOBJS) $(LIBS)
- @echo Linking $@
- @$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(BASEOBJS) $(LNXOBJS) $(LIBS)
-
-
-testupnpdescgen: $(TESTUPNPDESCGENOBJS)
- @echo Linking $@
- @$(CC) $(CFLAGS) -o $@ $(TESTUPNPDESCGENOBJS)
-
-config.h: genconfig.sh
- ./genconfig.sh
-
-depend: config.h
- makedepend -f$(MAKEFILE_LIST) -Y \
- $(ALLOBJS:.o=.c) $(TESTUPNPDESCGENOBJS:.o=.c) 2>/dev/null
-
-# DO NOT DELETE
-
-minidlna.o: config.h upnpglobalvars.h minidlnatypes.h
-minidlna.o: upnphttp.h upnpdescgen.h minidlnapath.h getifaddr.h upnpsoap.h
-minidlna.o: options.h minissdp.h daemonize.h upnpevents.h log.h
-upnphttp.o: config.h upnphttp.h upnpdescgen.h minidlnapath.h upnpsoap.h
-upnphttp.o: upnpevents.h image_utils.h sql.h log.h icons.c
-upnpdescgen.o: config.h upnpdescgen.h minidlnapath.h upnpglobalvars.h
-upnpdescgen.o: minidlnatypes.h upnpdescstrings.h log.h
-upnpsoap.o: config.h upnpglobalvars.h minidlnatypes.h log.h utils.h sql.h
-upnpsoap.o: upnphttp.h upnpsoap.h upnpreplyparse.h getifaddr.h log.h
-upnpreplyparse.o: upnpreplyparse.h minixml.h log.h
-minixml.o: minixml.h
-getifaddr.o: getifaddr.h log.h
-daemonize.o: daemonize.h config.h log.h
-upnpglobalvars.o: config.h upnpglobalvars.h
-upnpglobalvars.o: minidlnatypes.h
-options.o: options.h config.h upnpglobalvars.h
-options.o: minidlnatypes.h
-minissdp.o: config.h upnpdescstrings.h minidlnapath.h upnphttp.h
-minissdp.o: upnpglobalvars.h minidlnatypes.h minissdp.h log.h
-upnpevents.o: config.h upnpevents.h minidlnapath.h upnpglobalvars.h
-upnpevents.o: minidlnatypes.h upnpdescgen.h log.h uuid.h
-uuid.o: uuid.h
-testupnpdescgen.o: config.h upnpdescgen.h
-upnpdescgen.o: config.h upnpdescgen.h minidlnapath.h upnpglobalvars.h
-upnpdescgen.o: minidlnatypes.h upnpdescstrings.h
-scanner.o: upnpglobalvars.h metadata.h utils.h sql.h scanner.h log.h playlist.h
-metadata.o: upnpglobalvars.h metadata.h albumart.h utils.h sql.h log.h
-albumart.o: upnpglobalvars.h albumart.h utils.h image_utils.h sql.h log.h
-tagutils/misc.o: tagutils/misc.h
-tagutils/textutils.o: tagutils/misc.h tagutils/textutils.h log.h
-tagutils/tagutils.o: tagutils/tagutils-asf.c tagutils/tagutils-flc.c tagutils/tagutils-plist.c tagutils/tagutils-misc.c
-tagutils/tagutils.o: tagutils/tagutils-aac.c tagutils/tagutils-asf.h tagutils/tagutils-flc.h tagutils/tagutils-mp3.c tagutils/tagutils-wav.c
-tagutils/tagutils.o: tagutils/tagutils-ogg.c tagutils/tagutils-aac.h tagutils/tagutils.h tagutils/tagutils-mp3.h tagutils/tagutils-ogg.h log.h
-playlist.o: playlist.h
-inotify.o: inotify.h playlist.h
-image_utils.o: image_utils.h
-tivo_utils.o: config.h tivo_utils.h
-tivo_beacon.o: config.h tivo_beacon.h tivo_utils.h
-tivo_commands.o: config.h tivo_commands.h tivo_utils.h utils.h
-utils.o: utils.h
-sql.o: sql.h
-log.o: log.h
-
-.SUFFIXES: .c .o
-
-.c.o:
- @echo Compiling $*.c
- @$(CC) $(CFLAGS) -o $@ -c $< && exit 0;\
- echo "The following command failed:" 1>&2;\
- echo "$(CC) $(CFLAGS) -o $@ -c $<";\
- $(CC) $(CFLAGS) -o $@ -c $< &>/dev/null
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..f35e9e2
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,53 @@
+AM_CFLAGS = -Wall -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 @STATIC_CFLAGS@
+
+SUBDIRS=po
+
+bin_PROGRAMS = minidlna testupnpdescgen
+minidlna_SOURCES = minidlna.c upnphttp.c upnpdescgen.c upnpsoap.c \
+ upnpreplyparse.c minixml.c \
+ getifaddr.c daemonize.c upnpglobalvars.c \
+ options.c minissdp.c uuid.c upnpevents.c \
+ sql.c utils.c metadata.c scanner.c inotify.c \
+ tivo_utils.c tivo_beacon.c tivo_commands.c \
+ tagutils/textutils.c tagutils/misc.c tagutils/tagutils.c \
+ playlist.c image_utils.c albumart.c log.c
+
+
+#if NEED_VORBIS
+vorbisflag = -lvorbis
+#endif
+
+#if NEED_OGG
+flacoggflag = -logg
+#endif
+
+minidlna_LDADD = \
+ @LIBJPEG_LIBS@ \
+ @LIBID3TAG_LIBS@ \
+ @LIBSQLITE3_LIBS@ \
+ @LIBAVFORMAT_LIBS@ \
+ @LIBAVUTIL_LIBS@ \
+ @LIBAVCODEC_LIBS@ \
+ @LIBEXIF_LIBS@ \
+ @LIBDL_LIBS@ \
+ @LIBRT_LIBS@ \
+ -lpthread -lFLAC $(flacoggflag) $(vorbisflag)
+
+minidlna_LDFLAGS = @STATIC_LDFLAGS@
+
+testupnpdescgen_SOURCES = testupnpdescgen.c upnpdescgen.c
+testupnpdescgen_LDADD = \
+ @LIBJPEG_LIBS@ \
+ @LIBID3TAG_LIBS@ \
+ @LIBSQLITE3_LIBS@ \
+ @LIBAVFORMAT_LIBS@ \
+ @LIBAVUTIL_LIBS@ \
+ @LIBAVCODEC_LIBS@ \
+ @LIBEXIF_LIBS@ \
+ @LIBDL_LIBS@ \
+ -lpthread -lFLAC $(flacoggflag) $(vorbisflag)
+
+
+ACLOCAL_AMFLAGS = -I m4
+
+EXTRA_DIST = m4/ChangeLog
diff --git a/NEWS b/NEWS
index 5521433..0555979 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
-1.0.23 - Released 00-Month-0000
+1.1.0 - Released 00-Month-0000
--------------------------------
+- Add support for other operating systems.
+- Switch to autoconf from our little genconfig.sh.
- Enable the subtitle menu on some Samsung TV's.
1.0.22 - Released 24-Aug-2011
diff --git a/albumart.c b/albumart.c
index f184377..189cdd5 100644
--- a/albumart.c
+++ b/albumart.c
@@ -20,6 +20,7 @@
#include <string.h>
#include <unistd.h>
#include <dirent.h>
+#include <sys/param.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <libgen.h>
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..f005a50
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+package="minidlna"
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+cd "$srcdir"
+DIE=0
+
+(autoconf --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have autoconf installed to compile $package."
+ echo "Download the appropriate package for your system,"
+ echo "or get the source from one of the GNU ftp sites"
+ echo "listed in http://www.gnu.org/order/ftp.html"
+ DIE=1
+}
+
+(automake --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have automake installed to compile $package."
+ echo "Download the appropriate package for your system,"
+ echo "or get the source from one of the GNU ftp sites"
+ echo "listed in http://www.gnu.org/order/ftp.html"
+ DIE=1
+}
+
+if test "$DIE" -eq 1; then
+ exit 1
+fi
+
+echo "Generating configuration files for $package, please wait...."
+
+autoreconf -vfi
+
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..ae27a84
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,481 @@
+/* config.h.in. Generated from configure.ac by autoheader. */
+
+/* Define if building universal (internal helper macro) */
+#undef AC_APPLE_UNIVERSAL_BUILD
+
+/* DB path */
+#undef DEFAULT_DB_PATH
+
+/* Log path */
+#undef DEFAULT_LOG_PATH
+
+/* Define to 1 if translation of program messages to the user's native
+ language is requested. */
+#undef ENABLE_NLS
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#undef HAVE_ARPA_INET_H
+
+/* Define to 1 if you have the <avcodec.h> header file. */
+#undef HAVE_AVCODEC_H
+
+/* Define to 1 if you have the <avformat.h> header file. */
+#undef HAVE_AVFORMAT_H
+
+/* Define to 1 if you have the <avutil.h> header file. */
+#undef HAVE_AVUTIL_H
+
+/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the
+ CoreFoundation framework. */
+#undef HAVE_CFLOCALECOPYCURRENT
+
+/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in
+ the CoreFoundation framework. */
+#undef HAVE_CFPREFERENCESCOPYAPPVALUE
+
+/* Whether the __NR_clock_gettime syscall is defined */
+#undef HAVE_CLOCK_GETTIME_SYSCALL
+
+/* Whether darwin sendfile() API is available */
+#undef HAVE_DARWIN_SENDFILE_API
+
+/* Define if the GNU dcgettext() function is already present or preinstalled.
+ */
+#undef HAVE_DCGETTEXT
+
+/* Define to 1 if you have the <endian.h> header file. */
+#undef HAVE_ENDIAN_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the <ffmpeg/avcodec.h> header file. */
+#undef HAVE_FFMPEG_AVCODEC_H
+
+/* Define to 1 if you have the <ffmpeg/avutil.h> header file. */
+#undef HAVE_FFMPEG_AVUTIL_H
+
+/* Define to 1 if you have the <ffmpeg/libavcodec/avcodec.h> header file. */
+#undef HAVE_FFMPEG_LIBAVCODEC_AVCODEC_H
+
+/* Define to 1 if you have the <ffmpeg/libavformat/avformat.h> header file. */
+#undef HAVE_FFMPEG_LIBAVFORMAT_AVFORMAT_H
+
+/* Define to 1 if you have the <ffmpeg/libavformat.h> header file. */
+#undef HAVE_FFMPEG_LIBAVFORMAT_H
+
+/* Define to 1 if you have the <ffmpeg/libavutil/avutil.h> header file. */
+#undef HAVE_FFMPEG_LIBAVUTIL_AVUTIL_H
+
+/* Have flac */
+#undef HAVE_FLAC
+
+/* Define to 1 if you have the <FLAC/all.h> header file. */
+#undef HAVE_FLAC_ALL_H
+
+/* Define to 1 if you have the <FLAC/metadata.h> header file. */
+#undef HAVE_FLAC_METADATA_H
+
+/* Define to 1 if you have the `fork' function. */
+#undef HAVE_FORK
+
+/* Whether freebsd sendfile() API is available */
+#undef HAVE_FREEBSD_SENDFILE_API
+
+/* Define to 1 if you have the `gethostname' function. */
+#undef HAVE_GETHOSTNAME
+
+/* Define to 1 if you have the `getifaddrs' function. */
+#undef HAVE_GETIFADDRS
+
+/* Define if the GNU gettext() function is already present or preinstalled. */
+#undef HAVE_GETTEXT
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
+
+/* Define if you have the iconv() function. */
+#undef HAVE_ICONV
+
+/* Define to 1 if you have the <id3tag.h> header file. */
+#undef HAVE_ID3TAG_H
+
+/* Define to 1 if you have the `inet_ntoa' function. */
+#undef HAVE_INET_NTOA
+
+/* Define to enable inotify */
+#undef HAVE_INOTIFY_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <jpeglib.h> header file. */
+#undef HAVE_JPEGLIB_H
+
+/* Define to 1 if you have the <libavcodec/avcodec.h> header file. */
+#undef HAVE_LIBAVCODEC_AVCODEC_H
+
+/* Define to 1 if you have the <libavformat/avformat.h> header file. */
+#undef HAVE_LIBAVFORMAT_AVFORMAT_H
+
+/* Define to 1 if you have the <libavutil/avutil.h> header file. */
+#undef HAVE_LIBAVUTIL_AVUTIL_H
+
+/* Define to 1 if you have the <libav/avcodec.h> header file. */
+#undef HAVE_LIBAV_AVCODEC_H
+
+/* Define to 1 if you have the <libav/avutil.h> header file. */
+#undef HAVE_LIBAV_AVUTIL_H
+
+/* Define to 1 if you have the <libav/libavcodec/avcodec.h> header file. */
+#undef HAVE_LIBAV_LIBAVCODEC_AVCODEC_H
+
+/* Define to 1 if you have the <libav/libavformat/avformat.h> header file. */
+#undef HAVE_LIBAV_LIBAVFORMAT_AVFORMAT_H
+
+/* Define to 1 if you have the <libav/libavformat.h> header file. */
+#undef HAVE_LIBAV_LIBAVFORMAT_H
+
+/* Define to 1 if you have the <libav/libavutil/avutil.h> header file. */
+#undef HAVE_LIBAV_LIBAVUTIL_AVUTIL_H
+
+/* Define to 1 if you have the <libexif/exif-loader.h> header file. */
+#undef HAVE_LIBEXIF_EXIF_LOADER_H
+
+/* Define to 1 if you have the <libintl.h> header file. */
+#undef HAVE_LIBINTL_H
+
+/* Define to 1 if you have the `pthread' library (-lpthread). */
+#undef HAVE_LIBPTHREAD
+
+/* Whether linux sendfile() API is available */
+#undef HAVE_LINUX_SENDFILE_API
+
+/* Define to 1 if you have the <locale.h> header file. */
+#undef HAVE_LOCALE_H
+
+/* Define to 1 if you have the <machine/endian.h> header file. */
+#undef HAVE_MACHINE_ENDIAN_H
+
+/* Define to 1 if you have the <mach/mach_time.h> header file. */
+#undef HAVE_MACH_MACH_TIME_H
+
+/* Define to 1 if you have the `memmove' function. */
+#undef HAVE_MEMMOVE
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if you have the `mkdir' function. */
+#undef HAVE_MKDIR
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#undef HAVE_NETDB_H
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#undef HAVE_NETINET_IN_H
+
+/* Define to 1 if you have the <ogg/ogg.h> header file. */
+#undef HAVE_OGG_OGG_H
+
+/* Define to 1 if you have the `realpath' function. */
+#undef HAVE_REALPATH
+
+/* Define to 1 if you have the `select' function. */
+#undef HAVE_SELECT
+
+/* Define to 1 if you have the `sendfile' function. */
+#undef HAVE_SENDFILE
+
+/* Define to 1 if you have the `setlocale' function. */
+#undef HAVE_SETLOCALE
+
+/* Define to 1 if you have the `socket' function. */
+#undef HAVE_SOCKET
+
+/* Define to 1 if you have the <sqlite3.h> header file. */
+#undef HAVE_SQLITE3_H
+
+/* Define to 1 if stdbool.h conforms to C99. */
+#undef HAVE_STDBOOL_H
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#undef HAVE_STDDEF_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#undef HAVE_STRCASECMP
+
+/* Define to 1 if you have the `strchr' function. */
+#undef HAVE_STRCHR
+
+/* Define to 1 if you have the `strdup' function. */
+#undef HAVE_STRDUP
+
+/* Define to 1 if you have the `strerror' function. */
+#undef HAVE_STRERROR
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strncasecmp' function. */
+#undef HAVE_STRNCASECMP
+
+/* Define to 1 if you have the `strpbrk' function. */
+#undef HAVE_STRPBRK
+
+/* Define to 1 if you have the `strrchr' function. */
+#undef HAVE_STRRCHR
+
+/* Define to 1 if you have the `strstr' function. */
+#undef HAVE_STRSTR
+
+/* Define to 1 if you have the `strtol' function. */
+#undef HAVE_STRTOL
+
+/* Define to 1 if you have the `strtoul' function. */
+#undef HAVE_STRTOUL
+
+/* Define to 1 if `st_blocks' is a member of `struct stat'. */
+#undef HAVE_STRUCT_STAT_ST_BLOCKS
+
+/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use
+ `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */
+#undef HAVE_ST_BLOCKS
+
+/* Define to 1 if you have the <syscall.h> header file. */
+#undef HAVE_SYSCALL_H
+
+/* Define to 1 if you have the <sys/file.h> header file. */
+#undef HAVE_SYS_FILE_H
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#undef HAVE_SYS_IOCTL_H
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#undef HAVE_SYS_SOCKET_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/syscall.h> header file. */
+#undef HAVE_SYS_SYSCALL_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `vfork' function. */
+#undef HAVE_VFORK
+
+/* Define to 1 if you have the <vfork.h> header file. */
+#undef HAVE_VFORK_H
+
+/* lacking vorbisfile */
+#undef HAVE_VORBISFILE
+
+/* Define to 1 if you have the <vorbis/codec.h> header file. */
+#undef HAVE_VORBIS_CODEC_H
+
+/* Define to 1 if you have the <vorbis/vorbisfile.h> header file. */
+#undef HAVE_VORBIS_VORBISFILE_H
+
+/* Define to 1 if `fork' works. */
+#undef HAVE_WORKING_FORK
+
+/* Define to 1 if `vfork' works. */
+#undef HAVE_WORKING_VFORK
+
+/* Define to 1 if the system has the type `_Bool'. */
+#undef HAVE__BOOL
+
+/* Define as const if the declaration of iconv() needs const. */
+#undef ICONV_CONST
+
+/* Define to enable logging */
+#undef LOG_PERROR
+
+/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
+ slash. */
+#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
+
+/* Define to 1 if you want to enable NETGEAR support */
+#undef NETGEAR
+
+/* OS Name */
+#undef OS_NAME
+
+/* OS URL */
+#undef OS_URL
+
+/* OS Version */
+#undef OS_VERSION
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you want to enable NETGEAR support */
+#undef PNPX
+
+/* Define to 1 if you want to enable NETGEAR support */
+#undef READYNAS
+
+/* scandir needs const char cast */
+#undef SCANDIR_CONST
+
+/* we are on solaris */
+#undef SOLARIS
+
+/* Define to enable Solaris Kernel Stats */
+#undef SOLARIS_KSTATS
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if you want to enable TiVo support */
+#undef TIVO_SUPPORT
+
+/* use the system's builtin daemon() */
+#undef USE_DAEMON
+
+/* Define to enable IPF */
+#undef USE_IPF
+
+/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them. */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+
+
+/* Version number of package */
+#undef VERSION
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+# undef WORDS_BIGENDIAN
+# endif
+#endif
+
+/* Define to 1 if on MINIX. */
+#undef _MINIX
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+ this defined. */
+#undef _POSIX_1_SOURCE
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+#undef _POSIX_SOURCE
+
+/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+#undef _UINT32_T
+
+/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+#undef _UINT64_T
+
+/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
+ #define below would cause a syntax error. */
+#undef _UINT8_T
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to the type of a signed integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+#undef int32_t
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef mode_t
+
+/* Define to `long int' if <sys/types.h> does not define. */
+#undef off_t
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef pid_t
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef ssize_t
+
+/* Define to the type of an unsigned integer type of width exactly 32 bits if
+ such a type exists and the standard includes do not define it. */
+#undef uint32_t
+
+/* Define to the type of an unsigned integer type of width exactly 64 bits if
+ such a type exists and the standard includes do not define it. */
+#undef uint64_t
+
+/* Define to the type of an unsigned integer type of width exactly 8 bits if
+ such a type exists and the standard includes do not define it. */
+#undef uint8_t
+
+/* Define as `fork' if `vfork' does not work. */
+#undef vfork
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..82fc71d
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,556 @@
+AC_INIT(MiniDLNA,1.1.0,,minidlna)
+#LT_INIT
+
+AC_CANONICAL_TARGET
+AM_INIT_AUTOMAKE(minidlna,1.1.0)
+AC_CONFIG_HEADERS([config.h])
+AC_USE_SYSTEM_EXTENSIONS
+
+#MiniDLNA
+
+AM_ICONV
+AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT_VERSION(0.14.4)
+
+# Checks for programs.
+# AC_PROG_CXX
+AC_PROG_AWK
+AC_PROG_CC
+# AC_PROG_CPP
+AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PROG_MAKE_SET
+
+
+################################################################################################################
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_INLINE
+AC_TYPE_INT32_T
+AC_TYPE_MODE_T
+AC_TYPE_OFF_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_STRUCT_ST_BLOCKS
+AC_HEADER_STDBOOL
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
+AC_TYPE_UINT8_T
+AC_C_BIGENDIAN
+
+# Checks for library functions.
+AC_FUNC_FORK
+AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
+AC_CHECK_FUNCS([gethostname getifaddrs gettimeofday inet_ntoa memmove memset mkdir realpath select sendfile setlocale socket strcasecmp strchr strdup strerror strncasecmp strpbrk strrchr strstr strtol strtoul])
+
+################################################################################################################
+# Special include directories
+case $host in
+ *-*-darwin*)
+ DARWIN_OS=1
+ SEARCH_DIR="/opt/local"
+ ;;
+ *-*-solaris*)
+ AC_DEFINE([SOLARIS], [1], [we are on solaris])
+ ;;
+ *-*-cygwin*)
+ CYGWIN_OS=1
+ ;;
+ *-*-freebsd*)
+ FREEBSD_OS=1
+ ;;
+ *-*-openbsd*)
+ OPENBSD_OS=1
+ ;;
+esac
+
+AC_CHECK_HEADERS(syscall.h sys/syscall.h mach/mach_time.h)
+AC_MSG_CHECKING([for __NR_clock_gettime syscall])
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [
+ #include <asm/unistd.h>
+ ],
+ [
+ #ifndef __NR_clock_gettime
+ #error
+ #endif
+ ]
+ )],
+ [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_CLOCK_GETTIME_SYSCALL], [1], [Whether the __NR_clock_gettime syscall is defined])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ AC_CHECK_LIB([rt], [clock_gettime], [LIBRT_LIBS="-lrt"],)
+ AC_SUBST(LIBRT_LIBS)
+ ])
+
+################################################################################################################
+### Library checks
+#AM_NLS
+AC_CHECK_LIB([dl], [dlopen], [LIBDL_LIBS="-ldl"],)
+AC_SUBST(LIBDL_LIBS)
+
+CPPFLAGS_SAVE="$CPPFLAGS"
+for dir in "" /usr/local $SEARCH_DIR; do
+ if test -n "$dir"; then
+ CPPFLAGS="$CPPFLAGS -I$dir/include"
+ fi
+ AC_CHECK_HEADERS([libavutil/avutil.h ffmpeg/libavutil/avutil.h libav/libavutil/avutil.h avutil.h ffmpeg/avutil.h libav/avutil.h], [break], [continue], [])
+ if test -n "$dir"; then
+ if test x"$ac_cv_header_avutil_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include"
+ elif test x"$ac_cv_header_libavutil_avutil_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/libavutil"
+ elif test x"$ac_cv_header_ffmpeg_avutil_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/ffmpeg"
+ elif test x"$ac_cv_header_ffmpeg_libavutil_avutil_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/ffmpeg/libavutil"
+ elif test x"$ac_cv_header_libav_avutil_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/libav"
+ elif test x"$ac_cv_header_libav_libavutil_avutil_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/libav/libavutil"
+ else
+ unset ac_cv_header_avutil_h
+ unset ac_cv_header_libavutil_avutil_h
+ unset ac_cv_header_ffmpeg_avutil_h
+ unset ac_cv_header_ffmpeg_libavutil_avutil_h
+ unset ac_cv_header_libav_avutil_h
+ unset ac_cv_header_libav_libavutil_avutil_h
+ CPPFLAGS="$CPPFLAGS_SAVE"
+ continue
+ fi
+ fi
+ HAVE_LIBAVUTIL=1
+ break
+done
+if test -z "$HAVE_LIBAVUTIL"; then
+ AC_MSG_ERROR([libavutil headers not found or not usable])
+fi
+
+CPPFLAGS_SAVE="$CPPFLAGS"
+for dir in "" /usr/local $SEARCH_DIR; do
+ if test -n "$dir"; then
+ CPPFLAGS="$CPPFLAGS -I$dir/include"
+ fi
+ AC_CHECK_HEADERS([libavcodec/avcodec.h ffmpeg/libavcodec/avcodec.h libav/libavcodec/avcodec.h avcodec.h ffmpeg/avcodec.h libav/avcodec.h], [break], [continue], [])
+ if test -n "$dir"; then
+ if test x"$ac_cv_header_avcodec_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include"
+ elif test x"$ac_cv_header_libavcodec_avcodec_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/libavcodec"
+ elif test x"$ac_cv_header_ffmpeg_avcodec_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/ffmpeg"
+ elif test x"$ac_cv_header_ffmpeg_libavcodec_avcodec_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/ffmpeg/libavcodec"
+ elif test x"$ac_cv_header_libav_avcodec_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/libav"
+ elif test x"$ac_cv_header_libav_libavcodec_avcodec_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/libav/libavcodec"
+ else
+ unset ac_cv_header_avcodec_h
+ unset ac_cv_header_libavcodec_avcodec_h
+ unset ac_cv_header_ffmpeg_avcodec_h
+ unset ac_cv_header_ffmpeg_libavcodec_avcodec_h
+ unset ac_cv_header_libav_avcodec_h
+ unset ac_cv_header_libav_libavcodec_avcodec_h
+ CPPFLAGS="$CPPFLAGS_SAVE"
+ continue
+ fi
+ fi
+ HAVE_LIBAVCODEC=1
+ break
+done
+if test -z "$HAVE_LIBAVCODEC"; then
+ AC_MSG_ERROR([libavcodec headers not found or not usable])
+fi
+
+CPPFLAGS_SAVE="$CPPFLAGS"
+for dir in "" /usr/local $SEARCH_DIR; do
+ if test -n "$dir"; then
+ CPPFLAGS="$CPPFLAGS -I$dir/include"
+ fi
+ AC_CHECK_HEADERS([libavformat/avformat.h ffmpeg/libavformat/avformat.h libav/libavformat/avformat.h avformat.h ffmpeg/avformat.h libav/avformat.h], [break], [continue], [])
+ if test -n "$dir"; then
+ if test x"$ac_cv_header_avformat_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include"
+ elif test x"$ac_cv_header_libavformat_avformat_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/libavformat"
+ elif test x"$ac_cv_header_ffmpeg_avformat_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/ffmpeg"
+ elif test x"$ac_cv_header_ffmpeg_libavformat_avformat_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/ffmpeg/libavformat"
+ elif test x"$ac_cv_header_libav_avformat_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/libav"
+ elif test x"$ac_cv_header_libav_libavformat_avformat_h" = xyes; then
+ CPPFLAGS="$CPPFLAGS_SAVE -I$dir/include/libav/libavformat"
+ else
+ unset ac_cv_header_avformat_h
+ unset ac_cv_header_libavformat_avformat_h
+ unset ac_cv_header_ffmpeg_avformat_h
+ unset ac_cv_header_ffmpeg_libavformat_avformat_h
+ unset ac_cv_header_libav_avformat_h
+ unset ac_cv_header_libav_libavformat_avformat_h
+ CPPFLAGS="$CPPFLAGS_SAVE"
+ continue
+ fi
+ fi
+ HAVE_LIBAVFORMAT=1
+ break
+done
+if test -z "$HAVE_LIBAVFORMAT"; then
+ AC_MSG_ERROR([libavformat headers not found or not usable])
+fi
+
+CPPFLAGS_SAVE="$CPPFLAGS"
+for dir in "" /usr/local $SEARCH_DIR; do
+ if test -n "$dir"; then
+ CPPFLAGS="$CPPFLAGS -I$dir/include"
+ fi
+ AC_CHECK_HEADERS([jpeglib.h sqlite3.h libexif/exif-loader.h id3tag.h ogg/ogg.h vorbis/codec.h FLAC/metadata.h],,[unset $as_ac_Header; break],)
+ if test x"$ac_cv_header_jpeglib_h" != x"yes"; then
+ CPPFLAGS="$CPPFLAGS_SAVE"
+ continue
+ elif test x"$ac_cv_header_sqlite3_h" != x"yes"; then
+ CPPFLAGS="$CPPFLAGS_SAVE"
+ continue
+ elif test x"$ac_cv_header_libexif_exif_loader_h" != x"yes"; then
+ CPPFLAGS="$CPPFLAGS_SAVE"
+ continue
+ elif test x"$ac_cv_header_id3tag_h" != x"yes"; then
+ CPPFLAGS="$CPPFLAGS_SAVE"
+ continue
+ elif test x"$ac_cv_header_ogg_ogg_h" != x"yes"; then
+ CPPFLAGS="$CPPFLAGS_SAVE"
+ continue
+ elif test x"$ac_cv_header_vorbis_codec_h" != x"yes"; then
+ CPPFLAGS="$CPPFLAGS_SAVE"
+ continue
+ elif test x"$ac_cv_header_FLAC_metadata_h" != x"yes"; then
+ CPPFLAGS="$CPPFLAGS_SAVE"
+ continue
+ else
+ break;
+ fi
+done
+test x"$ac_cv_header_jpeglib_h" != x"yes" && AC_MSG_ERROR([libjpeg headers not found or not usable])
+test x"$ac_cv_header_sqlite3_h" != x"yes" && AC_MSG_ERROR([libsqlite3 headers not found or not usable])
+test x"$ac_cv_header_libexif_exif_loader_h" != x"yes" && AC_MSG_ERROR([libexif headers not found or not usable])
+test x"$ac_cv_header_id3tag_h" != x"yes" && AC_MSG_ERROR([libid3tag headers not found or not usable])
+test x"$ac_cv_header_ogg_ogg_h" != x"yes" && AC_MSG_ERROR([libogg headers not found or not usable])
+test x"$ac_cv_header_vorbis_codec_h" != x"yes" && AC_MSG_ERROR([libvorbis headers not found or not usable])
+test x"$ac_cv_header_FLAC_metadata_h" != x"yes" && AC_MSG_ERROR([libFLAC headers not found or not usable])
+
+CFLAGS_SAVE="$CFLAGS"
+CFLAGS="$CFLAGS -Wall -Werror"
+AC_MSG_CHECKING([if we should use the daemon() libc function])
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [
+ #include <stdlib.h>
+ ],
+ [
+ (void)daemon(0, 0);
+ ]
+ )],
+ [
+ AC_DEFINE([USE_DAEMON], [1],
+ [use the system's builtin daemon()])
+ AC_MSG_RESULT([yes])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ ])
+
+AC_MSG_CHECKING([if scandir declaration requires const char cast])
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [
+ #include <stdlib.h>
+ #include <sys/types.h>
+ #include <dirent.h>
+ ],
+ [
+ int filter(struct dirent *d);
+ struct dirent **ptr = NULL;
+ char *name = NULL;
+ (void)scandir(name, &ptr, filter, alphasort);
+ ]
+ )],
+ [
+ AC_MSG_RESULT([no])
+ ],
+ [
+ AC_DEFINE([SCANDIR_CONST], [1],
+ [scandir needs const char cast])
+
+ AC_MSG_RESULT([yes])
+ ])
+
+AC_MSG_CHECKING([for linux sendfile support])
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [
+ #include <sys/types.h>
+ #include <sys/sendfile.h>
+ ],
+ [
+ int tofd = 0, fromfd = 0;
+ off_t offset;
+ size_t total = 0;
+ ssize_t nwritten = sendfile(tofd, fromfd, &offset, total);
+ return nwritten;
+ ]
+ )],
+ [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_LINUX_SENDFILE_API], [1], [Whether linux sendfile() API is available])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ ])
+
+AC_MSG_CHECKING([for darwin sendfile support])
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [
+ #include <stdlib.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <sys/uio.h>
+ ],
+ [
+ int fd = 0, s = 0;
+ off_t offset = 0, len;
+ struct sf_hdtr *hdtr = NULL;
+ int flags = 0;
+ int ret;
+ ret = sendfile(fd, s, offset, &len, hdtr, flags);
+ return ret;
+ ]
+ )],
+ [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_DARWIN_SENDFILE_API], [1], [Whether darwin sendfile() API is available])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ ])
+
+AC_MSG_CHECKING([for freebsd sendfile support])
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [
+ #include <stdlib.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <sys/uio.h>
+ ],
+ [
+ int fromfd=0, tofd=0, ret, total=0;
+ off_t offset=0, nwritten;
+ struct sf_hdtr hdr;
+ struct iovec hdtrl;
+ hdr.headers = &hdtrl;
+ hdr.hdr_cnt = 1;
+ hdr.trailers = NULL;
+ hdr.trl_cnt = 0;
+ hdtrl.iov_base = NULL;
+ hdtrl.iov_len = 0;
+ ret = sendfile(fromfd, tofd, offset, total, &hdr, &nwritten, 0);
+ ]
+ )],
+ [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_FREEBSD_SENDFILE_API], [1], [Whether freebsd sendfile() API is available])
+ ],
+ [
+ AC_MSG_RESULT([no])
+ ])
+CFLAGS="$CFLAGS_SAVE"
+
+LDFLAGS_SAVE="$LDFLAGS"
+for dir in "" /usr/local $SEARCH_DIR; do
+ if test -n "$dir"; then
+ LDFLAGS="$LDFLAGS -L$dir/lib"
+ fi
+ AC_CHECK_LIB([jpeg], [jpeg_set_defaults], [LIBJPEG_LIBS="-ljpeg"], [unset ac_cv_lib_jpeg_jpeg_set_defaults; LDFLAGS="$LDFLAGS_SAVE"; continue])
+ break
+done
+test x"$ac_cv_lib_jpeg_jpeg_set_defaults" = x"yes" || AC_MSG_ERROR([Could not find libjpeg])
+AC_SUBST(LIBJPEG_LIBS)
+
+LDFLAGS_SAVE="$LDFLAGS"
+for dir in "" /usr/local $SEARCH_DIR; do
+ if test -n "$dir"; then
+ LDFLAGS="$LDFLAGS -L$dir/lib"
+ fi
+ AC_CHECK_LIB([exif], [exif_data_new_from_file], [LIBEXIF_LIBS="-lexif"], [unset ac_cv_lib_exif_exif_data_new_from_file; LDFLAGS="$LDFLAGS_SAVE"; continue])
+ break
+done
+test x"$ac_cv_lib_jpeg_jpeg_set_defaults" = x"yes" || AC_MSG_ERROR([Could not find libexif])
+AC_SUBST(LIBEXIF_LIBS)
+
+LDFLAGS_SAVE="$LDFLAGS"
+for dir in "" /usr/local $SEARCH_DIR; do
+ if test -n "$dir"; then
+ LDFLAGS="$LDFLAGS -L$dir/lib"
+ fi
+ AC_CHECK_LIB([id3tag], [id3_file_open], [LIBID3TAG_LIBS="-lid3tag"], [unset ac_cv_lib_id3tag_id3_file_open; LDFLAGS="$LDFLAGS_SAVE"; continue])
+ break
+done
+test x"$ac_cv_lib_id3tag_id3_file_open" = x"yes" || AC_MSG_ERROR([Could not find libid3tag])
+AC_SUBST(LIBID3TAG_LIBS)
+
+LDFLAGS_SAVE="$LDFLAGS"
+for dir in "" /usr/local $SEARCH_DIR; do
+ if test -n "$dir"; then
+ LDFLAGS="$LDFLAGS -L$dir/lib"
+ fi
+ AC_CHECK_LIB([sqlite3], [sqlite3_open], [LIBSQLITE3_LIBS="-lsqlite3"], [unset ac_cv_lib_sqlite3_sqlite3_open; LDFLAGS="$LDFLAGS_SAVE"; continue])
+ break
+done
+test x"$ac_cv_lib_sqlite3_sqlite3_open" = x"yes" || AC_MSG_ERROR([Could not find libsqlite3])
+AC_SUBST(LIBSQLITE3_LIBS)
+
+LDFLAGS_SAVE="$LDFLAGS"
+for dir in "" /usr/local $SEARCH_DIR; do
+ if test -n "$dir"; then
+ LDFLAGS="$LDFLAGS -L$dir/lib"
+ fi
+ AC_CHECK_LIB([avformat], [av_open_input_file], [LIBAVFORMAT_LIBS="-lavformat"], [unset ac_cv_lib_avformat_av_open_input_file; LDFLAGS="$LDFLAGS_SAVE"; continue])
+ AC_SUBST(LIBJPEG_LIBS)
+ break
+done
+test x"$ac_cv_lib_avformat_av_open_input_file" = x"yes" || AC_MSG_ERROR([Could not find libavformat - part of ffmpeg])
+AC_SUBST(LIBAVFORMAT_LIBS)
+
+AC_CHECK_LIB(avutil ,[av_rescale_q], [LIBAVUTIL_LIBS="-lavutil"], [AC_MSG_ERROR([Could not find libavutil - part of ffmpeg])])
+AC_SUBST(LIBAVUTIL_LIBS)
+
+AC_CHECK_LIB(avcodec ,[avcodec_init], [LIBAVCODEC_LIBS="-lavcodec"], [AC_MSG_ERROR([Could not find libavcodec - part of ffmpeg])])
+AC_SUBST(LIBAVCODEC_LIBS)
+
+AC_CHECK_LIB(pthread, pthread_create)
+
+# test if we have vorbisfile
+# prior versions had ov_open_callbacks in libvorbis, test that, too.
+AC_CHECK_LIB(vorbisfile, ov_open_callbacks,
+ [AC_CHECK_HEADERS([vorbis/vorbisfile.h],
+ AM_CONDITIONAL(HAVE_VORBISFILE, true)
+ AC_DEFINE(HAVE_VORBISFILE,1,[Have vorbisfile]),
+ AM_CONDITIONAL(HAVE_VORBISFILE, false)
+ AC_DEFINE(HAVE_VORBISFILE,0,[lacking vorbisfile]))],
+ AM_CONDITIONAL(HAVE_VORBISFILE, false),
+ -lvorbis -logg)
+AC_CHECK_LIB(FLAC, FLAC__stream_decoder_init_stream,
+ [AC_CHECK_HEADERS([FLAC/all.h],
+ AM_CONDITIONAL(HAVE_FLAC, true)
+ AC_DEFINE(HAVE_FLAC,1,[Have flac]),
+ AM_CONDITIONAL(HAVE_FLAC, false))],
+ AM_CONDITIONAL(HAVE_FLAC, false),
+ -logg)
+# test without -logg to see whether we really need it (libflac can be without)
+AC_CHECK_LIB(FLAC, FLAC__stream_decoder_init_ogg_stream,
+ AM_CONDITIONAL(HAVE_FLAC, true)
+ AC_DEFINE(HAVE_FLAC,1,[Have flac])
+ AM_CONDITIONAL(NEED_OGG, false),
+ [AM_CONDITIONAL(NEED_OGG, true)])
+AC_CHECK_LIB(vorbisfile, vorbis_comment_query,
+ AM_CONDITIONAL(NEED_VORBIS, false),
+ AM_CONDITIONAL(NEED_VORBIS, true),
+ -logg)
+
+################################################################################################################
+### Header checks
+
+#AC_HEADER_CHECK(libintl.h, AC_DEFINE([ENABLE_NLS], [1], [Define to use NLS]))
+AC_HEADER_CHECK(inotify.h, AC_DEFINE([HAVE_INOTIFY_H], [1], [Define to enable inotify]))
+
+# Checks for header files. (From autoscan)
+AC_CHECK_HEADERS([arpa/inet.h endian.h machine/endian.h fcntl.h libintl.h locale.h netdb.h netinet/in.h stddef.h stdlib.h string.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h])
+
+################################################################################################################
+### Build Options
+
+AC_ARG_WITH(logpath,
+ AS_HELP_STRING([--with-log-path],[Log path]),
+ [with_logpath="$withval"],[with_logpath="/var/log"])
+AC_DEFINE_UNQUOTED([DEFAULT_LOG_PATH],"${with_logpath}",[Log path])
+
+
+AC_ARG_WITH(dbpath,
+ AS_HELP_STRING([--with-db-path],[DB path]),
+ [with_dbpath="$withval"],[with_dbpath="/var/cache/minidlna"])
+AC_DEFINE_UNQUOTED([DEFAULT_DB_PATH],"${with_dbpath}",[DB path])
+
+AC_ARG_WITH(osname,
+ AS_HELP_STRING([--with-os-name],[OS Name]),
+ [with_osname="$withval"],[with_osname="$(uname -s)"])
+AC_DEFINE_UNQUOTED([OS_NAME],"${with_osname}",[OS Name])
+
+AC_ARG_WITH(osver,
+ AS_HELP_STRING([--with-os-version],[OS Version]),
+ [with_osver="$withval"],[with_osver="$(uname -r)"])
+AC_DEFINE_UNQUOTED([OS_VERSION],"${with_osver}",[OS Version])
+
+AC_ARG_WITH(osurl,
+ AS_HELP_STRING([--with-os-url],[OS URL]),
+ [with_osurl="$withval"],[with_osurl="http://www.netgear.com"])
+AC_DEFINE_UNQUOTED([OS_URL],"${with_osurl}",[OS URL])
+
+AC_ARG_WITH(tivo,
+ AS_HELP_STRING([--with-tivo],[TiVo Support]),
+ [with_tivo="$withval"],[with_tivo="yes"])
+if test "$with_tivo" = "yes"; then
+ AC_DEFINE([TIVO_SUPPORT],[1],[Define to 1 if you want to enable TiVo support])
+fi
+
+AC_ARG_WITH(netgear,
+ AS_HELP_STRING([--with-netgear],[NETGEAR ReadyNAS Support]),
+ [with_netgear="$withval"],[with_netgear="no"])
+if test "$with_netgear" = "yes"; then
+ AC_DEFINE([NETGEAR],[1],[Define to 1 if you want to enable NETGEAR support])
+ AC_DEFINE([READYNAS],[1],[Define to 1 if you want to enable NETGEAR support])
+ AC_DEFINE([PNPX],[5],[Define to 1 if you want to enable NETGEAR support])
+ AC_DEFINE_UNQUOTED([OS_URL],"http://www.readynas.com/",[OS URL])
+fi
+
+AC_ARG_WITH(staticbin,
+ AS_HELP_STRING([--with-staticbin],[Build statically linked binaries]),
+ [with_staticbin="$withval"],[with_staticbin="no"])
+if test "$with_staticbin" = "yes"; then
+ STATIC_CFLAGS="-DSTATIC"
+ AC_SUBST(STATIC_CFLAGS)
+ STATIC_LDFLAGS="-Wl,-Bstatic"
+ AC_SUBST(STATIC_LDFLAGS)
+fi
+
+case "$target_os" in
+ darwin*)
+ ;;
+ freebsd*)
+ VER=`grep '#define __FreeBSD_version' /usr/include/sys/param.h | awk '{print $3}'`
+ OS_URL=http://www.freebsd.org/
+ ;;
+ solaris*)
+ AC_DEFINE([USE_IPF], [1], [Define to enable IPF])
+ AC_DEFINE([LOG_PERROR], [0], [Define to enable logging])
+ AC_DEFINE([SOLARIS_KSTATS], [1], [Define to enable Solaris Kernel Stats])
+ ;;
+ kfreebsd*)
+ OS_URL=http://www.debian.org/
+ ;;
+ linux*)
+ ;;
+ *)
+ echo "Unknown OS : $target_os"
+ ;;
+esac
+
+
+AC_OUTPUT([ po/Makefile.in
+Makefile
+])
diff --git a/daemonize.c b/daemonize.c
index 9a10276..944f8f1 100644
--- a/daemonize.c
+++ b/daemonize.c
@@ -94,7 +94,7 @@ writepidfile(const char * fname, int pid)
int pidstringlen;
int pidfile;
- if(!fname || (strlen(fname) == 0))
+ if(!fname || *fname == '\0')
return -1;
if( (pidfile = open(fname, O_WRONLY|O_CREAT, 0644)) < 0)
@@ -129,7 +129,7 @@ checkforrunning(const char * fname)
int pidfile;
pid_t pid;
- if(!fname || (strlen(fname) == 0))
+ if(!fname || *fname == '\0')
return -1;
if( (pidfile = open(fname, O_RDONLY)) < 0)
diff --git a/genconfig.sh b/genconfig.sh
deleted file mode 100755
index ea933fd..0000000
--- a/genconfig.sh
+++ /dev/null
@@ -1,215 +0,0 @@
-#! /bin/sh
-# $Id$
-# MiniDLNA project
-# http://sourceforge.net/projects/minidlna/
-#
-# MiniDLNA media server
-# Copyright (C) 2008-2009 Justin Maggard
-#
-# This file is part of MiniDLNA.
-#
-# MiniDLNA is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# MiniDLNA 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 MiniDLNA. If not, see <http://www.gnu.org/licenses/>.
-
-RM="rm -f"
-CONFIGFILE="config.h"
-CONFIGMACRO="__CONFIG_H__"
-
-# Database path
-DB_PATH="/tmp/minidlna"
-# Log path
-LOG_PATH="${DB_PATH}"
-
-# detecting the OS name and version
-OS_NAME=`uname -s`
-OS_VERSION=`uname -r`
-TIVO="/*#define TIVO_SUPPORT*/"
-NETGEAR="/*#define NETGEAR*/"
-READYNAS="/*#define READYNAS*/"
-PNPX="#define PNPX 0"
-
-${RM} ${CONFIGFILE}
-
-# Detect if there are missing headers
-# NOTE: This check only works with a normal distro
-[ ! -e "/usr/include/sqlite3.h" ] && MISSING="libsqlite3 $MISSING"
-[ ! -e "/usr/include/jpeglib.h" ] && MISSING="libjpeg $MISSING"
-[ ! -e "/usr/include/libexif/exif-loader.h" ] && MISSING="libexif $MISSING"
-[ ! -e "/usr/include/id3tag.h" ] && MISSING="libid3tag $MISSING"
-[ ! -e "/usr/include/ogg/ogg.h" ] && MISSING="libogg $MISSING"
-[ ! -e "/usr/include/vorbis/codec.h" ] && MISSING="libvorbis $MISSING"
-[ ! -e "/usr/include/FLAC/metadata.h" ] && MISSING="libflac $MISSING"
-[ ! -e "/usr/include/ffmpeg/avutil.h" -a \
- ! -e "/usr/include/libavutil/avutil.h" -a \
- ! -e "/usr/include/ffmpeg/libavutil/avutil.h" ] && MISSING="libavutil $MISSING"
-[ ! -e "/usr/include/ffmpeg/avformat.h" -a \
- ! -e "/usr/include/libavformat/avformat.h" -a \
- ! -e "/usr/include/ffmpeg/libavformat/avformat.h" ] && MISSING="libavformat $MISSING"
-[ ! -e "/usr/include/ffmpeg/avcodec.h" -a \
- ! -e "/usr/include/libavcodec/avcodec.h" -a \
- ! -e "/usr/include/ffmpeg/libavcodec/avcodec.h" ] && MISSING="libavcodec $MISSING"
-if [ -n "$MISSING" ]; then
- echo -e "\nERROR! Cannot continue."
- echo -e "The following required libraries are either missing, or are missing development headers:\n"
- echo -e "$MISSING\n"
- exit 1
-fi
-
-echo "/* MiniDLNA Project" >> ${CONFIGFILE}
-echo " * http://sourceforge.net/projects/minidlna/" >> ${CONFIGFILE}
-echo " * (c) 2008-2009 Justin Maggard" >> ${CONFIGFILE}
-echo " * generated by $0 on `date` */" >> ${CONFIGFILE}
-echo "#ifndef $CONFIGMACRO" >> ${CONFIGFILE}
-echo "#define $CONFIGMACRO" >> ${CONFIGFILE}
-echo "" >> ${CONFIGFILE}
-
-# OS Specific stuff
-case $OS_NAME in
- OpenBSD)
- MAJORVER=`echo $OS_VERSION | cut -d. -f1`
- MINORVER=`echo $OS_VERSION | cut -d. -f2`
- #echo "OpenBSD majorversion=$MAJORVER minorversion=$MINORVER"
- # rtableid was introduced in OpenBSD 4.0
- if [ $MAJORVER -ge 4 ]; then
- echo "#define PFRULE_HAS_RTABLEID" >> ${CONFIGFILE}
- fi
- # from the 3.8 version, packets and bytes counters are double : in/out
- if [ \( $MAJORVER -ge 4 \) -o \( $MAJORVER -eq 3 -a $MINORVER -ge 8 \) ]; then
- echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
- fi
- OS_URL=http://www.openbsd.org/
- ;;
- FreeBSD)
- VER=`grep '#define __FreeBSD_version' /usr/include/sys/param.h | awk '{print $3}'`
- if [ $VER -ge 700049 ]; then
- echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
- fi
- OS_URL=http://www.freebsd.org/
- ;;
- pfSense)
- # we need to detect if PFRULE_INOUT_COUNTS macro is needed
- OS_URL=http://www.pfsense.com/
- ;;
- NetBSD)
- OS_URL=http://www.netbsd.org/
- ;;
- SunOS)
- echo "#define USE_IPF 1" >> ${CONFIGFILE}
- echo "#define LOG_PERROR 0" >> ${CONFIGFILE}
- echo "#define SOLARIS_KSTATS 1" >> ${CONFIGFILE}
- echo "typedef uint64_t u_int64_t;" >> ${CONFIGFILE}
- echo "typedef uint32_t u_int32_t;" >> ${CONFIGFILE}
- echo "typedef uint16_t u_int16_t;" >> ${CONFIGFILE}
- echo "typedef uint8_t u_int8_t;" >> ${CONFIGFILE}
- OS_URL=http://www.sun.com/solaris/
- ;;
- Linux)
- OS_URL=http://www.kernel.org/
- KERNVERA=`echo $OS_VERSION | awk -F. '{print $1}'`
- KERNVERB=`echo $OS_VERSION | awk -F. '{print $2}'`
- KERNVERC=`echo $OS_VERSION | awk -F. '{print $3}'`
- KERNVERD=`echo $OS_VERSION | awk -F. '{print $4}'`
- #echo "$KERNVERA.$KERNVERB.$KERNVERC.$KERNVERD"
- # NETGEAR ReadyNAS special case
- if [ -f /etc/raidiator_version ]; then
- OS_NAME=$(awk -F'!!|=' '{ print $1 }' /etc/raidiator_version)
- OS_VERSION=$(awk -F'!!|[=,.]' '{ print $3"."$4 }' /etc/raidiator_version)
- OS_URL="http://www.readynas.com/"
- LOG_PATH="/var/log"
- DB_PATH="/var/cache/minidlna"
- TIVO="#define TIVO_SUPPORT"
- NETGEAR="#define NETGEAR"
- READYNAS="#define READYNAS"
- PNPX="#define PNPX 5"
- # Debian GNU/Linux special case
- elif [ -f /etc/debian_version ]; then
- OS_NAME=Debian
- OS_VERSION=`cat /etc/debian_version`
- OS_URL=http://www.debian.org/
- LOG_PATH="/var/log"
- # use lsb_release (Linux Standard Base) when available
- LSB_RELEASE=`which lsb_release 2>/dev/null`
- if [ 0 -eq $? ]; then
- OS_NAME=`${LSB_RELEASE} -i -s`
- OS_VERSION=`${LSB_RELEASE} -r -s`
- fi
- else
- # use lsb_release (Linux Standard Base) when available
- LSB_RELEASE=`which lsb_release 2>/dev/null`
- if [ 0 -eq $? ]; then
- OS_NAME=`${LSB_RELEASE} -i -s`
- OS_VERSION=`${LSB_RELEASE} -r -s`
- fi
- fi
- ;;
- *)
- echo "Unknown OS : $OS_NAME"
- exit 1
- ;;
-esac
-
-echo "#define OS_NAME \"$OS_NAME\"" >> ${CONFIGFILE}
-echo "#define OS_VERSION \"$OS_NAME/$OS_VERSION\"" >> ${CONFIGFILE}
-echo "#define OS_URL \"${OS_URL}\"" >> ${CONFIGFILE}
-echo "" >> ${CONFIGFILE}
-
-echo "/* full path of the file database */" >> ${CONFIGFILE}
-echo "#define DEFAULT_DB_PATH \"${DB_PATH}\"" >> ${CONFIGFILE}
-echo "" >> ${CONFIGFILE}
-
-echo "/* full path of the log directory */" >> ${CONFIGFILE}
-echo "#define DEFAULT_LOG_PATH \"${LOG_PATH}\"" >> ${CONFIGFILE}
-echo "" >> ${CONFIGFILE}
-
-echo "/* Comment the following line to use home made daemonize() func instead" >> ${CONFIGFILE}
-echo " * of BSD daemon() */" >> ${CONFIGFILE}
-echo "#define USE_DAEMON" >> ${CONFIGFILE}
-echo "" >> ${CONFIGFILE}
-
-echo "/* Enable if the system inotify.h exists. Otherwise our own inotify.h will be used. */" >> ${CONFIGFILE}
-if [ -f /usr/include/sys/inotify.h ]; then
-echo "#define HAVE_INOTIFY_H" >> ${CONFIGFILE}
-else
-echo "/*#define HAVE_INOTIFY_H*/" >> ${CONFIGFILE}
-fi
-echo "" >> ${CONFIGFILE}
-
-echo "/* Enable if the system iconv.h exists. ID3 tag reading in various character sets will not work properly otherwise. */" >> ${CONFIGFILE}
-if [ -f /usr/include/iconv.h ]; then
-echo "#define HAVE_ICONV_H" >> ${CONFIGFILE}
-else
-echo -e "\nWARNING!! Iconv support not found. ID3 tag reading may not work."
-echo "/*#define HAVE_ICONV_H*/" >> ${CONFIGFILE}
-fi
-echo "" >> ${CONFIGFILE}
-
-echo "/* Enable if the system libintl.h exists for NLS support. */" >> ${CONFIGFILE}
-if [ -f /usr/include/libintl.h ]; then
-echo "#define ENABLE_NLS" >> ${CONFIGFILE}
-else
-echo "/*#define ENABLE_NLS*/" >> ${CONFIGFILE}
-fi
-echo "" >> ${CONFIGFILE}
-
-echo "/* Enable NETGEAR-specific tweaks. */" >> ${CONFIGFILE}
-echo "${NETGEAR}" >> ${CONFIGFILE}
-echo "/* Enable ReadyNAS-specific tweaks. */" >> ${CONFIGFILE}
-echo "${READYNAS}" >> ${CONFIGFILE}
-echo "/* Compile in TiVo support. */" >> ${CONFIGFILE}
-echo "${TIVO}" >> ${CONFIGFILE}
-echo "/* Enable PnPX support. */" >> ${CONFIGFILE}
-echo "${PNPX}" >> ${CONFIGFILE}
-echo "" >> ${CONFIGFILE}
-
-echo "#endif" >> ${CONFIGFILE}
-
-exit 0
diff --git a/getifaddr.c b/getifaddr.c
index f0cbdfc..4aeb92b 100644
--- a/getifaddr.c
+++ b/getifaddr.c
@@ -1,4 +1,4 @@
-/* $Id: getifaddr.c,v 1.14 2011/05/02 23:50:52 jmaggard Exp $ */
+/* $Id$ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
*
@@ -43,19 +43,82 @@
#include <sys/sockio.h>
#endif
+#include "config.h"
+#if HAVE_GETIFADDRS
+#include <ifaddrs.h>
+#ifdef __linux__
+#ifndef AF_LINK
+#define AF_LINK AF_INET
+#endif
+#else
+#include <net/if_dl.h>
+#endif
+#endif
#include "getifaddr.h"
#include "log.h"
+static uint32_t
+get_netmask(struct sockaddr_in *netmask)
+{
+ uint32_t mask;
+ int i;
+
+ if (!netmask)
+ return 0;
+ mask = ntohl(netmask->sin_addr.s_addr);
+ for (i = 0; i < 32; i++)
+ {
+ if ((mask >> i) & 1)
+ break;
+ }
+ mask = 32 - i;
+
+ return mask;
+}
+
int
getifaddr(const char * ifname, char * buf, int len)
{
/* SIOCGIFADDR struct ifreq * */
+ uint32_t mask = 0;
+ int i;
+#if HAVE_GETIFADDRS
+ struct ifaddrs *ifap, *p;
+ struct sockaddr_in *addr_in;
+
+ if( getifaddrs(&ifap) != 0 )
+ {
+ DPRINTF(E_ERROR, L_GENERAL, "getifaddrs(): %s\n", strerror(errno));
+ return -1;
+ }
+ for( p = ifap; p != NULL; p = p->ifa_next )
+ {
+ if( p->ifa_addr->sa_family == AF_INET )
+ {
+ if( strcmp(p->ifa_name, ifname) != 0 )
+ continue;
+ addr_in = (struct sockaddr_in *)p->ifa_addr;
+ if(!inet_ntop(AF_INET, &addr_in->sin_addr, buf, len))
+ {
+ DPRINTF(E_ERROR, L_GENERAL, "inet_ntop(): %s\n", strerror(errno));
+ break;
+ }
+ addr_in = (struct sockaddr_in *)p->ifa_netmask;
+ mask = get_netmask(addr_in);
+ break;
+ }
+ }
+ freeifaddrs(ifap);
+ if( !p )
+ {
+ DPRINTF(E_ERROR, L_GENERAL, "Network interface %s not found\n", ifname);
+ return -1;
+ }
+#else
int s;
struct ifreq ifr;
int ifrlen;
struct sockaddr_in * addr;
- uint32_t mask;
- int i;
ifrlen = sizeof(ifr);
s = socket(PF_INET, SOCK_DGRAM, 0);
@@ -81,22 +144,17 @@ getifaddr(const char * ifname, char * buf, int len)
if(ioctl(s, SIOCGIFNETMASK, &ifr, &ifrlen) == 0)
{
addr = (struct sockaddr_in *)&ifr.ifr_netmask;
- mask = ntohl(addr->sin_addr.s_addr);
- for (i = 0; i < 32; i++)
- {
- if ((mask >> i) & 1)
- break;
- }
- mask = 32 - i;
- if (mask)
- {
- i = strlen(buf);
- snprintf(buf+i, len-i, "/%u", mask);
- }
+ mask = get_netmask(addr);
}
else
DPRINTF(E_ERROR, L_GENERAL, "ioctl(s, SIOCGIFNETMASK, ...): %s\n", strerror(errno));
close(s);
+#endif
+ if (mask)
+ {
+ i = strlen(buf);
+ snprintf(buf+i, len-i, "/%u", mask);
+ }
return 0;
}
@@ -104,12 +162,42 @@ int
getsysaddr(char * buf, int len)
{
int i;
+ uint32_t mask = 0;
+ int ret = -1;
+#if HAVE_GETIFADDRS
+ struct ifaddrs *ifap, *p;
+ struct sockaddr_in *addr_in;
+ uint8_t a;
+
+ if( getifaddrs(&ifap) != 0 )
+ {
+ DPRINTF(E_ERROR, L_GENERAL, "getifaddrs(): %s\n", strerror(errno));
+ return -1;
+ }
+ for( p = ifap; p != NULL; p = p->ifa_next )
+ {
+ if (p->ifa_addr->sa_family == AF_INET)
+ {
+ addr_in = (struct sockaddr_in *)p->ifa_addr;
+ a = (htonl(addr_in->sin_addr.s_addr) >> 0x18) & 0xFF;
+ if( a == 127 )
+ continue;
+ if(!inet_ntop(AF_INET, &addr_in->sin_addr, buf, len))
+ {
+ DPRINTF(E_ERROR, L_GENERAL, "inet_ntop(): %s\n", strerror(errno));
+ break;
+ }
+ addr_in = (struct sockaddr_in *)p->ifa_netmask;
+ mask = get_netmask(addr_in);
+ ret = 0;
+ break;
+ }
+ }
+ freeifaddrs(ifap);
+#else
int s = socket(PF_INET, SOCK_STREAM, 0);
struct sockaddr_in addr;
struct ifreq ifr;
- uint32_t mask;
- int ret = -1;
-
for (i=1; i > 0; i++)
{
ifr.ifr_ifindex = i;
@@ -128,24 +216,19 @@ getsysaddr(char * buf, int len)
close(s);
break;
}
- ret = 0;
-
memcpy(&addr, &ifr.ifr_netmask, sizeof(addr));
- mask = ntohl(addr.sin_addr.s_addr);
- for (i = 0; i < 32; i++)
- {
- if ((mask >> i) & 1)
- break;
- }
- mask = 32 - i;
- if (mask)
- {
- i = strlen(buf);
- snprintf(buf+i, len-i, "/%u", mask);
- }
+ mask = get_netmask(&addr);
+ ret = 0;
break;
}
close(s);
+#endif
+
+ if (mask)
+ {
+ i = strlen(buf);
+ snprintf(buf+i, len-i, "/%u", mask);
+ }
return(ret);
}
@@ -153,11 +236,55 @@ getsysaddr(char * buf, int len)
int
getsyshwaddr(char * buf, int len)
{
- struct if_nameindex *ifaces, *if_idx;
unsigned char mac[6];
+ int ret = -1;
+#if HAVE_GETIFADDRS
+ struct ifaddrs *ifap, *p;
+ struct sockaddr_in *addr_in;
+ uint8_t a;
+
+ if( getifaddrs(&ifap) != 0 )
+ {
+ DPRINTF(E_ERROR, L_GENERAL, "getifaddrs(): %s\n", strerror(errno));
+ return -1;
+ }
+ for( p = ifap; p != NULL; p = p->ifa_next )
+ {
+ if (p->ifa_addr->sa_family == AF_LINK)
+ {
+ addr_in = (struct sockaddr_in *)p->ifa_addr;
+ a = (htonl(addr_in->sin_addr.s_addr) >> 0x18) & 0xFF;
+ if( a == 127 )
+ continue;
+#ifdef __linux__
+ struct ifreq ifr;
+ int fd;
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ if( fd < 0 )
+ continue;
+ strncpy(ifr.ifr_name, p->ifa_name, IFNAMSIZ);
+ if( ioctl(fd, SIOCGIFHWADDR, &ifr) < 0 )
+ {
+ close(fd);
+ continue;
+ }
+ memcpy(mac, ifr.ifr_hwaddr.sa_data, 6);
+#else
+ struct sockaddr_dl *sdl;
+ sdl = (struct sockaddr_dl*)p->ifa_addr;
+ memcpy(mac, LLADDR(sdl), sdl->sdl_alen);
+#endif
+ if( MACADDR_IS_ZERO(mac) )
+ continue;
+ ret = 0;
+ break;
+ }
+ }
+ freeifaddrs(ifap);
+#else
+ struct if_nameindex *ifaces, *if_idx;
struct ifreq ifr;
int fd;
- int ret = -1;
memset(&mac, '\0', sizeof(mac));
/* Get the spatially unique node identifier */
@@ -180,25 +307,21 @@ getsyshwaddr(char * buf, int len)
continue;
if( MACADDR_IS_ZERO(ifr.ifr_hwaddr.sa_data) )
continue;
+ memcpy(mac, ifr.ifr_hwaddr.sa_data, 6);
ret = 0;
break;
}
if_freenameindex(ifaces);
close(fd);
-
+#endif
if(ret == 0)
{
if(len > 12)
- {
- memmove(mac, ifr.ifr_hwaddr.sa_data, 6);
sprintf(buf, "%02x%02x%02x%02x%02x%02x",
mac[0]&0xFF, mac[1]&0xFF, mac[2]&0xFF,
mac[3]&0xFF, mac[4]&0xFF, mac[5]&0xFF);
- }
else if(len == 6)
- {
- memmove(buf, ifr.ifr_hwaddr.sa_data, 6);
- }
+ memmove(buf, mac, 6);
}
return ret;
}
diff --git a/image_utils.c b/image_utils.c
index c6b9abd..2135e3d 100644
--- a/image_utils.c
+++ b/image_utils.c
@@ -26,6 +26,7 @@
* The resize functions come from the resize_image project, at http://www.golac.fr/Image-Resizer
*/
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -33,7 +34,11 @@
#include <sys/types.h>
#include <setjmp.h>
#include <jpeglib.h>
+#ifdef HAVE_MACHINE_ENDIAN_H
+#include <machine/endian.h>
+#else
#include <endian.h>
+#endif
#include "upnpreplyparse.h"
#include "image_utils.h"
@@ -380,8 +385,7 @@ image_get_jpeg_date_xmp(const char * path, char ** date)
}
}
fclose(img);
- if( data )
- free(data);
+ free(data);
return ret;
}
@@ -463,8 +467,7 @@ image_new_from_jpeg(const char * path, int is_file, const char * buf, int size,
fclose(file);
if( vimage )
{
- if( vimage->buf )
- free(vimage->buf);
+ free(vimage->buf);
free(vimage);
}
return NULL;
diff --git a/inotify.c b/inotify.c
index 13074fc..6ed4da5 100644
--- a/inotify.c
+++ b/inotify.c
@@ -16,6 +16,8 @@
* along with MiniDLNA. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
+
+#ifdef HAVE_INOTIFY
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -216,8 +218,7 @@ inotify_remove_watches(int fd)
{
last_w = w;
inotify_rm_watch(fd, w->wd);
- if( w->path )
- free(w->path);
+ free(w->path);
rm_watches++;
w = w->next;
free(last_w);
@@ -729,3 +730,4 @@ quitting:
return 0;
}
+#endif
diff --git a/inotify.h b/inotify.h
index 91db6f6..0f378c2 100644
--- a/inotify.h
+++ b/inotify.h
@@ -1,6 +1,7 @@
-
+#ifdef HAVE_INOTIFY
int
inotify_remove_file(const char * path);
void *
start_inotify();
+#endif
diff --git a/metadata.c b/metadata.c
index 0f698d0..248868a 100644
--- a/metadata.c
+++ b/metadata.c
@@ -19,21 +19,61 @@
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
-#include <sys/stat.h>
-
+#include <libgen.h>
#include <unistd.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/param.h>
#include <fcntl.h>
+#include "config.h"
#include <libexif/exif-loader.h>
#include "image_utils.h"
+#include "tagutils/tagutils.h"
#include <jpeglib.h>
#include <setjmp.h>
+
+#if HAVE_FFMPEG_LIBAVUTIL_AVUTIL_H
+#include <ffmpeg/libavutil/avutil.h>
+#elif HAVE_LIBAV_LIBAVUTIL_AVUTIL_H
+#include <libav/libavutil/avutil.h>
+#elif HAVE_LIBAVUTIL_AVUTIL_H
+#include <libavutil/avutil.h>
+#elif HAVE_FFMPEG_AVUTIL_H
+#include <ffmpeg/avutil.h>
+#elif HAVE_LIBAV_AVUTIL_H
+#include <libav/avutil.h>
+#elif HAVE_AVUTIL_H
#include <avutil.h>
+#endif
+
+#if HAVE_FFMPEG_LIBAVCODEC_AVCODEC_H
+#include <ffmpeg/libavcodec/avcodec.h>
+#elif HAVE_LIBAV_LIBAVCODEC_AVCODEC_H
+#include <libav/libavcodec/avcodec.h>
+#elif HAVE_LIBAVCODEC_AVCODEC_H
+#include <libavcodec/avcodec.h>
+#elif HAVE_FFMPEG_AVCODEC_H
+#include <ffmpeg/avcodec.h>
+#elif HAVE_LIBAV_AVCODEC_H
+#include <libav/avcodec.h>
+#elif HAVE_AVCODEC_H
#include <avcodec.h>
+#endif
+
+#if HAVE_FFMPEG_LIBAVFORMAT_AVFORMAT_H
+#include <ffmpeg/libavformat/avformat.h>
+#elif HAVE_LIBAV_LIBAVFORMAT_AVFORMAT_H
+#include <libav/libavformat/avformat.h>
+#elif HAVE_LIBAVFORMAT_AVFORMAT_H
+#include <libavformat/avformat.h>
+#elif HAVE_FFMPEG_AVFORMAT_H
+#include <ffmpeg/avformat.h>
+#elif HAVE_LIBAV_LIBAVFORMAT_H
+#include <libav/avformat.h>
+#elif HAVE_AVFORMAT_H
#include <avformat.h>
-#include "tagutils/tagutils.h"
+#endif
#include "upnpglobalvars.h"
#include "upnpreplyparse.h"
@@ -150,7 +190,7 @@ is_tivo_file(const char * path)
void
check_for_captions(const char * path, sqlite_int64 detailID)
{
- char *file = malloc(PATH_MAX);
+ char *file = malloc(MAXPATHLEN);
char *id = NULL;
sprintf(file, "%s", path);
@@ -655,10 +695,11 @@ GetVideoMetadata(const char * path, char * name)
enum audio_profiles audio_profile = PROFILE_AUDIO_UNKNOWN;
char fourcc[4];
sqlite_int64 album_art = 0;
- char nfo[PATH_MAX], *ext;
+ char nfo[MAXPATHLEN], *ext;
struct song_metadata video;
metadata_t m;
uint32_t free_flags = 0xFFFFFFFF;
+ char *path_cpy, *basepath;
memset(&m, '\0', sizeof(m));
memset(&video, '\0', sizeof(video));
@@ -698,12 +739,15 @@ GetVideoMetadata(const char * path, char * name)
continue;
}
}
- /* This must not be a video file. */
+ path_cpy = strdup(path);
+ basepath = basename(path_cpy);
if( !vc )
{
+ /* This must not be a video file. */
av_close_input_file(ctx);
if( !is_audio(path) )
- DPRINTF(E_DEBUG, L_METADATA, "File %s does not contain a video stream.\n", basename(path));
+ DPRINTF(E_DEBUG, L_METADATA, "File %s does not contain a video stream.\n", basepath);
+ free(path_cpy);
return 0;
}
@@ -819,7 +863,7 @@ GetVideoMetadata(const char * path, char * name)
int off;
int duration, hours, min, sec, ms;
ts_timestamp_t ts_timestamp = NONE;
- DPRINTF(E_DEBUG, L_METADATA, "Container: '%s' [%s]\n", ctx->iformat->name, basename(path));
+ DPRINTF(E_DEBUG, L_METADATA, "Container: '%s' [%s]\n", ctx->iformat->name, basepath);
asprintf(&m.resolution, "%dx%d", vc->width, vc->height);
if( ctx->bit_rate > 8 )
asprintf(&m.bitrate, "%u", ctx->bit_rate / 8);
@@ -880,7 +924,7 @@ GetVideoMetadata(const char * path, char * name)
int raw_packet_size;
int dlna_ts_present = dlna_timestamp_is_present(path, &raw_packet_size);
DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s MPEG2 TS packet size %d\n",
- video_stream, basename(path), m.resolution, raw_packet_size);
+ video_stream, basepath, m.resolution, raw_packet_size);
off += sprintf(m.dlna_pn+off, "TS_");
if( (vc->width >= 1280) &&
(vc->height >= 720) )
@@ -906,7 +950,7 @@ GetVideoMetadata(const char * path, char * name)
else if( raw_packet_size != MPEG_TS_PACKET_LENGTH )
{
DPRINTF(E_DEBUG, L_METADATA, "Unsupported DLNA TS packet size [%d] (%s)\n",
- raw_packet_size, basename(path));
+ raw_packet_size, basepath);
free(m.dlna_pn);
m.dlna_pn = NULL;
}
@@ -928,7 +972,7 @@ GetVideoMetadata(const char * path, char * name)
else if( strcmp(ctx->iformat->name, "mpeg") == 0 )
{
DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s MPEG2 PS\n",
- video_stream, basename(path), m.resolution);
+ video_stream, basepath, m.resolution);
off += sprintf(m.dlna_pn+off, "PS_");
if( (vc->height == 576) ||
(vc->height == 288) )
@@ -940,7 +984,7 @@ GetVideoMetadata(const char * path, char * name)
else
{
DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s [%s] is %s non-DLNA MPEG2\n",
- video_stream, basename(path), ctx->iformat->name, m.resolution);
+ video_stream, basepath, ctx->iformat->name, m.resolution);
free(m.dlna_pn);
m.dlna_pn = NULL;
}
@@ -1019,7 +1063,7 @@ GetVideoMetadata(const char * path, char * name)
vc->profile != FF_PROFILE_H264_MAIN )
{
DPRINTF(E_DEBUG, L_METADATA, "Unknown AVC profile %d; assuming MP. [%s]\n",
- vc->profile, basename(path));
+ vc->profile, basepath);
}
if( vc->width <= 720 &&
vc->height <= 576 &&
@@ -1036,7 +1080,7 @@ GetVideoMetadata(const char * path, char * name)
else
{
DPRINTF(E_DEBUG, L_METADATA, "Unsupported h.264 video profile! [%s, %dx%d, %dbps : %s]\n",
- m.dlna_pn, vc->width, vc->height, vc->bit_rate, basename(path));
+ m.dlna_pn, vc->width, vc->height, vc->bit_rate, basepath);
free(m.dlna_pn);
m.dlna_pn = NULL;
}
@@ -1053,7 +1097,7 @@ GetVideoMetadata(const char * path, char * name)
else
{
DPRINTF(E_DEBUG, L_METADATA, "Unsupported h.264 HP video profile! [%dbps, %d audio : %s]\n",
- vc->bit_rate, audio_profile, basename(path));
+ vc->bit_rate, audio_profile, basepath);
free(m.dlna_pn);
m.dlna_pn = NULL;
}
@@ -1077,7 +1121,7 @@ GetVideoMetadata(const char * path, char * name)
break;
default:
DPRINTF(E_DEBUG, L_METADATA, "No DLNA profile found for %s file [%s]\n",
- m.dlna_pn, basename(path));
+ m.dlna_pn, basepath);
free(m.dlna_pn);
m.dlna_pn = NULL;
break;
@@ -1095,7 +1139,7 @@ GetVideoMetadata(const char * path, char * name)
else if( raw_packet_size != MPEG_TS_PACKET_LENGTH )
{
DPRINTF(E_DEBUG, L_METADATA, "Unsupported DLNA TS packet size [%d] (%s)\n",
- raw_packet_size, basename(path));
+ raw_packet_size, basepath);
free(m.dlna_pn);
m.dlna_pn = NULL;
}
@@ -1223,7 +1267,7 @@ GetVideoMetadata(const char * path, char * name)
if( strlen(m.dlna_pn) <= 11 )
{
DPRINTF(E_DEBUG, L_METADATA, "No DLNA profile found for %s file %s\n",
- m.dlna_pn, basename(path));
+ m.dlna_pn, basepath);
free(m.dlna_pn);
m.dlna_pn = NULL;
}
@@ -1239,7 +1283,7 @@ GetVideoMetadata(const char * path, char * name)
break;
default:
DPRINTF(E_DEBUG, L_METADATA, "AVC profile [%d] not recognized for file %s\n",
- vc->profile, basename(path));
+ vc->profile, basepath);
free(m.dlna_pn);
m.dlna_pn = NULL;
break;
@@ -1252,7 +1296,7 @@ GetVideoMetadata(const char * path, char * name)
}
if( m.dlna_pn )
sprintf(m.dlna_pn+off, ";%s", dlna_no_conv);
- DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is h.264\n", video_stream, basename(path));
+ DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is h.264\n", video_stream, basepath);
break;
case CODEC_ID_MPEG4:
fourcc[0] = vc->codec_tag & 0xff;
@@ -1260,7 +1304,7 @@ GetVideoMetadata(const char * path, char * name)
fourcc[2] = vc->codec_tag>>16 & 0xff;
fourcc[3] = vc->codec_tag>>24 & 0xff;
DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is MPEG4 [%c%c%c%c/0x%X]\n",
- video_stream, basename(path),
+ video_stream, basepath,
isprint(fourcc[0]) ? fourcc[0] : '_',
isprint(fourcc[1]) ? fourcc[1] : '_',
isprint(fourcc[2]) ? fourcc[2] : '_',
@@ -1285,7 +1329,7 @@ GetVideoMetadata(const char * path, char * name)
break;
default:
DPRINTF(E_DEBUG, L_METADATA, "No DLNA profile found for MPEG4-P2 3GP/0x%X file %s\n",
- ac->codec_id, basename(path));
+ ac->codec_id, basepath);
free(m.dlna_pn);
m.dlna_pn = NULL;
break;
@@ -1336,7 +1380,7 @@ GetVideoMetadata(const char * path, char * name)
}
m.dlna_pn = malloc(64);
off = sprintf(m.dlna_pn, "WMV");
- DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is VC1\n", video_stream, basename(path));
+ DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is VC1\n", video_stream, basepath);
asprintf(&m.mime, "video/x-ms-wmv");
if( (vc->width <= 176) &&
(vc->height <= 144) &&
@@ -1353,7 +1397,7 @@ GetVideoMetadata(const char * path, char * name)
break;
default:
DPRINTF(E_DEBUG, L_METADATA, "No DLNA profile found for WMVSPLL/0x%X file %s\n",
- audio_profile, basename(path));
+ audio_profile, basepath);
free(m.dlna_pn);
m.dlna_pn = NULL;
break;
@@ -1375,7 +1419,7 @@ GetVideoMetadata(const char * path, char * name)
break;
default:
DPRINTF(E_DEBUG, L_METADATA, "No DLNA profile found for WMVSPML/0x%X file %s\n",
- audio_profile, basename(path));
+ audio_profile, basepath);
free(m.dlna_pn);
m.dlna_pn = NULL;
break;
@@ -1399,7 +1443,7 @@ GetVideoMetadata(const char * path, char * name)
break;
default:
DPRINTF(E_DEBUG, L_METADATA, "No DLNA profile found for WMVMED/0x%X file %s\n",
- audio_profile, basename(path));
+ audio_profile, basepath);
free(m.dlna_pn);
m.dlna_pn = NULL;
break;
@@ -1420,7 +1464,7 @@ GetVideoMetadata(const char * path, char * name)
break;
default:
DPRINTF(E_DEBUG, L_METADATA, "No DLNA profile found for WMVHIGH/0x%X file %s\n",
- audio_profile, basename(path));
+ audio_profile, basepath);
free(m.dlna_pn);
m.dlna_pn = NULL;
break;
@@ -1433,7 +1477,7 @@ GetVideoMetadata(const char * path, char * name)
asprintf(&m.mime, "video/x-msvideo");
default:
DPRINTF(E_DEBUG, L_METADATA, "Stream %d of %s is %s [type %d]\n",
- video_stream, basename(path), m.resolution, vc->codec_id);
+ video_stream, basepath, m.resolution, vc->codec_id);
break;
}
}
@@ -1551,6 +1595,7 @@ video_no_dlna:
check_for_captions(path, ret);
}
free_metadata(&m, free_flags);
+ free(path_cpy);
return ret;
}
diff --git a/minidlna.c b/minidlna.c
index f699f2d..58ee34c 100644
--- a/minidlna.c
+++ b/minidlna.c
@@ -53,14 +53,15 @@
#include <ctype.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <sys/file.h>
+#include <sys/time.h>
+#include <sys/param.h>
+#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/time.h>
#include <time.h>
#include <signal.h>
-#include <sys/param.h>
#include <errno.h>
#include <pthread.h>
#include <pwd.h>
@@ -836,7 +837,7 @@ init(int argc, char * * argv)
}
/* set signal handler */
- signal(SIGCLD, SIG_IGN);
+ signal(SIGCHLD, SIG_IGN);
memset(&sa, 0, sizeof(struct sigaction));
sa.sa_handler = sigterm;
if (sigaction(SIGTERM, &sa, NULL))
@@ -922,7 +923,7 @@ main(int argc, char * * argv)
{
if( i < 0 )
{
- DPRINTF(E_WARN, L_GENERAL, "Creating new database...\n");
+ DPRINTF(E_WARN, L_GENERAL, "Creating new database at %s/files.db\n", db_path);
}
else
{
@@ -970,12 +971,13 @@ main(int argc, char * * argv)
start_scanner();
#endif
}
+#ifdef HAVE_INOTIFY
if( sqlite3_threadsafe() && sqlite3_libversion_number() >= 3005001 &&
GETFLAG(INOTIFY_MASK) && pthread_create(&inotify_thread, NULL, start_inotify, NULL) )
{
DPRINTF(E_FATAL, L_GENERAL, "ERROR: pthread_create() failed for start_inotify.\n");
}
-
+#endif
sudp = OpenAndConfSSDPReceiveSocket(n_lan_addr, lan_addr);
if(sudp < 0)
{
diff --git a/options.c b/options.c
index 11fa680..d36f948 100644
--- a/options.c
+++ b/options.c
@@ -76,7 +76,7 @@ readoptionsfile(const char * fname)
int i;
enum upnpconfigoptions id;
- if(!fname || (strlen(fname) == 0))
+ if(!fname || *fname == '\0')
return -1;
memset(buffer, 0, sizeof(buffer));
@@ -155,8 +155,17 @@ readoptionsfile(const char * fname)
}
else
{
- num_options += 1;
- ary_options = (struct option *) realloc(ary_options, num_options * sizeof(struct option));
+ num_options++;
+ t = realloc(ary_options, num_options * sizeof(struct option));
+ if(!t)
+ {
+ fprintf(stderr, "memory allocation error: %s=%s\n",
+ name, value);
+ num_options--;
+ continue;
+ }
+ else
+ ary_options = (struct option *)t;
ary_options[num_options-1].id = id;
strncpy(ary_options[num_options-1].value, value, MAX_OPTION_VALUE_LEN);
diff --git a/playlist.c b/playlist.c
index 3feb694..47a06c3 100644
--- a/playlist.c
+++ b/playlist.c
@@ -102,10 +102,7 @@ fill_playlists()
if( sql_get_table(db, sql_buf, &result, &rows, NULL) != SQLITE_OK )
return -1;
if( !rows )
- {
- sqlite3_free_table(result);
- return 0;
- }
+ goto done;
rows++;
for( i=3; i<rows*3; i++ )
@@ -221,6 +218,7 @@ found:
}
sql_exec(db, "UPDATE PLAYLISTS set FOUND = %d where ID = %lld", found, plID);
}
+done:
sqlite3_free_table(result);
DPRINTF(E_WARN, L_SCANNER, "Finished parsing playlists.\n");
diff --git a/scanner.c b/scanner.c
index 5b4581b..45f9f69 100644
--- a/scanner.c
+++ b/scanner.c
@@ -23,6 +23,7 @@
#include <locale.h>
#include <libgen.h>
#include <inttypes.h>
+#include <sys/param.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/resource.h>
@@ -43,6 +44,12 @@
#include "albumart.h"
#include "log.h"
+#if SCANDIR_CONST
+typedef const struct dirent scan_filter;
+#else
+typedef struct dirent scan_filter;
+#endif
+
int valid_cache = 0;
struct virtual_item
@@ -112,7 +119,7 @@ insert_container(const char * item, const char * rootParent, const char * refID,
ret = sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, DETAIL_ID, CLASS, NAME) "
"VALUES"
- " ('%s$%"PRIX64"', '%s', %Q, %"PRId64", 'container.%s', '%q')",
+ " ('%s$%llX', '%s', %Q, %lld, 'container.%s', '%q')",
rootParent, *parentID, rootParent, refID, detailID, class, item);
}
sqlite3_free(result);
@@ -138,7 +145,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
static struct virtual_item last_camdate;
static sqlite_int64 last_all_objectID = 0;
- asprintf(&sql, "SELECT DATE, CREATOR from DETAILS where ID = %"PRId64, detailID);
+ asprintf(&sql, "SELECT DATE, CREATOR from DETAILS where ID = %lld", detailID);
ret = sql_get_table(db, sql, &result, &row, &cols);
free(sql);
if( ret == SQLITE_OK )
@@ -164,7 +171,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
else
{
insert_container(date_taken, IMAGE_DATE_ID, NULL, "album.photoAlbum", NULL, NULL, NULL, &objectID, &parentID);
- sprintf(last_date.parentID, IMAGE_DATE_ID"$%"PRIX64, parentID);
+ sprintf(last_date.parentID, IMAGE_DATE_ID"$%llX", parentID);
last_date.objectID = objectID;
strcpy(last_date.name, date_taken);
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached date item: %s/%s/%X\n", last_date.name, last_date.parentID, last_date.objectID);
@@ -172,7 +179,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, NAME) "
"VALUES"
- " ('%s$%"PRIX64"', '%s', '%s', '%s', %"PRId64", %Q)",
+ " ('%s$%llX', '%s', '%s', '%s', %lld, %Q)",
last_date.parentID, last_date.objectID, last_date.parentID, refID, class, detailID, name);
if( cam )
@@ -187,7 +194,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
if( !valid_cache || strcmp(camera, last_cam.name) != 0 )
{
insert_container(camera, IMAGE_CAMERA_ID, NULL, "storageFolder", NULL, NULL, NULL, &objectID, &parentID);
- sprintf(last_cam.parentID, IMAGE_CAMERA_ID"$%"PRIX64, parentID);
+ sprintf(last_cam.parentID, IMAGE_CAMERA_ID"$%llX", parentID);
strncpy(last_cam.name, camera, 255);
last_camdate.name[0] = '\0';
}
@@ -199,7 +206,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
else
{
insert_container(date_taken, last_cam.parentID, NULL, "album.photoAlbum", NULL, NULL, NULL, &objectID, &parentID);
- sprintf(last_camdate.parentID, "%s$%"PRIX64, last_cam.parentID, parentID);
+ sprintf(last_camdate.parentID, "%s$%llX", last_cam.parentID, parentID);
last_camdate.objectID = objectID;
strcpy(last_camdate.name, date_taken);
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached camdate item: %s/%s/%s/%X\n", camera, last_camdate.name, last_camdate.parentID, last_camdate.objectID);
@@ -207,7 +214,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, NAME) "
"VALUES"
- " ('%s$%"PRIX64"', '%s', '%s', '%s', %"PRId64", %Q)",
+ " ('%s$%llX', '%s', '%s', '%s', %lld, %Q)",
last_camdate.parentID, last_camdate.objectID, last_camdate.parentID, refID, class, detailID, name);
/* All Images */
if( !last_all_objectID )
@@ -217,12 +224,12 @@ insert_containers(const char * name, const char *path, const char * refID, const
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, NAME) "
"VALUES"
- " ('"IMAGE_ALL_ID"$%"PRIX64"', '"IMAGE_ALL_ID"', '%s', '%s', %"PRId64", %Q)",
+ " ('"IMAGE_ALL_ID"$%llX', '"IMAGE_ALL_ID"', '%s', '%s', %lld, %Q)",
last_all_objectID++, refID, class, detailID, name);
}
else if( strstr(class, "audioItem") )
{
- asprintf(&sql, "SELECT ALBUM, ARTIST, GENRE, ALBUM_ART from DETAILS where ID = %"PRId64, detailID);
+ asprintf(&sql, "SELECT ALBUM, ARTIST, GENRE, ALBUM_ART from DETAILS where ID = %lld", detailID);
ret = sql_get_table(db, sql, &result, &row, &cols);
free(sql);
if( ret != SQLITE_OK )
@@ -261,7 +268,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, NAME) "
"VALUES"
- " ('%s$%"PRIX64"', '%s', '%s', '%s', %"PRId64", %Q)",
+ " ('%s$%llX', '%s', '%s', '%s', %lld, %Q)",
last_album.parentID, last_album.objectID, last_album.parentID, refID, class, detailID, name);
}
if( artist )
@@ -269,12 +276,12 @@ insert_containers(const char * name, const char *path, const char * refID, const
if( !valid_cache || strcmp(artist, last_artist.name) != 0 )
{
insert_container(artist, MUSIC_ARTIST_ID, NULL, "person.musicArtist", NULL, genre, NULL, &objectID, &parentID);
- sprintf(last_artist.parentID, MUSIC_ARTIST_ID"$%"PRIX64, parentID);
+ sprintf(last_artist.parentID, MUSIC_ARTIST_ID"$%llX", parentID);
strcpy(last_artist.name, artist);
last_artistAlbum.name[0] = '\0';
/* Add this file to the "- All Albums -" container as well */
insert_container(_("- All Albums -"), last_artist.parentID, NULL, "album", artist, genre, NULL, &objectID, &parentID);
- sprintf(last_artistAlbumAll.parentID, "%s$%"PRIX64, last_artist.parentID, parentID);
+ sprintf(last_artistAlbumAll.parentID, "%s$%llX", last_artist.parentID, parentID);
last_artistAlbumAll.objectID = objectID;
}
else
@@ -290,7 +297,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
{
insert_container(album?album:_("Unknown Album"), last_artist.parentID, album?last_album.parentID:NULL,
"album.musicAlbum", artist, genre, album_art, &objectID, &parentID);
- sprintf(last_artistAlbum.parentID, "%s$%"PRIX64, last_artist.parentID, parentID);
+ sprintf(last_artistAlbum.parentID, "%s$%llX", last_artist.parentID, parentID);
last_artistAlbum.objectID = objectID;
strcpy(last_artistAlbum.name, album?album:_("Unknown Album"));
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached artist/album item: %s/%s/%X\n", last_artist.name, last_artist.parentID, last_artist.objectID);
@@ -298,12 +305,12 @@ insert_containers(const char * name, const char *path, const char * refID, const
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, NAME) "
"VALUES"
- " ('%s$%"PRIX64"', '%s', '%s', '%s', %"PRId64", %Q)",
+ " ('%s$%llX', '%s', '%s', '%s', %lld, %Q)",
last_artistAlbum.parentID, last_artistAlbum.objectID, last_artistAlbum.parentID, refID, class, detailID, name);
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, NAME) "
"VALUES"
- " ('%s$%"PRIX64"', '%s', '%s', '%s', %"PRId64", %Q)",
+ " ('%s$%llX', '%s', '%s', '%s', %lld, %Q)",
last_artistAlbumAll.parentID, last_artistAlbumAll.objectID, last_artistAlbumAll.parentID, refID, class, detailID, name);
}
if( genre )
@@ -311,12 +318,12 @@ insert_containers(const char * name, const char *path, const char * refID, const
if( !valid_cache || strcmp(genre, last_genre.name) != 0 )
{
insert_container(genre, MUSIC_GENRE_ID, NULL, "genre.musicGenre", NULL, NULL, NULL, &objectID, &parentID);
- sprintf(last_genre.parentID, MUSIC_GENRE_ID"$%"PRIX64, parentID);
+ sprintf(last_genre.parentID, MUSIC_GENRE_ID"$%llX", parentID);
strcpy(last_genre.name, genre);
last_genreArtist.name[0] = '\0';
/* Add this file to the "- All Artists -" container as well */
insert_container(_("- All Artists -"), last_genre.parentID, NULL, "person", NULL, genre, NULL, &objectID, &parentID);
- sprintf(last_genreArtistAll.parentID, "%s$%"PRIX64, last_genre.parentID, parentID);
+ sprintf(last_genreArtistAll.parentID, "%s$%llX", last_genre.parentID, parentID);
last_genreArtistAll.objectID = objectID;
}
else
@@ -331,7 +338,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
{
insert_container(artist?artist:_("Unknown Artist"), last_genre.parentID, artist?last_artist.parentID:NULL,
"person.musicArtist", NULL, genre, NULL, &objectID, &parentID);
- sprintf(last_genreArtist.parentID, "%s$%"PRIX64, last_genre.parentID, parentID);
+ sprintf(last_genreArtist.parentID, "%s$%llX", last_genre.parentID, parentID);
last_genreArtist.objectID = objectID;
strcpy(last_genreArtist.name, artist?artist:_("Unknown Artist"));
//DEBUG DPRINTF(E_DEBUG, L_SCANNER, "Creating cached genre/artist item: %s/%s/%X\n", last_genreArtist.name, last_genreArtist.parentID, last_genreArtist.objectID);
@@ -339,12 +346,12 @@ insert_containers(const char * name, const char *path, const char * refID, const
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, NAME) "
"VALUES"
- " ('%s$%"PRIX64"', '%s', '%s', '%s', %"PRId64", %Q)",
+ " ('%s$%llX', '%s', '%s', '%s', %lld, %Q)",
last_genreArtist.parentID, last_genreArtist.objectID, last_genreArtist.parentID, refID, class, detailID, name);
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, NAME) "
"VALUES"
- " ('%s$%"PRIX64"', '%s', '%s', '%s', %"PRId64", %Q)",
+ " ('%s$%llX', '%s', '%s', '%s', %lld, %Q)",
last_genreArtistAll.parentID, last_genreArtistAll.objectID, last_genreArtistAll.parentID, refID, class, detailID, name);
}
/* All Music */
@@ -355,7 +362,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, NAME) "
"VALUES"
- " ('"MUSIC_ALL_ID"$%"PRIX64"', '"MUSIC_ALL_ID"', '%s', '%s', %"PRId64", %Q)",
+ " ('"MUSIC_ALL_ID"$%llX', '"MUSIC_ALL_ID"', '%s', '%s', %lld, %Q)",
last_all_objectID++, refID, class, detailID, name);
}
else if( strstr(class, "videoItem") )
@@ -370,7 +377,7 @@ insert_containers(const char * name, const char *path, const char * refID, const
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, NAME) "
"VALUES"
- " ('"VIDEO_ALL_ID"$%"PRIX64"', '"VIDEO_ALL_ID"', '%s', '%s', %"PRId64", %Q)",
+ " ('"VIDEO_ALL_ID"$%llX', '"VIDEO_ALL_ID"', '%s', '%s', %lld, %Q)",
last_all_objectID++, refID, class, detailID, name);
return;
}
@@ -423,7 +430,7 @@ insert_directory(const char * name, const char * path, const char * base, const
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, DETAIL_ID, CLASS, NAME) "
"VALUES"
- " ('%s', '%s', %Q, %"PRId64", '%s', '%q')",
+ " ('%s', '%s', %Q, %lld, '%s', '%q')",
id_buf, parent_buf, refID, detailID, class, strrchr(dir, '/')+1);
if( (p = strrchr(id_buf, '$')) )
*p = '\0';
@@ -444,10 +451,9 @@ insert_directory(const char * name, const char * path, const char * base, const
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, DETAIL_ID, CLASS, NAME) "
"VALUES"
- " ('%s%s$%X', '%s%s', %Q, %"PRId64", '%s', '%q')",
+ " ('%s%s$%X', '%s%s', %Q, %lld, '%s', '%q')",
base, parentID, objectID, base, parentID, refID, detailID, class, name);
- if( refID )
- free(refID);
+ free(refID);
return -1;
}
@@ -492,8 +498,7 @@ insert_file(char * name, const char * path, const char * parentID, int object)
strcpy(class, "item.audioItem.musicTrack");
detailID = GetAudioMetadata(path, name);
}
- if( orig_name )
- free(orig_name);
+ free(orig_name);
if( !detailID )
{
DPRINTF(E_WARN, L_SCANNER, "Unsuccessful getting details for %s!\n", path);
@@ -505,7 +510,7 @@ insert_file(char * name, const char * path, const char * parentID, int object)
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, CLASS, DETAIL_ID, NAME) "
"VALUES"
- " ('%s', '%s%s', '%s', %"PRId64", '%q')",
+ " ('%s', '%s%s', '%s', %lld, '%q')",
objectID, BROWSEDIR_ID, parentID, class, detailID, name);
if( *parentID )
@@ -524,7 +529,7 @@ insert_file(char * name, const char * path, const char * parentID, int object)
sql_exec(db, "INSERT into OBJECTS"
" (OBJECT_ID, PARENT_ID, REF_ID, CLASS, DETAIL_ID, NAME) "
"VALUES"
- " ('%s%s$%X', '%s%s', '%s', '%s', %"PRId64", '%q')",
+ " ('%s%s$%X', '%s%s', '%s', '%s', %lld, '%q')",
base, parentID, object, base, parentID, objectID, class, detailID, name);
insert_containers(name, path, objectID, class, detailID);
@@ -655,7 +660,7 @@ sql_failed:
}
int
-filter_audio(const struct dirent *d)
+filter_audio(scan_filter *d)
{
return ( (*d->d_name != '.') &&
((d->d_type == DT_DIR) ||
@@ -669,7 +674,7 @@ filter_audio(const struct dirent *d)
}
int
-filter_video(const struct dirent *d)
+filter_video(scan_filter *d)
{
return ( (*d->d_name != '.') &&
((d->d_type == DT_DIR) ||
@@ -681,7 +686,7 @@ filter_video(const struct dirent *d)
}
int
-filter_images(const struct dirent *d)
+filter_images(scan_filter *d)
{
return ( (*d->d_name != '.') &&
((d->d_type == DT_DIR) ||
@@ -693,7 +698,7 @@ filter_images(const struct dirent *d)
}
int
-filter_media(const struct dirent *d)
+filter_media(scan_filter *d)
{
return ( (*d->d_name != '.') &&
((d->d_type == DT_DIR) ||
diff --git a/sendfile.h b/sendfile.h
new file mode 100644
index 0000000..32bde69
--- /dev/null
+++ b/sendfile.h
@@ -0,0 +1,53 @@
+#if defined(HAVE_LINUX_SENDFILE_API)
+
+#include <sys/sendfile.h>
+
+int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
+{
+ return sendfile(sock, sendfd, offset, len);
+}
+
+#elif defined(HAVE_DARWIN_SENDFILE_API)
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+
+int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
+{
+ int ret;
+
+ ret = sendfile(sendfd, sock, *offset, &len, NULL, 0);
+ *offset += len;
+
+ return ret;
+}
+
+#elif defined(HAVE_FREEBSD_SENDFILE_API)
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+
+int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
+{
+ int ret;
+ size_t nbytes = len;
+
+ ret = sendfile(sendfd, sock, *offset, nbytes, NULL, &len, SF_MNOWAIT);
+ *offset += len;
+
+ return ret;
+}
+
+#else
+
+#include <errno.h>
+
+int sys_sendfile(int sock, int sendfd, off_t *offset, off_t len)
+{
+ errno = EINVAL;
+ return -1;
+}
+
+#endif
diff --git a/tagutils/misc.c b/tagutils/misc.c
index 08e00ae..f439b8c 100644
--- a/tagutils/misc.c
+++ b/tagutils/misc.c
@@ -19,9 +19,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "config.h"
#include <stdio.h>
#include <string.h>
+#ifdef HAVE_MACHINE_ENDIAN_H
+#include <machine/endian.h>
+#else
#include <endian.h>
+#endif
#include "misc.h"
diff --git a/tagutils/tagutils-asf.h b/tagutils/tagutils-asf.h
index 5fd2942..91fcaa2 100644
--- a/tagutils/tagutils-asf.h
+++ b/tagutils/tagutils-asf.h
@@ -23,7 +23,11 @@
#define __PACKED__ __attribute__((packed))
+#ifdef HAVE_MACHINE_ENDIAN_H
+#include <machine/endian.h>
+#else
#include <endian.h>
+#endif
typedef struct _GUID {
__u32 l;
diff --git a/tagutils/tagutils-misc.c b/tagutils/tagutils-misc.c
index 9934e7a..eef242b 100644
--- a/tagutils/tagutils-misc.c
+++ b/tagutils/tagutils-misc.c
@@ -33,10 +33,10 @@ typedef enum {
static iconv_result
do_iconv(const char* to_ces, const char* from_ces,
- char *inbuf, size_t inbytesleft,
+ ICONV_CONST char *inbuf, size_t inbytesleft,
char *outbuf_orig, size_t outbytesleft_orig)
{
-#ifdef HAVE_ICONV_H
+#ifdef HAVE_ICONV
size_t rc;
iconv_result ret = ICONV_OK;
@@ -65,9 +65,9 @@ do_iconv(const char* to_ces, const char* from_ces,
iconv_close(cd);
return ret;
-#else // HAVE_ICONV_H
+#else // HAVE_ICONV
return ICONV_FATAL;
-#endif // HAVE_ICONV_H
+#endif // HAVE_ICONV
}
#define N_LANG_ALT 8
diff --git a/tagutils/tagutils-mp3.c b/tagutils/tagutils-mp3.c
index 643b349..6998147 100644
--- a/tagutils/tagutils-mp3.c
+++ b/tagutils/tagutils-mp3.c
@@ -232,8 +232,7 @@ _get_mp3tags(char *file, struct song_metadata *psong)
if((utf8_text) && (strncasecmp((char*)utf8_text, "iTun", 4) != 0))
{
// read comment
- if(utf8_text)
- free(utf8_text);
+ free(utf8_text);
native_text = id3_field_getfullstring(&pid3frame->fields[3]);
if(native_text)
@@ -241,16 +240,14 @@ _get_mp3tags(char *file, struct song_metadata *psong)
utf8_text = (unsigned char*)id3_ucs4_utf8duplicate(native_text);
if(utf8_text)
{
- if (psong->comment)
- free(psong->comment);
+ free(psong->comment);
psong->comment = (char*)utf8_text;
}
}
}
else
{
- if(utf8_text)
- free(utf8_text);
+ free(utf8_text);
}
}
}
diff --git a/tagutils/tagutils.c b/tagutils/tagutils.c
index 7e147e7..9813bfc 100644
--- a/tagutils/tagutils.c
+++ b/tagutils/tagutils.c
@@ -37,7 +37,7 @@
#include <FLAC/metadata.h>
#include "../config.h"
-#ifdef HAVE_ICONV_H
+#ifdef HAVE_ICONV
#include <iconv.h>
#endif
diff --git a/tagutils/tagutils.h b/tagutils/tagutils.h
index 0d5f362..0c884be 100644
--- a/tagutils/tagutils.h
+++ b/tagutils/tagutils.h
@@ -30,6 +30,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <libgen.h>
#define ROLE_NOUSE 0
#define ROLE_START 1
diff --git a/tivo_beacon.c b/tivo_beacon.c
index 80632d8..5aa04e5 100644
--- a/tivo_beacon.c
+++ b/tivo_beacon.c
@@ -274,8 +274,9 @@ rcvBeaconMessage(char * beacon)
if( strcasecmp(method, "broadcast") == 0 )
{
- DPRINTF(E_DEBUG, L_TIVO, "Received new beacon: machine(%s) platform(%s) services(%s)\n",
+ DPRINTF(E_DEBUG, L_TIVO, "Received new beacon: machine(%s/%s) platform(%s) services(%s)\n",
machine ? machine : "-",
+ identity ? identity : "-",
platform ? platform : "-",
services ? services : "-" );
return 1;
diff --git a/tivo_commands.c b/tivo_commands.c
index f60aa88..95cb9f4 100644
--- a/tivo_commands.c
+++ b/tivo_commands.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <libgen.h>
#include <time.h>
+#include <sys/stat.h>
#include "tivo_utils.h"
#include "upnpglobalvars.h"
diff --git a/tivo_utils.c b/tivo_utils.c
index 2ae6247..aed424a 100644
--- a/tivo_utils.c
+++ b/tivo_utils.c
@@ -74,8 +74,7 @@ decodeString(char * string, int inplace)
}
if( inplace )
{
- if( ns )
- free(ns);
+ free(ns);
return string;
}
else
diff --git a/upnpdescgen.c b/upnpdescgen.c
index 8126d92..c9a40f6 100644
--- a/upnpdescgen.c
+++ b/upnpdescgen.c
@@ -584,7 +584,7 @@ static char *
genXML(char * str, int * len, int * tmplen,
const struct XMLElt * p)
{
- u_int16_t i, j, k;
+ uint16_t i, j, k;
int top;
const char * eltname, *s;
char c;
diff --git a/upnpevents.c b/upnpevents.c
index e9f8e08..895819d 100644
--- a/upnpevents.c
+++ b/upnpevents.c
@@ -340,10 +340,7 @@ static void upnp_event_prepare(struct upnp_event_notify * obj)
obj->sub->uuid, obj->sub->seq,
l, xml);
obj->buffersize = obj->tosend;
- if(xml) {
- free(xml);
- xml = NULL;
- }
+ free(xml);
DPRINTF(E_DEBUG, L_HTTP, "Sending UPnP Event response:\n%s\n", obj->buffer);
obj->state = ESending;
}
@@ -468,9 +465,7 @@ void upnpevents_processfds(fd_set *readset, fd_set *writeset)
free(obj->sub);
}
#endif
- if(obj->buffer) {
- free(obj->buffer);
- }
+ free(obj->buffer);
LIST_REMOVE(obj, entries);
free(obj);
}
diff --git a/upnpglobalvars.c b/upnpglobalvars.c
index bd6e122..1c20572 100644
--- a/upnpglobalvars.c
+++ b/upnpglobalvars.c
@@ -48,7 +48,7 @@
*/
#include <sys/types.h>
#include <netinet/in.h>
-#include <linux/limits.h>
+#include <sys/param.h>
#include "config.h"
#include "upnpglobalvars.h"
diff --git a/upnphttp.c b/upnphttp.c
index 19d4bc0..aee1333 100644
--- a/upnphttp.c
+++ b/upnphttp.c
@@ -54,6 +54,12 @@
#include <sys/socket.h>
#include <sys/param.h>
#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <arpa/inet.h>
+
#include "config.h"
#include "upnphttp.h"
#include "upnpdescgen.h"
@@ -61,13 +67,6 @@
#include "upnpsoap.h"
#include "upnpevents.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/sendfile.h>
-#include <arpa/inet.h>
-
#include "upnpglobalvars.h"
#include "utils.h"
#include "getifaddr.h"
@@ -79,6 +78,9 @@
#include "tivo_utils.h"
#include "tivo_commands.h"
#endif
+
+#include "sendfile.h"
+
//#define MAX_BUFFER_SIZE 4194304 // 4MB -- Too much?
#define MAX_BUFFER_SIZE 2147483647 // 2GB -- Too much?
#define MIN_BUFFER_SIZE 65536
@@ -1172,14 +1174,17 @@ send_file(struct upnphttp * h, int sendfd, off_t offset, off_t end_offset)
off_t send_size;
off_t ret;
char *buf = NULL;
+#if HAVE_SENDFILE
int try_sendfile = 1;
+#endif
while( offset < end_offset )
{
+#if HAVE_SENDFILE
if( try_sendfile )
{
send_size = ( ((end_offset - offset) < MAX_BUFFER_SIZE) ? (end_offset - offset + 1) : MAX_BUFFER_SIZE);
- ret = sendfile(h->socket, sendfd, &offset, send_size);
+ ret = sys_sendfile(h->socket, sendfd, &offset, send_size);
if( ret == -1 )
{
DPRINTF(E_DEBUG, L_HTTP, "sendfile error :: error no. %d [%s]\n", errno, strerror(errno));
@@ -1195,6 +1200,7 @@ send_file(struct upnphttp * h, int sendfd, off_t offset, off_t end_offset)
continue;
}
}
+#endif
/* Fall back to regular I/O */
if( !buf )
buf = malloc(MIN_BUFFER_SIZE);
diff --git a/upnphttp.h b/upnphttp.h
index b58ecae..9fcfc27 100644
--- a/upnphttp.h
+++ b/upnphttp.h
@@ -119,6 +119,10 @@ struct upnphttp {
#define FLAG_FREE_OBJECT_ID 0x00000001
#define FLAG_ROOT_CONTAINER 0x00000002
+#ifndef MSG_MORE
+#define MSG_MORE 0
+#endif
+
/* New_upnphttp() */
struct upnphttp *
New_upnphttp(int);
diff --git a/upnpsoap.c b/upnpsoap.c
index 2b2e8af..9141da1 100644
--- a/upnpsoap.c
+++ b/upnpsoap.c
@@ -353,7 +353,7 @@ static u_int32_t
set_filter_flags(char * filter, struct upnphttp *h)
{
char *item, *saveptr = NULL;
- u_int32_t flags = 0;
+ uint32_t flags = 0;
if( !filter || (strlen(filter) <= 1) )
return 0xFFFFFFFF;
diff --git a/utils.c b/utils.c
index 22fe37a..2757bf2 100644
--- a/utils.c
+++ b/utils.c
@@ -19,7 +19,7 @@
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
-#include <linux/limits.h>
+#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
@@ -193,6 +193,11 @@ make_dir(char * path, mode_t mode)
do {
c = '\0';
+ /* Before we do anything, skip leading /'s, so we don't bother
+ * trying to create /. */
+ while (*s == '/')
+ ++s;
+
/* Bypass leading non-'/'s and then subsequent '/'s. */
while (*s) {
if (*s == '/') {
diff --git a/uuid.c b/uuid.c
index bdb4abc..bdda7a6 100644
--- a/uuid.c
+++ b/uuid.c
@@ -28,22 +28,27 @@
#include <time.h>
#include <fcntl.h>
#include <unistd.h>
-#include <sys/syscall.h>
#include <string.h>
-#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <errno.h>
+#if HAVE_MACH_MACH_TIME_H
+#include <mach/mach_time.h>
+#elif HAVE_CLOCK_GETTIME_SYSCALL
+#include <sys/syscall.h>
+#endif
#include "getifaddr.h"
#include "log.h"
#define ETH_ALEN 6
+#ifndef NSEC_PER_SEC
#define NSEC_PER_SEC 1000000000L
+#endif
#define NSEC_PER_MSEC 1000000L
-static u_int32_t clock_seq;
-static const u_int32_t clock_seq_max = 0x3fff; /* 14 bits */
+static uint32_t clock_seq;
+static const uint32_t clock_seq_max = 0x3fff; /* 14 bits */
static int clock_seq_initialized;
unsigned long long
@@ -51,7 +56,17 @@ monotonic_us(void)
{
struct timespec ts;
+#if defined(HAVE_LIBRT)
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+#elif HAVE_CLOCK_GETTIME_SYSCALL
syscall(__NR_clock_gettime, CLOCK_MONOTONIC, &ts);
+#elif HAVE_MACH_MACH_TIME_H
+ return mach_absolute_time();
+#else
+ struct timeval tv;
+ gettimeofday(&tv, 0);
+ TIMEVAL_TO_TIMESPEC(&tv, &ts);
+#endif
return ts.tv_sec * 1000000ULL + ts.tv_nsec / 1000;
}
@@ -120,12 +135,12 @@ init_clockseq(void)
int
generate_uuid(unsigned char uuid_out[16])
{
- static u_int64_t last_time_all;
+ static uint64_t last_time_all;
static unsigned int clock_seq_started;
static char last_node[6] = { 0, 0, 0, 0, 0, 0 };
struct timespec ts;
- u_int64_t time_all;
+ uint64_t time_all;
int inc_clock_seq = 0;
unsigned char mac[6];
@@ -162,8 +177,16 @@ generate_uuid(unsigned char uuid_out[16])
* nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of
* Gregorian reform to the Christian calendar).
*/
+#if HAVE_LIBRT
+ clock_gettime(CLOCK_REALTIME, &ts);
+#elif HAVE_CLOCK_GETTIME_SYSCALL
syscall(__NR_clock_gettime, CLOCK_REALTIME, &ts);
- time_all = ((u_int64_t)ts.tv_sec) * (NSEC_PER_SEC / 100);
+#else
+ struct timeval tv;
+ gettimeofday(&tv, 0);
+ TIMEVAL_TO_TIMESPEC(&tv, &ts);
+#endif
+ time_all = ((uint64_t)ts.tv_sec) * (NSEC_PER_SEC / 100);
time_all += ts.tv_nsec / 100;
/* add offset from Gregorian Calendar to Jan 1 1970 */
@@ -192,14 +215,14 @@ generate_uuid(unsigned char uuid_out[16])
last_time_all = time_all;
/* Fill in timestamp and clock_seq values */
- uuid_out[3] = (u_int8_t)time_all;
- uuid_out[2] = (u_int8_t)(time_all >> 8);
- uuid_out[1] = (u_int8_t)(time_all >> 16);
- uuid_out[0] = (u_int8_t)(time_all >> 24);
- uuid_out[5] = (u_int8_t)(time_all >> 32);
- uuid_out[4] = (u_int8_t)(time_all >> 40);
- uuid_out[7] = (u_int8_t)(time_all >> 48);
- uuid_out[6] = (u_int8_t)(time_all >> 56);
+ uuid_out[3] = (uint8_t)time_all;
+ uuid_out[2] = (uint8_t)(time_all >> 8);
+ uuid_out[1] = (uint8_t)(time_all >> 16);
+ uuid_out[0] = (uint8_t)(time_all >> 24);
+ uuid_out[5] = (uint8_t)(time_all >> 32);
+ uuid_out[4] = (uint8_t)(time_all >> 40);
+ uuid_out[7] = (uint8_t)(time_all >> 48);
+ uuid_out[6] = (uint8_t)(time_all >> 56);
uuid_out[8] = clock_seq >> 8;
uuid_out[9] = clock_seq & 0xff;