Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fafeaac
Encode result file names
klausschuch Oct 10, 2022
eb96f11
Keep old result file names
klausschuch Jul 9, 2024
f7276b2
Use correct separator for PPD file writer
klausschuch Oct 10, 2022
461a524
Display correct tree in onlinemonitoring for parameters
klausschuch Oct 12, 2022
b3b4ace
Read units of naming convention arrays as well
Vaan5 Dec 15, 2022
810f123
Remove unused function
Vaan5 Jan 5, 2023
6e738a7
Remove not implemented micro store level
klausschuch Jan 22, 2023
bdf710c
Prepare for event mode
klausschuch Mar 9, 2024
48e71ac
StepType: Remove unnecessary GetTime() call
klausschuch Feb 9, 2023
0caa912
StepType: Set brackets for stepEndTime comparison correctly
klausschuch Feb 9, 2023
f0c3908
Use DiscreteFilter for clocked connections
Vaan5 Feb 13, 2023
643c0f5
cmake: Use python detected by cmake
Feb 2, 2023
5080d9e
Fix condition (consider channel types)
Vaan5 Mar 3, 2023
7ac586a
Change const type qualifier of argument of 'mcx_resolve_env_var'
klausschuch Mar 3, 2023
d939a0d
Do not replace env vars if not defined
Vaan5 Mar 7, 2023
fa93651
Deprecate %ENV_VAR% constructs
Vaan5 Mar 7, 2023
e2021e1
Initialize all local variables
Vaan5 Mar 7, 2023
130aca8
Function to strip the extension in a path
Vaan5 Mar 17, 2023
15e4d1c
Add flag 'isShadowComponent'
klausschuch Mar 15, 2023
0fa5ae2
Add getter and setter for 'isShadowComponent'
klausschuch Mar 15, 2023
924fb49
Add channels to observable channels if they are not channels from sha…
klausschuch Mar 15, 2023
82ae1eb
fmu2: Fix array parameter dimensionality
Mar 21, 2023
9ef91ff
Support long path when loading dlls in mcx
Vaan5 Mar 15, 2023
d79b581
util: Add mcx_string_decode for uri decoding
Mar 7, 2023
f8b6673
util: Use windows native uri-to-path function
Mar 7, 2023
bc91d8a
Add ConnectionStatus.h/.c for storing connection status of inports
klausschuch Apr 19, 2023
156cd4d
Add member connectionStatus to ChannelInfo
klausschuch Apr 19, 2023
f0b0215
Check if inport is already connected
klausschuch Apr 19, 2023
c96537a
fmu: Add more signal handler guards
Apr 13, 2023
82575cc
model: Destroy components in reverse creation order
Apr 18, 2023
79a7846
Warnings: Fix const-ness of function typedef args
Oct 13, 2022
9809f4d
Warnings: Make implicit conversions explicit casts
Apr 21, 2023
5a68523
Warnings: Improve const-istency
Apr 11, 2023
4425056
Warnings: Remove duplicate definition of OS_WINDOWS
Apr 11, 2023
1438105
Warnings: Ignore LNK4099 (PDB not found) on external libs
Apr 11, 2023
72793f5
Warnings: Use correct function argument type
Apr 11, 2023
a920213
fmu1: Use correct function
Apr 11, 2023
b683239
Warnings: Use correct strlen function for wchars
Apr 11, 2023
635a558
Use %zu for size_t
klausschuch Mar 5, 2025
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
6 changes: 4 additions & 2 deletions cmake/sspschemafiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ set(OUT_DIR "${INCLUDE_DIR}/reader/ssp/schema")

add_library(ssp_headers INTERFACE)

find_package(Python3 REQUIRED)

# process schema files
file(GLOB_RECURSE SCHEMA_FILES "${SSP_ROOT}/*.xsd")
foreach(SCHEMA_FILE ${SCHEMA_FILES})
Expand All @@ -61,7 +63,7 @@ foreach(SCHEMA_FILE ${SCHEMA_FILES})

