Fix headers, install mastodont-c!
FossilOrigin-Name: 60775398f43557f6a0e528ca684fa1ad9cd90247a943d7ddf4385405287a869b
This commit is contained in:
parent
98cc03f303
commit
1c5ee031c9
6 changed files with 68 additions and 38 deletions
|
@ -1,7 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
project(mastodont-c
|
||||
VERSION 0.0
|
||||
DESCRIPTION "Terrible library for Mastodon and Pleroma 'n Friends"
|
||||
project(mastodont
|
||||
VERSION 0.1
|
||||
DESCRIPTION "Library for Mastodon, Pleroma, Wormhole, etc."
|
||||
LANGUAGES C)
|
||||
|
||||
# Useful
|
||||
|
@ -9,9 +9,44 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(CURL REQUIRED)
|
||||
add_library(mastodont-c STATIC)
|
||||
add_library(mastodont STATIC)
|
||||
|
||||
target_sources(mastodont-c PUBLIC
|
||||
set(HEADERS_FILES
|
||||
include/mastodont_account.h
|
||||
include/mastodont_announcement.h
|
||||
include/mastodont_application.h
|
||||
include/mastodont_attachment.h
|
||||
include/mastodont_chats.h
|
||||
include/mastodont_codes.h
|
||||
include/mastodont_emoji.h
|
||||
include/mastodont_error.h
|
||||
include/mastodont_fetch.h
|
||||
include/mastodont_generate.h
|
||||
include/mastodont_history.h
|
||||
include/mastodont_hooks.h
|
||||
include/mastodont_instance.h
|
||||
include/mastodont_json_helper.h
|
||||
include/mastodont_list.h
|
||||
include/mastodont_mention.h
|
||||
include/mastodont_nodeinfo.h
|
||||
include/mastodont_notif_types.h
|
||||
include/mastodont_notification.h
|
||||
include/mastodont_pleroma.h
|
||||
include/mastodont_query.h
|
||||
include/mastodont_relationship.h
|
||||
include/mastodont_request.h
|
||||
include/mastodont_scrobbles.h
|
||||
include/mastodont_search.h
|
||||
include/mastodont_status.h
|
||||
include/mastodont_tag.h
|
||||
include/mastodont_timeline.h
|
||||
include/mastodont_types.h
|
||||
include/mastodont_uri.h
|
||||
include/mastodont_visibility_types.h
|
||||
include/mastodont.h
|
||||
)
|
||||
|
||||
target_sources(mastodont PUBLIC
|
||||
src/account.c
|
||||
src/application.c
|
||||
src/attachment.c
|
||||
|
@ -42,17 +77,17 @@ target_sources(mastodont-c PUBLIC
|
|||
libs/cjson/cJSON.c
|
||||
)
|
||||
|
||||
target_compile_options(mastodont-c PUBLIC
|
||||
target_compile_options(mastodont PUBLIC
|
||||
-Wall -Wextra -std=c99
|
||||
-Wshadow -Wcast-align -Wstrict-prototypes
|
||||
)
|
||||
|
||||
target_link_options(mastodont-c PUBLIC
|
||||
target_link_options(mastodont PUBLIC
|
||||
-lmastodont
|
||||
${CURL_LDFLAGS_OTHER}
|
||||
)
|
||||
|
||||
target_include_directories(mastodont-c PUBLIC
|
||||
target_include_directories(mastodont PUBLIC
|
||||
include/
|
||||
${CURL_INCLUDE_DIRS}
|
||||
|
||||
|
@ -60,3 +95,8 @@ target_include_directories(mastodont-c PUBLIC
|
|||
libs/
|
||||
)
|
||||
|
||||
install(FILES ${HEADER_FILES} DESTINATION include/mastodont/)
|
||||
install(TARGETS mastodont LIBRARY DESTINATION lib)
|
||||
# TODO
|
||||
#install(FILES MastodontConfig.cmake DESTINATION lib/cmake/mastodont)
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
#[=======================================================================[.rst:
|
||||
FindMastodont
|
||||
--------
|
||||
|
||||
Find the Mastodont library.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following variables:
|
||||
|
||||
``CURL_FOUND``
|
||||
``CURL_INCLUDE_DIRS``
|
||||
``CURL_LIBRARIES``
|
||||
``CURL_VERSION_STRING``
|
||||
|
||||
#]=======================================================================]
|
||||
|
|
@ -19,9 +19,11 @@
|
|||
#include <mastodont_chats.h>
|
||||
|
||||
/// Initializes libcurl
|
||||
void mstdnt_global_curl_init();
|
||||
void
|
||||
mstdnt_global_curl_init(void);
|
||||
/// Cleans up libcurl
|
||||
void mstdnt_global_curl_cleanup();
|
||||
void
|
||||
mstdnt_global_curl_cleanup(void);
|
||||
|
||||
/**
|
||||
* Initializes a mstdnt struct
|
||||
|
@ -29,14 +31,16 @@ void mstdnt_global_curl_cleanup();
|
|||
* @param data Pointer to struct to fill in
|
||||
* @return Value of curl_easy_init(); either Zero or non-zero
|
||||
*/
|
||||
int mstdnt_init(mastodont_t* data);
|
||||
int
|
||||
mstdnt_init(mastodont_t* data);
|
||||
|
||||
/**
|
||||
* Cleans up the mstdnt struct
|
||||
*
|
||||
* @param data Pointer to the mstdnt data
|
||||
*/
|
||||
void mstdnt_cleanup(mastodont_t* data);
|
||||
void
|
||||
mstdnt_cleanup(mastodont_t* data);
|
||||
|
||||
/**
|
||||
* Cleans up a storage struct.
|
||||
|
@ -45,6 +49,7 @@ void mstdnt_cleanup(mastodont_t* data);
|
|||
*
|
||||
* @param storage The storage block to cleanup
|
||||
*/
|
||||
void mstdnt_storage_cleanup(struct mstdnt_storage* storage);
|
||||
void
|
||||
mstdnt_storage_cleanup(struct mstdnt_storage *storage);
|
||||
|
||||
#endif /* MASTODONT_H */
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#ifndef MASTODONT_SCROBBLES_H
|
||||
#define MASTODONT_SCROBBLES_H
|
||||
#include <stddef.h>
|
||||
#include <mastodont.h>
|
||||
#include <mastodont_types.h>
|
||||
#include <mastodont_account.h>
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#ifndef MASTODONT_SEARCH_H
|
||||
#define MASTODONT_SEARCH_H
|
||||
#include "mastodont.h"
|
||||
#include "mastodont_types.h"
|
||||
|
||||
enum mstdnt_search_type
|
||||
|
|
|
@ -3,29 +3,34 @@
|
|||
#include <mastodont.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
void mstdnt_global_curl_init()
|
||||
void
|
||||
mstdnt_global_curl_init(void)
|
||||
{
|
||||
curl_global_init(CURL_GLOBAL_ALL);
|
||||
}
|
||||
|
||||
void mstdnt_global_curl_cleanup()
|
||||
void
|
||||
mstdnt_global_curl_cleanup(void)
|
||||
{
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
// Curl multi can still be used with single context's
|
||||
int mstdnt_init(mastodont_t* data)
|
||||
int
|
||||
mstdnt_init(mastodont_t* data)
|
||||
{
|
||||
data->curl = curl_multi_init();
|
||||
return data->curl == NULL;
|
||||
}
|
||||
|
||||
void mstdnt_cleanup(mastodont_t* data)
|
||||
void
|
||||
mstdnt_cleanup(mastodont_t* data)
|
||||
{
|
||||
curl_multi_cleanup(data->curl);
|
||||
}
|
||||
|
||||
void mstdnt_storage_cleanup(struct mstdnt_storage* storage)
|
||||
void
|
||||
mstdnt_storage_cleanup(struct mstdnt_storage* storage)
|
||||
{
|
||||
if (storage && storage->needs_cleanup)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue