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

(#293) Solved factor config_open_default_target out of wrapper.h #368

Merged
merged 11 commits into from
Sep 17, 2023
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
/* SPDX-License-Identifier: Apache-2.0 */

/*
* Copyright 2018-2022 Joel E. Anderson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright 2022 Joel E. Anderson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef __STUMPLESS_PRIVATE_CONFIG_WRAPPER_H
# define __STUMPLESS_PRIVATE_CONFIG_WRAPPER_H
#ifndef __STUMPLESS_PRIVATE_CONFIG_WRAPPER_CONFIG_OPEN_DEFAULT_TARGET_H
goatshriek marked this conversation as resolved.
Show resolved Hide resolved
# define __STUMPLESS_PRIVATE_CONFIG_WRAPPER_CONFIG_OPEN_DEFAULT_TARGET_H

# include <stumpless/config.h>


/* definition of config_open_default_target */
# ifdef STUMPLESS_WINDOWS_EVENT_LOG_TARGETS_SUPPORTED
# include "private/config/wel_supported.h"
Expand All @@ -38,5 +39,4 @@
# define config_open_default_target file_open_default_target
# define config_close_default_target stumpless_close_file_target
# endif

#endif /* __STUMPLESS_PRIVATE_CONFIG_WRAPPER_H */
#endif /* __STUMPLESS_PRIVATE_CONFIG_OPEN_DEFAULT_TARGET_H */
rmknan marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion include/stumpless/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ stumpless_element_has_param( const struct stumpless_element *element,
*
* @param element The element to get the name and params from.
*
* @return The formatted string of <name> or <name>:[param1,...] if no error is encountered.
* @return The formatted string of name or name=[param1,...] if no error is encountered.
* If an error is encountered, then NULL is returned and an error code is set appropriately.
*/
STUMPLESS_PUBLIC_FUNCTION
Expand Down
2 changes: 1 addition & 1 deletion include/stumpless/param.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ stumpless_set_param_value( struct stumpless_param *param, const char *value );
*
* @param param The param to get the name and the value from.
*
* @return The formatted string of "param_name: param_value" if no error is
* @return The formatted string of "param_name=param_value" if no error is
* encountered. If an error is encountered, then NULL is returned and an
* error code is set appropriately.
*/
Expand Down
19 changes: 9 additions & 10 deletions src/param.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,23 +215,22 @@ stumpless_param_to_string( const struct stumpless_param *param ) {
name_len = param->name_length;
value_len = param->value_length;

/* <name>:<value> */
format = alloc_mem( value_len + name_len + 6 );
/* name="value"*/
format = alloc_mem( value_len + name_len + 4 );
if( !format ) {
goto fail;
}

memcpy(format + 1, name, name_len);
memcpy(format + name_len + 4, value, value_len);

memcpy(format, name, name_len);
memcpy(format + name_len + 2, value, value_len);

unlock_param( param );

format[0] = '<';
format[name_len + 1] = '>';
format[name_len + 2] = ':';
format[name_len + 3] = '<';
format[name_len + value_len + 4] = '>';
format[name_len + value_len + 5] = '\0';
format[name_len ] = '=';
format[name_len + 1] = '\"';
format[name_len + value_len + 2] = '\"';
format[name_len + value_len + 3] = '\0';


clear_error( );
Expand Down
3 changes: 2 additions & 1 deletion src/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
#include "private/config.h"
#include "private/config/network_support_wrapper.h"
#include "private/config/locale/wrapper.h"
#include "private/config/wrapper.h"
// #include "private/config/wrapper.h"
rmknan marked this conversation as resolved.
Show resolved Hide resolved
#include "private/config/wrapper/open_default_target.h"
#include "private/config/wrapper/wel.h"
#include "private/config/wrapper/journald.h"
#include "private/config/wrapper/socket.h"
Expand Down
2 changes: 1 addition & 1 deletion test/function/element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ namespace {
format = stumpless_element_to_string( element_with_params );
ASSERT_NOT_NULL( format );

EXPECT_STREQ( format, "<element-with-params>:[<param-1>:<value-1>,<param-2>:<value-2>]" );
EXPECT_STREQ( format, "<element-with-params>:[param-1=\"value-1\",param-2=\"value-2\"]" );
EXPECT_NO_ERROR;

free( ( void * ) format );
Expand Down
2 changes: 1 addition & 1 deletion test/function/param.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ namespace {
format = stumpless_param_to_string( &basic_param );
ASSERT_NOT_NULL( format );

EXPECT_STREQ( format, "<basic-name>:<basic-value>" );
EXPECT_STREQ( format, "basic-name=\"basic-value\"" );
EXPECT_NO_ERROR;

free( ( void * ) format );
Expand Down
11 changes: 2 additions & 9 deletions tools/check_headers/stumpless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,25 @@
"CATEGORY_TREE": "docs/examples/wel/example_events.h"
"clear_error": "private/error.h"
"close_server_socket": "test/helper/server.hpp"
"config_close_default_target": "private/config/wrapper.h"
"config_close_default_target": "private/config/wrapper/open_default_target.h"
"config_close_network_target": "private/config/network_support_wrapper.h"
"config_close_tcp4_target": "private/config/network_support_wrapper.h"
"config_close_udp4_target": "private/config/network_support_wrapper.h"
"config_copy_wel_fields": "private/config/wrapper.h"
"config_destroy_insertion_params": "private/config/wrapper.h"
"config_fopen": "private/config/wrapper.h"
"config_gethostname": "private/config/wrapper.h"
"config_getpagesize": "private/config/wrapper/getpagesize.h"
"config_get_now": "private/config/wrapper/get_now.h"
"config_init_tcp4": "private/config/network_support_wrapper.h"
"config_init_udp4": "private/config/network_support_wrapper.h"
"config_network_free_all": "private/config/network_support_wrapper.h"
"config_network_target_is_open": "private/config/network_support_wrapper.h"
"config_open_default_target": "private/config/wrapper.h"
"config_open_default_target": "private/config/wrapper/open_default_target.h"
"config_open_network_target": "private/config/network_support_wrapper.h"
"config_open_tcp4_target": "private/config/network_support_wrapper.h"
"config_open_udp4_target": "private/config/network_support_wrapper.h"
"config_reopen_tcp4_target": "private/config/network_support_wrapper.h"
"config_reopen_udp4_target": "private/config/network_support_wrapper.h"
"config_send_entry_to_wel_target": "private/config/wrapper.h"
"config_sendto_network_target": "private/config/network_support_wrapper.h"
"config_sendto_tcp4_target": "private/config/network_support_wrapper.h"
"config_sendto_udp4_target": "private/config/network_support_wrapper.h"
"config_set_tcp4_port": "private/config/wrapper.h"
"config_set_udp4_port": "private/config/wrapper.h"
"config_socket_handle_t": "private/config/network_support_wrapper.h"
"config_tcp4_is_open": "private/config/network_support_wrapper.h"
"config_udp4_is_open": "private/config/network_support_wrapper.h"
Expand Down
Loading