Skip to content

Commit

Permalink
Switch cue_utils to new cue parser
Browse files Browse the repository at this point in the history
  • Loading branch information
mahkoh committed Oct 16, 2016
1 parent b7d60b3 commit 85237ec
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 34 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ mpris.o: CFLAGS += $(LIBSYSTEMD_CFLAGS)
# programs {{{
cmus-y := \
ape.o browser.o buffer.o cache.o channelmap.o cmdline.o cmus.o command_mode.o \
comment.o convert.lo cue.o debug.o discid.o editable.o expr.o \
comment.o convert.lo cue.o cue_utils.o debug.o discid.o editable.o expr.o \
filters.o format_print.o gbuf.o glob.o help.o history.o http.o id3.o input.o \
job.o keys.o keyval.o lib.o load_dir.o locking.o mergesort.o misc.o options.o \
output.o pcm.o player.o play_queue.o pl.o rbtree.o read_wrapper.o search_mode.o \
search.o server.o spawn.o tabexp_file.o tabexp.o track_info.o track.o tree.o \
uchar.o u_collate.o ui_curses.o window.o worker.o xstrjoin.o

cmus-$(CONFIG_CUE) += cue_utils.o
cmus-$(CONFIG_MPRIS) += mpris.o

$(cmus-y): CFLAGS += $(PTHREAD_CFLAGS) $(NCURSES_CFLAGS) $(ICONV_CFLAGS) $(DL_CFLAGS)
Expand Down
25 changes: 5 additions & 20 deletions cue_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "utils.h"
#include "cue_utils.h"
#include "xmalloc.h"
#include "cue.h"

#include <stdio.h>

Expand Down Expand Up @@ -51,27 +52,11 @@ char *associated_cue(const char *filename)

int cue_get_ntracks(const char *filename)
{
int n;
FILE *cue;
Cd *cd;

cue = fopen(filename, "r");
if (cue == NULL)
return -1;

disable_stdio();
cd = cue_parse_file(cue);
enable_stdio();
if (cd == NULL) {
fclose(cue);
struct cue_sheet *cd = cue_from_file(filename);
if (!cd)
return -1;
}

n = cd_get_ntrack(cd);

cd_delete(cd);
fclose(cue);

size_t n = cd->num_tracks;
cue_free(cd);
return n;
}

Expand Down
12 changes: 0 additions & 12 deletions cue_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@

#include <stdio.h>

#include "config/cue.h"

/*
* warning: this header does not contain include guards!
*/
#ifdef CONFIG_CUE2
#include <libcue.h>
#else
#include <libcue/libcue.h>
#endif


char *associated_cue(const char *filename);
int cue_get_ntracks(const char *filename);
char *construct_cue_url(const char *cue_filename, int track_n);
Expand Down
9 changes: 9 additions & 0 deletions ip/cue.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@
#include "comment.h"
#include "xmalloc.h"
#include "cue_utils.h"
#include "config/cue.h"

#include <stdio.h>
#include <fcntl.h>

/*
* warning: this header does not contain include guards!
*/
#ifdef CONFIG_CUE2
#include <libcue.h>
#else
#include <libcue/libcue.h>
#endif

struct cue_private {
struct input_plugin *child;
Expand Down

0 comments on commit 85237ec

Please sign in to comment.