Demonstrates n_proxy_cfg_parse and n_proxy_cfg_free.
Demonstrates n_proxy_cfg_parse and n_proxy_cfg_free.
- Author
- Castagnier Mickael
- Version
- 1.0
- Date
- 27/03/2026
#include <stdio.h>
#include <string.h>
int main(
int argc,
char* argv[]) {
int errors = 0;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-V") == 0 && i + 1 < argc) {
if (strcmp(argv[i + 1], "LOG_DEBUG") == 0)
else if (strcmp(argv[i + 1], "LOG_ERR") == 0)
else if (strcmp(argv[i + 1], "LOG_NOTICE") == 0)
}
}
{
if (cfg) {
if (strcmp(cfg->
scheme,
"http") != 0) errors++;
if (strcmp(cfg->
host,
"proxy.corp") != 0) errors++;
if (cfg->
port != 3128) errors++;
} else {
errors++;
}
}
{
if (cfg) {
if (strcmp(cfg->
scheme,
"socks5") != 0) errors++;
if (strcmp(cfg->
host,
"proxy.corp") != 0) errors++;
if (cfg->
port != 1080) errors++;
} else {
errors++;
}
}
{
if (cfg) {
if (strcmp(cfg->
scheme,
"https") != 0) errors++;
if (strcmp(cfg->
host,
"secure-proxy.corp") != 0) errors++;
if (cfg->
port != 8443) errors++;
} else {
errors++;
}
}
{
if (cfg) {
if (strcmp(cfg->
scheme,
"https") != 0) errors++;
if (cfg->
port != 3128) errors++;
} else {
errors++;
}
}
{
if (cfg) {
errors++;
} else {
}
}
errors == 0 ? "PASS" : "FAIL", errors, errors == 1 ? "" : "s");
return errors > 0 ? 1 : 0;
}
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
#define LOG_NOTICE
normal but significant condition
#define LOG_INFO
informational
char * host
proxy hostname
char * password
NULL if no auth.
char * scheme
"http", "https", or "socks5"
char * username
NULL if no auth.
N_PROXY_CFG * n_proxy_cfg_parse(const char *url)
Parse a proxy URL string into an N_PROXY_CFG struct.
void n_proxy_cfg_free(N_PROXY_CFG **cfg)
Free an N_PROXY_CFG created by n_proxy_cfg_parse().
Parsed proxy URL components.
Common headers and low-level functions & define.