Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rbus adapter (Work in progress - don't merge) #116

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions include/wrp-c/rbus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* SPDX-FileCopyrightText: 2022 Comcast Cable Communications Management, LLC */
/* SPDX-License-Identifier: Apache-2.0 */
#ifndef __WRPC_RBUS_H__
#define __WRPC_RBUS_H__

#include "wrp-c.h"
#include <rbus/rbus.h>
#include <stddef.h>
#include <stdint.h>

/**
* Converts a wrp structure to an rbus encoded form.
*
* @param src the message to encode
* @param dest If *dest != NULL then encode into the specified buffer.
* If *dest == NULL then the function will allocate a buffer and
* return a pointer to it here.
* @param len The dest buffer length if provided, and the number of valid
* encoded byte in dest.
*
* @retval WRPE_OK
* @retval WRPE_INVALID_ARGS
* @retval WRPE_NOT_A_WRP_MSG
* @retval WRPE_MSG_TOO_BIG
* @retval WRPE_OUT_OF_MEMORY
* @retval WRPE_OTHER_ERROR
*/
WRPcode wrp_to_rbus(const wrp_msg_t *src, rbusObject_t *dest);


/**
* Converts an rbus encoded message into the wrp c structure.
*
* @note All data is copied from the rbus objects because it does not
* provide a way to reference the information directly and safely.
*
* @param src the rbusObject_t object
* @param dest the resulting object (must be released by caller)
*
* @retval WRPE_OK
* @retval WRPE_INVALID_ARGS
* @retval WRPE_NOT_MSGPACK_FORMAT
* @retval WRPE_NOT_A_WRP_MSG
* @retval WRPE_MSG_TOO_BIG
* @retval WRPE_OUT_OF_MEMORY
* @retval WRPE_OTHER_ERROR
*/
WRPcode wrp_from_rbus(const rbusObject_t src, wrp_msg_t **dest);
#endif
2 changes: 2 additions & 0 deletions include/wrp-c/wrp-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ struct wrp_event_msg {
struct wrp_string msg_id; /* Optional */
struct wrp_string_list partner_ids; /* Optional */
struct wrp_blob payload; /* Optional */
struct wrp_int rdr; /* Optional */
struct wrp_string session_id; /* Optional */
struct wrp_string trans_id; /* Optional */
};

struct wrp_crud_msg {
Expand Down
20 changes: 16 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Meson build file
#
# SPDX-FileCopyrightText: 2021 Comcast Cable Communications Management, LLC
# SPDX-FileCopyrightText: 2021-2022 Comcast Cable Communications Management, LLC
# SPDX-License-Identifier: Apache-2.0

project('wrp-c', 'c',
version: '2.0.0',
license: ['Apache-2.0'],
default_options: ['c_std=c99',
default_options: ['c_std=c11',
'b_coverage=true'])

if not meson.is_subproject()
Expand All @@ -33,17 +33,22 @@ subdir('include/'+meson.project_name())
ludocode_mpack_dep = dependency('mpack', version: '>=1.0',
fallback: ['ludocode-mpack', 'ludocode_mpack_dep'],
)
cutils_dep = dependency('cutils', version: '>=1.0.0')
cutils_dep = dependency('cutils', version: '>=1.0.0')

all_deps = [ludocode_mpack_dep, cutils_dep]

if get_option('rbus-support')
librbus_dep = dependency('librbus')
all_deps += [librbus_dep]
endif

################################################################################
# Define the libraries
################################################################################

inc = include_directories([inc_base])

install_headers([inc_base+'/wrp-c.h', ver_h], subdir: meson.project_name())
headers = [inc_base+'/wrp-c.h', ver_h]

sources = [ 'src/constants.c',
'src/decode.c',
Expand All @@ -52,6 +57,13 @@ sources = [ 'src/constants.c',
'src/locator.c',
'src/string.c']

if get_option('rbus-support')
sources += [ 'src/rbus.c' ]
headers += [ inc_base+'/rbus.h' ]
endif

install_headers(headers, subdir: meson.project_name())

libwrpc = library(meson.project_name(),
sources,
include_directories: inc,
Expand Down
12 changes: 12 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- mode: meson -*-
# SPDX-FileCopyrightText: 2022 Comcast Cable Communications Management, LLC
# SPDX-License-Identifier: Apache-2.0

####################################################
# Under each section keep the options alphabetized #
####################################################

# Build configuration options
#-------------------------------------------------------------------------------
option('rbus-support', type: 'boolean', value: 'true',
description: 'build the rbus compatability code')
Loading