/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
void servd_main(int param_1,char **param_2)
{
int iVar1;
char *__ptr;
undefined4 uVar2;
char *__format;
char *__file;
stat sStack_c0;
sloop_init(0);
while( true ) {
iVar1 = getopt(param_1,param_2,"hvu:s:d:") //possible issue identified - semgrep
__file = PTR_s__var_run_servd_ctrl_usock_0041b014;
if (iVar1 < 1) break;
if (iVar1 == 0x68) {
uVar2 = 0;
LAB_00401e7c:
FUN_00401ca0(uVar2);
}
else if (iVar1 < 0x69) {
uVar2 = 0xffffffff;
if (iVar1 != 100) goto LAB_00401e7c;
iVar1 = strcmp(_optarg,"schedule_off");
if (iVar1 == 0) {
svc_schedule = 0;
}
}
else if (iVar1 == 0x73) {
o_helper = _optarg;
}
else {
uVar2 = 0xffffffff;
if (iVar1 != 0x76) goto LAB_00401e7c;
o_verbose = o_verbose + 1;
}
}
if (PTR_s__var_run_servd_ctrl_usock_0041b014 == (undefined *)0x0) {
fprintf(_stderr,"%s: no unix socket name for control interface !!\n","servd");
iVar1 = -1;
goto LAB_00402194;
}
sloop_register_signal(2,FUN_00402398,0);
sloop_register_signal(0xf,FUN_00402398,0);
sloop_register_signal(9,FUN_00402398,0);
sloop_register_signal(0xd,&LAB_00401950,0);
sloop_register_signal(0xe,FUN_00402398,0);
sloop_register_signal(0x10,FUN_0040246c,0);
sloop_register_signal(0x11,FUN_0040246c,0);
sloop_register_signal(0x12,FUN_00402348,0);
iVar1 = stat(__file,&sStack_c0) //possible issue identified - semgrep
if (-1 < iVar1) {
unlink(__file) //possible issue identified - semgrep
}
__ptr = dirname(__file);
iVar1 = make_valid_path(__ptr,0x1f8);
if (iVar1 == 0) {
__format = "%s: unable to create directory [%s]\n";
__file = __ptr;
LAB_00402164:
fprintf(_stderr,__format,"servd_main",__file);
}
else {
iVar1 = susock_server_open(__file,0x20,FUN_00401c50) //possible issue identified - semgrep
if (iVar1 == 0) {
__format = "%s: unable to create unix socket [%s]!\n";
goto LAB_00402164;
}
uVar2 = susock_fd(iVar1);
sloop_register_read_sock(uVar2,susock_server_sloop_handler,iVar1);
sloop_run();
susock_close(iVar1);
cleanup_service();
cleanup_event();
cleanup_pidmon();
}
free(__ptr);
iVar1 = 0;
LAB_00402194:
/* WARNING: Subroutine does not return */
exit(iVar1);
}