diff --git a/src/cmdline.c b/src/cmdline.c index 10de9a4..6479a7e 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -153,7 +153,7 @@ cmdline_parse(int argc, char *argv[], int *ret_p) cfg_set_program_verbosity(verbosity, NULL); if (playlistFile) { - playlist_t *pl; + playlist_t pl; const char *entry; if (0 > playlist_init()) { diff --git a/src/ezstream.c b/src/ezstream.c index 5532925..bc1a3a6 100644 --- a/src/ezstream.c +++ b/src/ezstream.c @@ -41,26 +41,26 @@ #define STREAM_SERVERR 3 #define STREAM_UPDMDATA 4 -playlist_t *playlist = NULL; -int playlistMode = 0; -unsigned int resource_errors = 0; +playlist_t playlist; +int playlistMode; +unsigned int resource_errors; #ifdef HAVE_SIGNALS const int ezstream_signals[] = { SIGTERM, SIGINT, SIGHUP, SIGUSR1, SIGUSR2 }; -volatile sig_atomic_t rereadPlaylist = 0; -volatile sig_atomic_t rereadPlaylist_notify = 0; -volatile sig_atomic_t skipTrack = 0; -volatile sig_atomic_t queryMetadata = 0; -volatile sig_atomic_t quit = 0; +volatile sig_atomic_t rereadPlaylist; +volatile sig_atomic_t rereadPlaylist_notify; +volatile sig_atomic_t skipTrack; +volatile sig_atomic_t queryMetadata; +volatile sig_atomic_t quit; #else -int rereadPlaylist = 0; -int rereadPlaylist_notify = 0; -int skipTrack = 0; -int queryMetadata = 0; -int quit = 0; +int rereadPlaylist; +int rereadPlaylist_notify; +int skipTrack; +int queryMetadata; +int quit; #endif /* HAVE_SIGNALS */ typedef struct tag_ID3Tag { diff --git a/src/playlist.c b/src/playlist.c index e386863..305951f 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -39,24 +39,24 @@ struct playlist { char *prog_track; }; -static playlist_t * playlist_create(const char *); -static int playlist_add(playlist_t *, const char *); -static unsigned int playlist_random(void); -static const char * playlist_run_program(playlist_t *); +static struct playlist * _playlist_create(const char *); +static int _playlist_add(struct playlist *, const char *); +static unsigned int _playlist_random(void); +static const char * _playlist_run_program(struct playlist *); -static playlist_t * -playlist_create(const char *filename) +static struct playlist * +_playlist_create(const char *filename) { - playlist_t *pl; + struct playlist *pl; - pl = xcalloc(1UL, sizeof(playlist_t)); + pl = xcalloc(1UL, sizeof(*pl)); pl->filename = xstrdup(filename); return (pl); } static int -playlist_add(playlist_t *pl, const char *entry) +_playlist_add(struct playlist *pl, const char *entry) { size_t num; @@ -84,7 +84,7 @@ playlist_add(playlist_t *pl, const char *entry) } static unsigned int -playlist_random(void) +_playlist_random(void) { unsigned int ret = 0; @@ -100,7 +100,7 @@ playlist_random(void) } static const char * -playlist_run_program(playlist_t *pl) +_playlist_run_program(struct playlist *pl) { FILE *filep; char buf[PATH_MAX]; @@ -173,16 +173,16 @@ playlist_init(void) void playlist_exit(void) {} -playlist_t * +struct playlist * playlist_read(const char *filename) { - playlist_t *pl; + struct playlist *pl; unsigned long line; FILE *filep; char buf[PATH_MAX]; if (filename != NULL) { - pl = playlist_create(filename); + pl = _playlist_create(filename); if ((filep = fopen(filename, "r")) == NULL) { log_error("%s: %s", filename, strerror(errno)); @@ -190,7 +190,7 @@ playlist_read(const char *filename) return (NULL); } } else { - pl = playlist_create("stdin"); + pl = _playlist_create("stdin"); if ((filep = fdopen(STDIN_FILENO, "r")) == NULL) { log_error("stdin: %s", strerror(errno)); @@ -233,7 +233,7 @@ playlist_read(const char *filename) continue; /* We got one. */ - if (!playlist_add(pl, buf)) { + if (!_playlist_add(pl, buf)) { fclose(filep); playlist_free(&pl); return (NULL); @@ -251,17 +251,17 @@ playlist_read(const char *filename) return (pl); } -playlist_t * +struct playlist * playlist_program(const char *filename) { - playlist_t *pl; + struct playlist *pl; #ifdef HAVE_STAT struct stat st; #else FILE *filep; #endif - pl = playlist_create(filename); + pl = _playlist_create(filename); pl->program = 1; #ifdef HAVE_STAT @@ -294,10 +294,10 @@ playlist_program(const char *filename) } void -playlist_free(playlist_t **pl_p) +playlist_free(struct playlist **pl_p) { size_t i; - playlist_t *pl; + struct playlist *pl; if (pl_p == NULL || (pl = *pl_p) == NULL) return; @@ -330,10 +330,10 @@ playlist_free(playlist_t **pl_p) } const char * -playlist_get_next(playlist_t *pl) +playlist_get_next(struct playlist *pl) { if (pl->program) - return (playlist_run_program(pl)); + return (_playlist_run_program(pl)); if (pl->num == 0) return (NULL); @@ -342,7 +342,7 @@ playlist_get_next(playlist_t *pl) } const char * -playlist_peek_next(playlist_t *pl) +playlist_peek_next(struct playlist *pl) { if (pl->program || pl->num == 0) return (NULL); @@ -351,7 +351,7 @@ playlist_peek_next(playlist_t *pl) } void -playlist_skip_next(playlist_t *pl) +playlist_skip_next(struct playlist *pl) { if (pl->program || pl->num == 0) return; @@ -361,7 +361,7 @@ playlist_skip_next(playlist_t *pl) } unsigned long -playlist_get_num_items(playlist_t *pl) +playlist_get_num_items(struct playlist *pl) { if (pl->program) return (0); @@ -370,7 +370,7 @@ playlist_get_num_items(playlist_t *pl) } unsigned long -playlist_get_position(playlist_t *pl) +playlist_get_position(struct playlist *pl) { if (pl->program) return (0); @@ -379,7 +379,7 @@ playlist_get_position(playlist_t *pl) } int -playlist_set_position(playlist_t *pl, unsigned long idx) +playlist_set_position(struct playlist *pl, unsigned long idx) { if (pl->program || idx > pl->num - 1) return (0); @@ -390,7 +390,7 @@ playlist_set_position(playlist_t *pl, unsigned long idx) } int -playlist_goto_entry(playlist_t *pl, const char *entry) +playlist_goto_entry(struct playlist *pl, const char *entry) { unsigned long i; @@ -408,7 +408,7 @@ playlist_goto_entry(playlist_t *pl, const char *entry) } void -playlist_rewind(playlist_t *pl) +playlist_rewind(struct playlist *pl) { if (pl->program) return; @@ -417,9 +417,9 @@ playlist_rewind(playlist_t *pl) } int -playlist_reread(playlist_t **plist) +playlist_reread(struct playlist **plist) { - playlist_t *new_pl, *pl; + struct playlist *new_pl, *pl; pl = *plist; @@ -439,7 +439,7 @@ playlist_reread(playlist_t **plist) * Yet another implementation of the "Knuth Shuffle": */ void -playlist_shuffle(playlist_t *pl) +playlist_shuffle(struct playlist *pl) { size_t d, i, range; char *temp; @@ -455,7 +455,7 @@ playlist_shuffle(playlist_t *pl) * largest multiple of our range. This reduces PRNG bias. */ do { - d = (unsigned long)playlist_random(); + d = (unsigned long)_playlist_random(); } while (d > RAND_MAX - (RAND_MAX % range)); /* diff --git a/src/playlist.h b/src/playlist.h index 166c075..80e72b4 100644 --- a/src/playlist.h +++ b/src/playlist.h @@ -17,7 +17,7 @@ #ifndef __PLAYLIST_H__ #define __PLAYLIST_H__ -typedef struct playlist playlist_t; +typedef struct playlist * playlist_t; /* * Initialize the playlist routines. Should be called before any of the other @@ -34,26 +34,26 @@ void playlist_exit(void); * Read a playlist file (in .M3U format), and return a new playlist handler * on success, or NULL on failure. */ -playlist_t * playlist_read(const char * /* filename */); +playlist_t playlist_read(const char * /* filename */); /* * For each call to playlist_get_next(), the specified program is run. This * program is supposed to print one line to standard output, containing the * path and filename of a media file. */ -playlist_t * playlist_program(const char * /* program name */); +playlist_t playlist_program(const char * /* program name */); /* * Free all memory used by a playlist handler that was created with * playlist_read(). */ -void playlist_free(playlist_t **); +void playlist_free(playlist_t *); /* * Get the next item in the playlist. Returns a NUL-terminated string of a * playlist entry, or NULL if the end of the list has been reached. */ -const char * playlist_get_next(playlist_t *); +const char * playlist_get_next(playlist_t); /* * The functions below work on playlist handlers obtained with playlist_read() @@ -65,40 +65,40 @@ const char * playlist_get_next(playlist_t *); * Returns a NUL-terminated string of the next playlist entry, or NULL if the * currently playing song is the last one in the list. */ -const char * playlist_peek_next(playlist_t *); +const char * playlist_peek_next(playlist_t); /* * Skip the playlist item that would be played next. */ -void playlist_skip_next(playlist_t *); +void playlist_skip_next(playlist_t); /* * Get the number of items in the playlist. */ -unsigned long playlist_get_num_items(playlist_t *); +unsigned long playlist_get_num_items(playlist_t); /* * Get the current position in the playlist. */ -unsigned long playlist_get_position(playlist_t *); +unsigned long playlist_get_position(playlist_t); /* * Set a position in the playlist. Returns 1 on success, and 0 on failure. */ -int playlist_set_position(playlist_t *, unsigned long /* index */); +int playlist_set_position(playlist_t, unsigned long /* index */); /* * Search for a given entry in the playlist and reposition to it. Returns 1 on * success and 0 on failure. A subsequent call to playlist_get_next() will * return this list item again. */ -int playlist_goto_entry(playlist_t *, const char * /* name */); +int playlist_goto_entry(playlist_t, const char * /* name */); /* * Rewind the playlist to the beginning, so that it can be replayed. Does * not reread the playlist file. */ -void playlist_rewind(playlist_t *); +void playlist_rewind(playlist_t); /* * Reread the playlist file and rewind to the beginning. Equivalent to calling @@ -106,11 +106,11 @@ void playlist_rewind(playlist_t *); * after calling this function. * Returns 1 on success, and 0 on error. */ -int playlist_reread(playlist_t **); +int playlist_reread(playlist_t*); /* * Shuffle the entries of the playlist randomly. */ -void playlist_shuffle(playlist_t *); +void playlist_shuffle(playlist_t); #endif /* __PLAYLIST_H__ */