Skip to content

Commit

Permalink
Move exported function decls to libcue.h
Browse files Browse the repository at this point in the history
  • Loading branch information
lipnitsk committed Oct 26, 2015
1 parent 60d6342 commit 62a4b71
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 165 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ ADD_LIBRARY(cue SHARED ${CUE_SOURCES}
${FLEX_CueScanner_OUTPUTS})

SET_TARGET_PROPERTIES (cue
PROPERTIES VERSION ${PACKAGE_VERSION})
PROPERTIES VERSION ${PACKAGE_VERSION}
C_VISIBILITY_PRESET hidden)

INSTALL(TARGETS cue
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/ DESTINATION include/libcue
FILES_MATCHING PATTERN "*.h")
INSTALL(FILES ${CMAKE_SOURCE_DIR}/libcue.h DESTINATION include)

ENABLE_TESTING()
ADD_EXECUTABLE(standard_cue ${CMAKE_SOURCE_DIR}/t/standard_cue.c)
Expand Down
37 changes: 18 additions & 19 deletions cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void cd_set_mode(Cd *cd, int mode)
cd->mode = mode;
}

int cd_get_mode(Cd *cd)
enum DiscMode cd_get_mode(const Cd *cd)
{
return cd->mode;
}
Expand All @@ -168,12 +168,12 @@ void cd_set_cdtextfile(Cd *cd, char *cdtextfile)
cd->cdtextfile = strdup(cdtextfile);
}

char *cd_get_cdtextfile(Cd *cd)
char *cd_get_cdtextfile(const Cd *cd)
{
return cd->cdtextfile;
}

Cdtext *cd_get_cdtext(Cd *cd)
Cdtext *cd_get_cdtext(const Cd *cd)
{
if (cd != NULL)
return cd->cdtext;
Expand All @@ -182,7 +182,7 @@ Cdtext *cd_get_cdtext(Cd *cd)
}

Rem*
cd_get_rem( Cd* cd)
cd_get_rem(const Cd* cd)
{
if (cd != NULL)
return cd->rem;
Expand All @@ -203,13 +203,12 @@ Track *cd_add_track(Cd *cd)
return cd->track[cd->ntrack - 1];
}


int cd_get_ntrack(Cd *cd)
int cd_get_ntrack(const Cd *cd)
{
return cd->ntrack;
}

Track *cd_get_track(Cd *cd, int i)
Track *cd_get_track(const Cd *cd, int i)
{
if ((0 < i) && (i <= cd->ntrack) && (cd != NULL))
return cd->track[i - 1];
Expand All @@ -229,7 +228,7 @@ void track_set_filename(Track *track, char *filename)
track->file.name = strdup(filename);
}

char *track_get_filename(Track *track)
char *track_get_filename(const Track *track)
{
return track->file.name;
}
Expand All @@ -239,7 +238,7 @@ void track_set_start(Track *track, long start)
track->file.start = start;
}

long track_get_start(Track *track)
long track_get_start(const Track *track)
{
return track->file.start;
}
Expand All @@ -249,7 +248,7 @@ void track_set_length(Track *track, long length)
track->file.length = length;
}

long track_get_length(Track *track)
long track_get_length(const Track *track)
{
return track->file.length;
}
Expand All @@ -259,7 +258,7 @@ void track_set_mode(Track *track, int mode)
track->mode = mode;
}

int track_get_mode(Track *track)
enum TrackMode track_get_mode(const Track *track)
{
return track->mode;
}
Expand All @@ -269,7 +268,7 @@ void track_set_sub_mode(Track *track, int sub_mode)
track->sub_mode = sub_mode;
}

int track_get_sub_mode(Track *track)
enum TrackSubMode track_get_sub_mode(const Track *track)
{
return track->sub_mode;
}
Expand All @@ -284,7 +283,7 @@ void track_clear_flag(Track *track, int flag)
track->flags &= ~flag;
}

int track_is_set_flag(Track *track, int flag)
int track_is_set_flag(const Track *track, enum TrackFlag flag)
{
return track->flags & flag;
}
Expand All @@ -294,7 +293,7 @@ void track_set_zero_pre(Track *track, long length)
track->zero_pre.length = length;
}

