Declare exported functions as C

Allows to be used by both C and C++ code.
So to leave part of the code in C and part move to C++.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
Frediano Ziglio 2019-05-23 05:43:55 +01:00 committed by Frediano Ziglio
parent 238f53d702
commit e0b395fb68
34 changed files with 144 additions and 0 deletions

View File

@ -23,6 +23,9 @@
#include <inttypes.h>
#include <glib.h>
#include <spice/macros.h>
SPICE_BEGIN_DECLS
/* Possible return values for agent_msg_filter_process_data */
typedef enum {
@ -58,4 +61,6 @@ void agent_msg_filter_config(AgentMsgFilter *filter,
AgentMsgFilterResult agent_msg_filter_process_data(AgentMsgFilter *filter,
const uint8_t *data, uint32_t len);
SPICE_END_DECLS
#endif /* AGENT_MSG_FILTER_H_ */

View File

@ -25,6 +25,8 @@
#include "red-channel.h"
#include "migration-protocol.h"
SPICE_BEGIN_DECLS
#define RED_TYPE_CHAR_DEVICE red_char_device_get_type()
#define RED_CHAR_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), RED_TYPE_CHAR_DEVICE, RedCharDevice))
@ -248,4 +250,6 @@ SpiceCharDeviceInstance *red_char_device_get_device_instance(RedCharDevice *dev)
SpiceCharDeviceInterface *spice_char_device_get_interface(SpiceCharDeviceInstance *instance);
SPICE_END_DECLS
#endif /* CHAR_DEVICE_H_ */

View File

@ -24,6 +24,8 @@
#include "red-common.h"
SPICE_BEGIN_DECLS
#define TYPE_DISPATCHER dispatcher_get_type()
#define DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_DISPATCHER, Dispatcher))
@ -167,4 +169,6 @@ SpiceWatch *dispatcher_create_watch(Dispatcher *dispatcher, SpiceCoreInterfaceIn
*/
void dispatcher_set_opaque(Dispatcher *dispatcher, void *opaque);
SPICE_END_DECLS
#endif /* DISPATCHER_H_ */

View File

@ -26,6 +26,8 @@
glz-encoder-priv.h
*/
SPICE_BEGIN_DECLS
typedef void GlzEncDictContext;
typedef void GlzEncDictImageContext;
@ -65,4 +67,6 @@ GlzEncDictContext *glz_enc_dictionary_restore(GlzEncDictRestoreData *restore_dat
void glz_enc_dictionary_remove_image(GlzEncDictContext *opaque_dict,
GlzEncDictImageContext *image, GlzEncoderUsrContext *usr);
SPICE_END_DECLS
#endif /* GLZ_ENCODER_DICT_H_ */

View File

@ -25,6 +25,8 @@
#include "red-common.h"
#include "glz-encoder-dict.h"
SPICE_BEGIN_DECLS
struct GlzEncoderUsrContext {
SPICE_GNUC_PRINTF(2, 3) void (*error)(GlzEncoderUsrContext *usr, const char *fmt, ...);
SPICE_GNUC_PRINTF(2, 3) void (*warn)(GlzEncoderUsrContext *usr, const char *fmt, ...);
@ -70,5 +72,6 @@ int glz_encode(GlzEncoderContext *opaque_encoder, LzImageType type, int width, i
uint8_t *io_ptr, unsigned int num_io_bytes, GlzUsrImageContext *usr_context,
GlzEncDictImageContext **o_enc_dict_context);
SPICE_END_DECLS
#endif /* GLZ_ENCODER_H_ */

View File

@ -24,6 +24,8 @@
#include <common/canvas_base.h>
#include <common/ring.h>
SPICE_BEGIN_DECLS
/* FIXME: move back to display-channel.h (once structs are private) */
typedef struct Drawable Drawable;
@ -60,4 +62,6 @@ void image_cache_localize_brush (ImageCache *cache, SpiceBrush *brush
void image_cache_localize_mask (ImageCache *cache, SpiceQMask *mask,
SpiceImage *image_store);
SPICE_END_DECLS
#endif /* IMAGE_CACHE_H_ */

View File

@ -34,6 +34,8 @@
#endif
#include "zlib-encoder.h"
SPICE_BEGIN_DECLS
struct RedClient;
typedef struct RedCompressBuf RedCompressBuf;
@ -218,4 +220,6 @@ bool image_encoders_compress_glz(ImageEncoders *enc, SpiceImage *dest,
#define RED_RELEASE_BUNCH_SIZE 64
SPICE_END_DECLS
#endif /* IMAGE_ENCODERS_H_ */

View File

@ -33,6 +33,8 @@
#include <spice/types.h>
SPICE_BEGIN_DECLS
typedef enum {
JPEG_IMAGE_TYPE_INVALID,
JPEG_IMAGE_TYPE_RGB16,
@ -59,4 +61,6 @@ int jpeg_encode(JpegEncoderContext *jpeg, int quality, JpegEncoderImageType type
int width, int height, uint8_t *lines, unsigned int num_lines, int stride,
uint8_t *io_ptr, unsigned int num_io_bytes);
SPICE_END_DECLS
#endif /* JPEG_ENCODER_H_ */

View File

@ -33,6 +33,8 @@
#include <spice/types.h>
SPICE_BEGIN_DECLS
typedef void* Lz4EncoderContext;
typedef struct Lz4EncoderUsrContext Lz4EncoderUsrContext;
@ -48,4 +50,6 @@ void lz4_encoder_destroy(Lz4EncoderContext *encoder);
int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
unsigned int num_io_bytes, int top_down, uint8_t format);
SPICE_END_DECLS
#endif /* LZ4_ENCODER_H_ */

View File

@ -23,6 +23,8 @@
#include "dispatcher.h"
#include "red-channel.h"
SPICE_BEGIN_DECLS
#define TYPE_MAIN_DISPATCHER main_dispatcher_get_type()
#define MAIN_DISPATCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), TYPE_MAIN_DISPATCHER, MainDispatcher))
@ -61,4 +63,6 @@ void main_dispatcher_client_disconnect(MainDispatcher *self, RedClient *client);
MainDispatcher* main_dispatcher_new(RedsState *reds);
SPICE_END_DECLS
#endif /* MAIN_DISPATCHER_H_ */

View File

@ -23,6 +23,8 @@
#include "red-common.h"
SPICE_BEGIN_DECLS
typedef struct MemSlot {
int generation;
uintptr_t virt_start_addr;
@ -73,4 +75,6 @@ void memslot_info_add_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uint32_
void memslot_info_del_slot(RedMemSlotInfo *info, uint32_t slot_group_id, uint32_t slot_id);
void memslot_info_reset(RedMemSlotInfo *info);
SPICE_END_DECLS
#endif /* MEMSLOT_H_ */

View File

@ -19,10 +19,15 @@
#define RED_NET_UTILS_H_
#include <stdbool.h>
#include <spice/macros.h>
SPICE_BEGIN_DECLS
bool red_socket_set_keepalive(int fd, bool enable, int timeout);
bool red_socket_set_no_delay(int fd, bool no_delay);
int red_socket_get_no_delay(int fd);
bool red_socket_set_non_blocking(int fd, bool non_blocking);
SPICE_END_DECLS
#endif /* RED_NET_UTILS_H_ */

View File

@ -23,6 +23,8 @@
#include "red-channel.h"
SPICE_BEGIN_DECLS
#define MAX_CACHE_CLIENTS 4
#define BITS_CACHE_HASH_SHIFT 10
@ -73,4 +75,6 @@ void pixmap_cache_clear(PixmapCache *cache);
int pixmap_cache_unlocked_set_lossy(PixmapCache *cache, uint64_t id, int lossy);
bool pixmap_cache_freeze(PixmapCache *cache);
SPICE_END_DECLS
#endif /* PIXMAP_CACHE_H_ */

View File

@ -24,6 +24,8 @@
#include "red-common.h"
#include "memslot.h"
SPICE_BEGIN_DECLS
typedef struct RedDrawable {
int refs;
QXLInstance *qxl;
@ -146,4 +148,6 @@ RedCursorCmd *red_cursor_cmd_new(QXLInstance *qxl, RedMemSlotInfo *slots,
RedCursorCmd *red_cursor_cmd_ref(RedCursorCmd *cmd);
void red_cursor_cmd_unref(RedCursorCmd *cmd);
SPICE_END_DECLS
#endif /* RED_PARSE_QXL_H_ */

View File

@ -22,6 +22,8 @@
#include <stddef.h>
#include <inttypes.h>
SPICE_BEGIN_DECLS
typedef struct RedPipeItem RedPipeItem;
typedef void red_pipe_item_free_t(RedPipeItem *item);
@ -47,4 +49,6 @@ static inline void red_pipe_item_init(RedPipeItem *item, int type)
/* a convenience function for unreffing a pipe item after it has been sent */
void marshaller_unref_pipe_item(uint8_t *data, void *opaque);
SPICE_END_DECLS
#endif /* RED_PIPE_ITEM_H_ */

View File

@ -21,6 +21,8 @@
#include "red-channel.h"
#include "spice-qxl.h"
SPICE_BEGIN_DECLS
void red_qxl_init(SpiceServer *reds, QXLInstance *qxl);
void red_qxl_destroy(QXLInstance *qxl);
@ -59,4 +61,6 @@ void red_qxl_set_client_capabilities(QXLInstance *qxl,
uint8_t client_present,
uint8_t caps[SPICE_CAPABILITIES_SIZE]);
SPICE_END_DECLS
#endif /* RED_QXL_H_ */

View File

@ -25,6 +25,8 @@
#include "memslot.h"
#include "utils.h"
SPICE_BEGIN_DECLS
typedef struct RedRecord RedRecord;
/**
@ -45,4 +47,6 @@ void red_record_event(RedRecord *record, int what, uint32_t type);
void red_record_qxl_command(RedRecord *record, RedMemSlotInfo *slots,
QXLCommandExt ext_cmd);
SPICE_END_DECLS
#endif /* RED_RECORD_QXL_H_ */

View File

@ -23,6 +23,8 @@
#include "spice.h"
#include "red-common.h"
SPICE_BEGIN_DECLS
typedef void (*AsyncReadDone)(void *opaque);
typedef void (*AsyncReadError)(void *opaque, int err);
@ -103,4 +105,6 @@ typedef enum {
typedef void (*RedSaslResult)(void *opaque, RedSaslError err);
bool red_sasl_start_auth(RedStream *stream, RedSaslResult result_cb, void *opaque);
SPICE_END_DECLS
#endif /* RED_STREAM_H_ */

View File

@ -26,6 +26,8 @@
#include "red-channel.h"
SPICE_BEGIN_DECLS
typedef struct RedWorker RedWorker;
RedWorker* red_worker_new(QXLInstance *qxl);
@ -241,4 +243,6 @@ enum {
void red_qxl_clear_pending(QXLState *qxl_state, int pending);
SPICE_END_DECLS
#endif /* RED_WORKER_H_ */

View File

@ -31,6 +31,8 @@
#include "main-dispatcher.h"
#include "migration-protocol.h"
SPICE_BEGIN_DECLS
static inline QXLInterface * qxl_get_interface(QXLInstance *qxl)
{
return SPICE_UPCAST(QXLInterface, qxl->base.sif);
@ -119,4 +121,6 @@ SpiceTimer *reds_core_timer_add(RedsState *reds,
SpiceTimerFunc func,
void *opaque);
SPICE_END_DECLS
#endif /* REDS_H_ */

View File

@ -24,6 +24,8 @@
#include "char-device.h"
#include "red-channel-client.h"
SPICE_BEGIN_DECLS
SPICE_DECLARE_TYPE(RedCharDeviceSmartcard, red_char_device_smartcard, CHAR_DEVICE_SMARTCARD);
#define RED_TYPE_CHAR_DEVICE_SMARTCARD red_char_device_smartcard_get_type()
@ -66,4 +68,6 @@ enum {
RED_PIPE_ITEM_TYPE_SMARTCARD_MIGRATE_DATA,
};
SPICE_END_DECLS
#endif /* SMART_CARD_H_ */

View File

@ -21,6 +21,8 @@
#include "red-common.h"
SPICE_BEGIN_DECLS
typedef enum {
BITMAP_GRADUAL_INVALID,
BITMAP_GRADUAL_NOT_AVAIL,
@ -90,4 +92,6 @@ void dump_bitmap(SpiceBitmap *bitmap);
int spice_bitmap_from_surface_type(uint32_t surface_format);
SPICE_END_DECLS
#endif /* SPICE_BITMAP_UTILS_H_ */

View File

@ -21,6 +21,8 @@
#include <stdint.h>
SPICE_BEGIN_DECLS
typedef uint32_t StatNodeRef;
#define INVALID_STAT_REF (~(StatNodeRef)0)
@ -37,4 +39,6 @@ uint64_t *stat_file_add_counter(RedStatFile *stat_file, StatNodeRef parent,
void stat_file_remove_node(RedStatFile *stat_file, StatNodeRef ref);
void stat_file_remove_counter(RedStatFile *stat_file, uint64_t *counter);
SPICE_END_DECLS
#endif /* STAT_FILE_H_ */

View File

@ -24,6 +24,8 @@
#include "spice.h"
#include "stat-file.h"
SPICE_BEGIN_DECLS
typedef struct {
#ifdef RED_STATISTICS
uint64_t *counter;
@ -189,4 +191,6 @@ static inline void stat_add(G_GNUC_UNUSED stat_info_t *info,
#endif
}
SPICE_END_DECLS
#endif /* STAT_H_ */

View File

@ -32,6 +32,10 @@
#else
# include <winsock2.h>
# include <windows.h>
# include <spice/macros.h>
SPICE_BEGIN_DECLS
typedef int socklen_t;
// this definition is ABI compatible with WSABUF
@ -137,6 +141,9 @@ socket_accept(int sock, struct sockaddr *addr, int *addrlen)
int socket_newpair(int type, int protocol, int sv[2]);
#define socketpair(family, type, protocol, sv) socket_newpair(type, protocol, sv)
SPICE_END_DECLS
#endif
#endif // RED_SYS_SOCKET_H_

View File

@ -21,10 +21,14 @@
#include <spice.h>
#include <glib.h>
SPICE_BEGIN_DECLS
GMainContext *basic_event_loop_get_context(void);
SpiceCoreInterface *basic_event_loop_init(void);
void basic_event_loop_destroy(void);
void basic_event_loop_mainloop(void);
void basic_event_loop_quit(void);
SPICE_END_DECLS
#endif // __BASIC_EVENT_LOOP_H__

View File

@ -21,6 +21,8 @@
#include <spice.h>
#include "basic-event-loop.h"
SPICE_BEGIN_DECLS
/*
* simple queue for commands.
* each command can have up to two parameters (grow as needed)
@ -141,4 +143,6 @@ uint32_t test_get_height(void);
void spice_test_config_parse_args(int argc, char **argv);
SPICE_END_DECLS
#endif /* __TEST_DISPLAY_BASE_H__ */

View File

@ -18,9 +18,15 @@
#ifndef TEST_WIN_ALARM_H
#define TEST_WIN_ALARM_H
#include <spice/macros.h>
SPICE_BEGIN_DECLS
#ifdef _WIN32
void test_alarm(unsigned int timeout);
#define alarm test_alarm
#endif
SPICE_END_DECLS
#endif // TEST_WIN_ALARM_H

View File

@ -25,6 +25,8 @@
#include "spice-bitmap-utils.h"
SPICE_BEGIN_DECLS
enum {
TREE_ITEM_TYPE_NONE,
TREE_ITEM_TYPE_DRAWABLE,
@ -97,4 +99,6 @@ Container* container_new (DrawItem *item);
void container_free (Container *container);
void container_cleanup (Container *container);
SPICE_END_DECLS
#endif /* TREE_H_ */

View File

@ -21,6 +21,9 @@
#include <stdint.h>
#include <glib.h>
#include <spice/macros.h>
SPICE_BEGIN_DECLS
#define SPICE_GNUC_VISIBLE __attribute__ ((visibility ("default")))
@ -80,4 +83,6 @@ static inline int64_t i64abs(int64_t value)
return (value >= 0) ? value : -value;
}
SPICE_END_DECLS
#endif /* UTILS_H_ */

View File

@ -26,6 +26,8 @@
#include <common/draw.h>
SPICE_BEGIN_DECLS
/* A structure containing the data for a compressed frame. See encode_frame(). */
typedef struct VideoBuffer VideoBuffer;
struct VideoBuffer {
@ -215,4 +217,6 @@ typedef struct RedVideoCodec {
char *video_codecs_to_string(GArray *video_codecs, const char *sep);
SPICE_END_DECLS
#endif /* VIDEO_ENCODER_H_ */

View File

@ -27,6 +27,8 @@
#include "red-channel.h"
#include "dcc.h"
SPICE_BEGIN_DECLS
#define RED_STREAM_DETECTION_MAX_DELTA (NSEC_PER_SEC / 5)
#define RED_STREAM_CONTINUOUS_MAX_DELTA NSEC_PER_SEC
#define RED_STREAM_TIMEOUT NSEC_PER_SEC
@ -152,4 +154,6 @@ void video_stream_agent_stop(VideoStreamAgent *agent);
void video_stream_detach_drawable(VideoStream *stream);
SPICE_END_DECLS
#endif /* VIDEO_STREAM_H_ */

View File

@ -19,9 +19,12 @@
#define WEBSOCKET_H_
#include <stdint.h>
#include <spice/macros.h>
#include "sys-socket.h"
SPICE_BEGIN_DECLS
typedef ssize_t (*websocket_read_cb_t)(void *opaque, void *buf, size_t nbyte);
typedef ssize_t (*websocket_write_cb_t)(void *opaque, const void *buf, size_t nbyte);
typedef ssize_t (*websocket_writev_cb_t)(void *opaque, struct iovec *iov, int iovcnt);
@ -49,4 +52,6 @@ int websocket_read(RedsWebSocket *ws, uint8_t *buf, size_t len, unsigned *flags)
int websocket_write(RedsWebSocket *ws, const void *buf, size_t len, unsigned flags);
int websocket_writev(RedsWebSocket *ws, const struct iovec *iov, int iovcnt, unsigned flags);
SPICE_END_DECLS
#endif

View File

@ -33,6 +33,8 @@
#include <inttypes.h>
SPICE_BEGIN_DECLS
typedef struct ZlibEncoder ZlibEncoder;
typedef struct ZlibEncoderUsrContext ZlibEncoderUsrContext;
@ -48,4 +50,6 @@ void zlib_encoder_destroy(ZlibEncoder *encoder);
int zlib_encode(ZlibEncoder *zlib, int level, int input_size,
uint8_t *io_ptr, unsigned int num_io_bytes);
SPICE_END_DECLS
#endif /* ZLIB_ENCODER_H_ */