re-indent

This commit is contained in:
Yves Rutschle 2017-04-18 20:53:19 +02:00
parent b0f4e24ce0
commit cce42c6882

View File

@ -5,8 +5,7 @@
static char* resolve_listen(const char *hostname, const char *port) { static char* resolve_listen(const char *hostname, const char *port) {
/* Need room in the strcat for \0 and :
/* Need room in the strcat for \0 and :
* the format in the socket unit file is hostname:port */ * the format in the socket unit file is hostname:port */
char *conn = (char*)malloc(strlen(hostname)+strlen(port)+2); char *conn = (char*)malloc(strlen(hostname)+strlen(port)+2);
strcpy(conn, hostname); strcpy(conn, hostname);
@ -19,15 +18,13 @@ static char* resolve_listen(const char *hostname, const char *port) {
static int get_listen_from_conf(const char *filename, char **listen) { static int get_listen_from_conf(const char *filename, char **listen) {
config_t config; config_t config;
config_setting_t *setting, *addr; config_setting_t *setting, *addr;
const char *hostname, *port; const char *hostname, *port;
int len = 0; int len = 0;
/* look up the listen stanzas in the config file so these /* look up the listen stanzas in the config file so these
* can be used in the socket file generated */ * can be used in the socket file generated */
config_init(&config); config_init(&config);
if (config_read_file(&config, filename) == CONFIG_FALSE) { if (config_read_file(&config, filename) == CONFIG_FALSE) {
/* we don't care if file is missing, skip it */ /* we don't care if file is missing, skip it */
@ -51,7 +48,6 @@ static int get_listen_from_conf(const char *filename, char **listen) {
config_setting_source_line(addr)); config_setting_source_line(addr));
return -1; return -1;
} else { } else {
listen[i] = malloc(strlen(resolve_listen(hostname, port))); listen[i] = malloc(strlen(resolve_listen(hostname, port)));
strcpy(listen[i], resolve_listen(hostname, port)); strcpy(listen[i], resolve_listen(hostname, port));
} }
@ -79,11 +75,10 @@ static int write_socket_unit(FILE *socket, char **listen, int num_addr, const ch
fprintf(socket, "ListenStream=%s\n", listen[i]); fprintf(socket, "ListenStream=%s\n", listen[i]);
} }
return 0; return 0;
} }
static int gen_sslh_config(char *runtime_unit_dir) { static int gen_sslh_config(char *runtime_unit_dir) {
char *sslh_conf; char *sslh_conf;
int num_addr; int num_addr;
FILE *config; FILE *config;
@ -91,7 +86,7 @@ static int gen_sslh_config(char *runtime_unit_dir) {
FILE *runtime_conf_fd = stdout; FILE *runtime_conf_fd = stdout;
const char *unit_file; const char *unit_file;
/* There are two default locations so check both with first given preference */ /* There are two default locations so check both with first given preference */
sslh_conf = "/etc/sslh.cfg"; sslh_conf = "/etc/sslh.cfg";
config = fopen(sslh_conf, "r"); config = fopen(sslh_conf, "r");
@ -110,7 +105,7 @@ static int gen_sslh_config(char *runtime_unit_dir) {
if (num_addr < 0) if (num_addr < 0)
return -1; return -1;
/* 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 != "") {
@ -125,11 +120,10 @@ static int gen_sslh_config(char *runtime_unit_dir) {
return write_socket_unit(runtime_conf_fd, listen, num_addr, sslh_conf); return write_socket_unit(runtime_conf_fd, listen, num_addr, sslh_conf);
} }
int main(int argc, char *argv[]){
int main(int argc, char *argv[]){
int r = 0; int r = 0;
int k; int k;
char *runtime_unit_dest = ""; char *runtime_unit_dest = "";
@ -147,7 +141,6 @@ int main(int argc, char *argv[]){
r = k; r = k;
return r < 0 ? -1 : 0; return r < 0 ? -1 : 0;
} }