iSulad/0037-Add-extend-C-for-header-files.patch

689 lines
20 KiB
Diff
Raw Normal View History

From d7b324c04b4b353270216887b05e245337942b97 Mon Sep 17 00:00:00 2001
From: zhongtao <taozh97@163.com>
Date: Mon, 24 Oct 2022 20:46:47 +0800
Subject: [PATCH 37/43] Add extend C for header files
Signed-off-by: zhongtao <taozh97@163.com>
---
src/cmd/isula/stream/attach.h | 9 +++++++++
src/cmd/isula/stream/cp.h | 8 ++++++++
src/cmd/isula/stream/exec.h | 8 ++++++++
src/daemon/modules/api/log_gather_api.h | 8 ++++++++
src/daemon/modules/api/plugin_api.h | 8 ++++++++
src/daemon/modules/container/container_events_handler.h | 8 ++++++++
.../modules/container/restart_manager/restartmanager.h | 8 ++++++++
src/daemon/modules/container/supervisor/supervisor.h | 8 ++++++++
src/daemon/modules/events/monitord.h | 8 ++++++++
src/daemon/modules/image/embedded/db/db_all.h | 8 ++++++++
src/daemon/modules/image/embedded/db/db_common.h | 8 ++++++++
src/daemon/modules/image/embedded/db/db_images_common.h | 8 ++++++++
src/daemon/modules/image/embedded/db/sqlite_common.h | 8 ++++++++
src/daemon/modules/image/embedded/embedded_image.h | 8 ++++++++
src/daemon/modules/image/embedded/lim.h | 8 ++++++++
src/daemon/modules/image/embedded/snapshot/embedded.h | 8 ++++++++
src/daemon/modules/image/embedded/snapshot/snapshot.h | 8 ++++++++
.../modules/image/embedded/snapshot/snapshot_def.h | 7 +++++++
src/daemon/modules/image/external/ext_image.h | 8 ++++++++
src/daemon/modules/image/oci/registry_type.h | 8 ++++++++
.../graphdriver/devmapper/devices_constants.h | 8 ++++++++
src/daemon/modules/plugin/pspec.h | 8 ++++++++
src/daemon/modules/spec/specs_mount.h | 8 ++++++++
src/daemon/modules/spec/specs_security.h | 8 ++++++++
src/utils/buffer/buffer.h | 8 ++++++++
src/utils/cutils/linked_list.h | 8 ++++++++
src/utils/http/parser.h | 8 ++++++++
27 files changed, 216 insertions(+)
diff --git a/src/cmd/isula/stream/attach.h b/src/cmd/isula/stream/attach.h
index 2e71852b..9792da9d 100644
--- a/src/cmd/isula/stream/attach.h
+++ b/src/cmd/isula/stream/attach.h
@@ -18,9 +18,18 @@
#include "client_arguments.h"
#include "isula_libutils/container_inspect.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern const char g_cmd_attach_desc[];
extern const char g_cmd_attach_usage[];
extern struct client_arguments g_cmd_attach_args;
int inspect_container(const struct client_arguments *args, container_inspect **inspect_data);
int cmd_attach_main(int argc, const char **argv);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif // CMD_ISULA_STREAM_ATTACH_H
diff --git a/src/cmd/isula/stream/cp.h b/src/cmd/isula/stream/cp.h
index 821a3887..491d5421 100644
--- a/src/cmd/isula/stream/cp.h
+++ b/src/cmd/isula/stream/cp.h
@@ -17,9 +17,17 @@
#include "client_arguments.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern const char g_cmd_cp_desc[];
extern const char g_cmd_cp_usage[];
extern struct client_arguments g_cmd_cp_args;
int cmd_cp_main(int argc, const char **argv);
+#ifdef __cplusplus
+}
+#endif
+
#endif // CMD_ISULA_STREAM_CP_H
diff --git a/src/cmd/isula/stream/exec.h b/src/cmd/isula/stream/exec.h
index 6161c62f..d507d71e 100644
--- a/src/cmd/isula/stream/exec.h
+++ b/src/cmd/isula/stream/exec.h
@@ -22,6 +22,10 @@
#include "attach.h"
#include "command_parser.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define EXEC_OPTIONS(cmdargs) \
{ \
CMD_OPT_TYPE_CALLBACK, false, "env", 'e', &(cmdargs).extra_env, "Set environment variables", \
@@ -51,4 +55,8 @@ extern const char g_cmd_exec_usage[];
extern struct client_arguments g_cmd_exec_args;
int cmd_exec_main(int argc, const char **argv);
+#ifdef __cplusplus
+}
+#endif
+
#endif // CMD_ISULA_STREAM_EXEC_H
diff --git a/src/daemon/modules/api/log_gather_api.h b/src/daemon/modules/api/log_gather_api.h
index b72a5800..2c98ff11 100644
--- a/src/daemon/modules/api/log_gather_api.h
+++ b/src/daemon/modules/api/log_gather_api.h
@@ -22,6 +22,10 @@
#define REV_BUF_SIZE 4096
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct log_gather_conf {
const char *fifo_path;
int *exitcode;
@@ -40,5 +44,9 @@ enum log_gather_driver {
void *log_gather(void *arg);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/api/plugin_api.h b/src/daemon/modules/api/plugin_api.h
index 303ba6bf..bf138ec1 100644
--- a/src/daemon/modules/api/plugin_api.h
+++ b/src/daemon/modules/api/plugin_api.h
@@ -41,6 +41,10 @@
#define PLUGIN_EVENT_CONTAINER_POST_STOP (1UL << 2)
#define PLUGIN_EVENT_CONTAINER_POST_REMOVE (1UL << 3)
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct plugin_manifest {
uint64_t init_type;
uint64_t watch_event;
@@ -109,4 +113,8 @@ int plugin_event_container_post_stop(const container_t *cont);
int plugin_event_container_post_remove(const container_t *cont);
int plugin_event_container_post_remove2(const char *cid, const oci_runtime_spec *oci);
+#ifdef __cplusplus
+}
+#endif
+
#endif // DAEMON_MODULES_API_PLUGIN_API_H
diff --git a/src/daemon/modules/container/container_events_handler.h b/src/daemon/modules/container/container_events_handler.h
index f38f293d..77cf5d06 100644
--- a/src/daemon/modules/container/container_events_handler.h
+++ b/src/daemon/modules/container/container_events_handler.h
@@ -22,10 +22,18 @@
#include "container_api.h"
#include "events_format.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
container_events_handler_t *container_events_handler_new();
void container_events_handler_free(container_events_handler_t *handler);
int container_events_handler_post_events(const struct isulad_events_format *event);
+#ifdef __cplusplus
+}
+#endif
+
#endif // DAEMON_MODULES_CONTAINER_CONTAINER_EVENTS_HANDLER_H
diff --git a/src/daemon/modules/container/restart_manager/restartmanager.h b/src/daemon/modules/container/restart_manager/restartmanager.h
index 1f5f13b3..106343b2 100644
--- a/src/daemon/modules/container/restart_manager/restartmanager.h
+++ b/src/daemon/modules/container/restart_manager/restartmanager.h
@@ -22,6 +22,10 @@
#include "isula_libutils/host_config.h"
#include "container_api.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void restart_policy_free(host_config_restart_policy *policy);
restart_manager_t *restart_manager_new(const host_config_restart_policy *policy, int failure_count);
@@ -43,4 +47,8 @@ int restart_manager_wait_cancel(restart_manager_t *rm, uint64_t timeout);
int container_restart_in_thread(const char *id, uint64_t timeout, int exit_code);
+#ifdef __cplusplus
+}
+#endif
+
#endif // DAEMON_MODULES_CONTAINER_RESTART_MANAGER_RESTARTMANAGER_H
diff --git a/src/daemon/modules/container/supervisor/supervisor.h b/src/daemon/modules/container/supervisor/supervisor.h
index e5b5a2e7..2b208c5a 100644
--- a/src/daemon/modules/container/supervisor/supervisor.h
+++ b/src/daemon/modules/container/supervisor/supervisor.h
@@ -19,8 +19,16 @@
#include "container_unix.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern char *exit_fifo_name(const char *cont_state_path);
extern int new_supervisor();
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/events/monitord.h b/src/daemon/modules/events/monitord.h
index beace80e..1741983d 100644
--- a/src/daemon/modules/events/monitord.h
+++ b/src/daemon/modules/events/monitord.h
@@ -20,6 +20,10 @@
#include "utils.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct monitord_sync_data {
sem_t *monitord_sem;
int *exit_code;
@@ -27,4 +31,8 @@ struct monitord_sync_data {
int new_monitord(struct monitord_sync_data *msync);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/image/embedded/db/db_all.h b/src/daemon/modules/image/embedded/db/db_all.h
index 9fbe2729..e72777c2 100644
--- a/src/daemon/modules/image/embedded/db/db_all.h
+++ b/src/daemon/modules/image/embedded/db/db_all.h
@@ -20,6 +20,10 @@
#include <stdbool.h>
#include "db_common.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct db_sninfo {
char *snid;
char *parent_snid;
@@ -73,5 +77,9 @@ int db_read_all_images_info(struct db_all_images **image_info);
void db_all_imginfo_free(struct db_all_images *images_info);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/image/embedded/db/db_common.h b/src/daemon/modules/image/embedded/db/db_common.h
index ab83599f..8ed1138c 100644
--- a/src/daemon/modules/image/embedded/db/db_common.h
+++ b/src/daemon/modules/image/embedded/db/db_common.h
@@ -25,9 +25,17 @@
#define DB_DEREF_ONLY 4
#define DB_NOT_EXIST 5
+#ifdef __cplusplus
+extern "C" {
+#endif
+
int db_common_init(const char *rootpath);
void db_common_finish(void);
+#ifdef __cplusplus
+}
+#endif
+
#endif // DAEMON_MODULES_IMAGE_EMBEDDED_DB_DB_COMMON_H
diff --git a/src/daemon/modules/image/embedded/db/db_images_common.h b/src/daemon/modules/image/embedded/db/db_images_common.h
index 1fde16cc..a35ea49f 100644
--- a/src/daemon/modules/image/embedded/db/db_images_common.h
+++ b/src/daemon/modules/image/embedded/db/db_images_common.h
@@ -17,6 +17,10 @@
#include <stdint.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* common interface definition for database */
struct db_single_image_info {
@@ -32,5 +36,9 @@ struct db_all_images_info {
struct db_single_image_info **images_info;
};
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/image/embedded/db/sqlite_common.h b/src/daemon/modules/image/embedded/db/sqlite_common.h
index 7562932c..8c5db83a 100644
--- a/src/daemon/modules/image/embedded/db/sqlite_common.h
+++ b/src/daemon/modules/image/embedded/db/sqlite_common.h
@@ -19,6 +19,10 @@
#define DBNAME "sqlite.db"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef int(*sqlite_callback_t)(void *, int, char **, char **);
sqlite3 *get_global_db();
@@ -32,5 +36,9 @@ int db_sqlite_request(const char *stmt);
int db_sqlite_request_callback(const char *stmt,
sqlite_callback_t callback, void *data);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/image/embedded/embedded_image.h b/src/daemon/modules/image/embedded/embedded_image.h
index 2177a40b..b1fafacf 100644
--- a/src/daemon/modules/image/embedded/embedded_image.h
+++ b/src/daemon/modules/image/embedded/embedded_image.h
@@ -18,6 +18,10 @@
#include <stdint.h>
#include "image_api.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
bool embedded_detect(const char *image_name);
int embedded_prepare_rf(const im_prepare_request *request, char **real_rootfs);
@@ -48,4 +52,8 @@ int embedded_init(const isulad_daemon_configs *args);
void embedded_exit();
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/image/embedded/lim.h b/src/daemon/modules/image/embedded/lim.h
index cb21884e..fb5bb414 100644
--- a/src/daemon/modules/image/embedded/lim.h
+++ b/src/daemon/modules/image/embedded/lim.h
@@ -22,6 +22,10 @@
#define IMAGE_DATA_TYPE_CONFIG "config"
#define IMAGE_DATA_TYPE_CONFIG_PATH "config_path"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct image_creator {
char *name;
char *type;
@@ -56,5 +60,9 @@ int lim_query_image_data(const char *name, const char *type,
int lim_create_rw_layer(char *name, const char *id, char **options,
char **mount_string);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/image/embedded/snapshot/embedded.h b/src/daemon/modules/image/embedded/snapshot/embedded.h
index eaf4b588..e0cf7bab 100644
--- a/src/daemon/modules/image/embedded/snapshot/embedded.h
+++ b/src/daemon/modules/image/embedded/snapshot/embedded.h
@@ -19,6 +19,10 @@
#include "linked_list.h"
#include "snapshot_def.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct snapshot_plugin ebd_plugin();
int ebd_create_layer(char *id, char *parent, uint32_t layer_attribute,
@@ -31,5 +35,9 @@ int ebd_apply_diff(char *id, char *parent, char *archive, char *metadata);
int ebd_generate_mount_string(struct db_image *imginfo,
struct db_sninfo **sninfos, char **mount_string);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/image/embedded/snapshot/snapshot.h b/src/daemon/modules/image/embedded/snapshot/snapshot.h
index dd2e42e7..fae6c8da 100644
--- a/src/daemon/modules/image/embedded/snapshot/snapshot.h
+++ b/src/daemon/modules/image/embedded/snapshot/snapshot.h
@@ -22,11 +22,19 @@
#include "db_all.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
int snapshot_init(uint32_t driver_type);
int snapshot_generate_mount_string(uint32_t driver_type,
struct db_image *imginfo,
struct db_sninfo **sninfos, char **mount_string);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/image/embedded/snapshot/snapshot_def.h b/src/daemon/modules/image/embedded/snapshot/snapshot_def.h
index fbc2c791..eaf397a6 100644
--- a/src/daemon/modules/image/embedded/snapshot/snapshot_def.h
+++ b/src/daemon/modules/image/embedded/snapshot/snapshot_def.h
@@ -26,6 +26,10 @@
#define LAYER_NUM_MAX 125
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef int(*create_layer_cb)(char *id, char *parent, uint32_t layer_attribute,
char **options, char **mount_string);
@@ -44,6 +48,9 @@ struct snapshot_plugin {
generate_mount_string_cb gms;
};
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/src/daemon/modules/image/external/ext_image.h b/src/daemon/modules/image/external/ext_image.h
index ded2b8ca..17ef4d98 100644
--- a/src/daemon/modules/image/external/ext_image.h
+++ b/src/daemon/modules/image/external/ext_image.h
@@ -26,6 +26,10 @@
#include "image_api.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
bool ext_detect(const char *image_name);
int ext_filesystem_usage(const im_container_fs_usage_request *request, imagetool_fs_info **fs_usage);
@@ -46,4 +50,8 @@ int ext_logout(const im_logout_request *request);
int ext_init(const isulad_daemon_configs *args);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/image/oci/registry_type.h b/src/daemon/modules/image/oci/registry_type.h
index 11135250..bfc77f4a 100644
--- a/src/daemon/modules/image/oci/registry_type.h
+++ b/src/daemon/modules/image/oci/registry_type.h
@@ -29,6 +29,10 @@
#define MAX_LAYER_NUM 125
#define ROOTFS_TYPE "layers"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct {
char *schema;
char *realm;
@@ -132,4 +136,8 @@ void free_challenge(challenge *c);
void free_layer_blob(layer_blob *layer);
void free_pull_desc(pull_descriptor *desc);
+#ifdef __cplusplus
+}
+#endif
+
#endif // DAEMON_MODULES_IMAGE_OCI_REGISTRY_TYPE_H
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/devices_constants.h b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/devices_constants.h
index 5b3db2bd..01bbfef7 100644
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/devices_constants.h
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/devices_constants.h
@@ -35,6 +35,10 @@
#define DEFAULT_DEVICE_SET_MODE 0700
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct {
map_t *map; // map string image_devmapper_device_info* key string will be strdup value ptr will not
} metadata_store_t;
@@ -73,4 +77,8 @@ struct device_set {
bool user_base_size;
};
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/plugin/pspec.h b/src/daemon/modules/plugin/pspec.h
index 618159b1..0ad26848 100644
--- a/src/daemon/modules/plugin/pspec.h
+++ b/src/daemon/modules/plugin/pspec.h
@@ -19,6 +19,10 @@
#include "isula_libutils/oci_runtime_spec.h"
#include "isula_libutils/oci_runtime_pspec.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* extract pspec from oci.
* return NULL when failed. oci not modified.
@@ -39,5 +43,9 @@ int set_pspec(oci_runtime_spec *oci, const char *data);
*/
char *merge_pspec(const char *base, const char *data);
+#ifdef __cplusplus
+}
+#endif
+
#endif // DAEMON_MODULES_PLUGIN_PSPEC_H
diff --git a/src/daemon/modules/spec/specs_mount.h b/src/daemon/modules/spec/specs_mount.h
index 07c07a37..3283d92b 100644
--- a/src/daemon/modules/spec/specs_mount.h
+++ b/src/daemon/modules/spec/specs_mount.h
@@ -26,6 +26,10 @@
#include "isula_libutils/oci_runtime_hooks.h"
#include "isula_libutils/oci_runtime_spec.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
int adapt_settings_for_mounts(oci_runtime_spec *oci_spec, container_config *container_spec);
int merge_conf_mounts(oci_runtime_spec *oci_spec, host_config *host_spec,
@@ -43,4 +47,8 @@ int merge_conf_device(oci_runtime_spec *oci_spec, host_config *host_spec);
int setup_ipc_dirs(host_config *host_spec, container_config_v2_common_config *v2_spec);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/daemon/modules/spec/specs_security.h b/src/daemon/modules/spec/specs_security.h
index f33814d2..37315a95 100644
--- a/src/daemon/modules/spec/specs_security.h
+++ b/src/daemon/modules/spec/specs_security.h
@@ -25,6 +25,10 @@
#include "isula_libutils/container_config_v2.h"
#include "isula_libutils/oci_runtime_spec.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
int merge_default_seccomp_spec(oci_runtime_spec *oci_spec, const defs_process_capabilities *capabilities);
int merge_caps(oci_runtime_spec *oci_spec, const char **adds, size_t adds_len, const char **drops, size_t drops_len);
int refill_oci_process_capabilities(defs_process_capabilities **caps, const char **src_caps, size_t src_caps_len);
@@ -36,4 +40,8 @@ int merge_seccomp(oci_runtime_spec *oci_spec, const char *seccomp_profile);
int merge_selinux(oci_runtime_spec *oci_spec, container_config_v2_common_config *v2_spec);
#endif
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/utils/buffer/buffer.h b/src/utils/buffer/buffer.h
index 168a61f6..83276100 100644
--- a/src/utils/buffer/buffer.h
+++ b/src/utils/buffer/buffer.h
@@ -19,6 +19,10 @@
#include <strings.h>
#include <stdarg.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct Buffer {
char *contents;
size_t bytes_used;
@@ -32,4 +36,8 @@ size_t buffer_strlen(const Buffer *buf);
void buffer_free(Buffer *buf);
int buffer_append(Buffer *buf, const char *append, size_t len);
void buffer_empty(Buffer *buf);
+
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/src/utils/cutils/linked_list.h b/src/utils/cutils/linked_list.h
index 59acb2a8..3a87990a 100644
--- a/src/utils/cutils/linked_list.h
+++ b/src/utils/cutils/linked_list.h
@@ -17,6 +17,10 @@
#include <stddef.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct linked_list {
void *elem;
struct linked_list *next;
@@ -122,5 +126,9 @@ static inline size_t linked_list_len(struct linked_list *list)
return i;
}
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/src/utils/http/parser.h b/src/utils/http/parser.h
index 9a37bd7f..ce5fe5e7 100644
--- a/src/utils/http/parser.h
+++ b/src/utils/http/parser.h
@@ -55,6 +55,10 @@
#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct parsed_http_message {
enum http_method method;
int status_code;
@@ -88,5 +92,9 @@ int parse_http(const char *buf, size_t len, struct parsed_http_message *m,
enum http_parser_type type);
char *get_header_value(const struct parsed_http_message *m, const char *header);
+#ifdef __cplusplus
+}
+#endif
+
#endif
--
2.25.1