shared: move src/import/curl-util.h to src/shared/

Move more common definitions in the header file instead of repeating
them in bunch of places. src/import/curl-util.[ch] is renamed so that
it's shared more naturally with other components.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-04-15 21:27:39 +02:00
parent 0ba59c3d32
commit cdc8aadaed
7 changed files with 21 additions and 23 deletions
+1 -2
View File
@@ -18,6 +18,7 @@
#include "chase.h"
#include "copy.h"
#include "creds-util.h"
#include "curl-util.h"
#include "device-private.h"
#include "dns-rr.h"
#include "errno-util.h"
@@ -53,8 +54,6 @@
#include "web-util.h"
#include "xattr-util.h"
#include "../import/curl-util.h"
/* This implements a client to the AWS' and Azure's "Instance Metadata Service", as well as GCP's "VM
* Metadata", i.e.:
*
+2 -2
View File
@@ -11,8 +11,8 @@ executables += [
'sources' : files(
'imdsd.c',
'imds-util.c'
) + import_curl_util_c,
'dependencies' : [ libcurl ],
) + curl_util_c,
'dependencies' : [libcurl],
},
libexec_template + {
'name' : 'systemd-imds',
+1 -3
View File
@@ -1,7 +1,5 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
import_curl_util_c = files('curl-util.c')
if conf.get('ENABLE_IMPORTD') != 1
subdir_done()
endif
@@ -35,7 +33,7 @@ executables += [
'pull-oci.c',
'pull-raw.c',
'pull-tar.c',
) + import_curl_util_c,
) + curl_util_c,
'objects' : ['systemd-importd'],
'dependencies' : common_deps + [
libopenssl,
+1 -12
View File
@@ -11,6 +11,7 @@
#include "alloc-util.h"
#include "build.h"
#include "conf-parser.h"
#include "curl-util.h"
#include "daemon-util.h"
#include "env-file.h"
#include "extract-word.h"
@@ -81,18 +82,6 @@ static void close_fd_input(Uploader *u);
#define STATE_FILE "/var/lib/systemd/journal-upload/state"
#define easy_setopt(curl, log_level, opt, value) ({ \
CURLcode code = curl_easy_setopt(ASSERT_PTR(curl), opt, value); \
if (code) \
log_full(log_level, \
"curl_easy_setopt %s failed: %s", \
#opt, curl_easy_strerror(code)); \
!code; \
})
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CURL*, curl_easy_cleanup, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct curl_slist*, curl_slist_free_all, NULL);
static size_t output_callback(char *buf,
size_t size,
size_t nmemb,
@@ -5,6 +5,19 @@
#include "shared-forward.h"
#define easy_setopt(curl, log_level, opt, value) ({ \
CURLcode code = curl_easy_setopt(ASSERT_PTR(curl), opt, value); \
if (code) \
log_full(log_level, \
"curl_easy_setopt %s failed: %s", \
#opt, curl_easy_strerror(code)); \
code == CURLE_OK; \
})
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CURL*, curl_easy_cleanup, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CURLM*, curl_multi_cleanup, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct curl_slist*, curl_slist_free_all, NULL);
typedef struct CurlGlue CurlGlue;
typedef struct CurlGlue {
@@ -30,7 +43,3 @@ void curl_glue_remove_and_free(CurlGlue *g, CURL *c);
struct curl_slist *curl_slist_new(const char *first, ...) _sentinel_;
int curl_header_strdup(const void *contents, size_t sz, const char *field, char **value);
int curl_parse_http_time(const char *t, usec_t *ret);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CURL*, curl_easy_cleanup, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CURLM*, curl_multi_cleanup, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct curl_slist*, curl_slist_free_all, NULL);
+3
View File
@@ -256,6 +256,9 @@ if get_option('tests') != 'false'
shared_sources += files('tests.c')
endif
# A small shared file that is is linked into a few places
curl_util_c = files('curl-util.c')
syscall_list_inc = custom_target(
input : syscall_list_txt,
output : 'syscall-list.inc',