removed stdio.h stdio.c
This commit is contained in:
@ -47,9 +47,6 @@
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#define QSE_STDOUT qse_getstdout()
|
||||
#define QSE_STDERR qse_getstderr()
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
static qse_httpd_t* g_httpd = QSE_NULL;
|
||||
@ -855,8 +852,8 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
cfg->xcfg[i] = qse_httpd_strntombsdup (httpd, ((qse_xli_str_t*)pair->val)->ptr, ((qse_xli_str_t*)pair->val)->len);
|
||||
if (cfg->xcfg[i] == QSE_NULL)
|
||||
{
|
||||
/*qse_putstrf (QSE_T("ERROR in copying - %s\n"), qse_httpd_geterrmsg (httpd));*/
|
||||
qse_putstrf (QSE_T("ERROR in copying\n"));
|
||||
/*qse_printf (QSE_T("ERROR in copying - %s\n"), qse_httpd_geterrmsg (httpd));*/
|
||||
qse_printf (QSE_T("ERROR in copying\n"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -872,7 +869,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
duptmp = qse_xli_dupflatstr (httpd_xtn->xli, (qse_xli_str_t*)pair->val, &duplen, &count);
|
||||
if (duptmp == QSE_NULL)
|
||||
{
|
||||
qse_putstrf (QSE_T("ERROR: memory failure in copying index\n"));
|
||||
qse_printf (QSE_T("ERROR: memory failure in copying index\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -881,7 +878,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
|
||||
if (cfg->index.files == QSE_NULL)
|
||||
{
|
||||
qse_putstrf (QSE_T("ERROR: memory failure in copying index\n"));
|
||||
qse_printf (QSE_T("ERROR: memory failure in copying index\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -910,7 +907,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
cgi = qse_httpd_callocmem (httpd, QSE_SIZEOF(*cgi));
|
||||
if (cgi == QSE_NULL)
|
||||
{
|
||||
qse_putstrf (QSE_T("ERROR: memory failure in copying cgi\n"));
|
||||
qse_printf (QSE_T("ERROR: memory failure in copying cgi\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -919,7 +916,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
if (!cgi->spec)
|
||||
{
|
||||
qse_httpd_freemem (httpd, cgi);
|
||||
qse_putstrf (QSE_T("ERROR: memory failure in copying cgi name\n"));
|
||||
qse_printf (QSE_T("ERROR: memory failure in copying cgi name\n"));
|
||||
return -1;
|
||||
}
|
||||
if (pair->val->type == QSE_XLI_STR)
|
||||
@ -942,7 +939,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
{
|
||||
qse_httpd_freemem (httpd, cgi->spec);
|
||||
qse_httpd_freemem (httpd, cgi);
|
||||
qse_putstrf (QSE_T("ERROR: memory failure in copying cgi shebang\n"));
|
||||
qse_printf (QSE_T("ERROR: memory failure in copying cgi shebang\n"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -984,7 +981,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
auth_rule = qse_httpd_callocmem (httpd, QSE_SIZEOF(*auth_rule));
|
||||
if (auth_rule == QSE_NULL)
|
||||
{
|
||||
qse_putstrf (QSE_T("ERROR: memory failure in copying auth-rule\n"));
|
||||
qse_printf (QSE_T("ERROR: memory failure in copying auth-rule\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -995,7 +992,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
if (!auth_rule->spec)
|
||||
{
|
||||
qse_httpd_freemem (httpd, auth_rule);
|
||||
qse_putstrf (QSE_T("ERROR: memory failure in copying auth-rule\n"));
|
||||
qse_printf (QSE_T("ERROR: memory failure in copying auth-rule\n"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1034,7 +1031,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
mime = qse_httpd_callocmem (httpd, QSE_SIZEOF(*mime));
|
||||
if (mime == QSE_NULL)
|
||||
{
|
||||
qse_putstrf (QSE_T("ERROR: memory failure in copying mime\n"));
|
||||
qse_printf (QSE_T("ERROR: memory failure in copying mime\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1043,7 +1040,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
if (!mime->spec)
|
||||
{
|
||||
qse_httpd_freemem (httpd, mime);
|
||||
qse_putstrf (QSE_T("ERROR: memory failure in copying mime\n"));
|
||||
qse_printf (QSE_T("ERROR: memory failure in copying mime\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1052,7 +1049,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
{
|
||||
qse_httpd_freemem (httpd, mime->spec);
|
||||
qse_httpd_freemem (httpd, mime);
|
||||
qse_putstrf (QSE_T("ERROR: memory failure in copying mime\n"));
|
||||
qse_printf (QSE_T("ERROR: memory failure in copying mime\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1099,7 +1096,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
acc = qse_httpd_callocmem (httpd, QSE_SIZEOF(*acc));
|
||||
if (acc == QSE_NULL)
|
||||
{
|
||||
qse_putstrf (QSE_T("ERROR: memory failure in copying acc\n"));
|
||||
qse_printf (QSE_T("ERROR: memory failure in copying acc\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1110,7 +1107,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
if (!acc->spec)
|
||||
{
|
||||
qse_httpd_freemem (httpd, acc);
|
||||
qse_putstrf (QSE_T("ERROR: memory failure in copying access\n"));
|
||||
qse_printf (QSE_T("ERROR: memory failure in copying access\n"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1131,7 +1128,7 @@ static int load_loccfg (qse_httpd_t* httpd, qse_xli_list_t* list, loccfg_t* cfg)
|
||||
/* TODO: perform more sanity check */
|
||||
if (qse_mbschr (cfg->xcfg[XCFG_AUTH], QSE_MT(':')) == QSE_NULL)
|
||||
{
|
||||
qse_putstrf (QSE_T("WARNING: no colon in the auth string - [%hs]\n"), cfg->xcfg[XCFG_AUTH]);
|
||||
qse_printf (QSE_T("WARNING: no colon in the auth string - [%hs]\n"), cfg->xcfg[XCFG_AUTH]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1207,8 +1204,8 @@ static int load_server_config (qse_httpd_t* httpd, qse_httpd_server_t* server, q
|
||||
server_xtn->scfg[i] = qse_httpd_strntombsdup (httpd, ((qse_xli_str_t*)pair->val)->ptr, ((qse_xli_str_t*)pair->val)->len);
|
||||
if (server_xtn->scfg[i] == QSE_NULL)
|
||||
{
|
||||
/*qse_putstrf (QSE_T("ERROR in copying - %s\n"), qse_httpd_geterrmsg (httpd));*/
|
||||
qse_putstrf (QSE_T("ERROR in copying\n"));
|
||||
/*qse_printf (QSE_T("ERROR in copying - %s\n"), qse_httpd_geterrmsg (httpd));*/
|
||||
qse_printf (QSE_T("ERROR in copying\n"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1331,7 +1328,7 @@ static qse_httpd_server_t* attach_server (qse_httpd_t* httpd, int num, qse_xli_l
|
||||
if (pair == QSE_NULL || pair->val->type != QSE_XLI_STR)
|
||||
{
|
||||
/* TOOD: logging */
|
||||
qse_putstrf (QSE_T("WARNING: no value or invalid value specified for bind\n"));
|
||||
qse_printf (QSE_T("WARNING: no value or invalid value specified for bind\n"));
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
@ -1339,7 +1336,7 @@ static qse_httpd_server_t* attach_server (qse_httpd_t* httpd, int num, qse_xli_l
|
||||
if (qse_strntonwad (((qse_xli_str_t*)pair->val)->ptr, ((qse_xli_str_t*)pair->val)->len, &dope.nwad) <= -1)
|
||||
{
|
||||
/* TOOD: logging */
|
||||
qse_putstrf (QSE_T("WARNING: invalid value for bind - %s\n"), ((qse_xli_str_t*)pair->val)->ptr);
|
||||
qse_printf (QSE_T("WARNING: invalid value for bind - %s\n"), ((qse_xli_str_t*)pair->val)->ptr);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
@ -1353,7 +1350,7 @@ static qse_httpd_server_t* attach_server (qse_httpd_t* httpd, int num, qse_xli_l
|
||||
if (xserver == QSE_NULL)
|
||||
{
|
||||
/* TODO: logging */
|
||||
qse_putstrf (QSE_T("WARNING: failed to attach server\n"));
|
||||
qse_printf (QSE_T("WARNING: failed to attach server\n"));
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
@ -1476,7 +1473,7 @@ static int open_config_file (qse_httpd_t* httpd)
|
||||
httpd_xtn->xli = qse_xli_openstd (0, 0);
|
||||
if (httpd_xtn->xli == QSE_NULL)
|
||||
{
|
||||
qse_sio_putstrf (QSE_STDERR, QSE_T("Cannot open xli\n"));
|
||||
qse_fprintf (QSE_STDERR, QSE_T("Cannot open xli\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1488,7 +1485,7 @@ static int open_config_file (qse_httpd_t* httpd)
|
||||
{
|
||||
if (qse_xli_definepair (httpd_xtn->xli, defs[i].name, &defs[i].scm) <= -1)
|
||||
{
|
||||
qse_sio_putstrf (QSE_STDERR, QSE_T("Cannot define %s - %s\n"), defs[i].name, qse_xli_geterrmsg(httpd_xtn->xli));
|
||||
qse_fprintf (QSE_STDERR, QSE_T("Cannot define %s - %s\n"), defs[i].name, qse_xli_geterrmsg(httpd_xtn->xli));
|
||||
qse_xli_close (httpd_xtn->xli);
|
||||
httpd_xtn->xli = QSE_NULL;
|
||||
return -1;
|
||||
@ -1507,12 +1504,12 @@ static int open_config_file (qse_httpd_t* httpd)
|
||||
|
||||
if (errloc->line > 0 || errloc->colm > 0)
|
||||
{
|
||||
qse_sio_putstrf (QSE_STDERR, QSE_T("Cannot load %s at line %lu column %lu - %s\n"),
|
||||
qse_fprintf (QSE_STDERR, QSE_T("Cannot load %s at line %lu column %lu - %s\n"),
|
||||
xli_in.u.file.path, (unsigned long int)errloc->line, (unsigned long int)errloc->colm, qse_xli_geterrmsg(httpd_xtn->xli));
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_sio_putstrf (QSE_STDERR, QSE_T("Cannot load %s - %s\n"), xli_in.u.file.path, qse_xli_geterrmsg(httpd_xtn->xli));
|
||||
qse_fprintf (QSE_STDERR, QSE_T("Cannot load %s - %s\n"), xli_in.u.file.path, qse_xli_geterrmsg(httpd_xtn->xli));
|
||||
}
|
||||
|
||||
qse_xli_close (httpd_xtn->xli);
|
||||
@ -1611,7 +1608,7 @@ static int load_config (qse_httpd_t* httpd)
|
||||
|
||||
if (pair->val->type != QSE_XLI_LIST)
|
||||
{
|
||||
qse_sio_putstrf (QSE_STDERR, QSE_T("WARNING: non-list value for server\n"));
|
||||
qse_fprintf (QSE_STDERR, QSE_T("WARNING: non-list value for server\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1622,7 +1619,7 @@ static int load_config (qse_httpd_t* httpd)
|
||||
{
|
||||
if (load_server_config (httpd, server, (qse_xli_list_t*)pair->val) <= -1)
|
||||
{
|
||||
qse_sio_putstrf (QSE_STDERR, QSE_T("failed to load configuration from %s\n"), httpd_xtn->cfgfile);
|
||||
qse_fprintf (QSE_STDERR, QSE_T("failed to load configuration from %s\n"), httpd_xtn->cfgfile);
|
||||
goto oops;
|
||||
}
|
||||
}
|
||||
@ -1631,7 +1628,7 @@ static int load_config (qse_httpd_t* httpd)
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
qse_sio_putstrf (QSE_STDERR, QSE_T("No valid server specified in %s\n"), httpd_xtn->cfgfile);
|
||||
qse_fprintf (QSE_STDERR, QSE_T("No valid server specified in %s\n"), httpd_xtn->cfgfile);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
@ -1641,7 +1638,7 @@ static int load_config (qse_httpd_t* httpd)
|
||||
{
|
||||
if (load_loccfg (httpd, (qse_xli_list_t*)pair->val, &httpd_xtn->dflcfg) <= -1)
|
||||
{
|
||||
qse_sio_putstrf (QSE_STDERR, QSE_T("failed to load configuration from %s\n"), httpd_xtn->cfgfile);
|
||||
qse_fprintf (QSE_STDERR, QSE_T("failed to load configuration from %s\n"), httpd_xtn->cfgfile);
|
||||
goto oops;
|
||||
}
|
||||
}
|
||||
@ -1715,27 +1712,27 @@ static void logact_httpd (qse_httpd_t* httpd, const qse_httpd_act_t* act)
|
||||
switch (act->code)
|
||||
{
|
||||
case QSE_HTTPD_CATCH_MERRMSG:
|
||||
qse_putstrf (QSE_T("ERROR: %hs\n"), act->u.merrmsg);
|
||||
qse_printf (QSE_T("ERROR: %hs\n"), act->u.merrmsg);
|
||||
break;
|
||||
|
||||
case QSE_HTTPD_CATCH_MDBGMSG:
|
||||
qse_putstrf (QSE_T("DEBUG: %hs\n"), act->u.mdbgmsg);
|
||||
qse_printf (QSE_T("DEBUG: %hs\n"), act->u.mdbgmsg);
|
||||
break;
|
||||
|
||||
case QSE_HTTPD_ACCEPT_CLIENT:
|
||||
qse_nwadtostr (&act->u.client->local_addr, tmp, QSE_COUNTOF(tmp), QSE_NWADTOSTR_ALL);
|
||||
qse_nwadtostr (&act->u.client->orgdst_addr, tmp2, QSE_COUNTOF(tmp2), QSE_NWADTOSTR_ALL);
|
||||
qse_nwadtostr (&act->u.client->remote_addr, tmp3, QSE_COUNTOF(tmp3), QSE_NWADTOSTR_ALL);
|
||||
qse_putstrf (QSE_T("accepted client %s(%s) from %s\n"), tmp, tmp2, tmp3);
|
||||
qse_printf (QSE_T("accepted client %s(%s) from %s\n"), tmp, tmp2, tmp3);
|
||||
|
||||
case QSE_HTTPD_PURGE_CLIENT:
|
||||
qse_nwadtostr (&act->u.client->remote_addr, tmp, QSE_COUNTOF(tmp), QSE_NWADTOSTR_ALL);
|
||||
qse_putstrf (QSE_T("purged client - %s\n"), tmp);
|
||||
qse_printf (QSE_T("purged client - %s\n"), tmp);
|
||||
break;
|
||||
|
||||
case QSE_HTTPD_READERR_CLIENT:
|
||||
qse_nwadtostr (&act->u.client->remote_addr, tmp, QSE_COUNTOF(tmp), QSE_NWADTOSTR_ALL);
|
||||
qse_putstrf (QSE_T("failed to read client - %s\n"), tmp);
|
||||
qse_printf (QSE_T("failed to read client - %s\n"), tmp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1743,23 +1740,23 @@ static void logact_httpd (qse_httpd_t* httpd, const qse_httpd_act_t* act)
|
||||
/* --------------------------------------------------------------------- */
|
||||
static void print_version (void)
|
||||
{
|
||||
qse_putstrf (QSE_T("QSEHTTPD version %hs\n"), QSE_PACKAGE_VERSION);
|
||||
qse_printf (QSE_T("QSEHTTPD version %hs\n"), QSE_PACKAGE_VERSION);
|
||||
}
|
||||
|
||||
static void print_usage (qse_sio_t* out, int argc, qse_char_t* argv[])
|
||||
{
|
||||
const qse_char_t* b = qse_basename (argv[0]);
|
||||
|
||||
qse_sio_putstrf (out, QSE_T("USAGE: %s [options] -c file\n"), b);
|
||||
qse_sio_putstrf (out, QSE_T(" %s [options] --config-file file\n"), b);
|
||||
qse_fprintf (out, QSE_T("USAGE: %s [options] -c file\n"), b);
|
||||
qse_fprintf (out, QSE_T(" %s [options] --config-file file\n"), b);
|
||||
|
||||
qse_sio_putstrf (out, QSE_T("options as follows:\n"));
|
||||
qse_sio_putstrf (out, QSE_T(" -h/--help show this message\n"));
|
||||
qse_sio_putstrf (out, QSE_T(" --version show version\n"));
|
||||
qse_sio_putstrf (out, QSE_T(" -c/--config-file file specify a configuration file\n"));
|
||||
qse_sio_putstrf (out, QSE_T(" -d/--daemon run in the background\n"));
|
||||
qse_sio_putstrf (out, QSE_T(" -n string specify a process name if supported\n"));
|
||||
qse_sio_putstrf (out, QSE_T(" -x output debugging messages\n"));
|
||||
qse_fprintf (out, QSE_T("options as follows:\n"));
|
||||
qse_fprintf (out, QSE_T(" -h/--help show this message\n"));
|
||||
qse_fprintf (out, QSE_T(" --version show version\n"));
|
||||
qse_fprintf (out, QSE_T(" -c/--config-file file specify a configuration file\n"));
|
||||
qse_fprintf (out, QSE_T(" -d/--daemon run in the background\n"));
|
||||
qse_fprintf (out, QSE_T(" -n string specify a process name if supported\n"));
|
||||
qse_fprintf (out, QSE_T(" -x output debugging messages\n"));
|
||||
}
|
||||
|
||||
static int handle_args (int argc, qse_char_t* argv[])
|
||||
@ -1787,14 +1784,14 @@ static int handle_args (int argc, qse_char_t* argv[])
|
||||
goto wrongusage;
|
||||
|
||||
case QSE_T('?'):
|
||||
qse_sio_putstrf (QSE_STDERR,
|
||||
qse_fprintf (QSE_STDERR,
|
||||
QSE_T("ERROR: bad option - %c\n"),
|
||||
opt.opt
|
||||
);
|
||||
goto wrongusage;
|
||||
|
||||
case QSE_T(':'):
|
||||
qse_sio_putstrf (QSE_STDERR,
|
||||
qse_fprintf (QSE_STDERR,
|
||||
QSE_T("ERROR: bad parameter for %c\n"),
|
||||
opt.opt
|
||||
);
|
||||
@ -1882,7 +1879,7 @@ static int httpd_main (int argc, qse_char_t* argv[])
|
||||
httpd = qse_httpd_openstd (QSE_SIZEOF(httpd_xtn_t));
|
||||
if (httpd == QSE_NULL)
|
||||
{
|
||||
qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: Cannot open httpd\n"));
|
||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: Cannot open httpd\n"));
|
||||
goto oops;
|
||||
}
|
||||
|
||||
@ -1898,7 +1895,7 @@ static int httpd_main (int argc, qse_char_t* argv[])
|
||||
{
|
||||
if (daemonize (1) <= -1)
|
||||
{
|
||||
qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: Cannot daemonize\n"));
|
||||
qse_fprintf (QSE_STDERR, QSE_T("ERROR: Cannot daemonize\n"));
|
||||
goto oops;
|
||||
}
|
||||
}
|
||||
@ -1929,7 +1926,7 @@ static int httpd_main (int argc, qse_char_t* argv[])
|
||||
restore_signal_handlers ();
|
||||
g_httpd = QSE_NULL;
|
||||
|
||||
if (ret <= -1) qse_sio_putstrf (QSE_STDERR, QSE_T("Httpd error - %d\n"), qse_httpd_geterrnum (httpd));
|
||||
if (ret <= -1) qse_fprintf (QSE_STDERR, QSE_T("Httpd error - %d\n"), qse_httpd_geterrnum (httpd));
|
||||
|
||||
oops:
|
||||
if (httpd) qse_httpd_close (httpd);
|
||||
@ -1969,7 +1966,7 @@ int qse_main (int argc, qse_achar_t* argv[])
|
||||
|
||||
if (WSAStartup (MAKEWORD(2,0), &wsadata) != 0)
|
||||
{
|
||||
qse_sio_putstrf (QSE_STDERR, QSE_T("Failed to start up winsock\n"));
|
||||
qse_fprintf (QSE_STDERR, QSE_T("Failed to start up winsock\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user