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

Rename vsnprintf() related functions #11

Merged
merged 2 commits into from
Jan 23, 2024
Merged
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
7 changes: 0 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,6 @@ impl bindgen::callbacks::ParseCallbacks for CustomCallbacks {
if original_item_name == "RS_EMPTY_ARRAY_SENTINEL" {
return Some("UA_EMPTY_ARRAY_SENTINEL".to_owned());
}
// Rename wrapper function back to its original name. See `wrapper.c` for details.
if original_item_name == "RS_vsnprintf" {
return Some("vsnprintf".to_owned());
}
if original_item_name == "RS_va_end" {
return Some("va_end".to_owned());
}
None
}
}
18 changes: 2 additions & 16 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use core::{ffi, ptr};

use open62541_sys::{
va_end, va_list_, vsnprintf, UA_Client_delete, UA_Client_new, UA_LogCategory, UA_LogLevel,
UA_Logger, UA_LoggerClearCallback_, UA_LoggerLogCallback_,
va_list_, UA_Client_delete, UA_Client_new, UA_LogCategory, UA_LogLevel, UA_Logger,
UA_LoggerClearCallback_, UA_LoggerLogCallback_,
};

#[test]
Expand Down Expand Up @@ -49,17 +49,3 @@ fn logger_types() {
clear,
};
}

#[test]
fn has_vsnprintf() {
// Make sure that `vsnprintf()` is available. On Microsoft Windows we have to provide a wrapper,
// to support older versions of the C library (before the introduction of the UCRT/Visual Studio
// 2015/Windows 10).
let _unused = vsnprintf;
}

#[test]
fn has_va_end() {
// Make sure that `va_end()` is available.
let _unused = va_end;
}
8 changes: 4 additions & 4 deletions wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// such as Microsoft Windows.
//
// Other than the standard `vsnprintf()`, this function does not consume the passed
// `va_list` argument! The caller is responsible for calling `va_end()` on the
// `va_list` argument! The caller is responsible for calling `vsnprintf_va_end()` on the
// `va_list` argument eventually.
#if defined(_MSC_VER) && _MSC_VER < 1900
int RS_vsnprintf(
int vsnprintf_va_copy(
char *buffer,
size_t count,
const char *format,
Expand All @@ -31,7 +31,7 @@ int RS_vsnprintf(
return result;
}
#else
int RS_vsnprintf(
int vsnprintf_va_copy(
char *buffer,
size_t count,
const char *format,
Expand All @@ -47,7 +47,7 @@ int RS_vsnprintf(
}
#endif

void RS_va_end(va_list args)
void vsnprintf_va_end(va_list args)
{
va_end(args);
}
Expand Down
8 changes: 5 additions & 3 deletions wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ extern const void *const RS_EMPTY_ARRAY_SENTINEL;
// such as Microsoft Windows.
//
// Other than the standard `vsnprintf()`, this implementation copies the `va_list`
// argument before passing it along to allow repeated calls.
int RS_vsnprintf(
// argument before passing it along to allow repeated calls. The caller is responsible
// to invoke `vsnprintf_va_end()` on the `va_list` argument eventually.
int vsnprintf_va_copy(
char *buffer,
size_t count,
const char *format,
va_list args);

void RS_va_end(va_list args);
// Wrapper for `va_end()` that is supposed to be used with `vsnprintf_va_copy()`.
void vsnprintf_va_end(va_list args);
Loading