Translate systemd C99 and C++ code to old C

This commit is contained in:
Robert de Bath 2017-12-17 14:55:23 +00:00
parent 0fc6bc8d12
commit 981091e39d
2 changed files with 7 additions and 4 deletions

View File

@ -82,8 +82,9 @@ int get_fd_sockets(int *sockfd[])
exit(1);
}
if (sd > 0) {
int i;
*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;
}
}

View File

@ -38,9 +38,10 @@ static int get_listen_from_conf(const char *filename, char **listen[]) {
} else {
setting = config_lookup(&config, "listen");
if (setting) {
int i;
len = config_setting_length(setting);
*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);
if (! (config_setting_lookup_string(addr, "host", &hostname) &&
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) {
int i;
fprintf(socket,
"# 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",
source);
for (int i = 0; i < num_addr; i++) {
for (i = 0; i < num_addr; 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
* otherwise write to standard out so that it's trivial to check what
* will be written */
if (runtime_unit_dir != "") {
if (runtime_unit_dir && *runtime_unit_dir) {
unit_file = "/sslh.socket";
size_t uf_len = strlen(unit_file);
size_t runtime_len = strlen(runtime_unit_dir) + uf_len + 1;