add_custom_command(
OUTPUT "${OUT_DIR}/${SUB_DIR}/${SCHEMA_FILE_NAME}.h"
COMMAND python "${PYTHON_SCRIPT}" "${SCHEMA_FILE}" -o "${OUT_DIR}/${SUB_DIR}" -p "${SUB_DIR}"
COMMAND "${Python3_EXECUTABLE}" "${PYTHON_SCRIPT}" "${SCHEMA_FILE}" -o "${OUT_DIR}/${SUB_DIR}" -p "${SUB_DIR}"
DEPENDS "${SCHEMA_FILE}"
COMMENT "${CMD_COMMENT}")

Expand All @@ -77,7 +79,7 @@ foreach(SCHEMA_FILE ${SCHEMA_FILES})

add_custom_command(
OUTPUT "${OUT_DIR}/${SCHEMA_FILE_NAME}.h"
COMMAND python "${PYTHON_SCRIPT}" "${SCHEMA_FILE}" -o "${OUT_DIR}"
COMMAND "${Python3_EXECUTABLE}" "${PYTHON_SCRIPT}" "${SCHEMA_FILE}" -o "${OUT_DIR}"
DEPENDS "${SCHEMA_FILE}"
COMMENT "${CMD_COMMENT}")

Expand Down
8 changes: 4 additions & 4 deletions libs/util/include/util/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ McxStatus mcx_os_set_env_var(const char * name, const char * value);
* %VAR%, $(VAR) or ${VAR} in path with their respective values and
* returns the result.
*/
char * mcx_resolve_env_var(char * path);
char * mcx_resolve_env_var(const char * path);

int mcx_parse_win_env_var(char * path, char ** res);
int mcx_parse_linux_par_env_var(char * path, char ** res);
int mcx_parse_linux_bra_env_var(char * path, char ** res);
int mcx_parse_win_env_var(const char * path, char ** res);
int mcx_parse_linux_par_env_var(const char * path, char ** res);
int mcx_parse_linux_bra_env_var(const char * path, char ** res);

/**
* Get string description of errno.
Expand Down
2 changes: 2 additions & 0 deletions libs/util/include/util/paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ extern "C" {
char * mcx_path_dir_name(const char * path);
char * mcx_path_file_name(const char * path);

void mcx_path_strip_ext(char * path);

char * mcx_path_get_absolute(const char * path);
int mcx_path_is_absolute(const char * path);

Expand Down
4 changes: 4 additions & 0 deletions libs/util/include/util/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ extern "C" {

char * mcx_string_dup(const char * s);

char * mcx_string_decode(const char * str, char _escape_char);
char * mcx_string_encode(const char * str, char _escape_char, const char _chars_to_escape[]);
char* mcx_string_encode_special_characters_except_hash(const char* str);
char * mcx_string_encode_filename(const char * str);
char * mcx_string_encode_filename_result_files(const char* str);

wchar_t * mcx_string_to_widechar(const char * str);
char * mcx_string_to_utf8(const wchar_t * wstr);
Expand All @@ -38,6 +41,7 @@ char * mcx_string_merge_array_with_spaces(char * args[]);
char * mcx_string_merge_quoted_array_with_spaces(char * strs[]);

char* mcx_string_sep(char** stringp, const char* delim);
void mcx_string_replace_char(char * str, char searched_char, char replacement_char);

#ifdef __cplusplus
} /* closing brace for extern "C" */
Expand Down
43 changes: 28 additions & 15 deletions libs/util/src/common/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <string.h>

#include "common/memory.h"
#include "common/logging.h"

#include "util/os.h"
#include "util/paths.h"
Expand Down Expand Up @@ -84,7 +85,7 @@ int mcx_os_fprintf(FILE *stream, const char *format, ...) {
return ret;
}

