Fixes for compiling on solaris -- fixes #66 and #5

This commit is contained in:
Ron Pedde 2006-04-15 08:53:56 +00:00
parent 8afa55222b
commit 6979a7a67e
21 changed files with 224 additions and 282 deletions

View File

@ -17,6 +17,8 @@ AC_CHECK_HEADERS([sys/wait.h])
AC_CHECK_HEADERS([sys/param.h])
AC_CHECK_FUNCS(strptime)
AC_CHECK_FUNCS(strtok_r)
AC_CHECK_FUNCS(timegm)
AM_CONDITIONAL(COND_REND_OSX,false)
AC_FUNC_SETPGRP
@ -173,7 +175,7 @@ AC_ARG_WITH(howl-libs,
[--with-howl-libs[[=DIR]] use howl lib files in DIR],[
if test "$withval" != "no" -a "$withval" != "yes"; then
Z_DIR=$withval
LDFLAGS="${LDFLAGS} -L$withval"
LDFLAGS="${LDFLAGS} -L$withval -R$withval"
fi
])
@ -189,7 +191,39 @@ AC_ARG_WITH(gdbm-libs,
[--with-gdbm-libs[[=DIR]] use gdbm lib files in DIR],[
if test "$withval" != "no" -a "$withval" != "yes"; then
Z_DIR=$withval
LDFLAGS="${LDFLAGS} -L$withval"
LDFLAGS="${LDFLAGS} -L$withval -R$withval"
fi
])
AC_ARG_WITH(sqlite-includes,
[--with-sqlite-includes[[=DIR]] use sqlite include files in DIR],[
if test "$withval" != "no" -a "$withval" != "yes"; then
Z_DIR=$withval
CPPFLAGS="${CPPFLAGS} -I$withval -R$withval"
fi
])
AC_ARG_WITH(sqlite-libs,
[--with-sqlite-libs[[=DIR]] use sqlite lib files in DIR],[
if test "$withval" != "no" -a "$withval" != "yes"; then
Z_DIR=$withval
LDFLAGS="${LDFLAGS} -L$withval -R$withval"
fi
])
AC_ARG_WITH(sqlite3-includes,
[--with-sqlite3-includes[[=DIR]] use sqlite3 include files in DIR],[
if test "$withval" != "no" -a "$withval" != "yes"; then
Z_DIR=$withval
CPPFLAGS="${CPPFLAGS} -I$withval"
fi
])
AC_ARG_WITH(sqlite3-libs,
[--with-sqlite3-libs[[=DIR]] use sqlite3 lib files in DIR],[
if test "$withval" != "no" -a "$withval" != "yes"; then
Z_DIR=$withval
LDFLAGS="${LDFLAGS} -L$withval -R$withval"
fi
])
@ -198,7 +232,7 @@ AC_ARG_WITH(id3tag,
if test "$withval" != "no" -a "$withval" != "yes"; then
Z_DIR=$withval
CPPFLAGS="${CPPFLAGS} -I$withval/include"
LDFLAGS="${LDFLAGS} -L$withval/lib"
LDFLAGS="${LDFLAGS} -L$withval/lib -R$withval/lib"
fi
])

View File

@ -49,21 +49,22 @@ mtd_update_SOURCES = mtd-update.c conf.c conf.h ll.c ll.h \
db-sql.c db-sql.h db-generic.c db-generic.h smart-parser.c \
smart-parser.h err.c err.h os-unix.c os.h xml-rpc.c xml-rpc.h \
restart.c restart.h uici.c uici.h ssc.c ssc.h \
webserver.c webserver.h $(PRENDSRC) $(ORENDSRC) $(HRENDSRC) \
webserver.c webserver.h compat.c compat.h \
$(PRENDSRC) $(ORENDSRC) $(HRENDSRC) \
$(SQLITEDB) $(SQLITE3DB)
wavstreamer_SOURCES = wavstreamer.c
mt_daapd_SOURCES = main.c daapd.h rend.h uici.c uici.h webserver.c \
webserver.h configfile.c configfile.h err.c err.h restart.c restart.h \
mp3-scanner.h mp3-scanner.c rend-unix.h strcasestr.c strcasestr.h \
strsep.c dynamic-art.c dynamic-art.h ssc.c ssc.h \
mp3-scanner.h mp3-scanner.c rend-unix.h \
dynamic-art.c dynamic-art.h ssc.c ssc.h \
db-generic.c db-generic.h dispatch.c dispatch.h \
rxml.c rxml.h redblack.c redblack.h scan-mp3.c scan-mp4.c \
scan-xml.c scan-wma.c scan-aac.c scan-aac.h scan-wav.c scan-url.c \
smart-parser.c smart-parser.h xml-rpc.c xml-rpc.h \
os.h strptime.c strptime.h ll.c ll.h conf.c conf.h \
strtok_r.c strtok_r.h os-unix.h os-unix.c os.h \
os.h ll.c ll.h conf.c conf.h compat.c compat.h \
os-unix.h os-unix.c os.h \
$(PRENDSRC) $(ORENDSRC) $(HRENDSRC) $(OGGVORBISSRC) $(FLACSRC) \
$(MUSEPACKSRC) $(SQLITEDB) $(SQLITE3DB) $(SQLDB) $(GDBM)