long track_get_zero_pre(Track *track)
long track_get_zero_pre(const Track *track)
{
return track->zero_pre.length;
}
Expand All @@ -304,7 +303,7 @@ void track_set_zero_post(Track *track, long length)
track->zero_post.length = length;
}

long track_get_zero_post(Track *track)
long track_get_zero_post(const Track *track)
{
return track->zero_post.length;
}
Expand All @@ -316,12 +315,12 @@ void track_set_isrc(Track *track, char *isrc)
track->isrc = strdup(isrc);
}

char *track_get_isrc(Track *track)
char *track_get_isrc(const Track *track)
{
return track->isrc;
}

Cdtext *track_get_cdtext(Track *track)
Cdtext *track_get_cdtext(const Track *track)
{
if (track != NULL)
return track->cdtext;
Expand All @@ -330,7 +329,7 @@ Cdtext *track_get_cdtext(Track *track)
}

Rem*
track_get_rem( Track* track)
track_get_rem(const Track* track)
{
if (track != NULL)
return track->rem;
Expand All @@ -348,7 +347,7 @@ void track_set_index(Track *track, int i, long ind)
track->index[i] = ind;
}

long track_get_index(Track *track, int i)
long track_get_index(const Track *track, int i)
{
if ((0 <= i) && (i < MAXTRACK))
return track->index[i];
Expand Down
109 changes: 1 addition & 108 deletions cd.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,163 +9,56 @@
#ifndef CD_H
#define CD_H

#include "libcue.h"
#include "cdtext.h"
#include "rem.h"

#define MAXTRACK 99 /* Red Book track limit */
#define MAXINDEX 99 /* Red Book index limit */
#define PARSER_BUFFER 1024 /* Parser buffer size */

/*
* disc modes
* DATA FORM OF MAIN DATA (5.29.2.8)
*/
enum DiscMode {
MODE_CD_DA, /* CD-DA */
MODE_CD_ROM, /* CD-ROM mode 1 */
MODE_CD_ROM_XA /* CD-ROM XA and CD-I */
};

/*
* track modes
* 5.29.2.8 DATA FORM OF MAIN DATA
* Table 350 - Data Block Type Codes
*/
enum TrackMode {
MODE_AUDIO, /* 2352 byte block length */
MODE_MODE1, /* 2048 byte block length */
MODE_MODE1_RAW, /* 2352 byte block length */
MODE_MODE2, /* 2336 byte block length */
MODE_MODE2_FORM1, /* 2048 byte block length */
MODE_MODE2_FORM2, /* 2324 byte block length */
MODE_MODE2_FORM_MIX, /* 2332 byte block length */
MODE_MODE2_RAW /* 2352 byte block length */
};

/*
* sub-channel mode
* 5.29.2.13 Data Form of Sub-channel
* NOTE: not sure if this applies to cue files
*/
enum TrackSubMode {
SUB_MODE_RW, /* RAW Data */
SUB_MODE_RW_RAW /* PACK DATA (written R-W */
};

/*
* track flags
* Q Sub-channel Control Field (4.2.3.3, 5.29.2.2)
*/
enum TrackFlag {
FLAG_NONE = 0x00, /* no flags set */
FLAG_PRE_EMPHASIS = 0x01, /* audio recorded with pre-emphasis */
FLAG_COPY_PERMITTED = 0x02, /* digital copy permitted */
FLAG_DATA = 0x04, /* data track */
FLAG_FOUR_CHANNEL = 0x08, /* 4 audio channels */
FLAG_SCMS = 0x10, /* SCMS (not Q Sub-ch.) (5.29.2.7) */
FLAG_ANY = 0xff /* any flags set */
};

enum DataType {
DATA_AUDIO,
DATA_DATA,
DATA_FIFO,
DATA_ZERO
};

/* ADTs */
typedef struct Cd Cd;
typedef struct Track Track;

/* return pointer to CD structure */
Cd *cd_init(void);

Track *track_init(void);

void track_delete(struct Track* track);

void cd_delete(struct Cd* cd);

void cd_dump(Cd *cd);

/*
* Cd functions
*/

void cd_set_mode(Cd *cd, int mode);
int cd_get_mode(Cd *cd);

void cd_set_catalog(Cd *cd, char *catalog);
char *cd_get_catalog(Cd *cd);

void cd_set_cdtextfile(Cd *cd, char *cdtextfile);
char *cd_get_cdtextfile(Cd *cd);

/*
* return pointer to cd's Cdtext
*/
Cdtext *cd_get_cdtext(Cd *cd);

Rem* cd_get_rem(Cd* cd);

/*
* add a new track to cd, increment number of tracks
* and return pointer to new track
*/
Track *cd_add_track(Cd *cd);

/*
* return number of tracks in cd
*/
int cd_get_ntrack(Cd *cd);

Track *cd_get_track(Cd *cd, int i);

/*
* Track functions
*/

/* filename of data file */
void track_set_filename(Track *track, char *filename);
char *track_get_filename(Track *track);

/* track start is starting position in data file */
void track_set_start(Track *track, long start);
long track_get_start(Track *track);

/* track length is length of data file to use */
void track_set_length(Track *track, long length);
long track_get_length(Track *track);

/* see enum TrackMode */
void track_set_mode(Track *track, int mode);
int track_get_mode(Track *track);

/* see enum TrackSubMode */
void track_set_sub_mode(Track *track, int sub_mode);
int track_get_sub_mode(Track *track);

/* see enum TrackFlag */
void track_set_flag(Track *track, int flag);
void track_clear_flag(Track *track, int flag);
int track_is_set_flag(Track *track, int flag);

/* zero data pregap */
void track_set_zero_pre(Track *track, long length);
long track_get_zero_pre(Track *track);

/* zero data postgap */
void track_set_zero_post(Track *track, long length);
long track_get_zero_post(Track *track);

void track_set_isrc(Track *track, char *isrc);
char *track_get_isrc(Track *track);

Cdtext *track_get_cdtext(Track *track);

Rem* track_get_rem(Track* track);

void track_set_index(Track *track, int i, long index);
long track_get_index(Track *track, int i);

#endif
2 changes: 1 addition & 1 deletion cdtext.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void cdtext_set(int pti, char *value, Cdtext *cdtext)
}

