Adding C++ support to libopensubsonic

This commit is contained in:
2025-10-06 18:23:09 +10:00
parent 0b934f50af
commit eba7bf2252
13 changed files with 100 additions and 14 deletions

View File

@@ -1,6 +1,10 @@
#ifndef _ENDPOINT_GETALBUM_H
#define _ENDPOINT_GETALBUM_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct {
char* id;
char* parent;
@@ -49,4 +53,8 @@ typedef struct {
int opensubsonic_getAlbum_parse(char* data, opensubsonic_getAlbum_struct** getAlbumStruct);
void opensubsonic_getAlbum_struct_free(opensubsonic_getAlbum_struct** getAlbumStruct);
#endif
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _ENDPOINT_GETALBUM_H

View File

@@ -1,6 +1,10 @@
#ifndef _ENDPOINT_GETALBUMLIST_H
#define _ENDPOINT_GETALBUMLIST_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct {
char* id;
char* parent;
@@ -30,4 +34,8 @@ typedef struct {
int opensubsonic_getAlbumList_parse(char* data, opensubsonic_getAlbumList_struct** getAlbumListStruct);
void opensubsonic_getAlbumList_struct_free(opensubsonic_getAlbumList_struct** getAlbumListStruct);
#endif
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _ENDPOINT_GETALBUMLIST_H

View File

@@ -1,6 +1,10 @@
#ifndef _ENDPOINT_GETARTIST_H
#define _ENDPOINT_GETARTIST_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct {
char* id; // Album ID
char* parent; // Parent ID
@@ -38,4 +42,8 @@ typedef struct {
int opensubsonic_getArtist_parse(char* data, opensubsonic_getArtist_struct** getArtistStruct);
void opensubsonic_getArtist_struct_free(opensubsonic_getArtist_struct** getArtistStruct);
#endif
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _ENDPOINT_GETARTIST_H

View File

@@ -1,6 +1,10 @@
#ifndef _ENDPOINT_GETARTISTS_H
#define _ENDPOINT_GETARTISTS_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct {
char* id;
char* name;
@@ -19,4 +23,8 @@ typedef struct {
int opensubsonic_getArtists_parse(char* data, opensubsonic_getArtists_struct** getArtistsStruct);
void opensubsonic_getArtists_struct_free(opensubsonic_getArtists_struct** getArtistsStruct);
#endif
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _ENDPOINT_GETARTISTS_H

View File

@@ -1,6 +1,10 @@
#ifndef _ENDPOINT_GETLYRICSBYSONGID_H
#define _ENDPOINT_GETLYRICSBYSONGID_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct {
char* data;
long offset;
@@ -19,4 +23,8 @@ typedef struct {
int opensubsonic_getLyricsBySongId_parse(char* data, opensubsonic_getLyricsBySongId_struct** getLyricsBySongIdStruct);
void opensubsonic_getLyricsBySongId_struct_free(opensubsonic_getLyricsBySongId_struct** getLyricsBySongIdStruct);
#endif
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _ENDPOINT_GETLYRICSBYSONGID_H

View File

@@ -2,6 +2,10 @@
#define _ENDPOINT_GETPLAYLIST_H
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct {
char* id;
char* parent;
@@ -46,4 +50,8 @@ typedef struct {
int opensubsonic_getPlaylist_parse(char* data, opensubsonic_getPlaylist_struct** getPlaylistStruct);
void opensubsonic_getPlaylist_struct_free(opensubsonic_getPlaylist_struct** getPlaylistStruct);
#endif
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _ENDPOINT_GETPLAYLIST_H

View File

@@ -1,6 +1,10 @@
#ifndef _ENDPOINT_GETPLAYLISTS_H
#define _ENDPOINT_GETPLAYLISTS_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct {
char* id; // Album ID
char* name; // Album name
@@ -23,4 +27,8 @@ typedef struct {
int opensubsonic_getPlaylists_parse(char* data, opensubsonic_getPlaylists_struct** getPlaylistsStruct);
void opensubsonic_getPlaylists_struct_free(opensubsonic_getPlaylists_struct** getPlaylistsStruct);
#endif
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _ENDPOINT_GETPLAYLISTS_H

View File

@@ -1,6 +1,10 @@
#ifndef _ENDPOINT_GETSONG_H
#define _ENDPOINT_GETSONG_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct {
char* status; // Request status
int errorCode; // Request error code (0 if none)
@@ -36,4 +40,8 @@ typedef struct {
int opensubsonic_getSong_parse(char* data, opensubsonic_getSong_struct** getSongStruct);
void opensubsonic_getSong_struct_free(opensubsonic_getSong_struct** getSongStruct);
#endif
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _ENDPOINT_GETSONG_H

View File

@@ -1,6 +1,10 @@
#ifndef _ENDPOINT_GETSTARRED_H
#define _ENDPOINT_GETSTARRED_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct {
char* id;
char* name;
@@ -68,4 +72,8 @@ typedef struct {
int opensubsonic_getStarred_parse(char* data, opensubsonic_getStarred_struct** getStarredStruct);
void opensubsonic_getStarred_struct_free(opensubsonic_getStarred_struct** getStarredStruct);
#endif
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _ENDPOINT_GETSTARRED_H

View File

@@ -3,6 +3,10 @@
#include <stdbool.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
typedef struct {
char* status;
char* version;
@@ -17,4 +21,8 @@ typedef struct {
int opensubsonic_ping_parse(char* data, opensubsonic_ping_struct** pingStruct);
void opensubsonic_ping_struct_free(opensubsonic_ping_struct** pingStruct);
#endif
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _ENDPOINT_PING_H

View File

@@ -3,6 +3,10 @@
#include <stdio.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#define SCROBBLER_LISTENBRAINZ 101
#define SCROBBLER_LASTFM 102
#define HTTP_METHOD_GET 201
@@ -72,4 +76,8 @@ typedef struct {
int opensubsonic_getAlbum(const char* protocol_ptr, const char* server_ptr, const char* user_ptr, char* login_token_ptr, char* login_salt_ptr, const char* opensubsonic_version_ptr, const char* client_name_ptr, char* id, char** response);
#endif
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // _HTTPCLIENT_H

View File

@@ -8,7 +8,6 @@
#include "../external/md5.h"
#include "../external/libcurl_uriescape.h"
#include "../configHandler.h"
#include "../DarwinHttpClient.h"
#include "../configHandler.h"
const char* lastFmScrobbleURL = "https://ws.audioscrobbler.com/2.0/";

View File

@@ -7,7 +7,6 @@
#include "endpoint_getSong.h"
#include "httpclient.h"
#include "scrobble_listenBrainz.h"
#include "../DarwinHttpClient.h"
const char* listenBrainzScrobbleURL = "https://api.listenbrainz.org/1/submit-listens";