/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
void xmldb_main(int param_1,char **param_2)
{
int iVar1;
FILE *__stream;
__pid_t _Var2;
undefined4 uVar3;
undefined4 *puVar4;
undefined4 *__s;
LAB_00402f70:
iVar1 = getopt(param_1,param_2,"hvts:p:n:") //possible issue identified - semgrep
if (iVar1 < 1) {
if (o_rootname == (char *)0x0) {
FUN_0040273c(0xffffffff);
}
if (DAT_00433ce0 == (char *)0x0) {
DAT_00433ce0 = "/var/run/xmldb_sock";
}
if (DAT_00433cd8 == (char *)0x0) {
sprintf(&DAT_00433ce4,"%s_%s.pid",DAT_00433ce0,o_rootname) //possible issue identified - semgrep
DAT_00433cd8 = &DAT_00433ce4;
}
FUN_00402e18("%s version %s\n","xmldb",&DAT_00421b54);
FUN_00402e18("Root Name : %s\n",o_rootname);
FUN_00402e18("Unix Socket : %s\n",DAT_00433ce0);
FUN_00402e18("PID file : %s\n",DAT_00433cd8);
__stream = fopen(DAT_00433cd8,"w") //possible issue identified - semgrep
if (__stream == (FILE *)0x0) {
FUN_00402e18("unable to create pid file : %s\n",DAT_00433cd8);
}
else {
_Var2 = getpid();
fprintf(__stream,"%d",_Var2);
fclose(__stream);
}
iVar1 = FUN_004023c0();
if (iVar1 < 0) {
iVar1 = -1;
}
else {
__s = &DAT_00433d70;
puVar4 = __s;
do {
memset(puVar4,0,0x34) //possible issue identified - semgrep
puVar4[2] = 0xffffffff;
*(undefined2 *)(puVar4 + 3) = 0;
puVar4[1] = 0;
puVar4 = puVar4 + 0xd;
} while (puVar4 != (undefined4 *)&DAT_004343f0);
memset(&DAT_004343f0,0,0x500) //possible issue identified - semgrep
sloop_init(0);
sloop_register_signal(2,FUN_00402d5c,0);
sloop_register_signal(0xf,FUN_00402d5c,0);
sloop_register_signal(9,FUN_00402d5c,0);
sloop_register_signal(0xd,&LAB_004023b8,0);
sloop_register_signal(0xe,FUN_00402d5c,0);
sloop_register_signal(0x10,&LAB_00402d18,0);
sloop_register_signal(0x11,&LAB_00402d18,0);
sloop_register_read_sock(iVar1,&DAT_00402840,0);
sloop_run();
do {
if (0 < (int)__s[2]) {
close(__s[2]);
}
if ((void *)__s[6] != (void *)0x0) {
free((void *)__s[6]);
}
if ((void *)__s[9] != (void *)0x0) {
free((void *)__s[9]);
}
memset(__s,0,0x34) //possible issue identified - semgrep
__s[2] = 0xffffffff;
*__s = 0;
*(undefined2 *)(__s + 3) = 0;
*(undefined2 *)((int)__s + 0xe) = 0;
__s = __s + 0xd;
} while (__s != (undefined4 *)&DAT_004343f0);
close(iVar1);
unlink(DAT_00433ce0) //possible issue identified - semgrep
unlink(DAT_00433cd8) //possible issue identified - semgrep
FUN_00402e18("Unix Socket (%s) closed\n",DAT_00433ce0);
xmldb_del_all();
ephp_clear_all();
puVar4 = &DAT_00434414;
do {
if ((void *)*puVar4 != (void *)0x0) {
free((void *)*puVar4);
}
puVar4 = puVar4 + 10;
} while (puVar4 != &DAT_00434914);
memset(&DAT_004343f0,0,0x500) //possible issue identified - semgrep
iVar1 = 0;
}
/* WARNING: Subroutine does not return */
exit(iVar1);
}
uVar3 = 0xffffffff;
switch(iVar1) {
case 0x68:
uVar3 = 0;
break;
case 0x69:
case 0x6a:
case 0x6b:
case 0x6c:
case 0x6d:
case 0x6f:
case 0x71:
case 0x72:
case 0x75:
uVar3 = 0xffffffff;
break;
case 0x6e:
o_rootname = _optarg;
goto LAB_00402f70;
case 0x70:
DAT_00433cd8 = _optarg;
goto LAB_00402f70;
case 0x73:
DAT_00433ce0 = _optarg;
goto LAB_00402f70;
case 0x74:
DAT_00433cd4 = DAT_00433cd4 + 1;
goto LAB_00402f70;
case 0x76:
goto switchD_00402f00_caseD_76;
}
FUN_0040273c(uVar3);
goto LAB_00402f70;
switchD_00402f00_caseD_76:
DAT_00433cdc = DAT_00433cdc + 1;
goto LAB_00402f70;
}