#include "api.h"
-int cli_api_error(const struct pakfire_xfer_response* response,
+int cli_api_error(const pakfire_xfer_response* response,
const char* format, ...) {
char* prefix = NULL;
char* error = NULL;
#include <pakfire/xfer.h>
-int cli_api_error(const struct pakfire_xfer_response* response, const char* format, ...)
+int cli_api_error(const pakfire_xfer_response* response, const char* format, ...)
__attribute__((format(printf, 2, 3)));;
#endif /* PAKFIRE_CLI_API_H */
return 0;
}
-static int build_callback(struct pakfire_xfer* xfer,
+static int build_callback(pakfire_xfer* xfer,
const pakfire_xfer_response* response, void* data) {
const char* uuid = NULL;
int r;
return 0;
}
-static int response_callback(struct pakfire_xfer* xfer,
+static int response_callback(pakfire_xfer* xfer,
const pakfire_xfer_response* response, void* data) {
if (!response->error)
return cli_dump_json(response->data);
static const char* doc = "Lists all uploads";
-static int list_callback(struct pakfire_xfer* xfer,
+static int list_callback(pakfire_xfer* xfer,
const pakfire_xfer_response* response, void* data) {
// XXX For now, just dump the entire JSON object
return cli_dump_json(response->data);
pakfire_client* client;
// Control Connection
- struct pakfire_xfer* control;
+ pakfire_xfer* control;
// Stats Timer
sd_event_source* stats_timer;
return r;
}
-int pakfire_builder_connected(struct pakfire_xfer* xfer, void* data) {
+int pakfire_builder_connected(pakfire_xfer* xfer, void* data) {
pakfire_builder* self = data;
int r;
This function is called whenever the connection to the build service could not
be established or was interrupted. It will try to reconnect.
*/
-int pakfire_builder_close(struct pakfire_xfer* xfer, int code, void* data) {
+int pakfire_builder_close(pakfire_xfer* xfer, int code, void* data) {
pakfire_builder* self = data;
int r;
return 0;
}
-int pakfire_builder_recv(struct pakfire_xfer* xfer,
+int pakfire_builder_recv(pakfire_xfer* xfer,
const char* message, const size_t size, void* data) {
pakfire_builder* self = data;
struct json_object* m = NULL;
return r;
}
-int pakfire_builder_send(struct pakfire_xfer* xfer, void* data) {
+int pakfire_builder_send(pakfire_xfer* xfer, void* data) {
pakfire_builder* self = data;
// Stream logs
int pakfire_builder_connect(pakfire_builder* self);
// Socket Callbacks
-int pakfire_builder_connected(struct pakfire_xfer* xfer, void* data);
-int pakfire_builder_close(struct pakfire_xfer* xfer, int code, void* data);
-int pakfire_builder_recv(struct pakfire_xfer* xfer, const char* message, const size_t size, void* data);
-int pakfire_builder_send(struct pakfire_xfer* xfer, void* data);
+int pakfire_builder_connected(pakfire_xfer* xfer, void* data);
+int pakfire_builder_close(pakfire_xfer* xfer, int code, void* data);
+int pakfire_builder_recv(pakfire_xfer* xfer, const char* message, const size_t size, void* data);
+int pakfire_builder_send(pakfire_xfer* xfer, void* data);
int pakfire_builder_send_message(pakfire_builder* self, struct json_object* message);
STAILQ_HEAD(uploads, pakfire_client_upload) uploads;
};
-static int pakfire_client_xfer_create(struct pakfire_xfer** xfer,
+static int pakfire_client_xfer_create(pakfire_xfer** xfer,
pakfire_client* self, const char* url, ...) __attribute__((format(printf, 3, 4)));
-static int pakfire_client_xfer_create(struct pakfire_xfer** xfer,
+static int pakfire_client_xfer_create(pakfire_xfer** xfer,
pakfire_client* self, const char* url, ...) {
- struct pakfire_xfer* x = NULL;
+ pakfire_xfer* x = NULL;
va_list args;
int r;
return 0;
}
-static int pakfire_client_auth_response(struct pakfire_xfer* xfer,
+static int pakfire_client_auth_response(pakfire_xfer* xfer,
const pakfire_xfer_response* response, void* data);
static int pakfire_client_auth_required(pakfire_client* self);
Triggers a refresh of the access and refresh tokens
*/
static int pakfire_client_auth_refresh(pakfire_client* self) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
struct json_object* request = NULL;
int r;
return r;
}
-static int pakfire_client_xfer_auth(pakfire_client* self, struct pakfire_xfer* xfer) {
+static int pakfire_client_xfer_auth(pakfire_client* self, pakfire_xfer* xfer) {
int r;
// Fail if not authenticated
return 0;
}
-static int pakfire_client_auth_response(struct pakfire_xfer* xfer,
+static int pakfire_client_auth_response(pakfire_xfer* xfer,
const pakfire_xfer_response* response, void* data) {
pakfire_client* self = data;
const char* refresh_token = NULL;
}
int pakfire_client_auth_user(pakfire_client* self, const char* password) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
struct {
char* username;
char* password;
#if 0
int pakfire_client_auth_builder(pakfire_client* self,
const char* username, const char* password) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
char hostname[HOST_NAME_MAX];
struct {
char* username;
}
int pakfire_client_builder_connect(pakfire_client* self, pakfire_builder* builder) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r;
// Create a new xfer
return r;
}
-int pakfire_client_builder_disconnected(pakfire_client* self, struct pakfire_xfer* xfer) {
+int pakfire_client_builder_disconnected(pakfire_client* self, pakfire_xfer* xfer) {
int r;
// Remove the connection from the client
int pakfire_client_build(pakfire_client* self, const char* upload, const char* repo,
const char** arches, int flags, pakfire_xfer_response_callback callback, void* data) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
struct json_object* request = NULL;
int r;
return r;
}
-static int pakfire_upload_payload_callback(struct pakfire_xfer* xfer,
+static int pakfire_upload_payload_callback(pakfire_xfer* xfer,
const pakfire_xfer_response* response, void* data) {
pakfire_client_upload_status s = PAKFIRE_CLIENT_UPLOAD_SUCCESSFUL;
pakfire_client_upload* upload = data;
static int pakfire_client_upload_payload(pakfire_client_upload* upload) {
pakfire_client* self = upload->client;
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r;
// Create a new xfer
return r;
}
-static int pakfire_client_upload_response(struct pakfire_xfer* xfer,
+static int pakfire_client_upload_response(pakfire_xfer* xfer,
const pakfire_xfer_response* response, void* data) {
pakfire_client_upload* self = data;
const char* uuid = NULL;
pakfire_client_upload* upload = NULL;
struct json_object* request = NULL;
char* hexdigest_blake2b512 = NULL;
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r;
// Create a new upload
int pakfire_client_list_uploads(pakfire_client* self,
pakfire_client_list_uploads_callback callback, void* data) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r;
// Create a new xfer
}
int pakfire_client_delete_upload(pakfire_client* self, const char* uuid) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r;
// Create a new xfer
// Repositories
int pakfire_client_list_repos(pakfire_client* self, const char* distro) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r;
// Check inputs
int pakfire_client_get_repo(pakfire_client* self,
const char* distro, const char* name) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r;
// Check inputs
int pakfire_client_create_repo(pakfire_client* self,
const char* distro, const char* name, const char* description) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
struct json_object* request = NULL;
int r;
int pakfire_client_delete_repo(pakfire_client* self, const char* distro,
const char* name, pakfire_xfer_response_callback callback, void* data) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r;
// Create a new xfer
int pakfire_client_job_finished(pakfire_client* self,
const char* job_id, const char* logfile, char** packages) {
struct json_object* request = NULL;
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r;
// Create a new request object
// Low-level functions
int pakfire_client_builder_connect(pakfire_client* self, pakfire_builder* builder);
-int pakfire_client_builder_disconnected(pakfire_client* self, struct pakfire_xfer* xfer);
+int pakfire_client_builder_disconnected(pakfire_client* self, pakfire_xfer* xfer);
// Builds
static int pakfire_dist_download_source(pakfire_ctx* ctx,
pakfire_mirrorlist* mirrorlist, const char* cache_path, const char* filename, ...) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
va_list args;
int r;
typedef struct pakfire_httpclient_xfer {
TAILQ_ENTRY(pakfire_httpclient_xfer) nodes;
- struct pakfire_xfer* xfer;
+ pakfire_xfer* xfer;
// Store the status
enum pakfire_httpclient_xfer_status {
}
static int pakfire_httpclient_xfer_create(
- pakfire_httpclient_xfer** x, struct pakfire_xfer* xfer) {
+ pakfire_httpclient_xfer** x, pakfire_xfer* xfer) {
pakfire_httpclient_xfer* e = NULL;
// Allocate some space
}
static pakfire_httpclient_xfer* pakfire_httpclient_xfer_find(
- pakfire_httpclient* self, struct pakfire_xfer* xfer) {
+ pakfire_httpclient* self, pakfire_xfer* xfer) {
pakfire_httpclient_xfer* e = NULL;
TAILQ_FOREACH(e, &self->xfers, nodes) {
static int pakfire_httpclient_check(pakfire_httpclient* self) {
pakfire_httpclient_xfer* e = NULL;
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r;
CURLMsg* msg = NULL;
return NULL;
}
-int pakfire_httpclient_enqueue(pakfire_httpclient* self, struct pakfire_xfer* xfer) {
+int pakfire_httpclient_enqueue(pakfire_httpclient* self, pakfire_xfer* xfer) {
pakfire_httpclient_xfer* e = NULL;
int r;
return 0;
}
-int pakfire_httpclient_dequeue(pakfire_httpclient* self, struct pakfire_xfer* xfer) {
+int pakfire_httpclient_dequeue(pakfire_httpclient* self, pakfire_xfer* xfer) {
pakfire_httpclient_xfer* e = NULL;
int r;
pakfire_httpclient* pakfire_httpclient_ref(pakfire_httpclient* self);
pakfire_httpclient* pakfire_httpclient_unref(pakfire_httpclient* self);
-int pakfire_httpclient_enqueue(pakfire_httpclient* self, struct pakfire_xfer* xfer);
-int pakfire_httpclient_dequeue(pakfire_httpclient* self, struct pakfire_xfer* xfer);
+int pakfire_httpclient_enqueue(pakfire_httpclient* self, pakfire_xfer* xfer);
+int pakfire_httpclient_dequeue(pakfire_httpclient* self, pakfire_xfer* xfer);
int pakfire_httpclient_run(pakfire_httpclient* self, const char* title);
*/
static int pakfire_job_exited(sd_event_source* s, const siginfo_t* si, void* data) {
pakfire_job* job = data;
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
const char* filename = NULL;
const char* path = NULL;
int r;
return __pakfire_cache_path(repo->pakfire, path, length, "%s/%s", name, buffer);
}
-static int pakfire_repo_xfer_create(struct pakfire_xfer** xfer, pakfire_repo* repo,
+static int pakfire_repo_xfer_create(pakfire_xfer** xfer, pakfire_repo* repo,
const char* url, ...) __attribute__((format(printf, 3, 4)));
/*
settings of this repository.
*/
static int pakfire_repo_xfer_create(
- struct pakfire_xfer** xfer, pakfire_repo* repo, const char* url, ...) {
+ pakfire_xfer** xfer, pakfire_repo* repo, const char* url, ...) {
pakfire_mirrorlist* mirrorlist = NULL;
- struct pakfire_xfer* x = NULL;
+ pakfire_xfer* x = NULL;
const char* baseurl = NULL;
va_list args;
int r;
static int pakfire_repo_download_database(
pakfire_repo* repo, const char* filename, const char* path) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
char title[NAME_MAX];
int r;
static int pakfire_repo_download_mirrorlist(pakfire_repo* self,
const char* path, const int force) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
char* url = NULL;
time_t age = -1;
int r;
static int pakfire_repo_verify_metadata(
pakfire_repo* self, const pakfire_buffer* repomd) {
pakfire_buffer signature = {};
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
FILE* f = NULL;
int r;
static int pakfire_repo_download_metadata(pakfire_repo* repo, const char* path, int force) {
pakfire_repomd repomd = {};
pakfire_buffer buffer = {};
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
struct json_object* json = NULL;
char* error = NULL;
int r;
return (self->repo == self->repo->pool->installed);
}
-int pakfire_repo_download_package(struct pakfire_xfer** xfer,
+int pakfire_repo_download_package(pakfire_xfer** xfer,
pakfire_repo* repo, pakfire_package* pkg) {
enum pakfire_hash_type hash = PAKFIRE_HASH_UNDEFINED;
const unsigned char* checksum = NULL;
size_t checksum_length = 0;
struct pakfire_hashes hashes = {};
- struct pakfire_xfer* x = NULL;
+ pakfire_xfer* x = NULL;
const char* cache_path = NULL;
const char* nevra = NULL;
const char* url = NULL;
static int pakfire_repo_download(pakfire_repo* repo, const char* url,
pakfire_package** package) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
FILE* f = NULL;
int r;
int pakfire_repo_import_archive(pakfire_repo* self,
pakfire_archive* archive, pakfire_package** package);
-int pakfire_repo_download_package(struct pakfire_xfer** xfer,
+int pakfire_repo_download_package(pakfire_xfer** xfer,
pakfire_repo* repo, pakfire_package* pkg);
int pakfire_repo_add(pakfire_repo* repo, const char* path,
static int pakfire_transaction_download_package(pakfire_transaction* transaction,
pakfire_httpclient* httpclient, pakfire_package* pkg) {
pakfire_repo* repo = NULL;
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r;
// Fetch the repository to download from
} state;
};
-static void pakfire_xfer_free(struct pakfire_xfer* xfer) {
+static void pakfire_xfer_free(pakfire_xfer* xfer) {
// Unlink
if (*xfer->tmpfile)
unlink(xfer->tmpfile);
#endif
static size_t pakfire_xfer_read(char* data, size_t size, size_t nmemb, void* p) {
- struct pakfire_xfer* xfer = p;
+ pakfire_xfer* xfer = p;
return fread(data, size, nmemb, xfer->fout);
}
static int pakfire_xfer_seek(void* p, curl_off_t offset, int origin) {
- struct pakfire_xfer* xfer = p;
+ pakfire_xfer* xfer = p;
int r;
// Perform the seek
static size_t pakfire_xfer_write(
char* data, size_t size, size_t nmemb, void* p) {
- struct pakfire_xfer* xfer = p;
+ pakfire_xfer* xfer = p;
int r;
// Do not write empty blocks
return fwrite(data, size, nmemb, xfer->fin);
}
-static int pakfire_xfer_setup(struct pakfire_xfer* xfer) {
+static int pakfire_xfer_setup(pakfire_xfer* xfer) {
pakfire_config* config = NULL;
const char* proxy = NULL;
int r;
return r;
}
-static int __pakfire_xfer_create_simple(struct pakfire_xfer** xfer,
+static int __pakfire_xfer_create_simple(pakfire_xfer** xfer,
pakfire_ctx* ctx, const char* url, ...) __attribute__((format(printf, 3, 4)));
// A helper function to create va_list
static int __pakfire_xfer_create_simple(
- struct pakfire_xfer** xfer, pakfire_ctx* ctx, const char* url, ...) {
+ pakfire_xfer** xfer, pakfire_ctx* ctx, const char* url, ...) {
va_list args;
int r;
}
int pakfire_xfer_create_simple(
- struct pakfire_xfer** xfer, pakfire_ctx* ctx, const char* url) {
+ pakfire_xfer** xfer, pakfire_ctx* ctx, const char* url) {
return __pakfire_xfer_create_simple(xfer, ctx, "%s", url);
}
-int pakfire_xfer_create(struct pakfire_xfer** xfer,
+int pakfire_xfer_create(pakfire_xfer** xfer,
pakfire_ctx* ctx, const char* url, va_list args) {
- struct pakfire_xfer* x = NULL;
+ pakfire_xfer* x = NULL;
int r;
// Fail if the context is flagged as offline
return r;
}
-struct pakfire_xfer* pakfire_xfer_ref(struct pakfire_xfer* xfer) {
+pakfire_xfer* pakfire_xfer_ref(pakfire_xfer* xfer) {
++xfer->nrefs;
return xfer;
}
-struct pakfire_xfer* pakfire_xfer_unref(struct pakfire_xfer* xfer) {
+pakfire_xfer* pakfire_xfer_unref(pakfire_xfer* xfer) {
if (--xfer->nrefs > 0)
return xfer;
return NULL;
}
-CURL* pakfire_xfer_handle(struct pakfire_xfer* xfer) {
+CURL* pakfire_xfer_handle(pakfire_xfer* xfer) {
return xfer->handle;
}
-int pakfire_xfer_set_method(struct pakfire_xfer* xfer,
+int pakfire_xfer_set_method(pakfire_xfer* xfer,
const pakfire_xfer_method_t method) {
const char* m = NULL;
return curl_easy_setopt(xfer->handle, CURLOPT_CUSTOMREQUEST, m);
}
-const char* pakfire_xfer_get_title(struct pakfire_xfer* xfer) {
+const char* pakfire_xfer_get_title(pakfire_xfer* xfer) {
char title[PATH_MAX];
int r;
return xfer->title;
}
-int pakfire_xfer_set_title(struct pakfire_xfer* xfer, const char* title) {
+int pakfire_xfer_set_title(pakfire_xfer* xfer, const char* title) {
return pakfire_string_set(xfer->title, title);
}
-int pakfire_xfer_set_baseurl(struct pakfire_xfer* xfer, const char* baseurl) {
+int pakfire_xfer_set_baseurl(pakfire_xfer* xfer, const char* baseurl) {
int r;
// Store the URL
return 0;
}
-const char* pakfire_xfer_get_effective_url(struct pakfire_xfer* xfer) {
+const char* pakfire_xfer_get_effective_url(pakfire_xfer* xfer) {
return xfer->effective_url;
}
/*
Helper function to set a chosen mirror
*/
-static int pakfire_xfer_select_mirror(struct pakfire_xfer* self, pakfire_mirror* mirror) {
+static int pakfire_xfer_select_mirror(pakfire_xfer* self, pakfire_mirror* mirror) {
// Free the previous mirror
if (self->mirror) {
pakfire_mirror_unref(self->mirror);
return 0;
}
-int pakfire_xfer_set_mirrorlist(struct pakfire_xfer* xfer, pakfire_mirrorlist* mirrors) {
+int pakfire_xfer_set_mirrorlist(pakfire_xfer* xfer, pakfire_mirrorlist* mirrors) {
pakfire_mirror* mirror = NULL;
int r;
// Size
-size_t pakfire_xfer_get_size(struct pakfire_xfer* xfer) {
+size_t pakfire_xfer_get_size(pakfire_xfer* xfer) {
return xfer->expected_size;
}
-int pakfire_xfer_set_size(struct pakfire_xfer* xfer, size_t size) {
+int pakfire_xfer_set_size(pakfire_xfer* xfer, size_t size) {
xfer->expected_size = size;
return 0;
}
-int pakfire_xfer_verify_hashes(struct pakfire_xfer* self, const struct pakfire_hashes* hashes) {
+int pakfire_xfer_verify_hashes(pakfire_xfer* self, const struct pakfire_hashes* hashes) {
return pakfire_hashes_import(&self->expected_hashes, hashes);
}
-char* pakfire_xfer_escape(struct pakfire_xfer* self, const char* s) {
+char* pakfire_xfer_escape(pakfire_xfer* self, const char* s) {
char* output = NULL;
char* result = NULL;
return result;
}
-int pakfire_xfer_add_header(struct pakfire_xfer* self, const char* format, ...) {
+int pakfire_xfer_add_header(pakfire_xfer* self, const char* format, ...) {
char* header = NULL;
va_list args;
int r;
return r;
}
-int pakfire_xfer_add_query(struct pakfire_xfer* xfer,
+int pakfire_xfer_add_query(pakfire_xfer* xfer,
const char* key, const char* format, ...) {
char* value = NULL;
va_list args;
return r;
}
-int pakfire_xfer_set_payload(struct pakfire_xfer* self, const char* payload) {
+int pakfire_xfer_set_payload(pakfire_xfer* self, const char* payload) {
if (self->payload) {
free(self->payload);
self->payload = NULL;
return 0;
}
-int pakfire_xfer_set_json_payload(struct pakfire_xfer* self, struct json_object* json) {
+int pakfire_xfer_set_json_payload(pakfire_xfer* self, struct json_object* json) {
const char* s = NULL;
int r;
return pakfire_xfer_set_payload(self, s);
}
-static void pakfire_xfer_reset_output(struct pakfire_xfer* xfer) {
+static void pakfire_xfer_reset_output(pakfire_xfer* xfer) {
if (xfer->fin) {
fclose(xfer->fin);
xfer->fin = NULL;
}
}
-int pakfire_xfer_set_output(struct pakfire_xfer* xfer, FILE* f) {
+int pakfire_xfer_set_output(pakfire_xfer* xfer, FILE* f) {
pakfire_xfer_reset_output(xfer);
// Store the new stream
return 0;
}
-int pakfire_xfer_set_output_buffer(struct pakfire_xfer* xfer,
+int pakfire_xfer_set_output_buffer(pakfire_xfer* xfer,
char** buffer, size_t* length) {
FILE* f = NULL;
return pakfire_xfer_set_output(xfer, f);
}
-int pakfire_xfer_set_response_callback(struct pakfire_xfer* self,
+int pakfire_xfer_set_response_callback(pakfire_xfer* self,
pakfire_xfer_response_callback callback, void* data) {
int r;
return 0;
}
-int pakfire_xfer_set_input(struct pakfire_xfer* xfer, FILE* f) {
+int pakfire_xfer_set_input(pakfire_xfer* xfer, FILE* f) {
struct stat stat;
int r;
return 0;
}
-static int pakfire_xfer_allocate_tmpfile_legacy(struct pakfire_xfer* xfer, const char* path) {
+static int pakfire_xfer_allocate_tmpfile_legacy(pakfire_xfer* xfer, const char* path) {
FILE* f = NULL;
int r;
return pakfire_xfer_set_output(xfer, f);
}
-static int pakfire_xfer_allocate_tmpfile(struct pakfire_xfer* xfer, const char* path) {
+static int pakfire_xfer_allocate_tmpfile(pakfire_xfer* xfer, const char* path) {
char dirname[PATH_MAX];
FILE* f = NULL;
int fd = -1;
return pakfire_xfer_set_output(xfer, f);
}
-int pakfire_xfer_set_output_path(struct pakfire_xfer* xfer, const char* path) {
+int pakfire_xfer_set_output_path(pakfire_xfer* xfer, const char* path) {
int r;
// Store the output path
/*
Called after something went wrong and we want to try again with another mirror
*/
-static int pakfire_xfer_next_mirror(struct pakfire_xfer* xfer) {
+static int pakfire_xfer_next_mirror(pakfire_xfer* xfer) {
pakfire_mirror* mirror = NULL;
int r = 0;
return r;
}
-static int pakfire_xfer_call_response_callback(struct pakfire_xfer* self, pakfire_xfer_error_code_t error, int status) {
+static int pakfire_xfer_call_response_callback(pakfire_xfer* self, pakfire_xfer_error_code_t error, int status) {
char* e = NULL;
int r;
return r;
}
-static int pakfire_xfer_fail(struct pakfire_xfer* xfer, pakfire_xfer_error_code_t code, int status) {
+static int pakfire_xfer_fail(pakfire_xfer* xfer, pakfire_xfer_error_code_t code, int status) {
int r;
// Drop the hasher
return "unknown";
}
-static int pakfire_xfer_socket_send(struct pakfire_xfer* self) {
+static int pakfire_xfer_socket_send(pakfire_xfer* self) {
int r;
// The socket is now ready to send
return 0;
}
-static int pakfire_xfer_socket_recv(struct pakfire_xfer* xfer) {
+static int pakfire_xfer_socket_recv(pakfire_xfer* xfer) {
const struct curl_ws_frame* meta = NULL;
char buffer[4096];
int r;
}
static int __pakfire_xfer_socket(sd_event_source* s, int fd, uint32_t events, void* data) {
- struct pakfire_xfer* xfer = data;
+ pakfire_xfer* xfer = data;
int r;
// Is there any data to read?
send or receive data.
*/
static pakfire_xfer_error_code_t pakfire_xfer_done_socket(
- struct pakfire_xfer* xfer, sd_event* loop, int code) {
+ pakfire_xfer* xfer, sd_event* loop, int code) {
curl_socket_t socket = -1;
int events = 0;
int r;
/*
This function checks if the hashes match (if set up)
*/
-static int pakfire_xfer_verify(struct pakfire_xfer* self) {
+static int pakfire_xfer_verify(pakfire_xfer* self) {
struct pakfire_hashes computed_hashes = {};
int r;
}
}
-static int pakfire_xfer_save(struct pakfire_xfer* xfer, int status) {
+static int pakfire_xfer_save(pakfire_xfer* xfer, int status) {
int fd = -EBADF;
int r;
}
pakfire_xfer_error_code_t pakfire_xfer_done(
- struct pakfire_xfer* xfer, sd_event* loop, int code) {
+ pakfire_xfer* xfer, sd_event* loop, int code) {
CURL* h = xfer->handle;
int r;
const char* scheme = NULL;
static int pakfire_xfer_update(void* data,
curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) {
- struct pakfire_xfer* xfer = data;
+ pakfire_xfer* xfer = data;
switch (xfer->direction) {
case PAKFIRE_XFER_DOWNLOAD:
return pakfire_progress_update(xfer->progress, xfer->xferred);
}
-static int pakfire_xfer_prepare_progress(struct pakfire_xfer* xfer,
+static int pakfire_xfer_prepare_progress(pakfire_xfer* xfer,
pakfire_progress* parent, int flags) {
const char* title = NULL;
int progress_flags =
return 0;
}
-static int pakfire_xfer_prepare_url(struct pakfire_xfer* xfer) {
+static int pakfire_xfer_prepare_url(pakfire_xfer* xfer) {
int r;
// If this has been called before, we free the former object
return r;
}
-int pakfire_xfer_prepare(struct pakfire_xfer* xfer, pakfire_progress* progress, int flags) {
+int pakfire_xfer_prepare(pakfire_xfer* xfer, pakfire_progress* progress, int flags) {
int r;
// Increment tries
return 0;
}
-int pakfire_xfer_socket(struct pakfire_xfer* xfer, pakfire_xfer_open_callback open,
+int pakfire_xfer_socket(pakfire_xfer* xfer, pakfire_xfer_open_callback open,
pakfire_xfer_recv_callback recv, pakfire_xfer_send_callback send,
pakfire_xfer_close_callback close, void* data) {
xfer->direction = PAKFIRE_XFER_SOCKET;
/*
This function sends a WebSocket message
*/
-static int __pakfire_xfer_send_message(struct pakfire_xfer* xfer,
+static int __pakfire_xfer_send_message(pakfire_xfer* xfer,
const char* message, const size_t length) {
size_t bytes_sent = 0;
size_t offset = 0;
return r;
}
-int pakfire_xfer_send_message(struct pakfire_xfer* self,
+int pakfire_xfer_send_message(pakfire_xfer* self,
const char* message, const size_t length) {
int r;
return __pakfire_xfer_send_message(self, message, length);
}
-int pakfire_xfer_is_ready_to_send(struct pakfire_xfer* self) {
+int pakfire_xfer_is_ready_to_send(pakfire_xfer* self) {
// This function is only supported for sockets
switch (self->direction) {
case PAKFIRE_XFER_SOCKET:
return (self->state & PAKFIRE_XFER_READY_TO_SEND);
}
-pakfire_xfer_error_code_t pakfire_xfer_run(struct pakfire_xfer* xfer, int flags) {
+pakfire_xfer_error_code_t pakfire_xfer_run(pakfire_xfer* xfer, int flags) {
int r;
// Prepare the xfer
#include <systemd/sd-event.h>
-struct pakfire_xfer;
+typedef struct pakfire_xfer pakfire_xfer;
typedef enum pakfire_xfer_error_code {
PAKFIRE_XFER_OK = 0,
} pakfire_xfer_method_t;
int pakfire_xfer_create_simple(
- struct pakfire_xfer** xfer, pakfire_ctx* ctx, const char* url);
+ pakfire_xfer** xfer, pakfire_ctx* ctx, const char* url);
-int pakfire_xfer_create(struct pakfire_xfer** xfer, pakfire_ctx* ctx,
+int pakfire_xfer_create(pakfire_xfer** xfer, pakfire_ctx* ctx,
const char* url, va_list args) __attribute__((format(printf, 3, 0)));
-struct pakfire_xfer* pakfire_xfer_ref(struct pakfire_xfer* xfer);
-struct pakfire_xfer* pakfire_xfer_unref(struct pakfire_xfer* xfer);
+pakfire_xfer* pakfire_xfer_ref(pakfire_xfer* xfer);
+pakfire_xfer* pakfire_xfer_unref(pakfire_xfer* xfer);
-CURL* pakfire_xfer_handle(struct pakfire_xfer* xfer);
+CURL* pakfire_xfer_handle(pakfire_xfer* xfer);
-int pakfire_xfer_set_method(struct pakfire_xfer* xfer,
+int pakfire_xfer_set_method(pakfire_xfer* xfer,
const pakfire_xfer_method_t method);
// Title
-const char* pakfire_xfer_get_title(struct pakfire_xfer* xfer);
-int pakfire_xfer_set_title(struct pakfire_xfer* xfer, const char* title);
+const char* pakfire_xfer_get_title(pakfire_xfer* xfer);
+int pakfire_xfer_set_title(pakfire_xfer* xfer, const char* title);
-int pakfire_xfer_set_baseurl(struct pakfire_xfer* xfer, const char* baseurl);
-const char* pakfire_xfer_get_effective_url(struct pakfire_xfer* xfer);
+int pakfire_xfer_set_baseurl(pakfire_xfer* xfer, const char* baseurl);
+const char* pakfire_xfer_get_effective_url(pakfire_xfer* xfer);
-int pakfire_xfer_set_mirrorlist(struct pakfire_xfer* xfer, pakfire_mirrorlist* mirrors);
+int pakfire_xfer_set_mirrorlist(pakfire_xfer* xfer, pakfire_mirrorlist* mirrors);
-size_t pakfire_xfer_get_size(struct pakfire_xfer* xfer);
-int pakfire_xfer_set_size(struct pakfire_xfer* xfer, size_t size);
+size_t pakfire_xfer_get_size(pakfire_xfer* xfer);
+int pakfire_xfer_set_size(pakfire_xfer* xfer, size_t size);
-int pakfire_xfer_verify_hashes(struct pakfire_xfer* self, const struct pakfire_hashes* hashes);
+int pakfire_xfer_verify_hashes(pakfire_xfer* self, const struct pakfire_hashes* hashes);
-char* pakfire_xfer_escape(struct pakfire_xfer* self, const char* s);
+char* pakfire_xfer_escape(pakfire_xfer* self, const char* s);
-int pakfire_xfer_add_header(struct pakfire_xfer* self, const char* format, ...)
+int pakfire_xfer_add_header(pakfire_xfer* self, const char* format, ...)
__attribute__((format(printf, 2, 3)));
-int pakfire_xfer_add_query(struct pakfire_xfer* xfer,
+int pakfire_xfer_add_query(pakfire_xfer* xfer,
const char* key, const char* format, ...) __attribute__((format(printf, 3, 4)));
// Payload
-int pakfire_xfer_set_payload(struct pakfire_xfer* self, const char* payload);
-int pakfire_xfer_set_json_payload(struct pakfire_xfer* self, struct json_object* json);
+int pakfire_xfer_set_payload(pakfire_xfer* self, const char* payload);
+int pakfire_xfer_set_json_payload(pakfire_xfer* self, struct json_object* json);
// Output
-int pakfire_xfer_set_output(struct pakfire_xfer* xfer, FILE* f);
-int pakfire_xfer_set_output_buffer(struct pakfire_xfer* xfer, char** buffer, size_t* length);
-int pakfire_xfer_set_output_path(struct pakfire_xfer* xfer, const char* path);
+int pakfire_xfer_set_output(pakfire_xfer* xfer, FILE* f);
+int pakfire_xfer_set_output_buffer(pakfire_xfer* xfer, char** buffer, size_t* length);
+int pakfire_xfer_set_output_path(pakfire_xfer* xfer, const char* path);
// Response
typedef int (*pakfire_xfer_response_callback)
- (struct pakfire_xfer* xfer, const pakfire_xfer_response* response, void* data);
+ (pakfire_xfer* xfer, const pakfire_xfer_response* response, void* data);
-int pakfire_xfer_set_response_callback(struct pakfire_xfer* xfer,
+int pakfire_xfer_set_response_callback(pakfire_xfer* xfer,
pakfire_xfer_response_callback callback, void* data);
int pakfire_xfer_response_get_error(const pakfire_xfer_response* response, char** error);
// Input
-int pakfire_xfer_set_input(struct pakfire_xfer* xfer, FILE* f);
+int pakfire_xfer_set_input(pakfire_xfer* xfer, FILE* f);
-int pakfire_xfer_prepare(struct pakfire_xfer* xfer, pakfire_progress* progress, int flags);
-pakfire_xfer_error_code_t pakfire_xfer_done(struct pakfire_xfer* xfer, sd_event* loop, int code);
+int pakfire_xfer_prepare(pakfire_xfer* xfer, pakfire_progress* progress, int flags);
+pakfire_xfer_error_code_t pakfire_xfer_done(pakfire_xfer* xfer, sd_event* loop, int code);
-pakfire_xfer_error_code_t pakfire_xfer_run(struct pakfire_xfer* xfer, int flags);
+pakfire_xfer_error_code_t pakfire_xfer_run(pakfire_xfer* xfer, int flags);
// WebSocket
-typedef int (*pakfire_xfer_open_callback)(struct pakfire_xfer* xfer, void* data);
-typedef int (*pakfire_xfer_recv_callback)(struct pakfire_xfer* xfer, const char* message, const size_t size, void* data);
-typedef int (*pakfire_xfer_send_callback)(struct pakfire_xfer* xfer, void* data);
-typedef int (*pakfire_xfer_close_callback)(struct pakfire_xfer* xfer, int code, void* data);
+typedef int (*pakfire_xfer_open_callback)(pakfire_xfer* xfer, void* data);
+typedef int (*pakfire_xfer_recv_callback)(pakfire_xfer* xfer, const char* message, const size_t size, void* data);
+typedef int (*pakfire_xfer_send_callback)(pakfire_xfer* xfer, void* data);
+typedef int (*pakfire_xfer_close_callback)(pakfire_xfer* xfer, int code, void* data);
-int pakfire_xfer_socket(struct pakfire_xfer* xfer, pakfire_xfer_open_callback open,
+int pakfire_xfer_socket(pakfire_xfer* xfer, pakfire_xfer_open_callback open,
pakfire_xfer_recv_callback recv, pakfire_xfer_send_callback send, pakfire_xfer_close_callback close, void* data);
-int pakfire_xfer_send_message(struct pakfire_xfer* xfer, const char* message, const size_t length);
-int pakfire_xfer_is_ready_to_send(struct pakfire_xfer* self);
+int pakfire_xfer_send_message(pakfire_xfer* xfer, const char* message, const size_t length);
+int pakfire_xfer_is_ready_to_send(pakfire_xfer* self);
#endif /* PAKFIRE_XFER_H */
}
static int test_one(const struct test* t) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
char* buffer = NULL;
size_t length = 0;
int r = EXIT_FAILURE;
return r;
}
-static int __test_create_transfer(const struct test* t, struct pakfire_xfer** xfer,
+static int __test_create_transfer(const struct test* t, pakfire_xfer** xfer,
char** buffer, size_t* length, const char* url, ...) __attribute__((format(printf, 5, 6)));
-static int __test_create_transfer(const struct test* t, struct pakfire_xfer** xfer,
+static int __test_create_transfer(const struct test* t, pakfire_xfer** xfer,
char** buffer, size_t* length, const char* url, ...) {
va_list args;
int r;
}
static int test_multiple(const struct test* t) {
- struct pakfire_xfer* xfer1 = NULL;
+ pakfire_xfer* xfer1 = NULL;
char* buffer1 = NULL;
size_t length1 = 0;
- struct pakfire_xfer* xfer2 = NULL;
+ pakfire_xfer* xfer2 = NULL;
char* buffer2 = NULL;
size_t length2 = 0;
- struct pakfire_xfer* xfer3 = NULL;
+ pakfire_xfer* xfer3 = NULL;
char* buffer3 = NULL;
size_t length3 = 0;
- struct pakfire_xfer* xfer4 = NULL;
+ pakfire_xfer* xfer4 = NULL;
char* buffer4 = NULL;
size_t length4 = 0;
int r = EXIT_FAILURE;
};
static int test_create(const struct test* t) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r = EXIT_FAILURE;
// Create a new transfer
}
static int test_download(const struct test* t) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r = EXIT_FAILURE;
// Create a new transfer
}
static int test_download_into_buffer(const struct test* t) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
char* buffer = NULL;
size_t length = 0;
int r = EXIT_FAILURE;
static int test_download_check_digest(const struct test* t) {
struct pakfire_hashes hashes = {};
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
char* buffer = NULL;
size_t length = 0;
int r = EXIT_FAILURE;
static int test_download_check_incorrect_digest(const struct test* t) {
struct pakfire_hashes hashes = {};
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
char* buffer = NULL;
size_t length = 0;
int r = EXIT_FAILURE;
#ifdef ENABLE_ONLINE_TESTS
static int test_online_download(const struct test* t) {
- struct pakfire_xfer* xfer = NULL;
+ pakfire_xfer* xfer = NULL;
int r = EXIT_FAILURE;
// Create a new transfer