diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-02-17 23:52:06 +0100 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-02-17 23:52:06 +0100 |
| commit | 7648a256d97abda40edbdc0d7bf59edd0a09fb95 (patch) | |
| tree | a86d829f85f4a3d8038741c299d9409cb2272686 /src/client.c | |
| parent | b2002d96f495dcb3bd2f5a738ec1615034ca876f (diff) | |
| download | BobinkCOpcUa-7648a256d97abda40edbdc0d7bf59edd0a09fb95.tar.gz BobinkCOpcUa-7648a256d97abda40edbdc0d7bf59edd0a09fb95.zip | |
Extract createServer and parseAuthConfig, simplify programs
Rename createSecureServer to createServer and add an unsecure path
(UA_ServerConfig_setMinimal) when certPath is NULL, eliminating the
if/else server creation blocks in server_lds.c and server_register.c.
Add parseAuthConfig() to common.c to replace four near-identical
authMode parsing blocks across the three programs.
Restructure server_register.c error handling with goto cleanup,
removing ~20 duplicated cleanup sequences.
Rename the CMake library target from DiscoveryCommon to common.
Diffstat (limited to 'src/client.c')
| -rw-r--r-- | src/client.c | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/src/client.c b/src/client.c index 8234963..f03a337 100644 --- a/src/client.c +++ b/src/client.c @@ -233,38 +233,11 @@ main (int argc, char **argv) const char *username = NULL, *password = NULL; - if (op == OP_READ_TIME) + if (op == OP_READ_TIME + && parseAuthConfig (&cfg, "Client", NULL, &username, &password) != 0) { - const char *authMode = configRequire (&cfg, "authMode", "Client"); - if (!authMode) - { - configFree (&cfg); - return EXIT_FAILURE; - } - - if (strcmp (authMode, "anonymous") == 0) - { - /* No credentials needed. */ - } - else if (strcmp (authMode, "user") == 0) - { - username = configRequire (&cfg, "username", "Client"); - password = configRequire (&cfg, "password", "Client"); - if (!username || !password) - { - configFree (&cfg); - return EXIT_FAILURE; - } - } - else - { - UA_LOG_FATAL (UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, - "Unknown auth mode: %s " - "(expected 'anonymous' or 'user')", - authMode); - configFree (&cfg); - return EXIT_FAILURE; - } + configFree (&cfg); + return EXIT_FAILURE; } /* ---- Trust store ---- */ |
