-Wall fixes

This commit is contained in:
Ron Pedde 2004-02-15 00:51:11 +00:00
parent 76bdffec53
commit 9289f526db
16 changed files with 84 additions and 96 deletions

View File

@ -15,7 +15,7 @@ AC_CANONICAL_HOST
AM_CONDITIONAL(COND_REND_OSX,false) AM_CONDITIONAL(COND_REND_OSX,false)
AC_ARG_ENABLE(debug,Enable debugging features,CPPFLAGS="$CPPFLAGS -DDEBUG -g") AC_ARG_ENABLE(debug,Enable debugging features,CPPFLAGS="$CPPFLAGS -DDEBUG_MEMORY -g -Wall")
AC_ARG_ENABLE(efence,Enable electric fence,LDFLAGS="$LDFLAGS -lefence") AC_ARG_ENABLE(efence,Enable electric fence,LDFLAGS="$LDFLAGS -lefence")
AC_ARG_ENABLE(howl,[ --enable-howl Use the howl mDNS library], AC_ARG_ENABLE(howl,[ --enable-howl Use the howl mDNS library],

View File

@ -27,12 +27,15 @@
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <pthread.h> #include <pthread.h>
#include <rend.h>
#include <restart.h>
#include <signal.h> #include <signal.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/wait.h> #include <sys/wait.h>
@ -81,6 +84,7 @@ CONFIGELEMENT config_elements[] = {
{ 1,1,0,CONFIG_TYPE_INT,"port",(void*)&config.port,config_emit_int }, { 1,1,0,CONFIG_TYPE_INT,"port",(void*)&config.port,config_emit_int },
{ 1,1,0,CONFIG_TYPE_STRING,"admin_pw",(void*)&config.adminpassword,config_emit_string }, { 1,1,0,CONFIG_TYPE_STRING,"admin_pw",(void*)&config.adminpassword,config_emit_string },
{ 1,1,0,CONFIG_TYPE_STRING,"mp3_dir",(void*)&config.mp3dir,config_emit_string }, { 1,1,0,CONFIG_TYPE_STRING,"mp3_dir",(void*)&config.mp3dir,config_emit_string },
{ 1,1,0,CONFIG_TYPE_STRING,"db_dir",(void*)&config.dbdir,config_emit_string },
{ 1,1,0,CONFIG_TYPE_STRING,"servername",(void*)&config.servername,config_emit_string }, { 1,1,0,CONFIG_TYPE_STRING,"servername",(void*)&config.servername,config_emit_string },
{ 1,0,0,CONFIG_TYPE_STRING,"playlist",(void*)&config.playlist,config_emit_string }, { 1,0,0,CONFIG_TYPE_STRING,"playlist",(void*)&config.playlist,config_emit_string },
{ 1,0,0,CONFIG_TYPE_STRING,"password",(void*)&config.readpassword, config_emit_string }, { 1,0,0,CONFIG_TYPE_STRING,"password",(void*)&config.readpassword, config_emit_string },
@ -358,9 +362,8 @@ void config_handler(WS_CONNINFO *pwsc) {
int file_fd; int file_fd;
struct stat sb; struct stat sb;
char *pw; char *pw;
int status;
DPRINTF(ERR_DEBUG,"Entereing config_handler\n"); DPRINTF(ERR_DEBUG,"Entering config_handler\n");
config_set_status(pwsc,0,"Serving admin pages"); config_set_status(pwsc,0,"Serving admin pages");
@ -493,8 +496,6 @@ void config_emit_int(WS_CONNINFO *pwsc, void *value, char *arg) {
*/ */
void config_emit_service_status(WS_CONNINFO *pwsc, void *value, char *arg) { void config_emit_service_status(WS_CONNINFO *pwsc, void *value, char *arg) {
int mdns_running; int mdns_running;
int status;
int err;
char *html; char *html;
ws_writefd(pwsc,"<TABLE><TR><TH ALIGN=LEFT>Service</TH>"); ws_writefd(pwsc,"<TABLE><TR><TH ALIGN=LEFT>Service</TH>");
@ -695,12 +696,6 @@ void config_emit_include(WS_CONNINFO *pwsc, void *value, char *arg) {
char path[PATH_MAX]; char path[PATH_MAX];
int file_fd; int file_fd;
struct stat sb; struct stat sb;
char argbuffer[30];
int in_arg;
char *argptr;
char next;
CONFIGELEMENT *pce;
char *first, *last;
DPRINTF(ERR_DEBUG,"Preparing to include %s\n",arg); DPRINTF(ERR_DEBUG,"Preparing to include %s\n",arg);
@ -819,7 +814,7 @@ void config_set_status(WS_CONNINFO *pwsc, int session, char *fmt, ...) {
int config_mutex_lock(void) { int config_mutex_lock(void) {
int err; int err;
if(err=pthread_mutex_lock(&scan_mutex)) { if((err=pthread_mutex_lock(&scan_mutex))) {
errno=err; errno=err;
return - 1; return - 1;
} }
@ -835,7 +830,7 @@ int config_mutex_lock(void) {
int config_mutex_unlock(void) { int config_mutex_unlock(void) {
int err; int err;
if(err=pthread_mutex_unlock(&scan_mutex)) { if((err=pthread_mutex_unlock(&scan_mutex))) {
errno=err; errno=err;
return -1; return -1;
} }

View File

@ -237,13 +237,11 @@ DAAP_BLOCK *daap_add_empty(DAAP_BLOCK *parent, char *tag) {
* Serialize a daap tree to a fd; * Serialize a daap tree to a fd;
*/ */
int daap_serialize(DAAP_BLOCK *root, int fd, int gzip) { int daap_serialize(DAAP_BLOCK *root, int fd, int gzip) {
DAAP_BLOCK *current;
char size[4]; char size[4];
if(!root) if(!root)
return 0; return 0;
r_write(fd,root->tag,4); r_write(fd,root->tag,4);
size[0] = (root->reported_size >> 24) & 0xFF; size[0] = (root->reported_size >> 24) & 0xFF;
@ -276,7 +274,7 @@ int daap_serialize(DAAP_BLOCK *root, int fd, int gzip) {
* *
* Free an entire daap formatted block * Free an entire daap formatted block
*/ */
int daap_free(DAAP_BLOCK *root) { void daap_free(DAAP_BLOCK *root) {
if(!root) if(!root)
return; return;
@ -289,5 +287,5 @@ int daap_free(DAAP_BLOCK *root) {
daap_free(root->children); daap_free(root->children);
daap_free(root->next); daap_free(root->next);
free(root); free(root);
return 0; return;
} }

View File

@ -43,7 +43,7 @@ DAAP_BLOCK *daap_add_char(DAAP_BLOCK *parent, char *tag, char value);
DAAP_BLOCK *daap_add_short(DAAP_BLOCK *parent, char *tag, short int value); DAAP_BLOCK *daap_add_short(DAAP_BLOCK *parent, char *tag, short int value);
DAAP_BLOCK *daap_add_long(DAAP_BLOCK *parent, char *tag, int v1, int v2); DAAP_BLOCK *daap_add_long(DAAP_BLOCK *parent, char *tag, int v1, int v2);
int daap_serialize(DAAP_BLOCK *root, int fd, int gzip); int daap_serialize(DAAP_BLOCK *root, int fd, int gzip);
int daap_free(DAAP_BLOCK *root); void daap_free(DAAP_BLOCK *root);
#endif #endif

View File

@ -28,6 +28,7 @@
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include "configfile.h"
#include "db-memory.h" #include "db-memory.h"
#include "daap-proto.h" #include "daap-proto.h"
#include "daap.h" #include "daap.h"
@ -239,7 +240,7 @@ DAAP_BLOCK *daap_response_songlist(void) {
mlcl=daap_add_empty(root,"mlcl"); mlcl=daap_add_empty(root,"mlcl");
if(mlcl) { if(mlcl) {
while(current=db_enum(&henum)) { while((current=db_enum(&henum))) {
DPRINTF(ERR_DEBUG,"Got entry for %s\n",current->fname); DPRINTF(ERR_DEBUG,"Got entry for %s\n",current->fname);
mlit=daap_add_empty(mlcl,"mlit"); mlit=daap_add_empty(mlcl,"mlit");
if(mlit) { if(mlit) {
@ -379,9 +380,9 @@ DAAP_BLOCK *daap_response_update(int fd, int clientver) {
* handle the daap block for the /databases/containers URI * handle the daap block for the /databases/containers URI
*/ */
DAAP_BLOCK *daap_response_playlists(char *name) { DAAP_BLOCK *daap_response_playlists(char *name) {
DAAP_BLOCK *root; DAAP_BLOCK *root=NULL;
DAAP_BLOCK *mlcl; DAAP_BLOCK *mlcl=NULL;
DAAP_BLOCK *mlit; DAAP_BLOCK *mlit=NULL;
int g=1; int g=1;
int playlistid; int playlistid;
ENUMHANDLE henum; ENUMHANDLE henum;
@ -442,9 +443,9 @@ DAAP_BLOCK *daap_response_playlists(char *name) {
*/ */
DAAP_BLOCK *daap_response_dbinfo(char *name) { DAAP_BLOCK *daap_response_dbinfo(char *name) {
DAAP_BLOCK *root; DAAP_BLOCK *root=NULL;
DAAP_BLOCK *mlcl; DAAP_BLOCK *mlcl=NULL;
DAAP_BLOCK *mlit; DAAP_BLOCK *mlit=NULL;
int g=1; int g=1;
DPRINTF(ERR_DEBUG,"Preparing to send db info\n"); DPRINTF(ERR_DEBUG,"Preparing to send db info\n");
@ -555,7 +556,7 @@ DAAP_BLOCK *daap_response_playlist_items(unsigned int playlist) {
if(mlcl) { if(mlcl) {
if(playlist == 1) { if(playlist == 1) {
while(current=db_enum(&henum)) { while((current=db_enum(&henum))) {
mlit=daap_add_empty(mlcl,"mlit"); mlit=daap_add_empty(mlcl,"mlit");
if(mlit) { if(mlit) {
g = g && daap_add_char(mlit,"mikd",2); g = g && daap_add_char(mlit,"mikd",2);

View File

@ -41,6 +41,7 @@ typedef struct tag_config {
char *servername; char *servername;
char *playlist; char *playlist;
char *runas; char *runas;
char *dbdir;
SONGENTRY songlist; SONGENTRY songlist;
} CONFIG; } CONFIG;
@ -48,6 +49,6 @@ typedef struct tag_config {
extern CONFIG config; extern CONFIG config;
/* Forwards */ /* Forwards */
extern drop_privs(char *user); extern int drop_privs(char *user);
#endif /* _DAAPD_H_ */ #endif /* _DAAPD_H_ */

View File

@ -221,7 +221,7 @@ int db_add_playlist(unsigned int playlistid, char *name) {
DPRINTF(ERR_DEBUG,"Adding new playlist %s\n",name); DPRINTF(ERR_DEBUG,"Adding new playlist %s\n",name);
if(err=pthread_rwlock_wrlock(&db_rwlock)) { if((err=pthread_rwlock_wrlock(&db_rwlock))) {
DPRINTF(ERR_WARN,"cannot lock wrlock in db_add\n"); DPRINTF(ERR_WARN,"cannot lock wrlock in db_add\n");
free(pnew->name); free(pnew->name);
free(pnew); free(pnew);
@ -262,7 +262,7 @@ int db_add_playlist_song(unsigned int playlistid, unsigned int itemid) {
DPRINTF(ERR_DEBUG,"Adding new playlist item\n"); DPRINTF(ERR_DEBUG,"Adding new playlist item\n");
if(err=pthread_rwlock_wrlock(&db_rwlock)) { if((err=pthread_rwlock_wrlock(&db_rwlock))) {
DPRINTF(ERR_WARN,"cannot lock wrlock in db_add\n"); DPRINTF(ERR_WARN,"cannot lock wrlock in db_add\n");
free(pnew); free(pnew);
errno=err; errno=err;
@ -344,7 +344,7 @@ int db_add(MP3FILE *mp3file) {
return -1; return -1;
} }
if(err=pthread_rwlock_wrlock(&db_rwlock)) { if((err=pthread_rwlock_wrlock(&db_rwlock))) {
DPRINTF(ERR_WARN,"cannot lock wrlock in db_add\n"); DPRINTF(ERR_WARN,"cannot lock wrlock in db_add\n");
db_freerecord(pnew); db_freerecord(pnew);
errno=err; errno=err;
@ -393,7 +393,7 @@ void db_freerecord(MP3RECORD *mp3record) {
MP3RECORD *db_enum_begin(void) { MP3RECORD *db_enum_begin(void) {
int err; int err;
if(err=pthread_rwlock_rdlock(&db_rwlock)) { if((err=pthread_rwlock_rdlock(&db_rwlock))) {
log_err(0,"Cannot lock rwlock\n"); log_err(0,"Cannot lock rwlock\n");
errno=err; errno=err;
return NULL; return NULL;
@ -411,7 +411,7 @@ DB_PLAYLIST *db_playlist_enum_begin(void) {
int err; int err;
DB_PLAYLIST *current; DB_PLAYLIST *current;
if(err=pthread_rwlock_rdlock(&db_rwlock)) { if((err=pthread_rwlock_rdlock(&db_rwlock))) {
log_err(0,"Cannot lock rwlock\n"); log_err(0,"Cannot lock rwlock\n");
errno=err; errno=err;
return NULL; return NULL;
@ -432,10 +432,9 @@ DB_PLAYLIST *db_playlist_enum_begin(void) {
*/ */
DB_PLAYLISTENTRY *db_playlist_items_enum_begin(int playlistid) { DB_PLAYLISTENTRY *db_playlist_items_enum_begin(int playlistid) {
DB_PLAYLIST *current; DB_PLAYLIST *current;
DB_PLAYLISTENTRY *retval;
int err; int err;
if(err=pthread_rwlock_rdlock(&db_rwlock)) { if((err=pthread_rwlock_rdlock(&db_rwlock))) {
log_err(0,"Cannot lock rwlock\n"); log_err(0,"Cannot lock rwlock\n");
errno=err; errno=err;
return NULL; return NULL;
@ -580,7 +579,7 @@ int db_get_playlist_entry_count(int playlistid) {
DB_PLAYLIST *current; DB_PLAYLIST *current;
int err; int err;
if(err=pthread_rwlock_rdlock(&db_rwlock)) { if((err=pthread_rwlock_rdlock(&db_rwlock))) {
log_err(0,"Cannot lock rwlock\n"); log_err(0,"Cannot lock rwlock\n");
errno=err; errno=err;
return -1; return -1;
@ -612,7 +611,7 @@ char *db_get_playlist_name(int playlistid) {
DB_PLAYLIST *current; DB_PLAYLIST *current;
int err; int err;
if(err=pthread_rwlock_rdlock(&db_rwlock)) { if((err=pthread_rwlock_rdlock(&db_rwlock))) {
log_err(0,"Cannot lock rwlock\n"); log_err(0,"Cannot lock rwlock\n");
errno=err; errno=err;
return NULL; return NULL;

View File

@ -23,13 +23,20 @@
#include <stdarg.h> #include <stdarg.h>
#include <errno.h> #include <errno.h>
#include <pthread.h> #include <pthread.h>
#include <syslog.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <syslog.h>
#define __IN_ERR__ #define __IN_ERR__
#include "err.h" #include "err.h"
int err_debuglevel=0;
int err_logdestination=LOGDEST_STDERR;
#ifdef DEBUG_MEMORY
typedef struct tag_err_leak { typedef struct tag_err_leak {
void *ptr; void *ptr;
char *file; char *file;
@ -38,10 +45,6 @@ typedef struct tag_err_leak {
struct tag_err_leak *next; struct tag_err_leak *next;
} ERR_LEAK; } ERR_LEAK;
int err_debuglevel=0;
int err_logdestination=LOGDEST_STDERR;
#ifdef DEBUG
pthread_mutex_t err_mutex=PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t err_mutex=PTHREAD_MUTEX_INITIALIZER;
ERR_LEAK err_leak = { NULL, NULL, 0, 0, NULL }; ERR_LEAK err_leak = { NULL, NULL, 0, 0, NULL };
#endif #endif
@ -99,7 +102,7 @@ void log_setdest(char *app, int destination) {
} }
} }
#ifdef DEBUG #ifdef DEBUG_MEMORY
/* /*
* err_lock * err_lock
@ -109,7 +112,7 @@ void log_setdest(char *app, int destination) {
int err_lock_mutex(void) { int err_lock_mutex(void) {
int err; int err;
if(err=pthread_mutex_lock(&err_mutex)) { if((err=pthread_mutex_lock(&err_mutex))) {
errno=err; errno=err;
return -1; return -1;
} }
@ -128,7 +131,7 @@ int err_lock_mutex(void) {
int err_unlock_mutex(void) { int err_unlock_mutex(void) {
int err; int err;
if(err=pthread_mutex_unlock(&err_mutex)) { if((err=pthread_mutex_unlock(&err_mutex))) {
errno=err; errno=err;
return -1; return -1;
} }
@ -249,7 +252,7 @@ void err_leakcheck(void) {
current=err_leak.next; current=err_leak.next;
while(current) { while(current) {
printf("%s: %d - %d bytes at %x\n",current->file, current->line, current->size, printf("%s: %d - %d bytes at %p\n",current->file, current->line, current->size,
current->ptr); current->ptr);
current=current->next; current=current->next;
} }

View File

@ -36,14 +36,11 @@ extern int err_logdestination;
extern void log_err(int quit, char *fmt, ...); extern void log_err(int quit, char *fmt, ...);
extern void log_setdest(char *app, int destination); extern void log_setdest(char *app, int destination);
#ifdef DEBUG
# define DPRINTF(level, fmt, arg...) \
{ if((level) <= err_debuglevel) { log_err(0,"%s: ",__FILE__); log_err(0,fmt,##arg); }}
#else
# define DPRINTF(level, fmt, arg...)
#endif /* DEBUG */
#ifdef DEBUG # define DPRINTF(level, fmt, arg...) \
{ if((level) <= err_debuglevel) { log_err(0,"%s, %d: ",__FILE__,__LINE__); log_err(0,fmt,##arg); }}
#ifdef DEBUG_MEMORY
# ifndef __IN_ERR__ # ifndef __IN_ERR__
# define malloc(x) err_malloc(__FILE__,__LINE__,x) # define malloc(x) err_malloc(__FILE__,__LINE__,x)
# define strdup(x) err_strdup(__FILE__,__LINE__,x) # define strdup(x) err_strdup(__FILE__,__LINE__,x)
@ -60,5 +57,5 @@ extern void err_leakcheck(void);
#else #else
# define MEMNOTIFY(x) # define MEMNOTIFY(x)
#endif /* DEBUG */ #endif /* DEBUG_MEMORY */
#endif /* __ERR_H__ */ #endif /* __ERR_H__ */

View File

@ -28,6 +28,7 @@
#include <limits.h> #include <limits.h>
#include <pthread.h> #include <pthread.h>
#include <pwd.h> #include <pwd.h>
#include <restart.h>
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -36,6 +37,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h>
#include "configfile.h" #include "configfile.h"
#include "db-memory.h" #include "db-memory.h"
@ -86,17 +88,15 @@ int daap_auth(char *username, char *password) {
* Handle daap-related web pages * Handle daap-related web pages
*/ */
void daap_handler(WS_CONNINFO *pwsc) { void daap_handler(WS_CONNINFO *pwsc) {
int len;
int close; int close;
DAAP_BLOCK *root,*error; DAAP_BLOCK *root;
int compress=0;
int clientrev; int clientrev;
/* for the /databases URI */ /* for the /databases URI */
char *uri; char *uri;
int db_index; int db_index;
int playlist_index; int playlist_index;
int item; int item=0;
char *first, *last; char *first, *last;
int streaming=0; int streaming=0;
@ -364,9 +364,7 @@ int daemon_start(int reap_children)
void usage(char *program) { void usage(char *program) {
printf("Usage: %s [options]\n\n",program); printf("Usage: %s [options]\n\n",program);
printf("Options:\n"); printf("Options:\n");
#ifdef DEBUG
printf(" -d <number> Debuglevel (0-9)\n"); printf(" -d <number> Debuglevel (0-9)\n");
#endif
printf(" -m Disable mDNS\n"); printf(" -m Disable mDNS\n");
printf(" -c <file> Use configfile specified"); printf(" -c <file> Use configfile specified");
printf(" -p Parse playlist file\n"); printf(" -p Parse playlist file\n");
@ -412,24 +410,15 @@ int main(int argc, char *argv[]) {
char *configfile=DEFAULT_CONFIGFILE; char *configfile=DEFAULT_CONFIGFILE;
WSCONFIG ws_config; WSCONFIG ws_config;
WSHANDLE server; WSHANDLE server;
ENUMHANDLE handle;
MP3FILE *pmp3;
int status;
int parseonly=0; int parseonly=0;
int foreground=0; int foreground=0;
config.use_mdns=1; config.use_mdns=1;
#ifdef DEBUG
char *optval="d:c:mpf";
#else
char *optval="c:mpf";
#endif /* DEBUG */
fprintf(stderr,"mt-daapd: version %s\n",VERSION); fprintf(stderr,"mt-daapd: version %s\n",VERSION);
fprintf(stderr,"Copyright (c) 2003 Ron Pedde. All rights reserved\n"); fprintf(stderr,"Copyright (c) 2003 Ron Pedde. All rights reserved\n");
fprintf(stderr,"Portions Copyright (c) 1999-2001 Apple Computer, Inc. All rights Reserved.\n\n"); fprintf(stderr,"Portions Copyright (c) 1999-2001 Apple Computer, Inc. All rights Reserved.\n\n");
while((option=getopt(argc,argv,optval)) != -1) { while((option=getopt(argc,argv,"d:c:mpf")) != -1) {
switch(option) { switch(option) {
#ifdef DEBUG #ifdef DEBUG
case 'd': case 'd':
@ -459,13 +448,6 @@ int main(int argc, char *argv[]) {
} }
} }
#ifdef DEBUG
if(!foreground) {
fprintf(stderr,"WARNING: Debug mode: not detaching\n");
foreground=1;
}
#endif
/* read the configfile, if specified, otherwise /* read the configfile, if specified, otherwise
* try defaults */ * try defaults */
@ -561,7 +543,7 @@ int main(int argc, char *argv[]) {
if(foreground) fprintf(stderr,"Closing database\n"); if(foreground) fprintf(stderr,"Closing database\n");
db_deinit(); db_deinit();
#ifdef DEBUG #ifdef DEBUG_MEMORY
fprintf(stderr,"Leaked memory:\n"); fprintf(stderr,"Leaked memory:\n");
err_leakcheck(); err_leakcheck();
#endif #endif

View File

@ -20,11 +20,13 @@
*/ */
#define _POSIX_PTHREAD_SEMANTICS #define _POSIX_PTHREAD_SEMANTICS
#include <ctype.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <id3tag.h> #include <id3tag.h>
#include <limits.h> #include <limits.h>
#include <restart.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -399,7 +401,7 @@ int scan_gettags(char *file, MP3FILE *pmp3) {
int index; int index;
int used; int used;
unsigned char *utf8_text; unsigned char *utf8_text;
int genre; int genre=WINAMP_GENRE_UNKNOWN;
int have_utf8; int have_utf8;
int have_text; int have_text;
id3_ucs4_t const *native_text; id3_ucs4_t const *native_text;

View File

@ -20,12 +20,18 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "db-memory.h"
#include "err.h" #include "err.h"
#include "mp3-scanner.h" #include "mp3-scanner.h"
#include "playlist.h" #include "playlist.h"
#include "parser.h" #include "parser.h"
/* Externs */
extern int yyparse(void *);
/* Globals */ /* Globals */
SMART_PLAYLIST pl_smart = { NULL, 0, NULL, NULL }; SMART_PLAYLIST pl_smart = { NULL, 0, NULL, NULL };
int pl_error=0; int pl_error=0;
@ -158,7 +164,7 @@ int pl_load(char *file) {
} }
yyin=fin; yyin=fin;
result=yyparse(); result=yyparse(NULL);
fclose(fin); fclose(fin);
if(pl_error) { if(pl_error) {
@ -204,13 +210,14 @@ void pl_eval(MP3FILE *pmp3) {
*/ */
int pl_eval_node(MP3FILE *pmp3, PL_NODE *pnode) { int pl_eval_node(MP3FILE *pmp3, PL_NODE *pnode) {
int r_arg,r_arg2; int r_arg,r_arg2;
int argtypec; char *cval=NULL;
char *cval; int ival=0;
int ival;
int boolarg; int boolarg;
int not=0; int not=0;
int retval=0; int retval=0;
r_arg=r_arg2=0;
if((pnode->op == AND) || (pnode->op == OR)) { if((pnode->op == AND) || (pnode->op == OR)) {
r_arg=pl_eval_node(pmp3,pnode->arg1.plval); r_arg=pl_eval_node(pmp3,pnode->arg1.plval);
if((pnode->op == AND) && !r_arg) if((pnode->op == AND) && !r_arg)
@ -257,7 +264,7 @@ int pl_eval_node(MP3FILE *pmp3, PL_NODE *pnode) {
retval = not ? r_arg : !r_arg; retval = not ? r_arg : !r_arg;
break; break;
case INCLUDES: case INCLUDES:
r_arg=strcasestr(cval,pnode->arg2.cval); r_arg=(int)strcasestr(cval,pnode->arg2.cval);
retval = not ? !r_arg : r_arg; retval = not ? !r_arg : r_arg;
break; break;
} }

View File

@ -21,6 +21,7 @@
#include <unistd.h> #include <unistd.h>
#include <pwd.h> #include <pwd.h>
#include <pthread.h>
#include <sys/types.h> #include <sys/types.h>
#include <libc.h> #include <libc.h>
@ -106,7 +107,6 @@ static void rend_reply(DNSServiceRegistrationReplyErrorType errorCode, void *con
*/ */
void *rend_pipe_monitor(void* arg) { void *rend_pipe_monitor(void* arg) {
fd_set rset; fd_set rset;
struct timeval tv;
int result; int result;

View File

@ -24,7 +24,10 @@
#endif #endif
#include <errno.h> #include <errno.h>
#include <restart.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include "daapd.h" #include "daapd.h"

View File

@ -23,16 +23,19 @@
# include "config.h" # include "config.h"
#endif #endif
#include <ctype.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <pthread.h> #include <pthread.h>
#include <regex.h> #include <regex.h>
#include <restart.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <uici.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/types.h> #include <sys/types.h>
@ -88,7 +91,6 @@ int ws_getpostvars(WS_CONNINFO *pwsc);
int ws_getgetvars(WS_CONNINFO *pwsc, char *string); int ws_getgetvars(WS_CONNINFO *pwsc, char *string);
char *ws_getarg(ARGLIST *root, char *key); char *ws_getarg(ARGLIST *root, char *key);
int ws_testarg(ARGLIST *root, char *key, char *value); int ws_testarg(ARGLIST *root, char *key, char *value);
void ws_emitheaders(WS_CONNINFO *pwsc);
int ws_findhandler(WS_PRIVATE *pwsp, WS_CONNINFO *pwsc, int ws_findhandler(WS_PRIVATE *pwsp, WS_CONNINFO *pwsc,
void(**preq)(WS_CONNINFO*), void(**preq)(WS_CONNINFO*),
int(**pauth)(char *, char *), int(**pauth)(char *, char *),
@ -121,7 +123,7 @@ char *ws_moy[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
int ws_lock_unsafe(void) { int ws_lock_unsafe(void) {
int err; int err;
if(err=pthread_mutex_lock(&ws_unsafe)) { if((err=pthread_mutex_lock(&ws_unsafe))) {
errno=err; errno=err;
return -1; return -1;
} }
@ -140,7 +142,7 @@ int ws_lock_unsafe(void) {
int ws_unlock_unsafe(void) { int ws_unlock_unsafe(void) {
int err; int err;
if(err=pthread_mutex_unlock(&ws_unsafe)) { if((err=pthread_mutex_unlock(&ws_unsafe))) {
errno=err; errno=err;
return -1; return -1;
} }
@ -176,12 +178,12 @@ WSHANDLE ws_start(WSCONFIG *config) {
pwsp->dispatch_threads=0; pwsp->dispatch_threads=0;
pwsp->handlers.next=NULL; pwsp->handlers.next=NULL;
if(err=pthread_cond_init(&pwsp->exit_cond, NULL)) { if((err=pthread_cond_init(&pwsp->exit_cond, NULL))) {
errno=err; errno=err;
return NULL; return NULL;
} }
if(err=pthread_mutex_init(&pwsp->exit_mutex,NULL)) { if((err=pthread_mutex_init(&pwsp->exit_mutex,NULL))) {
errno=err; errno=err;
return NULL; return NULL;
} }
@ -196,7 +198,7 @@ WSHANDLE ws_start(WSCONFIG *config) {
} }
DPRINTF(ERR_INFO,"Starting server thread\n"); DPRINTF(ERR_INFO,"Starting server thread\n");
if(err=pthread_create(&pwsp->server_tid,NULL,ws_mainthread,(void*)pwsp)) { if((err=pthread_create(&pwsp->server_tid,NULL,ws_mainthread,(void*)pwsp))) {
DPRINTF(ERR_WARN,"Could not spawn thread: %s\n",strerror(err)); DPRINTF(ERR_WARN,"Could not spawn thread: %s\n",strerror(err));
r_close(pwsp->server_fd); r_close(pwsp->server_fd);
errno=err; errno=err;
@ -326,7 +328,7 @@ void *ws_mainthread(void *arg) {
if(pthread_mutex_lock(&pwsp->exit_mutex)) if(pthread_mutex_lock(&pwsp->exit_mutex))
log_err(1,"Cannot lock condition mutex\n"); log_err(1,"Cannot lock condition mutex\n");
if(err=pthread_create(&tid,NULL,ws_dispatcher,(void*)pwsc)) { if((err=pthread_create(&tid,NULL,ws_dispatcher,(void*)pwsc))) {
pwsc->error=err; pwsc->error=err;
DPRINTF(ERR_WARN,"Could not spawn thread: %s\n",strerror(err)); DPRINTF(ERR_WARN,"Could not spawn thread: %s\n",strerror(err));
pthread_mutex_unlock(&pwsp->exit_mutex); pthread_mutex_unlock(&pwsp->exit_mutex);
@ -427,7 +429,6 @@ void ws_emitheaders(WS_CONNINFO *pwsc) {
* get headers * get headers
*/ */
int ws_getpostvars(WS_CONNINFO *pwsc) { int ws_getpostvars(WS_CONNINFO *pwsc) {
char *first, *last;
char *content_length; char *content_length;
int length; int length;
char *buffer; char *buffer;
@ -592,9 +593,7 @@ void *ws_dispatcher(void *arg) {
WS_CONNINFO *pwsc=(WS_CONNINFO*)arg; WS_CONNINFO *pwsc=(WS_CONNINFO*)arg;
WS_PRIVATE *pwsp=pwsc->pwsp; WS_PRIVATE *pwsp=pwsc->pwsp;
char buffer[MAX_LINEBUFFER]; char buffer[MAX_LINEBUFFER];
char *buffp;
char *first,*last; char *first,*last;
int done;
int connection_done=0; int connection_done=0;
int can_dispatch; int can_dispatch;
char *auth, *username, *password; char *auth, *username, *password;
@ -1029,7 +1028,7 @@ int ws_addarg(ARGLIST *root, char *key, char *fmt, ...) {
char *ws_urldecode(char *string) { char *ws_urldecode(char *string) {
char *pnew; char *pnew;
char *src,*dst; char *src,*dst;
int val; int val=0;
pnew=(char*)malloc(strlen(string)+1); pnew=(char*)malloc(strlen(string)+1);
if(!pnew) if(!pnew)
@ -1201,7 +1200,7 @@ int ws_decodepassword(char *header, char **username, char **password) {
decodebuffer=(unsigned char *)malloc(strlen(header)); decodebuffer=(unsigned char *)malloc(strlen(header));
if(!decodebuffer) if(!decodebuffer)
return; return -1;
DPRINTF(ERR_DEBUG,"Preparing to decode %s\n",header); DPRINTF(ERR_DEBUG,"Preparing to decode %s\n",header);

View File

@ -84,5 +84,6 @@ extern int ws_writefd(WS_CONNINFO *pwsc, char *fmt, ...);
extern char *ws_getvar(WS_CONNINFO *pwsc, char *var); extern char *ws_getvar(WS_CONNINFO *pwsc, char *var);
extern char *ws_getrequestheader(WS_CONNINFO *pwsc, char *header); extern char *ws_getrequestheader(WS_CONNINFO *pwsc, char *header);
extern int ws_testrequestheader(WS_CONNINFO *pwsc, char *header, char *value); extern int ws_testrequestheader(WS_CONNINFO *pwsc, char *header, char *value);
extern void ws_emitheaders(WS_CONNINFO *pwsc);
#endif /* _WEBSERVER_H_ */ #endif /* _WEBSERVER_H_ */