Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ SET(libdiscid_MAJOR 0)
SET(libdiscid_MINOR 6)
SET(libdiscid_PATCH 5)

# Build options
OPTION(ENABLE_USE_HTTPS "Enable creating HTTPS URLs" OFF)


SET(libdiscid_VERSION ${libdiscid_MAJOR}.${libdiscid_MINOR}.${libdiscid_PATCH})
SET(libdiscid_SOVERSION ${libdiscid_MAJOR})
Expand Down Expand Up @@ -107,6 +110,9 @@ SET_TARGET_PROPERTIES(libdiscid PROPERTIES
)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include ${MUSICBRAINZ5_INCLUDE_DIRS})
IF(ENABLE_USE_HTTPS)
TARGET_COMPILE_DEFINITIONS(libdiscid PUBLIC DISCID_USE_HTTPS)
ENDIF()

ADD_EXECUTABLE(discid examples/discid.c)
TARGET_LINK_LIBRARIES(discid libdiscid)
Expand Down
26 changes: 26 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,38 @@ Optional API documentation in HTML format is created by Doxygen with:

make docs


Compiler flags
--------------

The following defines can be used to change the build:

DISCID_USE_HTTPS: If set, the functions discid_get_submission_url and
discid_get_webservice_url will generate URLs using the HTTPS protocol instead
of HTTP. This might break existing applications that rely on the exact URL
structure being returned.

To enable this feature when using CMake, change the cmake command from above to:

cmake -DENABLE_USE_HTTPS=ON …

To enable this feature when using Autotools, change the configure command from above to:

../configure --enable-use-https=yes

NOTE: Having DISCID_USE_HTTPS enabled will become the default in a future release.
Please prepare your code to not rely on the specific URL protocol for URLs
generated by libdiscid.


Building from git repository
----------------------------
If you fetched the source with git, you should either
use Cmake (no difference to the source distribution)
or have autoconf, automake and libtool installed and do ./autogen.sh
before doing the usual build.


Tips for Windows
----------------
For most systems cmake and autotools work (nearly) "out of the box".
Expand All @@ -51,6 +76,7 @@ Building with NMake (MS Visual Studio command line):
cmake -G "NMake Makefiles" ..
nmake


Notes for BSD
-------------
With Cmake builds the library version/soname will work the same as on Linux.
Expand Down
10 changes: 9 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ define(PATCH, 5)
# so we use the library version also as project version
AC_INIT([libdiscid],[MAJOR.MINOR.PATCH])

AC_ARG_ENABLE([use_https],
AS_HELP_STRING([--enable-use-https], [Enable creating HTTPS URLs]),
[use_https=$enableval],
[use_https=no]
)

AC_CONFIG_SRCDIR([src/disc.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_AUX_DIR([build-aux]) # where to put config.guess etc.
Expand Down Expand Up @@ -42,7 +48,9 @@ dnl Set the host_cpu, host_vendor, and host_os variables.
AC_CANONICAL_HOST

AC_DEFINE(libdiscid_EXPORTS, [], "the header is used to create the library")

if test "x$use_https" = "xyes"; then
AC_DEFINE([DISCID_USE_HTTPS], [1], [Define to 1 if use_https is enabled])
fi

case "${host_cpu}-${host_os}" in
*-haiku*) os=haiku;;
Expand Down
16 changes: 13 additions & 3 deletions include/discid/discid_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,18 @@
#ifndef MUSICBRAINZ_DISC_ID_PRIVATE_H
#define MUSICBRAINZ_DISC_ID_PRIVATE_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "discid/discid.h"

#ifdef DISCID_USE_HTTPS
#define MB_URL_PROTOCOL "https"
#else
#define MB_URL_PROTOCOL "http"
#endif

/* Length of toc string, "xxx+xxx" + 100 tracks 7 bytes each ("+xxxxxx")
* The highest possible offset is 90 minutes * 60 seconds/minute * 75 frames/second = 405000.
* That is 6 digits plus one plus sign = 7 characters per track.
Expand All @@ -52,10 +62,10 @@
#define MB_MAX_URL_LENGTH (MB_URL_PREFIX_LENGTH + MB_DISC_ID_LENGTH + MB_TOC_STRING_LENGTH)

/* The URL that can be used for submitting DiscIDs (no parameters yet) */
#define MB_SUBMISSION_URL "https://musicbrainz.org/cdtoc/attach"
#define MB_SUBMISSION_URL MB_URL_PROTOCOL"://musicbrainz.org/cdtoc/attach"

/* The URL that can be used for retrieving XML for a CD */
#define MB_WEBSERVICE_URL "https://musicbrainz.org/ws/1/release"
#define MB_WEBSERVICE_URL MB_URL_PROTOCOL"://musicbrainz.org/ws/1/release"

/* Maximum length of a Media Catalogue Number string */
#define MCN_STR_LENGTH 13
Expand Down Expand Up @@ -117,7 +127,7 @@ LIBDISCID_INTERNAL int mb_disc_read_unportable(mb_disc_private *disc, const char


/*
* This should return the name of the default/preferred CDROM/DVD device
* This should return the name of the default/preferred CDROM/DVD device
* on this operating system. It has to be in a format usable for the second
* parameter of mb_disc_read_unportable().
*/
Expand Down
5 changes: 3 additions & 2 deletions test/test_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <string.h>

#include <discid/discid.h>
#include <discid/discid_private.h>
#include "test.h"


Expand Down Expand Up @@ -100,14 +101,14 @@ int main(int argc, char *argv[]) {

/* MusicBrainz web submit URL */
announce("discid_get_submission_url");
expected = "https://musicbrainz.org/cdtoc/attach?id=xUp1F2NkfP8s8jaeFn_Av3jNEI4-&tracks=22&toc=1+22+303602+150+9700+25887+39297+53795+63735+77517+94877+107270+123552+135522+148422+161197+174790+192022+205545+218010+228700+239590+255470+266932+288750";
expected = MB_URL_PROTOCOL "://musicbrainz.org/cdtoc/attach?id=xUp1F2NkfP8s8jaeFn_Av3jNEI4-&tracks=22&toc=1+22+303602+150+9700+25887+39297+53795+63735+77517+94877+107270+123552+135522+148422+161197+174790+192022+205545+218010+228700+239590+255470+266932+288750";
evaluate(equal_str(discid_get_submission_url(d), expected));

announce("discid_get_error_msg");
evaluate(strlen(discid_get_error_msg(d)) == 0);

discid_free(d);

return !test_result();
}

Expand Down