mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Cleanup: Converted some int -> bool
This commit is contained in:
parent
3231a0a310
commit
00368b68e8
31
src/main.c
31
src/main.c
@ -18,6 +18,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
@ -87,7 +88,7 @@
|
|||||||
#undef CATMODULE
|
#undef CATMODULE
|
||||||
#define CATMODULE "main"
|
#define CATMODULE "main"
|
||||||
|
|
||||||
static int background;
|
static bool background;
|
||||||
static char *pidfile = NULL;
|
static char *pidfile = NULL;
|
||||||
|
|
||||||
static void pidfile_update(ice_config_t *config, int always_try);
|
static void pidfile_update(ice_config_t *config, int always_try);
|
||||||
@ -209,19 +210,19 @@ void main_config_reload(ice_config_t *config)
|
|||||||
pidfile_update(config, 0);
|
pidfile_update(config, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _parse_config_opts(int argc, char **argv, char *filename, size_t size)
|
static bool _parse_config_opts(int argc, char **argv, char *filename, size_t size)
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
int config_ok = 0;
|
bool config_ok = false;
|
||||||
|
|
||||||
background = 0;
|
background = false;
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
if (filename[0] != 0) {
|
if (filename[0] != 0) {
|
||||||
/* We have a default filename, so we can work with no options. */
|
/* We have a default filename, so we can work with no options. */
|
||||||
return 1;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
/* We need at least a config filename. */
|
/* We need at least a config filename. */
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +242,7 @@ static int _parse_config_opts(int argc, char **argv, char *filename, size_t size
|
|||||||
fprintf(stderr, "FATAL: Unable to fork child!");
|
fprintf(stderr, "FATAL: Unable to fork child!");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
background = 1;
|
background = true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) {
|
if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) {
|
||||||
@ -253,18 +254,15 @@ static int _parse_config_opts(int argc, char **argv, char *filename, size_t size
|
|||||||
if (i + 1 < argc) {
|
if (i + 1 < argc) {
|
||||||
strncpy(filename, argv[i + 1], size-1);
|
strncpy(filename, argv[i + 1], size-1);
|
||||||
filename[size-1] = 0;
|
filename[size-1] = 0;
|
||||||
config_ok = 1;
|
config_ok = true;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config_ok)
|
return config_ok;
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _start_logging_stdout(void) {
|
static int _start_logging_stdout(void) {
|
||||||
@ -578,7 +576,7 @@ int mainService(int argc, char **argv)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int res, ret;
|
int ret;
|
||||||
#ifdef ICECAST_DEFAULT_CONFIG
|
#ifdef ICECAST_DEFAULT_CONFIG
|
||||||
char filename[512] = ICECAST_DEFAULT_CONFIG;
|
char filename[512] = ICECAST_DEFAULT_CONFIG;
|
||||||
#else
|
#else
|
||||||
@ -590,8 +588,7 @@ int main(int argc, char **argv)
|
|||||||
/* parse the '-c icecast.xml' option
|
/* parse the '-c icecast.xml' option
|
||||||
** only, so that we can read a configfile
|
** only, so that we can read a configfile
|
||||||
*/
|
*/
|
||||||
res = _parse_config_opts(argc, argv, filename, sizeof(filename));
|
if (_parse_config_opts(argc, argv, filename, sizeof(filename))) {
|
||||||
if (res == 1) {
|
|
||||||
#if !defined(_WIN32) || defined(_CONSOLE) || defined(__MINGW32__) || defined(__MINGW64__)
|
#if !defined(_WIN32) || defined(_CONSOLE) || defined(__MINGW32__) || defined(__MINGW64__)
|
||||||
/* startup all the modules */
|
/* startup all the modules */
|
||||||
initialize_subsystems();
|
initialize_subsystems();
|
||||||
@ -629,7 +626,7 @@ int main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (res == -1) {
|
} else {
|
||||||
_print_usage();
|
_print_usage();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user