int mcx_parse_win_env_var(char * path, char ** res) {
int mcx_parse_win_env_var(const char * path, char ** res) {
size_t i = 0;

*res = NULL;
Expand Down Expand Up @@ -119,7 +120,7 @@ int mcx_parse_win_env_var(char * path, char ** res) {
return (int)i;
}

static int input_parse_linux_env_var(char * path, char ** res, char open, char close) {
static int input_parse_linux_env_var(const char * path, char ** res, char open, char close) {
size_t i = 0;

*res = NULL;
Expand Down Expand Up @@ -160,11 +161,11 @@ static int input_parse_linux_env_var(char * path, char ** res, char open, char c
return (int)i;
}

int mcx_parse_linux_par_env_var(char * path, char ** res) {
int mcx_parse_linux_par_env_var(const char * path, char ** res) {
return input_parse_linux_env_var(path, res, '(', ')');
}

int mcx_parse_linux_bra_env_var(char * path, char ** res) {
int mcx_parse_linux_bra_env_var(const char * path, char ** res) {
return input_parse_linux_env_var(path, res, '{', '}');
}

Expand All @@ -183,7 +184,7 @@ int mcx_parse_linux_bra_env_var(char * path, char ** res) {
* If path does not start with an environment variable, *res is set to
* NULL and 0 is returned.
*/
static int mcx_parse_env_var(char * path, char ** res) {
static int mcx_parse_env_var(const char * path, char ** res) {
int num;

if (num = mcx_parse_win_env_var(path, res)) {
Expand All @@ -200,23 +201,23 @@ static int mcx_parse_env_var(char * path, char ** res) {
return 0;
}

static int mcx_parse_escaped_env_delimiter_win(char * path) {
static int mcx_parse_escaped_env_delimiter_win(const char * path) {
if (strlen(path) > 1 && path[0] == '%' && path[1] == '%') {
return (int)'%';
} else {
return 0;
}
}

static int mcx_parse_escaped_env_delimiter_linux(char * path) {
static int mcx_parse_escaped_env_delimiter_linux(const char * path) {
if (strlen(path) > 1 && path[0] == '$' && path[1] == '$') {
return (int)'$';
} else {
return 0;
}
}

static int mcx_parse_escaped_env_delimiter(char * path) {
static int mcx_parse_escaped_env_delimiter(const char * path) {
int num;

if (num = mcx_parse_escaped_env_delimiter_win(path)) {
Expand All @@ -229,7 +230,7 @@ static int mcx_parse_escaped_env_delimiter(char * path) {
return 0;
}

char * mcx_resolve_env_var(char * path) {
char * mcx_resolve_env_var(const char * path) {
int i = 0;

int resolved_len = 1; // for '\0'
Expand All @@ -239,9 +240,9 @@ char * mcx_resolve_env_var(char * path) {
}

while (path[i]) {
char * name;
char quote;
int num;
char * name = NULL;
char quote = 0;
int num = 0;

// skip over chars until we find a variable or a quote
while (path[i] &&
Expand Down Expand Up @@ -281,9 +282,7 @@ char * mcx_resolve_env_var(char * path) {

// copy env-var value
if (name) {
char * value;

value = mcx_os_get_env_var(name);
char * value = mcx_os_get_env_var(name);
if (value) {
resolved_len += (int)strlen(value);
resolved = mcx_realloc(resolved, resolved_len);
Expand All @@ -296,6 +295,20 @@ char * mcx_resolve_env_var(char * path) {

strcat(resolved, value);
mcx_free(value);

if (path[i] == '%') {
mcx_log(LOG_WARNING, "Defining environment variables via '%%env_var%%' (%s) is deprecated. Please switch to the '${env_var}' construct instead", path);
}
} else {
resolved_len += num;
resolved = mcx_realloc(resolved, resolved_len);
if (!resolved) {
mcx_free(name);
return NULL;
}

strncat(resolved, path + i, num);
resolved[resolved_len - 1] = '\0';
}

mcx_free(name);
Expand Down
65 changes: 11 additions & 54 deletions libs/util/src/common/paths.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include "util/paths.h"


#define LOCATION_PREFIX "file://"


#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
Expand Down Expand Up @@ -60,6 +63,14 @@ char * mcx_path_file_name(const char * path) {
return dir;
}

void mcx_path_strip_ext(char * path) {
char * dot = strrchr(path, '.');

if (dot) {
*dot = '\0';
}
}

char ** mcx_path_split(char * path) {
size_t partsNum = 0;
size_t pos = 0;
Expand Down Expand Up @@ -247,60 +258,6 @@ char * mcx_path_get_relative(const char * fileName, const char * path) {
return mergedPath;
}

char * mcx_path_from_uri(const char * uri) {
char * buffer = NULL;
size_t i = 0;
size_t j = 0;
#if defined (OS_WINDOWS)
/* use of PathCreateFromUrl was considered, dismissed because of
needed effort */
#define LOCATION_PREFIX "file:///"
#define LOCATION_PREFIX_2SLASHES "file://"
if (0 == strncmp(uri, LOCATION_PREFIX, strlen(LOCATION_PREFIX))) {
uri += strlen(LOCATION_PREFIX);
} else if (0 == strncmp(uri, LOCATION_PREFIX_2SLASHES, strlen(LOCATION_PREFIX_2SLASHES))) {
uri += strlen(LOCATION_PREFIX_2SLASHES);
}
#else
#define LOCATION_PREFIX "file://"
/* check if this is file uri */
if (strncmp(uri, LOCATION_PREFIX, strlen(LOCATION_PREFIX))) {
/* not a file uri */
return NULL;
}

/* check if uri has authority component */
if (uri[strlen(LOCATION_PREFIX)] == '/') {
/* no authority component */
uri += strlen(LOCATION_PREFIX);
} else {
/* skip over authority component */
uri += strlen(LOCATION_PREFIX);
while (*uri != '\0' && *uri != '/') {
uri++;
}
}
#endif /* OS_WINDOWS */
buffer = (char *)mcx_calloc(strlen(uri) + 1, sizeof(char));
if (!buffer) { return NULL; }

/* convert escaped characters back */
while (uri[i]) {
if (uri[i] == '%') {
char str[3] = {uri[i+1], uri[i+2], 0};
buffer[j] = (char) strtol(str, NULL, 16);
i += 3;
j += 1;
} else {
buffer[j] = uri[i];
i += 1;
j += 1;
}
}
buffer[j] = '\0';

return buffer;
}

char * mcx_path_to_uri(const char * path) {
char * uri = NULL;
Expand Down
56 changes: 56 additions & 0 deletions libs/util/src/common/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "common/memory.h"
#include "common/logging.h"

#include "util/string.h"

Expand Down Expand Up @@ -44,6 +46,37 @@ static int mcx_string_contains_char(const char * str, char c) {
return 0;
}

char * mcx_string_decode(const char * str, char _escape_char) {
int i = 0;
int j = 0;
char * buffer = NULL;

buffer = (char *) mcx_calloc(strlen(str) + 1, sizeof(char));
if (!buffer) {
return NULL;
}

while (str[i]) {
if (str[i] == _escape_char) {
if (!str[i+1] || !str[i+2]) {
mcx_log(LOG_ERROR, "Invalid escape sequence encountered in string: %s", str);
return NULL;
}
char escape_sequence[3] = {str[i+1], str[i+2], 0};
buffer[j] = (char) strtol(escape_sequence, NULL, 16);
i += 3;
j += 1;
} else {
buffer[j] = str[i];
i += 1;
j += 1;
}
}
buffer[j] = '\0';

return buffer;
}

char * mcx_string_encode(const char * str, char _escape_char, const char _chars_to_escape[]) {
size_t len = strlen(str);
size_t num = 0;
Expand Down Expand Up @@ -78,6 +111,17 @@ char * mcx_string_encode_filename(const char * str) {
return mcx_string_encode(str, '%', "\\\"<>|!#$&'()*+,/:;=?@[]%");
}

char* mcx_string_encode_special_characters_except_hash(const char* str) {
return mcx_string_encode(str, '%', "\\\"<>|!$&'()*+,/:;=?@[]%._`*{}");
}

char* mcx_string_encode_filename_result_files(const char* str) {
char* str_encoded = mcx_string_encode_special_characters_except_hash(str);
mcx_string_replace_char(str_encoded, ' ', '_');
mcx_string_replace_char(str_encoded, '#', '.');
return str_encoded;
}

int mcx_string_ends_with(const char * str, const char * suffix) {
if ( *str ) {
char * pos = strstr(str, suffix);
Expand Down Expand Up @@ -243,6 +287,18 @@ char* mcx_string_sep(char** stringp, const char* delim)
return start;
}

void mcx_string_replace_char(char* str, char searched_char, char replacement_char) {
size_t len = strlen(str);
size_t i = 0;

for (i = 0; i < len; i++) {
if (searched_char == str[i]) {
str[i] = replacement_char;
}
}
}


#ifdef __cplusplus
} /* closing brace for extern "C" */
#endif /* __cplusplus */
Loading