split into library and applications
This commit is contained in:
26
libdc/include/dc/account.h
Normal file
26
libdc/include/dc/account.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef DC_ACCOUNT_H
|
||||
#define DC_ACCOUNT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct dc_account_;
|
||||
typedef struct dc_account_ *dc_account_t;
|
||||
|
||||
dc_account_t dc_account_new(void);
|
||||
dc_account_t dc_account_new2(char const *email, char const *pass);
|
||||
|
||||
void dc_account_set_email(dc_account_t a, char const *email);
|
||||
char const *dc_account_email(dc_account_t a);
|
||||
|
||||
void dc_account_set_password(dc_account_t a, char const *password);
|
||||
char const *dc_account_password(dc_account_t a);
|
||||
|
||||
void dc_account_set_id(dc_account_t a, char const *id);
|
||||
char const *dc_account_id(dc_account_t a);
|
||||
|
||||
void dc_account_set_token(dc_account_t a, char const *token);
|
||||
char const *dc_account_token(dc_account_t a);
|
||||
bool dc_account_has_token(dc_account_t a);
|
||||
|
||||
#endif
|
||||
37
libdc/include/dc/api.h
Normal file
37
libdc/include/dc/api.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef NCDC_API_H
|
||||
#define NCDC_API_H
|
||||
|
||||
#include <dc/apisync.h>
|
||||
#include <dc/account.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <jansson.h>
|
||||
#include <event.h>
|
||||
|
||||
struct dc_api_;
|
||||
typedef struct dc_api_ *dc_api_t;
|
||||
|
||||
dc_api_t dc_api_new(void);
|
||||
|
||||
void dc_api_set_curl_multi(dc_api_t api, CURLM *curl);
|
||||
void dc_api_set_event_base(dc_api_t api, struct event_base *base);
|
||||
|
||||
/* call this function in case the MULTI has told us that some
|
||||
* transfer has finished.
|
||||
*/
|
||||
void dc_api_signal(dc_api_t api, CURL *easy, int code);
|
||||
|
||||
/* internal curl stuff
|
||||
*/
|
||||
dc_api_sync_t dc_api_call(dc_api_t api, char const *token,
|
||||
char const *method, json_t *j);
|
||||
json_t *dc_api_call_sync(dc_api_t api, char const *token,
|
||||
char const *method, json_t *j);
|
||||
|
||||
bool dc_api_authenticate(dc_api_t api, dc_account_t account);
|
||||
bool dc_api_userinfo(dc_api_t api, dc_account_t logion,
|
||||
dc_account_t user);
|
||||
|
||||
|
||||
#endif
|
||||
23
libdc/include/dc/apisync.h
Normal file
23
libdc/include/dc/apisync.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef DC_API_ASYNC_H
|
||||
#define DC_API_ASYNC_H
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct dc_api_sync_;
|
||||
typedef struct dc_api_sync_ *dc_api_sync_t;
|
||||
|
||||
dc_api_sync_t dc_api_sync_new(CURLM *curl, CURL *easy);
|
||||
|
||||
FILE *dc_api_sync_stream(dc_api_sync_t sync);
|
||||
char const *dc_api_sync_data(dc_api_sync_t sync);
|
||||
size_t dc_api_sync_datalen(dc_api_sync_t sync);
|
||||
int dc_api_sync_code(dc_api_sync_t sync);
|
||||
struct curl_slist *dc_api_sync_list(dc_api_sync_t sync);
|
||||
|
||||
bool dc_api_sync_wait(dc_api_sync_t sync);
|
||||
void dc_api_sync_finish(dc_api_sync_t sync, int code);
|
||||
|
||||
#endif
|
||||
14
libdc/include/dc/refable.h
Normal file
14
libdc/include/dc/refable.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef DC_REFABLE_H
|
||||
#define DC_REFABLE_H
|
||||
|
||||
typedef void (*dc_cleanup_t)(void *);
|
||||
|
||||
typedef struct {
|
||||
int ref;
|
||||
dc_cleanup_t cleanup;
|
||||
} dc_refable_t;
|
||||
|
||||
void *dc_ref(void *);
|
||||
void dc_unref(void *);
|
||||
|
||||
#endif
|
||||
8
libdc/include/dc/util.h
Normal file
8
libdc/include/dc/util.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef NCDC_UTIL_H
|
||||
#define NCDC_UTIL_H
|
||||
|
||||
#include <jansson.h>
|
||||
|
||||
void ncdc_util_dump_json(json_t *j);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user