mirror of
https://github.com/yrutschle/sslh.git
synced 2025-04-18 17:57:39 +03:00
Translate systemd C99 and C++ code to old C
This commit is contained in:
parent
0fc6bc8d12
commit
981091e39d
3
common.c
3
common.c
@ -82,8 +82,9 @@ int get_fd_sockets(int *sockfd[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (sd > 0) {
|
if (sd > 0) {
|
||||||
|
int i;
|
||||||
*sockfd = malloc(sd * sizeof(*sockfd[0]));
|
*sockfd = malloc(sd * sizeof(*sockfd[0]));
|
||||||
for (int i = 0; i < sd; i++) {
|
for (i = 0; i < sd; i++) {
|
||||||
(*sockfd)[i] = SD_LISTEN_FDS_START + i;
|
(*sockfd)[i] = SD_LISTEN_FDS_START + i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,10 @@ static int get_listen_from_conf(const char *filename, char **listen[]) {
|
|||||||
} else {
|
} else {
|
||||||
setting = config_lookup(&config, "listen");
|
setting = config_lookup(&config, "listen");
|
||||||
if (setting) {
|
if (setting) {
|
||||||
|
int i;
|
||||||
len = config_setting_length(setting);
|
len = config_setting_length(setting);
|
||||||
*listen = malloc(len * sizeof(**listen));
|
*listen = malloc(len * sizeof(**listen));
|
||||||
for (int i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
addr = config_setting_get_elem(setting, i);
|
addr = config_setting_get_elem(setting, i);
|
||||||
if (! (config_setting_lookup_string(addr, "host", &hostname) &&
|
if (! (config_setting_lookup_string(addr, "host", &hostname) &&
|
||||||
config_setting_lookup_string(addr, "port", &port))) {
|
config_setting_lookup_string(addr, "port", &port))) {
|
||||||
@ -61,6 +62,7 @@ static int get_listen_from_conf(const char *filename, char **listen[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int write_socket_unit(FILE *socket, char *listen[], int num_addr, const char *source) {
|
static int write_socket_unit(FILE *socket, char *listen[], int num_addr, const char *source) {
|
||||||
|
int i;
|
||||||
|
|
||||||
fprintf(socket,
|
fprintf(socket,
|
||||||
"# Automatically generated by systemd-sslh-generator\n\n"
|
"# Automatically generated by systemd-sslh-generator\n\n"
|
||||||
@ -72,7 +74,7 @@ static int write_socket_unit(FILE *socket, char *listen[], int num_addr, const c
|
|||||||
"FreeBind=true\n",
|
"FreeBind=true\n",
|
||||||
source);
|
source);
|
||||||
|
|
||||||
for (int i = 0; i < num_addr; i++) {
|
for (i = 0; i < num_addr; i++) {
|
||||||
fprintf(socket, "ListenStream=%s\n", listen[i]);
|
fprintf(socket, "ListenStream=%s\n", listen[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +110,7 @@ static int gen_sslh_config(char *runtime_unit_dir) {
|
|||||||
/* If this is run by systemd directly write to the location told to
|
/* If this is run by systemd directly write to the location told to
|
||||||
* otherwise write to standard out so that it's trivial to check what
|
* otherwise write to standard out so that it's trivial to check what
|
||||||
* will be written */
|
* will be written */
|
||||||
if (runtime_unit_dir != "") {
|
if (runtime_unit_dir && *runtime_unit_dir) {
|
||||||
unit_file = "/sslh.socket";
|
unit_file = "/sslh.socket";
|
||||||
size_t uf_len = strlen(unit_file);
|
size_t uf_len = strlen(unit_file);
|
||||||
size_t runtime_len = strlen(runtime_unit_dir) + uf_len + 1;
|
size_t runtime_len = strlen(runtime_unit_dir) + uf_len + 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user