View File

@ -1,3 +1,36 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
#if !HAVE_STRCASESTR
/* case-independent string matching, similar to strstr but
* matching */
char * strcasestr(char* haystack, char* needle) {
int i;
int nlength = (int) strlen (needle);
int hlength = (int) strlen (haystack);
if (nlength > hlength) return NULL;
if (hlength <= 0) return NULL;
if (nlength <= 0) return haystack;
/* hlength and nlength > 0, nlength <= hlength */
for (i = 0; i <= (hlength - nlength); i++) {
if (strncasecmp (haystack + i, needle, nlength) == 0) {
return haystack + i;
}
}
/* substring not found */
return NULL;
}
#endif /* !HAVE_STRCASESTR */
/*
* Copyright (c) 1994 Powerdog Industries. All rights reserved.
*
@ -29,16 +62,7 @@
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifndef HAVE_STRPTIME
#include <ctype.h>
#include <time.h>
#include <string.h>
#define asizeof(a) (sizeof (a) / sizeof ((a)[0]))
@ -371,3 +395,122 @@ char *strptime(char *buf, char *fmt, struct tm *tm) {
}
#endif /* ndef HAVE_STRPTIME */
/* Compliments of Jay Freeman <saurik@saurik.com> */
#if !HAVE_STRSEP
char *strsep(char **stringp, const char *delim) {
char *ret = *stringp;
if (ret == NULL) return(NULL); /* grrr */
if ((*stringp = strpbrk(*stringp, delim)) != NULL) {
*((*stringp)++) = '\0';
}
return(ret);
}
#endif /* !HAVE_STRSEP */
/* Reentrant string tokenizer. Generic version.
Copyright (C) 1991,1996-1999,2001,2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef HAVE_STRTOK_R
#include <stdio.h>
/* Parse S into tokens separated by characters in DELIM.
If S is NULL, the saved pointer in SAVE_PTR is used as
the next starting point. For example:
char s[] = "-abc-=-def";
char *sp;
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
x = strtok_r(NULL, "=", &sp); // x = NULL
// s = "abc\0-def\0"
*/
char *strtok_r(char *s, const char *delim, char **last)
{
char *spanp;
int c, sc;
char *tok;
if (s == NULL && (s = *last) == NULL) {
return NULL;
}
/*
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
*/
cont:
c = *s++;
for (spanp = (char *)delim; (sc = *spanp++) != 0; ) {
if (c == sc) {
goto cont;
}
}
if (c == 0) { /* no non-delimiter characters */
*last = NULL;
return NULL;
}
tok = s - 1;
/*
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
* Note that delim must have one NUL; we stop if we see that, too.
*/
for (;;) {
c = *s++;
spanp = (char *)delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0) {
s = NULL;
}
else {
char *w = s - 1;
*w = '\0';
}
*last = s;
return tok;
}
}
while (sc != 0);
}
/* NOTREACHED */
}
#endif
#ifndef HAVE_TIMEGM
time_t timegm(struct tm *tm) {
time_t ret;
char *tz;
char buffer[255];
tz = getenv("TZ");
_putenv("TZ=UTC0");
_tzset();
ret = mktime(tm);
if(tz)
sprintf(buffer,"TZ=%s",tz);
else
strcpy(buffer,"TZ=");
_putenv(buffer);
_tzset();
return ret;
}
#endif