/* returns value for pti, NULL if pti is not found */
char *cdtext_get(int pti, Cdtext *cdtext)
char *cdtext_get(enum Pti pti, const Cdtext *cdtext)
{
for (; PTI_END != cdtext->pti; cdtext++)
if (pti == cdtext->pti)
Expand Down
28 changes: 1 addition & 27 deletions cdtext.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,13 @@
#ifndef CDTEXT_H
#define CDTEXT_H

#include <stdio.h>

/* cdtext pack type indicators */
enum Pti {
PTI_TITLE, /* title of album or track titles */
PTI_PERFORMER, /* name(s) of the performer(s) */
PTI_SONGWRITER, /* name(s) of the songwriter(s) */
PTI_COMPOSER, /* name(s) of the composer(s) */
PTI_ARRANGER, /* name(s) of the arranger(s) */
PTI_MESSAGE, /* message(s) from the content provider and/or artist */
PTI_DISC_ID, /* (binary) disc identification information */
PTI_GENRE, /* (binary) genre identification and genre information */
PTI_TOC_INFO1, /* (binary) table of contents information */
PTI_TOC_INFO2, /* (binary) second table of contents information */
PTI_RESERVED1, /* reserved */
PTI_RESERVED2, /* reserved */
PTI_RESERVED3, /* reserved */
PTI_RESERVED4, /* reserved for content provider only */
PTI_UPC_ISRC, /* UPC/EAN code of the album and ISRC code of each track */
PTI_SIZE_INFO, /* (binary) size information of the block */
PTI_END /* terminating PTI (for stepping through PTIs) */
};
#include "libcue.h"

enum PtiFormat {
FORMAT_CHAR, /* single or double byte character string */
FORMAT_BINARY /* binary data */
};

typedef struct Cdtext Cdtext;

/* return a pointer to a new Cdtext */
Cdtext *cdtext_init(void);

Expand All @@ -51,9 +28,6 @@ int cdtext_is_empty(Cdtext *cdtext);
/* set CD-TEXT field to value for PTI pti */
void cdtext_set(int pti, char *value, Cdtext *cdtext);

/* returns pointer to CD-TEXT value for PTI pti */
char *cdtext_get(int pti, Cdtext *cdtext);

/*
* returns appropriate string for PTI pti
* if istrack is zero, UPC/EAN string will be returned for PTI_UPC_ISRC
Expand Down
Loading

0 comments on commit 62a4b71

Please sign in to comment.