diff options
Diffstat (limited to 'src')
93 files changed, 167 insertions, 477 deletions
diff --git a/src/audio.c b/src/audio.c index 16367efa0..07183d1ea 100644 --- a/src/audio.c +++ b/src/audio.c @@ -25,15 +25,7 @@ #include "playerData.h" #include "utils.h" #include "state_file.h" - -#include <stdlib.h> -#include <string.h> -#include <assert.h> -#include <signal.h> -#include <sys/stat.h> -#include <sys/param.h> -#include <errno.h> -#include <unistd.h> +#include "os_compat.h" #define AUDIO_DEVICE_STATE "audio_device_state:" #define AUDIO_DEVICE_STATE_LEN 19 /* strlen(AUDIO_DEVICE_STATE) */ diff --git a/src/audio.h b/src/audio.h index 3663d289d..857b4aaf6 100644 --- a/src/audio.h +++ b/src/audio.h @@ -23,8 +23,7 @@ #include "mpd_types.h" #include "tag.h" - -#include <stdio.h> +#include "os_compat.h" #define AUDIO_AO_DRIVER_DEFAULT "default" diff --git a/src/audioOutput.c b/src/audioOutput.c index 03a5ed782..43d073b48 100644 --- a/src/audioOutput.c +++ b/src/audioOutput.c @@ -21,8 +21,7 @@ #include "list.h" #include "log.h" #include "pcm_utils.h" - -#include <string.h> +#include "os_compat.h" #define AUDIO_OUTPUT_TYPE "type" #define AUDIO_OUTPUT_NAME "name" diff --git a/src/audioOutput.h b/src/audioOutput.h index 1591c814a..6bde49b39 100644 --- a/src/audioOutput.h +++ b/src/audioOutput.h @@ -27,6 +27,7 @@ #include "tag.h" #include "conf.h" #include "utils.h" +#include "os_compat.h" #define DISABLED_AUDIO_OUTPUT_PLUGIN(plugin) AudioOutputPlugin plugin; diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index 1122eb5bf..1f90c6ee0 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -18,8 +18,6 @@ #include "../audioOutput.h" -#include <stdlib.h> - #ifdef HAVE_ALSA #define ALSA_PCM_NEW_HW_PARAMS_API @@ -34,8 +32,7 @@ #include "../conf.h" #include "../log.h" - -#include <string.h> +#include "../os_compat.h" #include <alsa/asoundlib.h> diff --git a/src/audioOutputs/audioOutput_ao.c b/src/audioOutputs/audioOutput_ao.c index a7f437ef4..e7f3dcd6b 100644 --- a/src/audioOutputs/audioOutput_ao.c +++ b/src/audioOutputs/audioOutput_ao.c @@ -22,8 +22,7 @@ #include "../conf.h" #include "../log.h" - -#include <string.h> +#include "../os_compat.h" #include <ao/ao.h> @@ -240,7 +239,5 @@ AudioOutputPlugin aoPlugin = { #else -#include <stdio.h> - DISABLED_AUDIO_OUTPUT_PLUGIN(aoPlugin) #endif diff --git a/src/audioOutputs/audioOutput_fifo.c b/src/audioOutputs/audioOutput_fifo.c index 66c54dd7f..b01f37f67 100644 --- a/src/audioOutputs/audioOutput_fifo.c +++ b/src/audioOutputs/audioOutput_fifo.c @@ -17,8 +17,7 @@ */ #include "../audioOutput.h" - -#include <stdlib.h> +#include "../os_compat.h" #ifdef HAVE_FIFO @@ -27,13 +26,6 @@ #include "../utils.h" #include "../timer.h" -#include <errno.h> -#include <fcntl.h> -#include <string.h> -#include <unistd.h> -#include <sys/stat.h> -#include <sys/types.h> - #define FIFO_BUFFER_SIZE 65536 /* pipe capacity on Linux >= 2.6.11 */ typedef struct _FifoData { diff --git a/src/audioOutputs/audioOutput_jack.c b/src/audioOutputs/audioOutput_jack.c index d38f00bad..253da2159 100644 --- a/src/audioOutputs/audioOutput_jack.c +++ b/src/audioOutputs/audioOutput_jack.c @@ -19,15 +19,10 @@ #ifdef HAVE_JACK -#include <stdlib.h> -#include <errno.h> - +#include "../os_compat.h" #include "../conf.h" #include "../log.h" -#include <string.h> -#include <pthread.h> - #include <jack/jack.h> #include <jack/types.h> #include <jack/ringbuffer.h> @@ -37,7 +32,11 @@ pthread_cond_t play_audio = PTHREAD_COND_INITIALIZER; /*#include "dmalloc.h"*/ -#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#ifdef MIN +# undef MIN +# define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + /*#define SAMPLE_SIZE sizeof(jack_default_audio_sample_t);*/ diff --git a/src/audioOutputs/audioOutput_mvp.c b/src/audioOutputs/audioOutput_mvp.c index ea365c657..c633bb96b 100644 --- a/src/audioOutputs/audioOutput_mvp.c +++ b/src/audioOutputs/audioOutput_mvp.c @@ -20,23 +20,13 @@ */ #include "../audioOutput.h" - -#include <stdlib.h> +#include "../os_compat.h" #ifdef HAVE_MVP #include "../conf.h" #include "../log.h" -#include <string.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> - typedef struct { unsigned long dsp_status; unsigned long stream_decode_type; diff --git a/src/audioOutputs/audioOutput_oss.c b/src/audioOutputs/audioOutput_oss.c index 74c62ce96..68c82bf30 100644 --- a/src/audioOutputs/audioOutput_oss.c +++ b/src/audioOutputs/audioOutput_oss.c @@ -20,23 +20,13 @@ */ #include "../audioOutput.h" - -#include <stdlib.h> +#include "../os_compat.h" #ifdef HAVE_OSS #include "../conf.h" #include "../log.h" -#include <string.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <unistd.h> -#include <errno.h> - #if defined(__OpenBSD__) || defined(__NetBSD__) # include <soundcard.h> #else /* !(defined(__OpenBSD__) || defined(__NetBSD__) */ diff --git a/src/audioOutputs/audioOutput_osx.c b/src/audioOutputs/audioOutput_osx.c index 1caebade5..4a6e8ccf1 100644 --- a/src/audioOutputs/audioOutput_osx.c +++ b/src/audioOutputs/audioOutput_osx.c @@ -21,8 +21,6 @@ #ifdef HAVE_OSX #include <AudioUnit/AudioUnit.h> -#include <stdlib.h> -#include <pthread.h> #include "../log.h" @@ -368,7 +366,5 @@ AudioOutputPlugin osxPlugin = { #else -#include <stdio.h> - DISABLED_AUDIO_OUTPUT_PLUGIN(osxPlugin) #endif diff --git a/src/audioOutputs/audioOutput_pulse.c b/src/audioOutputs/audioOutput_pulse.c index 8948e0263..69566444b 100644 --- a/src/audioOutputs/audioOutput_pulse.c +++ b/src/audioOutputs/audioOutput_pulse.c @@ -18,15 +18,11 @@ #include "../audioOutput.h" -#include <stdlib.h> - #ifdef HAVE_PULSE #include "../conf.h" #include "../log.h" - -#include <string.h> -#include <time.h> +#include "../os_compat.h" #include <pulse/simple.h> #include <pulse/error.h> diff --git a/src/audioOutputs/audioOutput_shout.c b/src/audioOutputs/audioOutput_shout.c index 455a635f6..e4ee4916d 100644 --- a/src/audioOutputs/audioOutput_shout.c +++ b/src/audioOutputs/audioOutput_shout.c @@ -18,8 +18,6 @@ #include "../audioOutput.h" -#include <stdlib.h> - #ifdef HAVE_SHOUT #include "../conf.h" @@ -27,9 +25,6 @@ #include "../pcm_utils.h" #include "../timer.h" -#include <string.h> -#include <time.h> - #include <shout/shout.h> #include <vorbis/vorbisenc.h> diff --git a/src/buffer2array.c b/src/buffer2array.c index 1684bad94..0479de51b 100644 --- a/src/buffer2array.c +++ b/src/buffer2array.c @@ -17,12 +17,7 @@ */ #include "buffer2array.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - +#include "os_compat.h" static inline int diff --git a/src/charConv.c b/src/charConv.c index a4b596efe..c2ef722a8 100644 --- a/src/charConv.c +++ b/src/charConv.c @@ -21,10 +21,7 @@ #include "utf8.h" #include "utils.h" #include "path.h" - -#include <stdlib.h> -#include <errno.h> -#include <string.h> +#include "os_compat.h" #ifdef HAVE_ICONV #include <iconv.h> diff --git a/src/command.c b/src/command.c index 83a8d3a2d..c6d751258 100644 --- a/src/command.c +++ b/src/command.c @@ -31,12 +31,7 @@ #include "tag.h" #include "utils.h" #include "storedPlaylist.h" - -#include <assert.h> -#include <stdarg.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> +#include "os_compat.h" #define COMMAND_PLAY "play" #define COMMAND_PLAYID "playid" diff --git a/src/command.h b/src/command.h index a560b9484..71516b122 100644 --- a/src/command.h +++ b/src/command.h @@ -26,9 +26,7 @@ #include "log.h" #include "ack.h" #include "sllist.h" - -#include <unistd.h> -#include <stdio.h> +#include "os_compat.h" #define COMMAND_RETURN_KILL 10 #define COMMAND_RETURN_CLOSE 20 diff --git a/src/compress.c b/src/compress.c index d8db7ab64..7e526dc7a 100644 --- a/src/compress.c +++ b/src/compress.c @@ -20,11 +20,7 @@ * */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> - +#include "os_compat.h" #include "compress.h" #include "utils.h" diff --git a/src/conf.c b/src/conf.c index 291ae30d2..6b3973a1d 100644 --- a/src/conf.c +++ b/src/conf.c @@ -23,16 +23,8 @@ #include "utils.h" #include "buffer2array.h" #include "list.h" - -#include <sys/param.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/types.h> -#include <pwd.h> -#include <errno.h> #include "path.h" +#include "os_compat.h" #define MAX_STRING_SIZE MPD_PATH_MAX+80 diff --git a/src/dbUtils.h b/src/dbUtils.h index 0607bc3b5..e6a71485c 100644 --- a/src/dbUtils.h +++ b/src/dbUtils.h @@ -19,7 +19,7 @@ #ifndef DB_UTILS_H #define DB_UTILS_H -#include <stdio.h> +#include "os_compat.h" #include "locate.h" diff --git a/src/decode.c b/src/decode.c index 47bff4504..0ebdb9282 100644 --- a/src/decode.c +++ b/src/decode.c @@ -28,14 +28,7 @@ #include "sig_handlers.h" #include "ls.h" #include "utf8.h" - -#include <signal.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <sys/wait.h> -#include <unistd.h> -#include <string.h> +#include "os_compat.h" static int decode_pid; diff --git a/src/decode.h b/src/decode.h index 1c93d3843..14dc0e8ee 100644 --- a/src/decode.h +++ b/src/decode.h @@ -26,9 +26,7 @@ #include "mpd_types.h" #include "audio.h" -#include <stdio.h> -#include <sys/param.h> -#include <signal.h> +#include "os_compat.h" #define DECODE_TYPE_FILE 0 #define DECODE_TYPE_URL 1 diff --git a/src/directory.c b/src/directory.c index 45e583d2d..6a203b9c1 100644 --- a/src/directory.c +++ b/src/directory.c @@ -37,11 +37,6 @@ #include "volume.h" #include "ls.h" -#include <sys/wait.h> -#include <dirent.h> -#include <errno.h> -#include <assert.h> - #define DIRECTORY_DIR "directory: " #define DIRECTORY_MTIME "mtime: " #define DIRECTORY_BEGIN "begin: " diff --git a/src/inputPlugin.c b/src/inputPlugin.c index ec5624bf2..e9c6d4a70 100644 --- a/src/inputPlugin.c +++ b/src/inputPlugin.c @@ -20,9 +20,7 @@ #include "list.h" #include "myfprintf.h" - -#include <stdlib.h> -#include <string.h> +#include "os_compat.h" static List *inputPlugin_list; diff --git a/src/inputPlugins/_flac_common.c b/src/inputPlugins/_flac_common.c index 11126cd1b..9a415f4b6 100644 --- a/src/inputPlugins/_flac_common.c +++ b/src/inputPlugins/_flac_common.c @@ -31,10 +31,8 @@ #include "../outputBuffer.h" #include "../decode.h" #include "../replayGain.h" +#include "../os_compat.h" -#include <stdio.h> -#include <string.h> -#include <unistd.h> #include <FLAC/format.h> #include <FLAC/metadata.h> diff --git a/src/inputPlugins/_ogg_common.c b/src/inputPlugins/_ogg_common.c index ca68ae4f1..3ec227a66 100644 --- a/src/inputPlugins/_ogg_common.c +++ b/src/inputPlugins/_ogg_common.c @@ -28,8 +28,7 @@ (defined(FLAC_API_VERSION_CURRENT) && FLAC_API_VERSION_CURRENT > 7) #include "../utils.h" - -#include <string.h> +#include "../os_compat.h" ogg_stream_type ogg_stream_type_detect(InputStream * inStream) { diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c index 0cbb4c97a..0091b396e 100644 --- a/src/inputPlugins/aac_plugin.c +++ b/src/inputPlugins/aac_plugin.c @@ -27,11 +27,8 @@ #include "../log.h" #include "../inputStream.h" #include "../outputBuffer.h" +#include "../os_compat.h" -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> #include <faad.h> /* all code here is either based on or copied from FAAD2's frontend code */ diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c index 68a87022a..8527a47a9 100644 --- a/src/inputPlugins/audiofile_plugin.c +++ b/src/inputPlugins/audiofile_plugin.c @@ -27,14 +27,8 @@ #include "../log.h" #include "../pcm_utils.h" #include "../playerData.h" +#include "../os_compat.h" -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> #include <audiofile.h> static int getAudiofileTotalTime(char *file) diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index 920e71947..c906314f3 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -27,11 +27,7 @@ #include "../outputBuffer.h" #include "../replayGain.h" #include "../audio.h" - -#include <stdio.h> -#include <string.h> -#include <unistd.h> -#include <assert.h> +#include "../os_compat.h" /* this code was based on flac123, from flac-tools */ diff --git a/src/inputPlugins/mod_plugin.c b/src/inputPlugins/mod_plugin.c index 0b20690e4..0c01caadb 100644 --- a/src/inputPlugins/mod_plugin.c +++ b/src/inputPlugins/mod_plugin.c @@ -25,14 +25,8 @@ #include "../log.h" #include "../pcm_utils.h" #include "../playerData.h" +#include "../os_compat.h" -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> #include <mikmod.h> /* this is largely copied from alsaplayer */ diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 8a9dfad5c..9bb3f2f4b 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -33,13 +33,7 @@ #include "../tag.h" #include "../conf.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <errno.h> +#include "../os_compat.h" #define FRAMES_CUSHION 2000 diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c index 5261580fc..2e3dd18ae 100644 --- a/src/inputPlugins/mp4_plugin.c +++ b/src/inputPlugins/mp4_plugin.c @@ -27,15 +27,11 @@ #include "../inputStream.h" #include "../outputBuffer.h" #include "../decode.h" +#include "../os_compat.h" #include "../mp4ff/mp4ff.h" -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> #include <faad.h> - /* all code here is either based on or copied from FAAD2's frontend code */ static int mp4_getAACTrack(mp4ff_t * infile) diff --git a/src/inputPlugins/mpc_plugin.c b/src/inputPlugins/mpc_plugin.c index 60fd6fde6..0d18c113a 100644 --- a/src/inputPlugins/mpc_plugin.c +++ b/src/inputPlugins/mpc_plugin.c @@ -27,14 +27,9 @@ #include "../inputStream.h" #include "../outputBuffer.h" #include "../replayGain.h" +#include "../os_compat.h" -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> #include <mpcdec/mpcdec.h> -#include <errno.h> -#include <math.h> typedef struct _MpcCallbackData { InputStream *inStream; diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c index 50636274a..e980a04b2 100644 --- a/src/inputPlugins/oggflac_plugin.c +++ b/src/inputPlugins/oggflac_plugin.c @@ -32,10 +32,7 @@ #include "../outputBuffer.h" #include "../replayGain.h" #include "../audio.h" - -#include <stdio.h> -#include <string.h> -#include <unistd.h> +#include "../os_compat.h" static void oggflac_cleanup(FlacData * data, OggFLAC__SeekableStreamDecoder * decoder) diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c index 05c665386..2e9342526 100644 --- a/src/inputPlugins/oggvorbis_plugin.c +++ b/src/inputPlugins/oggvorbis_plugin.c @@ -31,11 +31,7 @@ #include "../inputStream.h" #include "../outputBuffer.h" #include "../replayGain.h" - -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> +#include "../os_compat.h" #ifndef HAVE_TREMOR #include <vorbis/vorbisfile.h> @@ -52,8 +48,6 @@ #define ov_time_seek_page(VF, S) (ov_time_seek_page(VF, (S)*1000)) #endif /* HAVE_TREMOR */ -#include <errno.h> - #ifdef WORDS_BIGENDIAN #define OGG_DECODE_USE_BIGENDIAN 1 #else diff --git a/src/inputPlugins/wavpack_plugin.c b/src/inputPlugins/wavpack_plugin.c index 97fbc37f9..b6a3ee6ed 100644 --- a/src/inputPlugins/wavpack_plugin.c +++ b/src/inputPlugins/wavpack_plugin.c @@ -28,15 +28,9 @@ #include "../pcm_utils.h" #include "../playerData.h" #include "../outputBuffer.h" +#include "../os_compat.h" -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> #include <wavpack/wavpack.h> -#include <math.h> #define ERRORLEN 80 diff --git a/src/inputStream.c b/src/inputStream.c index 013d75f17..9495beb8a 100644 --- a/src/inputStream.c +++ b/src/inputStream.c @@ -21,9 +21,7 @@ #include "inputStream_file.h" #include "inputStream_http.h" -#include <stdio.h> -#include <sys/types.h> -#include <unistd.h> +#include "os_compat.h" void initInputStream(void) { diff --git a/src/inputStream.h b/src/inputStream.h index 74397f07f..c1e2e4f83 100644 --- a/src/inputStream.h +++ b/src/inputStream.h @@ -19,7 +19,7 @@ #ifndef INPUT_STREAM_H #define INPUT_STREAM_H -#include <stdlib.h> +#include "os_compat.h" typedef struct _InputStream InputStream; diff --git a/src/inputStream_file.c b/src/inputStream_file.c index 389aaad01..fb433d380 100644 --- a/src/inputStream_file.c +++ b/src/inputStream_file.c @@ -19,14 +19,7 @@ #include "inputStream_file.h" #include "log.h" - -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <unistd.h> -#include <errno.h> -#define _XOPEN_SOURCE 600 -#include <fcntl.h> +#include "os_compat.h" void inputStream_initFile(void) { diff --git a/src/inputStream_http.c b/src/inputStream_http.c index 80b908a2e..db8b3062a 100644 --- a/src/inputStream_http.c +++ b/src/inputStream_http.c @@ -21,20 +21,7 @@ #include "utils.h" #include "log.h" #include "conf.h" - -#include <stdio.h> -#include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <netdb.h> -#include <sys/param.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <unistd.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> +#include "os_compat.h" #define HTTP_CONN_STATE_CLOSED 0 #define HTTP_CONN_STATE_INIT 1 diff --git a/src/interface.c b/src/interface.c index e11266741..5b754b504 100644 --- a/src/interface.c +++ b/src/interface.c @@ -27,21 +27,7 @@ #include "sllist.h" #include "utils.h" #include "ioops.h" - -#include <stdio.h> -#include <stdlib.h> -#include <assert.h> -#include <sys/select.h> -#include <sys/time.h> -#include <sys/types.h> -#include <unistd.h> -#include <sys/param.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <string.h> -#include <fcntl.h> -#include <errno.h> -#include <signal.h> +#include "os_compat.h" #define GREETING "OK MPD " PROTOCOL_VERSION "\n" diff --git a/src/interface.h b/src/interface.h index 6f3c2c070..70ba424dc 100644 --- a/src/interface.h +++ b/src/interface.h @@ -20,11 +20,7 @@ #define INTERFACE_H #include "../config.h" - -#include <stdio.h> -#include <time.h> -#include <sys/types.h> -#include <sys/socket.h> +#include "os_compat.h" void initInterfaces(void); void openAInterface(int fd, struct sockaddr *addr); diff --git a/src/ioops.h b/src/ioops.h index e797a7153..7da440290 100644 --- a/src/ioops.h +++ b/src/ioops.h @@ -19,7 +19,7 @@ #ifndef IOOPS_H #define IOOPS_H -#include <sys/select.h> +#include "os_compat.h" struct ioOps { struct ioOps *prev, *next; diff --git a/src/list.c b/src/list.c index 14832adb7..b360fe65a 100644 --- a/src/list.c +++ b/src/list.c @@ -18,12 +18,7 @@ #include "list.h" #include "utils.h" - -#include <stdlib.h> -#include <string.h> -#include <assert.h> -#include <time.h> -#include <stdio.h> +#include "os_compat.h" static void makeListNodesArray(List * list) { diff --git a/src/list.h b/src/list.h index 35451ec24..2c4d423ee 100644 --- a/src/list.h +++ b/src/list.h @@ -20,8 +20,7 @@ #define LIST_H #include "../config.h" - -#include <stdlib.h> +#include "os_compat.h" /* used to make a list where free() will be used to free data in list */ #define DEFAULT_FREE_DATA_FUNC free diff --git a/src/listen.c b/src/listen.c index 521834a63..91813b4b8 100644 --- a/src/listen.c +++ b/src/listen.c @@ -21,18 +21,7 @@ #include "conf.h" #include "log.h" #include "utils.h" - -#include <stdio.h> -#include <stdlib.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/param.h> -#include <netinet/in.h> -#include <netdb.h> -#include <string.h> -#include <errno.h> -#include <resolv.h> -#include <fcntl.h> +#include "os_compat.h" #define MAXHOSTNAME 1024 diff --git a/src/listen.h b/src/listen.h index d7c2d3639..04c6d8286 100644 --- a/src/listen.h +++ b/src/listen.h @@ -20,11 +20,7 @@ #define LISTEN_H #include "../config.h" - -#include <sys/time.h> -#include <sys/types.h> -#include <unistd.h> -#include <sys/select.h> +#include "os_compat.h" extern int boundPort; @@ -21,12 +21,7 @@ #include "conf.h" #include "myfprintf.h" #include "utils.h" - -#include <assert.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> -#include <time.h> +#include "os_compat.h" #define LOG_DATE_BUF_SIZE 16 #define LOG_DATE_LEN (LOG_DATE_BUF_SIZE - 1) @@ -21,8 +21,7 @@ #include "../config.h" #include "gcc.h" - -#include <unistd.h> +#include "os_compat.h" #define LOG_LEVEL_LOW 0 #define LOG_LEVEL_SECURE 1 @@ -23,10 +23,7 @@ #include "log.h" #include "utf8.h" #include "utils.h" - -#include <dirent.h> -#include <stdio.h> -#include <errno.h> +#include "os_compat.h" static char *remoteUrlPrefixes[] = { "http://", @@ -22,12 +22,7 @@ #include "../config.h" #include "inputPlugin.h" - -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <time.h> +#include "os_compat.h" int lsPlaylists(int fd, char *utf8path); diff --git a/src/main.c b/src/main.c index 72359820a..b92ef6abd 100644 --- a/src/main.c +++ b/src/main.c @@ -43,20 +43,7 @@ #include "utils.h" #include "normalize.h" #include "zeroconf.h" - -#include <stdio.h> -#include <sys/select.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/stat.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <fcntl.h> -#include <pwd.h> -#include <grp.h> -#include <time.h> -#include <unistd.h> +#include "os_compat.h" #define SYSTEM_CONFIG_FILE_LOCATION "/etc/mpd.conf" #define USER_CONFIG_FILE_LOCATION "/.mpdconf" diff --git a/src/metadataChunk.c b/src/metadataChunk.c index bc5118fd0..4adfa29c0 100644 --- a/src/metadataChunk.c +++ b/src/metadataChunk.c @@ -18,8 +18,7 @@ #include "metadataChunk.h" #include "gcc.h" - -#include <string.h> +#include "os_compat.h" static void initMetadataChunk(MetadataChunk * chunk) { diff --git a/src/mpd_types.h b/src/mpd_types.h index 1b5e40b69..765d0d001 100644 --- a/src/mpd_types.h +++ b/src/mpd_types.h @@ -20,16 +20,7 @@ #define MPD_TYPES_H #include "../config.h" - -#if defined(HAVE_STDINT_H) -#include <stdint.h> -#elif defined(HAVE_INTTYPES_H) -#include <inttypes.h> -#elif defined(HAVE_SYS_INTTYPES_H) -#include <sys/inttypes.h> -#elif defined(HAVE_SYS_TYPES_H) -#include <sys/types.h> -#endif +#include "os_compat.h" typedef unsigned char mpd_uint8; typedef signed char mpd_sint8; diff --git a/src/myfprintf.c b/src/myfprintf.c index 930078398..fdea2b78f 100644 --- a/src/myfprintf.c +++ b/src/myfprintf.c @@ -22,14 +22,7 @@ #include "log.h" #include "conf.h" #include "utils.h" - -#include <stdarg.h> -#include <sys/param.h> -#include <unistd.h> -#include <sys/select.h> -#include <fcntl.h> -#include <string.h> -#include <errno.h> +#include "os_compat.h" #define BUFFER_LENGTH MPD_PATH_MAX+1024 diff --git a/src/myfprintf.h b/src/myfprintf.h index 287902f9b..c857b3e50 100644 --- a/src/myfprintf.h +++ b/src/myfprintf.h @@ -21,9 +21,7 @@ #include "../config.h" #include "gcc.h" - -#include <stdarg.h> -#include <stdio.h> +#include "os_compat.h" mpd_fprintf void fdprintf(const int fd, const char *fmt, ...); void vfdprintf(const int fd, const char *fmt, va_list arglist); diff --git a/src/normalize.c b/src/normalize.c index ee21fc919..0bdee3eb5 100644 --- a/src/normalize.c +++ b/src/normalize.c @@ -19,8 +19,7 @@ #include "compress.h" #include "conf.h" #include "normalize.h" - -#include <stdlib.h> +#include "os_compat.h" #define DEFAULT_VOLUME_NORMALIZATION 0 diff --git a/src/os_compat.h b/src/os_compat.h new file mode 100644 index 000000000..c6268d0d8 --- /dev/null +++ b/src/os_compat.h @@ -0,0 +1,77 @@ +/* the Music Player Daemon (MPD) + * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com) + * This project's homepage is: http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef OS_COMPAT_H +#define OS_COMPAT_H + +/* + * This includes OS-wide headers that can be expected to be available + * on any machine that mpd can be compiled on for any UNIX-like OS. + * + * This does not include headers for optional dependencies such as + * those for: + * 1) input/output plugins + * 2) optional features in core (libsamplerate, avahi, ...) + */ + +#if defined(HAVE_STDINT_H) +#include <stdint.h> +#elif defined(HAVE_INTTYPES_H) +#include <inttypes.h> +#elif defined(HAVE_SYS_INTTYPES_H) +#include <sys/inttypes.h> +#endif +#include <sys/types.h> + +#define _XOPEN_SOURCE 600 /* for posix_fadvise, won't hurt if not available */ +#include <fcntl.h> + +#include <stdio.h> +#include <sys/stat.h> +#include <unistd.h> +#include <time.h> +#include <sys/time.h> +#include <sys/wait.h> +#include <sys/socket.h> +#include <stdlib.h> +#include <signal.h> +#include <string.h> +#include <errno.h> +#include <assert.h> +#include <sys/param.h> +#include <pthread.h> +#include <sys/ioctl.h> +#include <ctype.h> +#include <stdarg.h> +#include <dirent.h> +#include <math.h> +#include <sys/select.h> +#include <netdb.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <pwd.h> +#include <grp.h> +#include <limits.h> +#include <stddef.h> /* needed? this defines NULL + offsetof() */ +#include <resolv.h> + +/* remove when we switch to pthreads: */ +#include <sys/ipc.h> +#include <sys/shm.h> + +#endif /* OS_COMPAT_H */ diff --git a/src/outputBuffer.c b/src/outputBuffer.c index c7ff8b479..7570be5d8 100644 --- a/src/outputBuffer.c +++ b/src/outputBuffer.c @@ -24,11 +24,9 @@ #include "log.h" #include "normalize.h" #include "conf.h" - -#include <string.h> +#include "os_compat.h" static mpd_sint16 currentChunk = -1; - static mpd_sint8 currentMetaChunk = -1; static mpd_sint8 sendMetaChunk; diff --git a/src/path.c b/src/path.c index a99f8bd2c..258363036 100644 --- a/src/path.c +++ b/src/path.c @@ -23,14 +23,7 @@ #include "utf8.h" #include "utils.h" #include "playlist.h" - -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <errno.h> -#include <dirent.h> +#include "os_compat.h" #ifdef HAVE_LOCALE #ifdef HAVE_LANGINFO_CODESET diff --git a/src/path.h b/src/path.h index fef935400..560cf6073 100644 --- a/src/path.h +++ b/src/path.h @@ -20,9 +20,7 @@ #define PATH_H #include "../config.h" - -#include <sys/param.h> -#include <limits.h> +#include "os_compat.h" #if !defined(MPD_PATH_MAX) # if defined(MAXPATHLEN) diff --git a/src/pcm_utils.c b/src/pcm_utils.c index 807c04c78..d11d4d42f 100644 --- a/src/pcm_utils.c +++ b/src/pcm_utils.c @@ -22,10 +22,7 @@ #include "log.h" #include "utils.h" #include "conf.h" - -#include <string.h> -#include <math.h> -#include <assert.h> +#include "os_compat.h" void pcm_volumeChange(char *buffer, int bufferSize, AudioFormat * format, int volume) diff --git a/src/pcm_utils.h b/src/pcm_utils.h index 1b7757be0..7362cb7b8 100644 --- a/src/pcm_utils.h +++ b/src/pcm_utils.h @@ -22,8 +22,7 @@ #include "../config.h" #include "audio.h" - -#include <stdlib.h> +#include "os_compat.h" #ifdef HAVE_LIBSAMPLERATE #include <samplerate.h> diff --git a/src/permission.c b/src/permission.c index 3d597052c..4d53fa0cf 100644 --- a/src/permission.c +++ b/src/permission.c @@ -22,8 +22,7 @@ #include "list.h" #include "log.h" #include "utils.h" - -#include <string.h> +#include "os_compat.h" #define PERMISSION_PASSWORD_CHAR "@" #define PERMISSION_SEPERATOR "," diff --git a/src/player.c b/src/player.c index f41a35cc9..45e3f5ca9 100644 --- a/src/player.c +++ b/src/player.c @@ -31,18 +31,7 @@ #include "playerData.h" #include "permission.h" #include "sig_handlers.h" - -#include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <sys/time.h> -#include <sys/wait.h> -#include <stdlib.h> -#include <signal.h> -#include <string.h> -#include <errno.h> -#include <fcntl.h> +#include "os_compat.h" static void playerCloseAudio(void); diff --git a/src/player.h b/src/player.h index 03e16b72f..48a87227f 100644 --- a/src/player.h +++ b/src/player.h @@ -25,9 +25,7 @@ #include "mpd_types.h" #include "song.h" #include "metadataChunk.h" - -#include <stdio.h> -#include <sys/param.h> +#include "os_compat.h" #define PLAYER_STATE_STOP 0 #define PLAYER_STATE_PAUSE 1 diff --git a/src/playerData.c b/src/playerData.c index 69ef56bae..a84601bb0 100644 --- a/src/playerData.c +++ b/src/playerData.c @@ -19,14 +19,7 @@ #include "playerData.h" #include "conf.h" #include "log.h" - -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/ipc.h> -#include <sys/shm.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "os_compat.h" int buffered_before_play; int buffered_chunks; diff --git a/src/playlist.c b/src/playlist.c index 4689cc2de..5806273c3 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -29,14 +29,7 @@ #include "sig_handlers.h" #include "state_file.h" #include "storedPlaylist.h" - -#include <string.h> -#include <stdlib.h> -#include <sys/stat.h> -#include <sys/param.h> -#include <errno.h> -#include <unistd.h> -#include <time.h> +#include "os_compat.h" #define PLAYLIST_STATE_STOP 0 #define PLAYLIST_STATE_PLAY 1 diff --git a/src/playlist.h b/src/playlist.h index c725e8612..a26b7f45f 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -22,10 +22,7 @@ #include "../config.h" #include "dbUtils.h" - -#include <stdio.h> -#include <sys/param.h> -#include <time.h> +#include "os_compat.h" #define PLAYLIST_FILE_SUFFIX "m3u" #define PLAYLIST_COMMENT '#' diff --git a/src/replayGain.c b/src/replayGain.c index ce9d48085..49b98dc40 100644 --- a/src/replayGain.c +++ b/src/replayGain.c @@ -22,10 +22,7 @@ #include "log.h" #include "conf.h" - -#include <string.h> -#include <math.h> -#include <stdlib.h> +#include "os_compat.h" /* Added 4/14/2004 by AliasMrJones */ int replayGainState = REPLAYGAIN_OFF; diff --git a/src/sig_handlers.c b/src/sig_handlers.c index e092f51e7..fbd9e0573 100644 --- a/src/sig_handlers.c +++ b/src/sig_handlers.c @@ -27,14 +27,7 @@ #include "log.h" #include "player.h" #include "decode.h" - -#include <signal.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <sys/wait.h> -#include <errno.h> -#include <unistd.h> +#include "os_compat.h" int handlePendingSignals(void) { diff --git a/src/signal_check.c b/src/signal_check.c index 77a2b1251..3751232d4 100644 --- a/src/signal_check.c +++ b/src/signal_check.c @@ -18,9 +18,7 @@ */ #include "signal_check.h" - -#include <errno.h> -#include <stddef.h> +#include "os_compat.h" static volatile sig_atomic_t __caught_signals[NSIG]; diff --git a/src/signal_check.h b/src/signal_check.h index 58c9f3c3e..931b5333c 100644 --- a/src/signal_check.h +++ b/src/signal_check.h @@ -20,7 +20,7 @@ #ifndef SIGNAL_CHECK_H #define SIGNAL_CHECK_H -#include <signal.h> +#include "os_compat.h" void signal_handle(int sig); void signal_unhandle(int sig); diff --git a/src/sllist.c b/src/sllist.c index 00408a3cd..7df4aedab 100644 --- a/src/sllist.c +++ b/src/sllist.c @@ -18,7 +18,7 @@ /* a very simple singly-linked-list structure for queues/buffers */ -#include <string.h> +#include "os_compat.h" #include "sllist.h" #include "utils.h" diff --git a/src/sllist.h b/src/sllist.h index 1e81abef3..39860a59f 100644 --- a/src/sllist.h +++ b/src/sllist.h @@ -21,8 +21,6 @@ #ifndef SLLIST_H #define SLLIST_H -#include <stddef.h> - /* just free the entire structure if it's free-able, the 'data' member * should _NEVER_ be explicitly freed * diff --git a/src/song.c b/src/song.c index 4dee27c9c..d8d4251dd 100644 --- a/src/song.c +++ b/src/song.c @@ -30,9 +30,7 @@ #define SONG_KEY "key: " #define SONG_MTIME "mtime: " -#include <stdlib.h> -#include <string.h> -#include <assert.h> +#include "os_compat.h" Song *newNullSong(void) { diff --git a/src/song.h b/src/song.h index 46435efb8..ccf87e348 100644 --- a/src/song.h +++ b/src/song.h @@ -20,10 +20,7 @@ #define SONG_H #include "../config.h" - -#include <sys/param.h> -#include <time.h> - +#include "os_compat.h" #include "tag.h" #include "list.h" diff --git a/src/state_file.c b/src/state_file.c index 1b0b41f1a..a4b2c108f 100644 --- a/src/state_file.c +++ b/src/state_file.c @@ -25,12 +25,7 @@ #include "playlist.h" #include "utils.h" #include "volume.h" - -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> +#include "os_compat.h" static struct _sf_cb { void (*reader)(FILE *); diff --git a/src/state_file.h b/src/state_file.h index 4a7d012ec..29f071a97 100644 --- a/src/state_file.h +++ b/src/state_file.h @@ -21,8 +21,6 @@ #include "gcc.h" -#include <stdio.h> - void write_state_file(void); void read_state_file(void); void mpd_noreturn state_file_fatal(void); diff --git a/src/stats.c b/src/stats.c index 5045077c0..505324032 100644 --- a/src/stats.c +++ b/src/stats.c @@ -23,8 +23,7 @@ #include "player.h" #include "tag.h" #include "tagTracker.h" - -#include <time.h> +#include "os_compat.h" Stats stats; diff --git a/src/stats.h b/src/stats.h index cd7d0122c..5365bff69 100644 --- a/src/stats.h +++ b/src/stats.h @@ -21,8 +21,6 @@ #include "../config.h" -#include <stdio.h> - typedef struct _Stats { unsigned long daemonStart; int numberOfSongs; diff --git a/src/storedPlaylist.c b/src/storedPlaylist.c index 153a0fcdb..c456b543f 100644 --- a/src/storedPlaylist.c +++ b/src/storedPlaylist.c @@ -25,9 +25,7 @@ #include "command.h" #include "ls.h" #include "directory.h" - -#include <string.h> -#include <errno.h> +#include "os_compat.h" static ListNode *nodeOfStoredPlaylist(List *list, int index) { @@ -29,13 +29,7 @@ #include "mpd_types.h" #include "gcc.h" #include "song.h" - -#include <sys/stat.h> -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <assert.h> -#include <errno.h> +#include "os_compat.h" #ifdef HAVE_ID3TAG # define isId3v1(tag) (id3_tag_options(tag, 0, 0) & ID3_TAG_OPTION_ID3V1) @@ -23,9 +23,6 @@ #include "mpd_types.h" -#include <string.h> - -#include <stdio.h> #ifdef HAVE_ID3TAG #include <id3tag.h> #endif diff --git a/src/tagTracker.c b/src/tagTracker.c index ab356e500..9fc7fa840 100644 --- a/src/tagTracker.c +++ b/src/tagTracker.c @@ -22,9 +22,7 @@ #include "log.h" #include "utils.h" #include "myfprintf.h" - -#include <assert.h> -#include <stdlib.h> +#include "os_compat.h" static Tree *tagTrees[TAG_NUM_OF_ITEM_TYPES]; diff --git a/src/timer.c b/src/timer.c index 0406a945e..04a6f23c4 100644 --- a/src/timer.c +++ b/src/timer.c @@ -18,10 +18,7 @@ #include "timer.h" #include "utils.h" - -#include <assert.h> -#include <limits.h> -#include <sys/time.h> +#include "os_compat.h" static uint64_t now(void) { diff --git a/src/tree.c b/src/tree.c index 87028d744..26b58845c 100644 --- a/src/tree.c +++ b/src/tree.c @@ -18,10 +18,7 @@ #include "tree.h" #include "utils.h" - -#include <assert.h> -#include <stdlib.h> -#include <string.h> +#include "os_compat.h" #ifndef CHILDREN_PER_NODE #define CHILDREN_PER_NODE 25 diff --git a/src/utf8.c b/src/utf8.c index bb62a34f7..d7b1503c3 100644 --- a/src/utf8.c +++ b/src/utf8.c @@ -18,10 +18,7 @@ #include "utf8.h" #include "utils.h" - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> +#include "os_compat.h" char *latin1_to_utf8(char *dest, char *in_latin1) { diff --git a/src/utils.c b/src/utils.c index e9865aa24..2a0fcf89d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -19,19 +19,7 @@ #include "utils.h" #include "log.h" #include "conf.h" - -#include <stdlib.h> -#include <string.h> -#include <ctype.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/select.h> -#include <sys/time.h> -#include <unistd.h> -#include <assert.h> -#include <pwd.h> -#include <signal.h> -#include <sys/param.h> +#include "os_compat.h" char *myFgets(char *buffer, int bufferSize, FILE * fp) { diff --git a/src/utils.h b/src/utils.h index 258b725f3..564db0fe7 100644 --- a/src/utils.h +++ b/src/utils.h @@ -21,14 +21,7 @@ #include "../config.h" #include "gcc.h" - -#include <unistd.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> +#include "os_compat.h" #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) diff --git a/src/volume.c b/src/volume.c index 59e8b550c..6f11377e5 100644 --- a/src/volume.c +++ b/src/volume.c @@ -24,14 +24,8 @@ #include "state_file.h" #include "gcc.h" #include "utils.h" +#include "os_compat.h" -#include <math.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <sys/ioctl.h> -#include <fcntl.h> -#include <errno.h> #ifdef HAVE_OSS #include <sys/soundcard.h> #endif diff --git a/src/volume.h b/src/volume.h index fcaefc64d..48627dafe 100644 --- a/src/volume.h +++ b/src/volume.h @@ -20,8 +20,7 @@ #define VOLUME_H #include "../config.h" - -#include <stdio.h> +#include "os_compat.h" #define VOLUME_MIXER_OSS "oss" #define VOLUME_MIXER_ALSA "alsa" diff --git a/src/zeroconf.c b/src/zeroconf.c index aab09143a..27e921604 100644 --- a/src/zeroconf.c +++ b/src/zeroconf.c @@ -16,11 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <stdlib.h> -#include <assert.h> -#include <string.h> -#include <arpa/inet.h> - +#include "os_compat.h" #include "zeroconf.h" #include "conf.h" #include "log.h" |