24
src/compat.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef _COMPAT_H_
#define _COMPAT_H_
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifndef HAVE_STRCASESTR
extern char * strcasestr(char* haystack, char* needle);
#endif
#ifndef HAVE_STRPTIME
char * strptime( char *buf, char *fmt, struct tm *tm );
#endif
#ifndef HAVE_STRTOK_R
extern char *strtok_r(char *s, const char *delim, char **last);
#endif
#ifndef HAVE_TIMEGM
extern time_t timegm(struct tm *tm);
#endif
#endif /* _COMPAT_H_ */

View File

@ -32,6 +32,7 @@
#define _DAAPD_H_
#include <time.h>
#include "compat.h"
#include "webserver.h"
/** Simple struct for holding stat info.

View File

@ -46,7 +46,6 @@
#include "ssc.h"
#include "dynamic-art.h"
#include "restart.h"
#include "strtok_r.h"
#include "daapd.h"

View File

@ -534,6 +534,9 @@ typedef signed short mDNSs16;
typedef unsigned short mDNSu16;
#include <sys/types.h>
typedef int32_t mDNSs32;
#ifndef u_int32_t
# define u_int32_t uint32_t
#endif
typedef u_int32_t mDNSu32;
// To enforce useful type checking, we make mDNSInterfaceID be a pointer to a dummy struct

View File

@ -121,6 +121,7 @@ struct ifi_info *get_ifi_info(int family, int doaliases)
struct ifconf ifc;
struct ifreq *ifr, ifrcopy;
struct sockaddr_in *sinptr;
int index;
#if defined(AF_INET6) && defined(HAVE_IPV6)
struct sockaddr_in6 *sinptr6;

View File

@ -54,10 +54,6 @@
#include "restart.h"
#include "ssc.h"
#ifndef HAVE_STRCASESTR
# include "strcasestr.h"
#endif
/*
* Typedefs
*/

View File

@ -490,24 +490,6 @@ void _os_socket_shutdown(void) {
}
/* COMPAT FUNCTIONS */
time_t timegm(struct tm *tm) {
time_t ret;
char *tz;
char buffer[255];
tz = getenv("TZ");
_putenv("TZ=UTC0");
_tzset();
ret = mktime(tm);
if(tz)
sprintf(buffer,"TZ=%s",tz);
else
strcpy(buffer,"TZ=");
_putenv(buffer);
_tzset();
return ret;
}
/* opendir/closedir/readdir emulation taken from emacs. Thanks. :) */
DIR *os_opendir(char *filename) {

View File

@ -61,7 +61,6 @@ extern int os_gettimeofday (struct timeval *tv, struct timezone* tz);
extern int os_readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
extern void os_closedir(DIR *dirp);
extern DIR *os_opendir(char *filename);
extern time_t timegm(struct tm *tm);
extern char *os_strerror (int error_no);
#endif /* _OS_WIN32_H_ */

View File

@ -42,10 +42,6 @@
#include "err.h"
#include "mp3-scanner.h"
#ifndef HAVE_STRCASESTR
# include "strcasestr.h"
#endif
#include <FLAC/metadata.h>

View File

@ -37,7 +37,6 @@
#include "mp3-scanner.h"
#include "rxml.h"
#include "redblack.h"
#include "strptime.h"
/* Forwards */
int scan_xml_playlist(char *filename);

View File

@ -19,8 +19,6 @@
#include <string.h>
#include <time.h>
#include "strptime.h"
#include "err.h"
#ifdef HAVE_SQL

View File

@ -48,10 +48,6 @@
#include "mp3-scanner.h"
#include "ssc.h"
#ifndef HAVE_STRCASESTR
# include "strcasestr.h"
#endif
/**
* Check if the file specified by fname should be converted in
* server to wav. Currently it does this by file extension, but

View File

@ -1,28 +0,0 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#if !HAVE_STRCASESTR
/* case-independent string matching, similar to strstr but
* matching */
char * strcasestr(char* haystack, char* needle) {
int i;
int nlength = (int) strlen (needle);
int hlength = (int) strlen (haystack);
if (nlength > hlength) return NULL;
if (hlength <= 0) return NULL;
if (nlength <= 0) return haystack;
/* hlength and nlength > 0, nlength <= hlength */
for (i = 0; i <= (hlength - nlength); i++) {
if (strncasecmp (haystack + i, needle, nlength) == 0) {
return haystack + i;
}
}
/* substring not found */
return NULL;
}
#endif /* !HAVE_STRCASESTR */

View File

@ -1,8 +0,0 @@
#ifndef _STRCASESTR_H_
#define _STRCASESTR_H_
#ifndef HAVE_STRCASESTR
extern char * strcasestr(char* haystack, char* needle);
#endif
#endif

View File

@ -1,39 +0,0 @@
/******************************************************************************
**
** Copyright (C) 2001 - the shmoo group -
**
** This program is free software; you can redistribute it and/or
** modify it, however, you cannot sell it.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**
** You should have received a copy of the license attached to the
** use of this software. If not, visit www.shmoo.com/osiris for
** details.
**
******************************************************************************/
/******************************************************************************
**
** The Shmoo Group (TSG)
**
** File: strptime.h
** Author: Brian Wotring
**
** Date: June 22, 2001.
** Project: osiris
**
******************************************************************************/
#ifndef STRPTIME_H
#define STRPTIME_H
#ifndef HAVE_STRPTIME
char * strptime( char *buf, char *fmt, struct tm *tm );
#endif
#endif

View File

@ -1,18 +0,0 @@
/* Compliments of Jay Freeman <saurik@saurik.com> */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <string.h>
#if !HAVE_STRSEP
char *strsep(char **stringp, const char *delim) {
char *ret = *stringp;
if (ret == NULL) return(NULL); /* grrr */
if ((*stringp = strpbrk(*stringp, delim)) != NULL) {
*((*stringp)++) = '\0';
}
return(ret);
}
#endif /* !HAVE_STRSEP */

View File

@ -1,88 +0,0 @@
/* Reentrant string tokenizer. Generic version.
Copyright (C) 1991,1996-1999,2001,2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifndef HAVE_STRTOK_R
#include <stdio.h>
/* Parse S into tokens separated by characters in DELIM.
If S is NULL, the saved pointer in SAVE_PTR is used as
the next starting point. For example:
char s[] = "-abc-=-def";
char *sp;
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
x = strtok_r(NULL, "=", &sp); // x = NULL
// s = "abc\0-def\0"
*/
char *strtok_r(char *s, const char *delim, char **last)
{
char *spanp;
int c, sc;
char *tok;
if (s == NULL && (s = *last) == NULL) {
return NULL;
}
/*
* Skip (span) leading delimiters (s += strspn(s, delim), sort of).
*/
cont:
c = *s++;
for (spanp = (char *)delim; (sc = *spanp++) != 0; ) {
if (c == sc) {
goto cont;
}
}
if (c == 0) { /* no non-delimiter characters */
*last = NULL;
return NULL;
}
tok = s - 1;
/*
* Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
* Note that delim must have one NUL; we stop if we see that, too.
*/
for (;;) {
c = *s++;
spanp = (char *)delim;
do {
if ((sc = *spanp++) == c) {
if (c == 0) {
s = NULL;
}
else {
char *w = s - 1;
*w = '\0';
}
*last = s;
return tok;
}
}
while (sc != 0);
}
/* NOTREACHED */
}
#endif

View File

@ -1,49 +0,0 @@
/* Split string into tokens
Copyright (C) 2004-2005 Free Software Foundation, Inc.
Written by Simon Josefsson.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifndef _STRTOK_R_H
#define _STRTOK_R_H
/* Parse S into tokens separated by characters in DELIM.
If S is NULL, the saved pointer in SAVE_PTR is used as
the next starting point. For example:
char s[] = "-abc-=-def";
char *sp;
x = strtok_r(s, "-", &sp); // x = "abc", sp = "=-def"
x = strtok_r(NULL, "-=", &sp); // x = "def", sp = NULL
x = strtok_r(NULL, "=", &sp); // x = NULL
// s = "abc\0-def\0"
This is a variant of strtok() that is multithread-safe.
For the POSIX documentation for this function, see:
http://www.opengroup.org/susv3xsh/strtok.html
Caveat: It modifies the original string.
Caveat: These functions cannot be used on constant strings.
Caveat: The identity of the delimiting character is lost.
Caveat: It doesn't work with multibyte strings unless all of the delimiter
characters are ASCII characters < 0x30.
See also strsep().
*/
#ifndef HAVE_STRTOK_R
extern char *strtok_r(char *s, const char *delim, char **last);
#endif
#endif /* _STRTOK_R_H */