diff --git a/qse/cmd/awk/awk.c b/qse/cmd/awk/awk.c index 97bd8d59..6265d5df 100644 --- a/qse/cmd/awk/awk.c +++ b/qse/cmd/awk/awk.c @@ -59,9 +59,6 @@ # define USE_LTDL #endif -#define QSE_STDOUT qse_getstdout() -#define QSE_STDERR qse_getstderr() - static qse_awk_rtx_t* app_rtx = QSE_NULL; static int app_debug = 0; @@ -358,14 +355,14 @@ static void on_statement (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde) static void print_version (void) { - qse_sio_putstrf (QSE_STDOUT, QSE_T("QSEAWK version %hs\n"), QSE_PACKAGE_VERSION); + qse_fprintf (QSE_STDOUT, QSE_T("QSEAWK version %hs\n"), QSE_PACKAGE_VERSION); } static void print_error (const qse_char_t* fmt, ...) { va_list va; - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: ")); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: ")); va_start (va, fmt); qse_sio_putstrvf (QSE_STDERR, fmt, va); va_end (va); @@ -401,35 +398,35 @@ static void print_usage (qse_sio_t* out, const qse_char_t* argv0) int j; const qse_char_t* b = qse_basename (argv0); - qse_sio_putstrf (out, QSE_T("USAGE: %s [options] -f sourcefile [ -- ] [datafile]*\n"), b); - qse_sio_putstrf (out, QSE_T(" %s [options] [ -- ] sourcestring [datafile]*\n"), b); - qse_sio_putstrf (out, QSE_T("Where options are:\n")); - qse_sio_putstrf (out, QSE_T(" -h/--help print this message\n")); - qse_sio_putstrf (out, QSE_T(" --version print version\n")); - qse_sio_putstrf (out, QSE_T(" -D show extra information\n")); - qse_sio_putstrf (out, QSE_T(" -c/--call name call a function instead of entering\n")); - qse_sio_putstrf (out, QSE_T(" the pattern-action loop. [datafile]* is\n")); - qse_sio_putstrf (out, QSE_T(" passed to the function as parameters\n")); - qse_sio_putstrf (out, QSE_T(" -f/--file sourcefile set the source script file\n")); - qse_sio_putstrf (out, QSE_T(" -d/--deparsed-file deparsedfile set the deparsing output file\n")); - qse_sio_putstrf (out, QSE_T(" -F/--field-separator string set a field separator(FS)\n")); - qse_sio_putstrf (out, QSE_T(" -v/--assign var=value add a global variable with a value\n")); - qse_sio_putstrf (out, QSE_T(" -m/--memory-limit number limit the memory usage (bytes)\n")); - qse_sio_putstrf (out, QSE_T(" -w expand datafile wildcards\n")); + qse_fprintf (out, QSE_T("USAGE: %s [options] -f sourcefile [ -- ] [datafile]*\n"), b); + qse_fprintf (out, QSE_T(" %s [options] [ -- ] sourcestring [datafile]*\n"), b); + qse_fprintf (out, QSE_T("Where options are:\n")); + qse_fprintf (out, QSE_T(" -h/--help print this message\n")); + qse_fprintf (out, QSE_T(" --version print version\n")); + qse_fprintf (out, QSE_T(" -D show extra information\n")); + qse_fprintf (out, QSE_T(" -c/--call name call a function instead of entering\n")); + qse_fprintf (out, QSE_T(" the pattern-action loop. [datafile]* is\n")); + qse_fprintf (out, QSE_T(" passed to the function as parameters\n")); + qse_fprintf (out, QSE_T(" -f/--file sourcefile set the source script file\n")); + qse_fprintf (out, QSE_T(" -d/--deparsed-file deparsedfile set the deparsing output file\n")); + qse_fprintf (out, QSE_T(" -F/--field-separator string set a field separator(FS)\n")); + qse_fprintf (out, QSE_T(" -v/--assign var=value add a global variable with a value\n")); + qse_fprintf (out, QSE_T(" -m/--memory-limit number limit the memory usage (bytes)\n")); + qse_fprintf (out, QSE_T(" -w expand datafile wildcards\n")); #if defined(QSE_BUILD_DEBUG) - qse_sio_putstrf (out, QSE_T(" -X number fail the number'th memory allocation\n")); + qse_fprintf (out, QSE_T(" -X number fail the number'th memory allocation\n")); #endif #if defined(QSE_CHAR_IS_WCHAR) - qse_sio_putstrf (out, QSE_T(" --script-encoding string specify script file encoding name\n")); - qse_sio_putstrf (out, QSE_T(" --console-encoding string specify console encoding name\n")); + qse_fprintf (out, QSE_T(" --script-encoding string specify script file encoding name\n")); + qse_fprintf (out, QSE_T(" --console-encoding string specify console encoding name\n")); #endif - qse_sio_putstrf (out, QSE_T(" --modern run in the modern mode(default)\n")); - qse_sio_putstrf (out, QSE_T(" --classic run in the classic mode\n")); + qse_fprintf (out, QSE_T(" --modern run in the modern mode(default)\n")); + qse_fprintf (out, QSE_T(" --classic run in the classic mode\n")); for (j = 0; opttab[j].name; j++) { - qse_sio_putstrf (out, + qse_fprintf (out, QSE_T(" --%-18s on/off %s\n"), opttab[j].name, opttab[j].desc); } @@ -1016,7 +1013,7 @@ static int awk_main (int argc, qse_char_t* argv[]) xma_mmgr.ctx = qse_xma_open (QSE_MMGR_GETDFL(), 0, arg.memlimit); if (xma_mmgr.ctx == QSE_NULL) { - qse_putstrf (QSE_T("ERROR: cannot open memory heap\n")); + qse_printf (QSE_T("ERROR: cannot open memory heap\n")); goto oops; } mmgr = &xma_mmgr; @@ -1026,7 +1023,7 @@ static int awk_main (int argc, qse_char_t* argv[]) /*awk = qse_awk_openstd (0);*/ if (awk == QSE_NULL) { - qse_putstrf (QSE_T("ERROR: cannot open awk\n")); + qse_printf (QSE_T("ERROR: cannot open awk\n")); goto oops; } @@ -1122,13 +1119,13 @@ oops: #if defined(QSE_BUILD_DEBUG) if (arg.failmalloc > 0) { - qse_sio_putstrf (QSE_STDERR, QSE_T("\n")); - qse_sio_putstrf (QSE_STDERR, QSE_T("-[MALLOC COUNTS]---------------------------------------\n")); - qse_sio_putstrf (QSE_STDERR, QSE_T("ALLOC: %lu FREE: %lu: REALLOC: %lu\n"), + qse_fprintf (QSE_STDERR, QSE_T("\n")); + qse_fprintf (QSE_STDERR, QSE_T("-[MALLOC COUNTS]---------------------------------------\n")); + qse_fprintf (QSE_STDERR, QSE_T("ALLOC: %lu FREE: %lu: REALLOC: %lu\n"), (unsigned long)debug_mmgr_alloc_count, (unsigned long)debug_mmgr_free_count, (unsigned long)debug_mmgr_realloc_count); - qse_sio_putstrf (QSE_STDERR, QSE_T("-------------------------------------------------------\n")); + qse_fprintf (QSE_STDERR, QSE_T("-------------------------------------------------------\n")); } #endif diff --git a/qse/cmd/http/httpd.c b/qse/cmd/http/httpd.c index f6682a9f..4fb57678 100644 --- a/qse/cmd/http/httpd.c +++ b/qse/cmd/http/httpd.c @@ -47,9 +47,6 @@ # include #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; } diff --git a/qse/cmd/sed/sed.c b/qse/cmd/sed/sed.c index f820429d..62744c28 100644 --- a/qse/cmd/sed/sed.c +++ b/qse/cmd/sed/sed.c @@ -54,9 +54,6 @@ # include #endif -#define QSE_STDOUT qse_getstdout() -#define QSE_STDERR qse_getstderr() - static struct { qse_sed_iostd_t* io; @@ -142,46 +139,46 @@ static qse_mmgr_t xma_mmgr = static void print_version (void) { - qse_putstrf (QSE_T("QSESED version %hs\n"), QSE_PACKAGE_VERSION); + qse_printf (QSE_T("QSESED 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] script [file]\n"), b); - qse_sio_putstrf (out, QSE_T(" %s [options] -f script-file [file]\n"), b); - qse_sio_putstrf (out, QSE_T(" %s [options] -e script [file]\n"), b); + qse_fprintf (out, QSE_T("USAGE: %s [options] script [file]\n"), b); + qse_fprintf (out, QSE_T(" %s [options] -f script-file [file]\n"), b); + qse_fprintf (out, QSE_T(" %s [options] -e script [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(" -n disable auto-print\n")); - qse_sio_putstrf (out, QSE_T(" -e script specify a script\n")); - qse_sio_putstrf (out, QSE_T(" -f file specify a script file\n")); - qse_sio_putstrf (out, QSE_T(" -o file specify an output file\n")); - qse_sio_putstrf (out, QSE_T(" -r use the extended regular expression\n")); - qse_sio_putstrf (out, QSE_T(" -R enable non-standard extensions to the regular\n")); - qse_sio_putstrf (out, QSE_T(" expression\n")); - qse_sio_putstrf (out, QSE_T(" -i perform in-place editing. imply -s\n")); - qse_sio_putstrf (out, QSE_T(" -s process input files separately\n")); - qse_sio_putstrf (out, QSE_T(" -a perform strict address and label check\n")); - qse_sio_putstrf (out, QSE_T(" -b allow extended address formats\n")); - qse_sio_putstrf (out, QSE_T(" ,,,<0,/regex/>\n")); - qse_sio_putstrf (out, QSE_T(" -x allow text on the same line as c, a, i\n")); - qse_sio_putstrf (out, QSE_T(" -y ensure a newline at text end\n")); - qse_sio_putstrf (out, QSE_T(" -m number specify the maximum amount of memory to use in bytes\n")); - qse_sio_putstrf (out, QSE_T(" -w expand file wildcards\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(" -n disable auto-print\n")); + qse_fprintf (out, QSE_T(" -e script specify a script\n")); + qse_fprintf (out, QSE_T(" -f file specify a script file\n")); + qse_fprintf (out, QSE_T(" -o file specify an output file\n")); + qse_fprintf (out, QSE_T(" -r use the extended regular expression\n")); + qse_fprintf (out, QSE_T(" -R enable non-standard extensions to the regular\n")); + qse_fprintf (out, QSE_T(" expression\n")); + qse_fprintf (out, QSE_T(" -i perform in-place editing. imply -s\n")); + qse_fprintf (out, QSE_T(" -s process input files separately\n")); + qse_fprintf (out, QSE_T(" -a perform strict address and label check\n")); + qse_fprintf (out, QSE_T(" -b allow extended address formats\n")); + qse_fprintf (out, QSE_T(" ,,,<0,/regex/>\n")); + qse_fprintf (out, QSE_T(" -x allow text on the same line as c, a, i\n")); + qse_fprintf (out, QSE_T(" -y ensure a newline at text end\n")); + qse_fprintf (out, QSE_T(" -m number specify the maximum amount of memory to use in bytes\n")); + qse_fprintf (out, QSE_T(" -w expand file wildcards\n")); #if defined(QSE_ENABLE_SEDTRACER) - qse_sio_putstrf (out, QSE_T(" -t print command traces\n")); + qse_fprintf (out, QSE_T(" -t print command traces\n")); #endif #if defined(QSE_BUILD_DEBUG) - qse_sio_putstrf (out, QSE_T(" -X number fail the number'th memory allocation\n")); + qse_fprintf (out, QSE_T(" -X number fail the number'th memory allocation\n")); #endif #if defined(QSE_CHAR_IS_WCHAR) - qse_sio_putstrf (out, QSE_T(" --script-encoding string specify script file encoding name\n")); - qse_sio_putstrf (out, QSE_T(" --infile-encoding string specify input file encoding name\n")); - qse_sio_putstrf (out, QSE_T(" --outfile-encoding string specify output file encoding name\n")); + qse_fprintf (out, QSE_T(" --script-encoding string specify script file encoding name\n")); + qse_fprintf (out, QSE_T(" --infile-encoding string specify input file encoding name\n")); + qse_fprintf (out, QSE_T(" --outfile-encoding string specify output file encoding name\n")); #endif } @@ -197,7 +194,7 @@ static int add_script (const qse_char_t* str, int mem) QSE_SIZEOF(*g_script.io) * (g_script.capa + 16 + 1)); if (tmp == QSE_NULL) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: out of memory while processing %s\n"), str); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: out of memory while processing %s\n"), str); return -1; } @@ -268,7 +265,7 @@ static int handle_args (int argc, qse_char_t* argv[]) goto oops; case QSE_T('?'): - qse_sio_putstrf (QSE_STDERR, + qse_fprintf (QSE_STDERR, QSE_T("ERROR: bad option - %c\n"), opt.opt ); @@ -276,7 +273,7 @@ static int handle_args (int argc, qse_char_t* argv[]) goto oops; case QSE_T(':'): - qse_sio_putstrf (QSE_STDERR, + qse_fprintf (QSE_STDERR, QSE_T("ERROR: bad parameter for %c\n"), opt.opt ); @@ -370,7 +367,7 @@ static int handle_args (int argc, qse_char_t* argv[]) g_script_cmgr = qse_findcmgr (opt.arg); if (g_script_cmgr == QSE_NULL) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: unknown script encoding - %s\n"), opt.arg); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: unknown script encoding - %s\n"), opt.arg); goto oops; } } @@ -379,7 +376,7 @@ static int handle_args (int argc, qse_char_t* argv[]) g_infile_cmgr = qse_findcmgr (opt.arg); if (g_infile_cmgr == QSE_NULL) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: unknown input file encoding - %s\n"), opt.arg); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: unknown input file encoding - %s\n"), opt.arg); goto oops; } } @@ -388,7 +385,7 @@ static int handle_args (int argc, qse_char_t* argv[]) g_outfile_cmgr = qse_findcmgr (opt.arg); if (g_outfile_cmgr == QSE_NULL) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: unknown output file encoding - %s\n"), opt.arg); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: unknown output file encoding - %s\n"), opt.arg); goto oops; } } @@ -427,7 +424,7 @@ void print_exec_error (qse_sed_t* sed) const qse_sed_loc_t* errloc = qse_sed_geterrloc(sed); if (errloc->line > 0 || errloc->colm > 0) { - qse_sio_putstrf (QSE_STDERR, + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot execute - %s at line %lu column %lu\n"), qse_sed_geterrmsg(sed), (unsigned long)errloc->line, @@ -436,7 +433,7 @@ void print_exec_error (qse_sed_t* sed) } else { - qse_sio_putstrf (QSE_STDERR, + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot execute - %s\n"), qse_sed_geterrmsg(sed) ); @@ -569,16 +566,16 @@ static void trace_exec (qse_sed_t* sed, qse_sed_tracer_op_t op, const qse_sed_cm switch (op) { case QSE_SED_TRACER_READ: - /*qse_sio_putstrf (QSE_STDERR, QSE_T("reading...\n"));*/ + /*qse_fprintf (QSE_STDERR, QSE_T("reading...\n"));*/ break; case QSE_SED_TRACER_WRITE: - /*qse_sio_putstrf (QSE_STDERR, QSE_T("wrting...\n"));*/ + /*qse_fprintf (QSE_STDERR, QSE_T("wrting...\n"));*/ break; /* TODO: use function to get hold space and pattern space and print them */ case QSE_SED_TRACER_MATCH: - qse_sio_putstrf (QSE_STDERR, QSE_T("%s:%lu [%c] MA\n"), + qse_fprintf (QSE_STDERR, QSE_T("%s:%lu [%c] MA\n"), ((cmd->lid && cmd->lid[0])? cmd->lid: QSE_T("<>")), (unsigned long)cmd->loc.line, cmd->type @@ -586,7 +583,7 @@ static void trace_exec (qse_sed_t* sed, qse_sed_tracer_op_t op, const qse_sed_cm break; case QSE_SED_TRACER_EXEC: - qse_sio_putstrf (QSE_STDERR, QSE_T("%s:%lu [%c] EC\n"), + qse_fprintf (QSE_STDERR, QSE_T("%s:%lu [%c] EC\n"), ((cmd->lid && cmd->lid[0])? cmd->lid: QSE_T("<>")), (unsigned long)cmd->loc.line, cmd->type @@ -711,7 +708,7 @@ static int sed_main (int argc, qse_char_t* argv[]) xma_mmgr.ctx = qse_xma_open (QSE_MMGR_GETDFL(), 0, g_memlimit); if (xma_mmgr.ctx == QSE_NULL) { - qse_putstrf (QSE_T("ERROR: cannot open memory heap\n")); + qse_printf (QSE_T("ERROR: cannot open memory heap\n")); goto oops; } mmgr = &xma_mmgr; @@ -722,13 +719,13 @@ static int sed_main (int argc, qse_char_t* argv[]) fs = qse_fs_open (mmgr, 0); if (fs == QSE_NULL) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: cannot open file system handler\n")); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open file system handler\n")); goto oops; } if (qse_fs_chdir (fs, QSE_T(".")) <= -1) { - qse_sio_putstrf (QSE_STDERR, + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot change direcotry in file system handler\n")); goto oops; } @@ -737,7 +734,7 @@ static int sed_main (int argc, qse_char_t* argv[]) sed = qse_sed_openstdwithmmgr (mmgr, 0); if (sed == QSE_NULL) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: cannot open stream editor\n")); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open stream editor\n")); goto oops; } @@ -766,7 +763,7 @@ static int sed_main (int argc, qse_char_t* argv[]) if (errloc->line > 0 || errloc->colm > 0) { - qse_sio_putstrf (QSE_STDERR, + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot compile %s - %s at line %lu column %lu\n"), target, qse_sed_geterrmsg(sed), @@ -776,7 +773,7 @@ static int sed_main (int argc, qse_char_t* argv[]) } else { - qse_sio_putstrf (QSE_STDERR, + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot compile %s - %s\n"), target, qse_sed_geterrmsg(sed) @@ -819,7 +816,7 @@ static int sed_main (int argc, qse_char_t* argv[]) ); if (out_file.u.sio == QSE_NULL) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: cannot open %s\n"), g_output_file); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open %s\n"), g_output_file); goto oops; } @@ -830,7 +827,7 @@ static int sed_main (int argc, qse_char_t* argv[]) /* perform wild-card expansions for non-unix platforms */ if (expand_wildcards (argc - g_infile_pos, &argv[g_infile_pos], g_wildcard, &xarg) <= -1) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: out of memory\n")); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: out of memory\n")); goto oops; } @@ -852,7 +849,7 @@ static int sed_main (int argc, qse_char_t* argv[]) tmpl_tmpfile = qse_strdup2 (in[0].u.file.path, QSE_T(".XXXX"), qse_sed_getmmgr(sed)); if (tmpl_tmpfile == QSE_NULL) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: out of memory\n")); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: out of memory\n")); goto oops; } @@ -872,7 +869,7 @@ static int sed_main (int argc, qse_char_t* argv[]) { if (retried) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: cannot open %s\n"), tmpl_tmpfile); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open %s\n"), tmpl_tmpfile); QSE_MMGR_FREE (qse_sed_getmmgr(sed), tmpl_tmpfile); goto oops; } @@ -883,7 +880,7 @@ static int sed_main (int argc, qse_char_t* argv[]) tmpl_tmpfile = qse_strdup (QSE_T("TMP-XXXX"), qse_sed_getmmgr(sed)); if (tmpl_tmpfile == QSE_NULL) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: out of memory\n")); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: out of memory\n")); goto oops; } retried = 1; @@ -915,7 +912,7 @@ static int sed_main (int argc, qse_char_t* argv[]) if (qse_fs_move (fs, tmpl_tmpfile, in[0].u.file.path) <= -1) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: cannot rename %s to %s. not deleting %s\n"), + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot rename %s to %s. not deleting %s\n"), tmpl_tmpfile, in[0].u.file.path, tmpl_tmpfile); QSE_MMGR_FREE (qse_sed_getmmgr(sed), tmpl_tmpfile); goto oops; @@ -945,14 +942,14 @@ static int sed_main (int argc, qse_char_t* argv[]) /* perform wild-card expansions for non-unix platforms */ if (expand_wildcards (argc - g_infile_pos, &argv[g_infile_pos], g_wildcard, &xarg) <= -1) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: out of memory\n")); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: out of memory\n")); goto oops; } in = QSE_MMGR_ALLOC (qse_sed_getmmgr(sed), QSE_SIZEOF(*in) * (xarg.size + 1)); if (in == QSE_NULL) { - qse_sio_putstrf (QSE_STDERR, QSE_T("ERROR: out of memory\n")); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: out of memory\n")); goto oops; } @@ -1010,13 +1007,13 @@ oops: #if defined(QSE_BUILD_DEBUG) if (g_failmalloc > 0) { - qse_sio_putstrf (QSE_STDERR, QSE_T("\n")); - qse_sio_putstrf (QSE_STDERR, QSE_T("-[MALLOC COUNTS]---------------------------------------\n")); - qse_sio_putstrf (QSE_STDERR, QSE_T("ALLOC: %lu FREE: %lu: REALLOC: %lu\n"), + qse_fprintf (QSE_STDERR, QSE_T("\n")); + qse_fprintf (QSE_STDERR, QSE_T("-[MALLOC COUNTS]---------------------------------------\n")); + qse_fprintf (QSE_STDERR, QSE_T("ALLOC: %lu FREE: %lu: REALLOC: %lu\n"), (unsigned long)debug_mmgr_alloc_count, (unsigned long)debug_mmgr_free_count, (unsigned long)debug_mmgr_realloc_count); - qse_sio_putstrf (QSE_STDERR, QSE_T("-------------------------------------------------------\n")); + qse_fprintf (QSE_STDERR, QSE_T("-------------------------------------------------------\n")); } #endif return ret; diff --git a/qse/cmd/xli/xli.c b/qse/cmd/xli/xli.c index 2d3c9c75..529c9fd1 100644 --- a/qse/cmd/xli/xli.c +++ b/qse/cmd/xli/xli.c @@ -116,38 +116,38 @@ static qse_mmgr_t xma_mmgr = static void print_version (void) { - qse_putstrf (QSE_T("QSEXLI version %hs\n"), QSE_PACKAGE_VERSION); + qse_printf (QSE_T("QSEXLI 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] -i input-file [key]\n"), b); + qse_fprintf (out, QSE_T("USAGE: %s [options] -i input-file [key]\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(" -i file specify an input file\n")); - qse_sio_putstrf (out, QSE_T(" -o file specify an output file\n")); - qse_sio_putstrf (out, QSE_T(" -u disallow duplicate keys\n")); - qse_sio_putstrf (out, QSE_T(" -a allow a key alias\n")); - qse_sio_putstrf (out, QSE_T(" -f keep file inclusion info\n")); - qse_sio_putstrf (out, QSE_T(" -t keep comment text\n")); - qse_sio_putstrf (out, QSE_T(" -s allow multi-segmented strings\n")); - qse_sio_putstrf (out, QSE_T(" -d allow a leading digit in identifiers\n")); - qse_sio_putstrf (out, QSE_T(" -n disallow nil\n")); - qse_sio_putstrf (out, QSE_T(" -l disallow lists\n")); - qse_sio_putstrf (out, QSE_T(" -K allow key tags\n")); - qse_sio_putstrf (out, QSE_T(" -S allow string tags\n")); - qse_sio_putstrf (out, QSE_T(" -v perform validation\n")); - qse_sio_putstrf (out, QSE_T(" -m number specify the maximum amount of memory to use in bytes\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(" -i file specify an input file\n")); + qse_fprintf (out, QSE_T(" -o file specify an output file\n")); + qse_fprintf (out, QSE_T(" -u disallow duplicate keys\n")); + qse_fprintf (out, QSE_T(" -a allow a key alias\n")); + qse_fprintf (out, QSE_T(" -f keep file inclusion info\n")); + qse_fprintf (out, QSE_T(" -t keep comment text\n")); + qse_fprintf (out, QSE_T(" -s allow multi-segmented strings\n")); + qse_fprintf (out, QSE_T(" -d allow a leading digit in identifiers\n")); + qse_fprintf (out, QSE_T(" -n disallow nil\n")); + qse_fprintf (out, QSE_T(" -l disallow lists\n")); + qse_fprintf (out, QSE_T(" -K allow key tags\n")); + qse_fprintf (out, QSE_T(" -S allow string tags\n")); + qse_fprintf (out, QSE_T(" -v perform validation\n")); + qse_fprintf (out, QSE_T(" -m number specify the maximum amount of memory to use in bytes\n")); #if defined(QSE_BUILD_DEBUG) - qse_sio_putstrf (out, QSE_T(" -X number fail the number'th memory allocation\n")); + qse_fprintf (out, QSE_T(" -X number fail the number'th memory allocation\n")); #endif #if defined(QSE_CHAR_IS_WCHAR) - qse_sio_putstrf (out, QSE_T(" --infile-encoding string specify input file encoding name\n")); - qse_sio_putstrf (out, QSE_T(" --outfile-encoding string specify output file encoding name\n")); + qse_fprintf (out, QSE_T(" --infile-encoding string specify input file encoding name\n")); + qse_fprintf (out, QSE_T(" --outfile-encoding string specify output file encoding name\n")); #endif } @@ -180,27 +180,27 @@ static int handle_args (int argc, qse_char_t* argv[]) switch (c) { default: - print_usage (qse_getstderr(), argc, argv); + print_usage (QSE_STDERR, argc, argv); goto oops; case QSE_T('?'): - qse_sio_putstrf (qse_getstderr(), + qse_fprintf (QSE_STDERR, QSE_T("ERROR: bad option - %c\n"), opt.opt ); - print_usage (qse_getstderr(), argc, argv); + print_usage (QSE_STDERR, argc, argv); goto oops; case QSE_T(':'): - qse_sio_putstrf (qse_getstderr(), + qse_fprintf (QSE_STDERR, QSE_T("ERROR: bad parameter for %c\n"), opt.opt ); - print_usage (qse_getstderr(), argc, argv); + print_usage (QSE_STDERR, argc, argv); goto oops; case QSE_T('h'): - print_usage (qse_getstdout(), argc, argv); + print_usage (QSE_STDOUT, argc, argv); goto done; case QSE_T('i'): @@ -277,7 +277,7 @@ static int handle_args (int argc, qse_char_t* argv[]) g_infile_cmgr = qse_findcmgr (opt.arg); if (g_infile_cmgr == QSE_NULL) { - qse_sio_putstrf (qse_getstderr(), QSE_T("ERROR: unknown input file encoding - %s\n"), opt.arg); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: unknown input file encoding - %s\n"), opt.arg); goto oops; } } @@ -286,7 +286,7 @@ static int handle_args (int argc, qse_char_t* argv[]) g_outfile_cmgr = qse_findcmgr (opt.arg); if (g_outfile_cmgr == QSE_NULL) { - qse_sio_putstrf (qse_getstderr(), QSE_T("ERROR: unknown output file encoding - %s\n"), opt.arg); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: unknown output file encoding - %s\n"), opt.arg); goto oops; } } @@ -298,7 +298,7 @@ static int handle_args (int argc, qse_char_t* argv[]) if (!g_input_file) { - print_usage (qse_getstderr(), argc, argv); + print_usage (QSE_STDERR, argc, argv); goto oops; } @@ -306,7 +306,7 @@ static int handle_args (int argc, qse_char_t* argv[]) if (opt.ind < argc) { - print_usage (qse_getstderr(), argc, argv); + print_usage (QSE_STDERR, argc, argv); goto oops; } @@ -325,7 +325,7 @@ void print_exec_error (qse_xli_t* xli) const qse_xli_loc_t* errloc = qse_xli_geterrloc(xli); if (errloc->line > 0 || errloc->colm > 0) { - qse_sio_putstrf (qse_getstderr(), + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot execute - %s at line %lu column %lu\n"), qse_xli_geterrmsg(xli), (unsigned long)errloc->line, @@ -334,7 +334,7 @@ void print_exec_error (qse_xli_t* xli) } else { - qse_sio_putstrf (qse_getstderr(), + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot execute - %s\n"), qse_xli_geterrmsg(xli) ); @@ -368,7 +368,7 @@ static int xli_main (int argc, qse_char_t* argv[]) xma_mmgr.ctx = qse_xma_open (QSE_MMGR_GETDFL(), 0, g_memlimit); if (xma_mmgr.ctx == QSE_NULL) { - qse_sio_putstrf (qse_getstderr(), QSE_T("ERROR: cannot open memory heap\n")); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open memory heap\n")); goto oops; } mmgr = &xma_mmgr; @@ -377,7 +377,7 @@ static int xli_main (int argc, qse_char_t* argv[]) xli = qse_xli_openstdwithmmgr (mmgr, 0, 0); if (xli == QSE_NULL) { - qse_sio_putstrf (qse_getstderr(), QSE_T("ERROR: cannot open stream editor\n")); + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open stream editor\n")); goto oops; } @@ -494,7 +494,7 @@ for (i = 0; i < QSE_COUNTOF(defs); i++) qse_xli_definepair (xli, defs[i].name, & if (errloc->line > 0 || errloc->colm > 0) { - qse_sio_putstrf (qse_getstderr(), + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot read %s - %s at line %lu column %lu%s%s\n"), g_input_file, qse_xli_geterrmsg(xli), @@ -506,7 +506,7 @@ for (i = 0; i < QSE_COUNTOF(defs); i++) qse_xli_definepair (xli, defs[i].name, & } else { - qse_sio_putstrf (qse_getstderr(), + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot read %s - %s\n"), g_input_file, qse_xli_geterrmsg(xli) @@ -525,7 +525,7 @@ for (i = 0; i < QSE_COUNTOF(defs); i++) qse_xli_definepair (xli, defs[i].name, & if (qse_xli_insertpairwithstrs (xli, qse_xli_getroot(xli), QSE_NULL, QSE_T("test-key"), QSE_NULL, QSE_NULL, strs, QSE_COUNTOF(strs)) == QSE_NULL) { - qse_sio_putstrf (qse_getstderr(), + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot insert a string pair - %s \n"), qse_xli_geterrmsg(xli) ); @@ -538,12 +538,12 @@ for (i = 0; i < QSE_COUNTOF(defs); i++) qse_xli_definepair (xli, defs[i].name, & qse_size_t count; count = qse_xli_countpairs (xli, QSE_NULL, g_lookup_key); - qse_putstrf (QSE_T("COUNT: %lu\n"), (unsigned long)count); + qse_printf (QSE_T("COUNT: %lu\n"), (unsigned long)count); pair = qse_xli_findpair (xli, QSE_NULL, g_lookup_key); if (pair == QSE_NULL) { - qse_sio_putstrf (qse_getstderr(), + qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot find %s - %s \n"), g_lookup_key, qse_xli_geterrmsg(xli) @@ -555,15 +555,15 @@ for (i = 0; i < QSE_COUNTOF(defs); i++) qse_xli_definepair (xli, defs[i].name, & if (pair->val->type == QSE_XLI_STR) { qse_xli_str_t* str = (qse_xli_str_t*)pair->val; - qse_putstrf (QSE_T("[%.*s]\n"), (int)str->len, str->ptr); + qse_printf (QSE_T("[%.*s]\n"), (int)str->len, str->ptr); } else if (pair->val->type == QSE_XLI_NIL) { - qse_putstrf (QSE_T("#NIL\n")); + qse_printf (QSE_T("#NIL\n")); } else { - qse_putstrf (QSE_T("#LIST\n")); + qse_printf (QSE_T("#LIST\n")); } } } @@ -581,13 +581,13 @@ oops: #if defined(QSE_BUILD_DEBUG) if (g_failmalloc > 0) { - qse_sio_putstrf (qse_getstderr(), QSE_T("\n")); - qse_sio_putstrf (qse_getstderr(), QSE_T("-[MALLOC COUNTS]---------------------------------------\n")); - qse_sio_putstrf (qse_getstderr(), QSE_T("ALLOC: %lu FREE: %lu: REALLOC: %lu\n"), + qse_fprintf (QSE_STDERR, QSE_T("\n")); + qse_fprintf (QSE_STDERR, QSE_T("-[MALLOC COUNTS]---------------------------------------\n")); + qse_fprintf (QSE_STDERR, QSE_T("ALLOC: %lu FREE: %lu: REALLOC: %lu\n"), (unsigned long)debug_mmgr_alloc_count, (unsigned long)debug_mmgr_free_count, (unsigned long)debug_mmgr_realloc_count); - qse_sio_putstrf (qse_getstderr(), QSE_T("-------------------------------------------------------\n")); + qse_fprintf (QSE_STDERR, QSE_T("-------------------------------------------------------\n")); } #endif diff --git a/qse/configure b/qse/configure index 8e1970a5..e43d91ba 100755 --- a/qse/configure +++ b/qse/configure @@ -17666,8 +17666,6 @@ done LIBS="$OLDLIBS" -if test "${platform_win32}" = "no" -then for ac_func in quadmath_snprintf do : ac_fn_c_check_func "$LINENO" "quadmath_snprintf" "ac_cv_func_quadmath_snprintf" @@ -17774,7 +17772,6 @@ fi done LIBS="$OLDLIBS" -fi for ac_func in connect gethostbyname diff --git a/qse/configure.ac b/qse/configure.ac index 89403511..09407ce4 100644 --- a/qse/configure.ac +++ b/qse/configure.ac @@ -156,8 +156,8 @@ AC_CHECK_FUNCS([pow fmod sin cos tan atan atan2 log log10 exp sqrt ceil floor ro AC_CHECK_FUNCS([powf fmodf sinf cosf tanf atanf atan2f logf log10f expf sqrtf ceilf floorf roundf]) LIBS="$OLDLIBS" -if test "${platform_win32}" = "no" -then +dnl if test "${platform_win32}" = "no" +dnl then AC_CHECK_FUNCS([quadmath_snprintf]) if test "$ac_cv_func_quadmath_snprintf" = "no" then @@ -183,7 +183,7 @@ then AC_CHECK_FUNCS([powq fmodq sinq cosq tanq atanq atan2q logq log10q expq sqrtq ceilq floorq roundq]) AC_CHECK_FUNCS([strtoflt128]) LIBS="$OLDLIBS" -fi +dnl fi AC_SUBST(QUADMATH_LIBS) dnl OLDLIBS="$LIBS" diff --git a/qse/include/qse/cmn/Makefile.am b/qse/include/qse/cmn/Makefile.am index 700c8075..c85a061c 100644 --- a/qse/include/qse/cmn/Makefile.am +++ b/qse/include/qse/cmn/Makefile.am @@ -37,7 +37,6 @@ pkginclude_HEADERS = \ sio.h \ sll.h \ slmb.h \ - stdio.h \ str.h \ task.h \ time.h \ diff --git a/qse/include/qse/cmn/Makefile.in b/qse/include/qse/cmn/Makefile.in index 0a44c49c..d45367ae 100644 --- a/qse/include/qse/cmn/Makefile.in +++ b/qse/include/qse/cmn/Makefile.in @@ -62,8 +62,8 @@ am__pkginclude_HEADERS_DIST = alg.h chr.h cp949.h cp950.h dir.h dll.h \ env.h fio.h fma.h fmt.h fs.h gdl.h glob.h htb.h hton.h ipad.h \ lda.h main.h map.h mb8.h mbwc.h mem.h mux.h nwad.h nwif.h \ nwio.h oht.h opt.h path.h pio.h pma.h rbt.h rex.h sio.h sll.h \ - slmb.h stdio.h str.h task.h time.h tio.h tre.h uni.h uri.h \ - utf8.h xma.h Mmgr.hpp StdMmgr.hpp Mmged.hpp + slmb.h str.h task.h time.h tio.h tre.h uni.h uri.h utf8.h \ + xma.h Mmgr.hpp StdMmgr.hpp Mmged.hpp am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -276,8 +276,8 @@ pkginclude_HEADERS = alg.h chr.h cp949.h cp950.h dir.h dll.h env.h \ fio.h fma.h fmt.h fs.h gdl.h glob.h htb.h hton.h ipad.h lda.h \ main.h map.h mb8.h mbwc.h mem.h mux.h nwad.h nwif.h nwio.h \ oht.h opt.h path.h pio.h pma.h rbt.h rex.h sio.h sll.h slmb.h \ - stdio.h str.h task.h time.h tio.h tre.h uni.h uri.h utf8.h \ - xma.h $(am__append_1) + str.h task.h time.h tio.h tre.h uni.h uri.h utf8.h xma.h \ + $(am__append_1) all: all-am .SUFFIXES: diff --git a/qse/include/qse/cmn/rbt.h b/qse/include/qse/cmn/rbt.h index 5c667357..6952c7bc 100644 --- a/qse/include/qse/cmn/rbt.h +++ b/qse/include/qse/cmn/rbt.h @@ -34,7 +34,7 @@ * @code * #include * #include - * #include + * #include * * static qse_rbt_walk_t walk (qse_rbt_t* rbt, qse_rbt_pair_t* pair, void* ctx) * { diff --git a/qse/include/qse/cmn/sio.h b/qse/include/qse/cmn/sio.h index 1ae6c2ef..34a62398 100644 --- a/qse/include/qse/cmn/sio.h +++ b/qse/include/qse/cmn/sio.h @@ -427,6 +427,15 @@ QSE_EXPORT qse_ssize_t qse_errputwcsvf ( # define qse_errputstrvf(fmt,ap) qse_errputwcsvf(fmt,ap) #endif +/* Some convenience macros */ +#define QSE_STDOUT (qse_getstdout()) +#define QSE_STDERR (qse_getstderr()) +#define qse_printf qse_putstrf +#define qse_vprintf qse_putstrvf +#define qse_fprintf qse_sio_putstrf +#define qse_vfprintf qse_sio_putstrvf + + #ifdef __cplusplus } #endif diff --git a/qse/include/qse/cmn/stdio.h b/qse/include/qse/cmn/stdio.h deleted file mode 100644 index 4283afbd..00000000 --- a/qse/include/qse/cmn/stdio.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * $Id$ - * - Copyright 2006-2012 Chung, Hyung-Hwan. - This file is part of QSE. - - QSE is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - QSE is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with QSE. If not, see . - */ - -#ifndef _QSE_CMN_STDIO_H_ -#define _QSE_CMN_STDIO_H_ - -/** @file - * This file defines stdio wrapper functions for #qse_char_t. - */ - -#include -#include - -#include - -typedef struct QSE_FILE QSE_FILE; - -#define QSE_STDIN ((QSE_FILE*)1) -#define QSE_STDOUT ((QSE_FILE*)2) -#define QSE_STDERR ((QSE_FILE*)3) - -typedef int (*qse_getdelim_t) (const qse_char_t* ptr,qse_size_t len,void* arg); - -#ifdef __cplusplus -extern "C" { -#endif - -QSE_EXPORT int qse_vsprintf ( - qse_char_t* buf, - qse_size_t size, - const qse_char_t* fmt, - va_list ap -); - -QSE_EXPORT int qse_sprintf ( - qse_char_t* buf, - qse_size_t size, - const qse_char_t* fmt, - ... -); - -QSE_EXPORT int qse_vfprintf ( - QSE_FILE *stream, const qse_char_t* fmt, va_list ap); -QSE_EXPORT int qse_vprintf ( - const qse_char_t* fmt, va_list ap); -QSE_EXPORT int qse_fprintf ( - QSE_FILE* file, const qse_char_t* fmt, ...); -QSE_EXPORT int qse_printf ( - const qse_char_t* fmt, ...); - -QSE_EXPORT int qse_dprintf ( - const qse_char_t* fmt, ...); -QSE_EXPORT QSE_FILE* qse_fopen ( - const qse_char_t* path, const qse_char_t* mode); - -QSE_EXPORT void qse_fclose (QSE_FILE* stream); -QSE_EXPORT int qse_fflush (QSE_FILE* stream); -QSE_EXPORT void qse_clearerr (QSE_FILE* stream); -QSE_EXPORT int qse_feof (QSE_FILE* stream); -QSE_EXPORT int qse_ferror (QSE_FILE* stream); - -/** - * The qse_getline() function read a line from a file pointer @a fp - * until a new line character is met. - * - * @return -2 on error, -1 on eof, length of data read on success - */ -QSE_EXPORT qse_ssize_t qse_getline ( - qse_char_t **buf, qse_size_t *n, QSE_FILE *stream); - -/** - * The qse_getdelim() function reads characters from a file pointer @a fp - * until a certain condition is met as defined by @a fn and @a fnarg. - * - * @return -3 on line breaker error, -2 on error, -1 on eof, - * length of data read on success - */ -QSE_EXPORT qse_ssize_t qse_getdelim ( - qse_char_t **buf, qse_size_t *n, - qse_getdelim_t fn, void* fnarg, QSE_FILE* stream); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/qse/lib/awk/Makefile.am b/qse/lib/awk/Makefile.am index e44b19f6..7d19f4c0 100644 --- a/qse/lib/awk/Makefile.am +++ b/qse/lib/awk/Makefile.am @@ -12,7 +12,7 @@ LDFLAGS_ALL_COMMON = -L. -L../cmn -version-info 1:0:0 -no-undefined CPPFLAGS_LIB_COMMON = $(CPPFLAGS_ALL_COMMON) $(LTDLINCL) LDFLAGS_LIB_COMMON = $(LDFLAGS_ALL_COMMON) -LIBADD_LIB_COMMON = -lqsecmn $(LIBM) $(LIBLTDL) +LIBADD_LIB_COMMON = -lqsecmn $(LIBM) $(LIBLTDL) if WIN32 # you must adjust the value of DEFAULT_MODPOSTFIX according @@ -33,7 +33,7 @@ lib_LTLIBRARIES += libqseawkxx.la libqseawkxx_la_SOURCES = Awk.cpp StdAwk.cpp libqseawkxx_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) libqseawkxx_la_LDFLAGS = $(LDFLAGS_LIB_COMMON) -libqseawkxx_la_LIBADD = -lqseawk -lqsecmnxx $(LIBADD_LIB_COMMON) +libqseawkxx_la_LIBADD = -lqseawk -lqsecmnxx -lqseawk -lqsecmn $(LIBADD_LIB_COMMON) endif if ENABLE_STATIC_MODULE diff --git a/qse/lib/awk/Makefile.in b/qse/lib/awk/Makefile.in index 8dd84063..28fc0603 100644 --- a/qse/lib/awk/Makefile.in +++ b/qse/lib/awk/Makefile.in @@ -440,7 +440,7 @@ LDFLAGS_ALL_COMMON = -L. -L../cmn -version-info 1:0:0 -no-undefined CPPFLAGS_LIB_COMMON = $(CPPFLAGS_ALL_COMMON) $(LTDLINCL) \ $(am__append_1) $(am__append_2) LDFLAGS_LIB_COMMON = $(LDFLAGS_ALL_COMMON) -LIBADD_LIB_COMMON = -lqsecmn $(LIBM) $(LIBLTDL) +LIBADD_LIB_COMMON = -lqsecmn $(LIBM) $(LIBLTDL) lib_LTLIBRARIES = libqseawk.la $(am__append_3) libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c \ fnc.c misc.c rio.c std.c awk.h err.h rio.h val.h fnc.h misc.h \ @@ -452,7 +452,7 @@ libqseawk_la_LIBADD = $(LIBADD_LIB_COMMON) $(am__append_9) @ENABLE_CXX_TRUE@libqseawkxx_la_SOURCES = Awk.cpp StdAwk.cpp @ENABLE_CXX_TRUE@libqseawkxx_la_CPPFLAGS = $(CPPFLAGS_LIB_COMMON) @ENABLE_CXX_TRUE@libqseawkxx_la_LDFLAGS = $(LDFLAGS_LIB_COMMON) -@ENABLE_CXX_TRUE@libqseawkxx_la_LIBADD = -lqseawk -lqsecmnxx $(LIBADD_LIB_COMMON) +@ENABLE_CXX_TRUE@libqseawkxx_la_LIBADD = -lqseawk -lqsecmnxx -lqseawk -lqsecmn $(LIBADD_LIB_COMMON) ################################################## # DYNAMIC MODULES diff --git a/qse/lib/awk/StdAwk.cpp b/qse/lib/awk/StdAwk.cpp index c901d8f1..ed96cd23 100644 --- a/qse/lib/awk/StdAwk.cpp +++ b/qse/lib/awk/StdAwk.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include "awk.h" #include diff --git a/qse/lib/cmn/Makefile.am b/qse/lib/cmn/Makefile.am index 42ce5b9c..1deafd5d 100644 --- a/qse/lib/cmn/Makefile.am +++ b/qse/lib/cmn/Makefile.am @@ -73,7 +73,6 @@ libqsecmn_la_SOURCES = \ sio.c \ sll.c \ slmb.c \ - stdio.c \ str-beg.c \ str-cat.c \ str-chr.c \ diff --git a/qse/lib/cmn/Makefile.in b/qse/lib/cmn/Makefile.in index f959e104..f73daf3c 100644 --- a/qse/lib/cmn/Makefile.in +++ b/qse/lib/cmn/Makefile.in @@ -92,15 +92,15 @@ am__libqsecmn_la_SOURCES_DIST = alg-base64.c alg-rand.c alg-search.c \ hton.c ipad.c lda.c main.c mb8.c mbwc.c mbwc-str.c mem.c mux.c \ nwad.c nwad-skad.c nwif.c nwif-cfg.c nwio.c oht.c opt.c \ path-basename.c path-canon.c pio.c pma.c rbt.c rex.c sio.c \ - sll.c slmb.c stdio.c str-beg.c str-cat.c str-chr.c str-cnv.c \ - str-cmp.c str-cpy.c str-del.c str-dup.c str-dyn.c str-end.c \ - str-excl.c str-fcpy.c str-fmt.c str-fnmat.c str-incl.c \ - str-join.c str-len.c str-pac.c str-pbrk.c str-put.c str-rev.c \ - str-rot.c str-set.c str-spl.c str-spn.c str-str.c str-subst.c \ - str-tok.c str-trm.c str-word.c task.c time.c tio.c tre.c \ - tre-ast.c tre-compile.c tre-match-backtrack.c \ - tre-match-parallel.c tre-parse.c tre-stack.c uri.c utf8.c \ - xma.c uni.c cp949.c cp950.c + sll.c slmb.c str-beg.c str-cat.c str-chr.c str-cnv.c str-cmp.c \ + str-cpy.c str-del.c str-dup.c str-dyn.c str-end.c str-excl.c \ + str-fcpy.c str-fmt.c str-fnmat.c str-incl.c str-join.c \ + str-len.c str-pac.c str-pbrk.c str-put.c str-rev.c str-rot.c \ + str-set.c str-spl.c str-spn.c str-str.c str-subst.c str-tok.c \ + str-trm.c str-word.c task.c time.c tio.c tre.c tre-ast.c \ + tre-compile.c tre-match-backtrack.c tre-match-parallel.c \ + tre-parse.c tre-stack.c uri.c utf8.c xma.c uni.c cp949.c \ + cp950.c @ENABLE_BUNDLED_UNICODE_TRUE@am__objects_1 = uni.lo @ENABLE_XCMGRS_TRUE@am__objects_2 = cp949.lo cp950.lo am_libqsecmn_la_OBJECTS = alg-base64.lo alg-rand.lo alg-search.lo \ @@ -110,16 +110,16 @@ am_libqsecmn_la_OBJECTS = alg-base64.lo alg-rand.lo alg-search.lo \ mbwc.lo mbwc-str.lo mem.lo mux.lo nwad.lo nwad-skad.lo nwif.lo \ nwif-cfg.lo nwio.lo oht.lo opt.lo path-basename.lo \ path-canon.lo pio.lo pma.lo rbt.lo rex.lo sio.lo sll.lo \ - slmb.lo stdio.lo str-beg.lo str-cat.lo str-chr.lo str-cnv.lo \ - str-cmp.lo str-cpy.lo str-del.lo str-dup.lo str-dyn.lo \ - str-end.lo str-excl.lo str-fcpy.lo str-fmt.lo str-fnmat.lo \ - str-incl.lo str-join.lo str-len.lo str-pac.lo str-pbrk.lo \ - str-put.lo str-rev.lo str-rot.lo str-set.lo str-spl.lo \ - str-spn.lo str-str.lo str-subst.lo str-tok.lo str-trm.lo \ - str-word.lo task.lo time.lo tio.lo tre.lo tre-ast.lo \ - tre-compile.lo tre-match-backtrack.lo tre-match-parallel.lo \ - tre-parse.lo tre-stack.lo uri.lo utf8.lo xma.lo \ - $(am__objects_1) $(am__objects_2) + slmb.lo str-beg.lo str-cat.lo str-chr.lo str-cnv.lo str-cmp.lo \ + str-cpy.lo str-del.lo str-dup.lo str-dyn.lo str-end.lo \ + str-excl.lo str-fcpy.lo str-fmt.lo str-fnmat.lo str-incl.lo \ + str-join.lo str-len.lo str-pac.lo str-pbrk.lo str-put.lo \ + str-rev.lo str-rot.lo str-set.lo str-spl.lo str-spn.lo \ + str-str.lo str-subst.lo str-tok.lo str-trm.lo str-word.lo \ + task.lo time.lo tio.lo tre.lo tre-ast.lo tre-compile.lo \ + tre-match-backtrack.lo tre-match-parallel.lo tre-parse.lo \ + tre-stack.lo uri.lo utf8.lo xma.lo $(am__objects_1) \ + $(am__objects_2) libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -394,15 +394,15 @@ libqsecmn_la_SOURCES = alg-base64.c alg-rand.c alg-search.c alg-sort.c \ ipad.c lda.c main.c mb8.c mbwc.c mbwc-str.c mem.c mux.c nwad.c \ nwad-skad.c nwif.c nwif-cfg.c nwio.c oht.c opt.c \ path-basename.c path-canon.c pio.c pma.c rbt.c rex.c sio.c \ - sll.c slmb.c stdio.c str-beg.c str-cat.c str-chr.c str-cnv.c \ - str-cmp.c str-cpy.c str-del.c str-dup.c str-dyn.c str-end.c \ - str-excl.c str-fcpy.c str-fmt.c str-fnmat.c str-incl.c \ - str-join.c str-len.c str-pac.c str-pbrk.c str-put.c str-rev.c \ - str-rot.c str-set.c str-spl.c str-spn.c str-str.c str-subst.c \ - str-tok.c str-trm.c str-word.c task.c time.c tio.c tre.c \ - tre-ast.c tre-compile.c tre-match-backtrack.c \ - tre-match-parallel.c tre-parse.c tre-stack.c uri.c utf8.c \ - xma.c $(am__append_1) $(am__append_2) + sll.c slmb.c str-beg.c str-cat.c str-chr.c str-cnv.c str-cmp.c \ + str-cpy.c str-del.c str-dup.c str-dyn.c str-end.c str-excl.c \ + str-fcpy.c str-fmt.c str-fnmat.c str-incl.c str-join.c \ + str-len.c str-pac.c str-pbrk.c str-put.c str-rev.c str-rot.c \ + str-set.c str-spl.c str-spn.c str-str.c str-subst.c str-tok.c \ + str-trm.c str-word.c task.c time.c tio.c tre.c tre-ast.c \ + tre-compile.c tre-match-backtrack.c tre-match-parallel.c \ + tre-parse.c tre-stack.c uri.c utf8.c xma.c $(am__append_1) \ + $(am__append_2) libqsecmn_la_LDFLAGS = -version-info 1:0:0 -no-undefined libqsecmn_la_LIBADD = $(SOCKET_LIBS) $(QUADMATH_LIBS) @ENABLE_CXX_TRUE@libqsecmnxx_la_SOURCES = \ @@ -534,7 +534,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sll.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slmb.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str-beg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str-cat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str-chr.Plo@am__quote@ diff --git a/qse/lib/cmn/stdio.c b/qse/lib/cmn/stdio.c deleted file mode 100644 index dbe8b6a2..00000000 --- a/qse/lib/cmn/stdio.c +++ /dev/null @@ -1,608 +0,0 @@ -/* - * $Id$ - * - Copyright 2006-2012 Chung, Hyung-Hwan. - This file is part of QSE. - - QSE is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as - published by the Free Software Foundation, either version 3 of - the License, or (at your option) any later version. - - QSE is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with QSE. If not, see . - */ - -#include -#include -#include -#include "mem.h" - -#include - -#if defined(__GLIBC__) -/* for vswprintf */ -# define __USE_UNIX98 -#endif -#include - -#include -#include - -#if defined(_WIN32) && !defined(__WATCOMC__) -# include -# define FGETC(x) _fgettc(x) -#elif defined(QSE_CHAR_IS_MCHAR) -# define FGETC(x) fgetc(x) -#else -# define FGETC(x) fgetwc(x) -#endif - -#define STREAM_TO_FILE(stream) \ - ((stream == QSE_STDOUT)? stdout: \ - (stream == QSE_STDERR)? stderr: \ - (stream == QSE_STDIN)? stdin: (FILE*)stream) - -static qse_char_t* __adjust_format (const qse_char_t* format); - -int qse_vfprintf (QSE_FILE *stream, const qse_char_t* fmt, va_list ap) -{ - int n; - qse_char_t* nf; - FILE* fp; - - nf = __adjust_format (fmt); - if (nf == QSE_NULL) return -1; - - fp = STREAM_TO_FILE (stream); - -#if defined(QSE_CHAR_IS_MCHAR) - n = vfprintf (fp, nf, ap); -#else - n = vfwprintf (fp, nf, ap); -#endif - QSE_MMGR_FREE (QSE_MMGR_GETDFL(), nf); - return n; -} - -int qse_vprintf (const qse_char_t* fmt, va_list ap) -{ - int n; - qse_char_t* nf; - - nf = __adjust_format (fmt); - if (nf == QSE_NULL) return -1; - -#if defined(QSE_CHAR_IS_MCHAR) - n = vfprintf (stdout, nf, ap); -#else - n = vfwprintf (stdout, nf, ap); -#endif - - QSE_MMGR_FREE (QSE_MMGR_GETDFL(), nf); - return n; -} - -int qse_fprintf (QSE_FILE* stream, const qse_char_t* fmt, ...) -{ - int n; - va_list ap; - qse_char_t* nf; - FILE* fp; - - nf = __adjust_format (fmt); - if (nf == QSE_NULL) return -1; - - fp = STREAM_TO_FILE (stream); - - va_start (ap, fmt); -#if defined(QSE_CHAR_IS_MCHAR) - n = vfprintf (fp, nf, ap); -#else - n = vfwprintf (fp, nf, ap); -#endif - va_end (ap); - - QSE_MMGR_FREE (QSE_MMGR_GETDFL(), nf); - return n; -} - -int qse_printf (const qse_char_t* fmt, ...) -{ - int n; - va_list ap; - qse_char_t* nf; - - nf = __adjust_format (fmt); - if (nf == QSE_NULL) return -1; - - va_start (ap, fmt); -#if defined(QSE_CHAR_IS_MCHAR) - n = vfprintf (stdout, nf, ap); -#else - n = vfwprintf (stdout, nf, ap); -#endif - va_end (ap); - - QSE_MMGR_FREE (QSE_MMGR_GETDFL(), nf); - return n; -} - -int qse_dprintf (const qse_char_t* fmt, ...) -{ - int n; - va_list ap; - qse_char_t* nf; - - nf = __adjust_format (fmt); - if (nf == QSE_NULL) return -1; - - va_start (ap, fmt); -#if defined(QSE_CHAR_IS_MCHAR) - n = vfprintf (stderr, nf, ap); -#else - n = vfwprintf (stderr, nf, ap); -#endif - va_end (ap); - - QSE_MMGR_FREE (QSE_MMGR_GETDFL(), nf); - return n; -} - -int qse_vsprintf (qse_char_t* buf, qse_size_t size, const qse_char_t* fmt, va_list ap) -{ - int n; - qse_char_t* nf = __adjust_format (fmt); - if (nf == QSE_NULL) return -1; - -#if defined(QSE_CHAR_IS_MCHAR) - #if defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200)) || defined(HAVE__VSNPRINTF) - n = _vsnprintf (buf, size, nf, ap); - #else - n = vsnprintf (buf, size, nf, ap); - #endif -#else - #if defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200)) || defined(HAVE__VSNWPRINTF) - n = _vsnwprintf (buf, size, nf, ap); - #else - n = vswprintf (buf, size, nf, ap); - #endif -#endif - - if (n < 0 || (size_t)n >= size) - { - if (size > 0) buf[size-1] = QSE_T('\0'); - n = -1; - } - - QSE_MMGR_FREE (QSE_MMGR_GETDFL(), nf); - return n; -} - -int qse_sprintf (qse_char_t* buf, qse_size_t size, const qse_char_t* fmt, ...) -{ - int n; - va_list ap; - - va_start (ap, fmt); - n = qse_vsprintf (buf, size, fmt, ap); - va_end (ap); - return n; -} - -#define MOD_SHORT 1 -#define MOD_LONG 2 -#define MOD_LONGLONG 3 - -#define ADDC(buf,c) \ - do { \ - if (buf.len >= buf.cap) \ - { \ - qse_char_t* tmp; \ - tmp = (qse_char_t*) QSE_MMGR_REALLOC ( \ - QSE_MMGR_GETDFL(), buf.ptr, \ - QSE_SIZEOF(qse_char_t) * (buf.cap+256+1)); \ - if (tmp == QSE_NULL) \ - { \ - QSE_MMGR_FREE (QSE_MMGR_GETDFL(), buf.ptr); \ - return QSE_NULL; \ - } \ - buf.ptr = tmp; \ - buf.cap = buf.cap + 256; \ - } \ - buf.ptr[buf.len++] = c; \ - } while (0) - -static qse_char_t* __adjust_format (const qse_char_t* format) -{ - const qse_char_t* fp = format; - int modifier; - qse_char_t ch; - - struct - { - qse_char_t* ptr; - qse_size_t len; - qse_size_t cap; - } buf; - - buf.len = 0; - buf.cap = 256; - - buf.ptr = (qse_char_t*) QSE_MMGR_ALLOC ( - QSE_MMGR_GETDFL(), QSE_SIZEOF(qse_char_t) * (buf.cap+1)); - if (buf.ptr == QSE_NULL) return QSE_NULL; - - while (*fp != QSE_T('\0')) - { - while (*fp != QSE_T('\0') && *fp != QSE_T('%')) - { - ADDC (buf, *fp++); - } - - if (*fp == QSE_T('\0')) break; - - ch = *fp++; - ADDC (buf, ch); /* add % */ - - ch = *fp++; - - /* flags */ - while (1) - { - if (ch == QSE_T(' ') || ch == QSE_T('+') || - ch == QSE_T('-') || ch == QSE_T('#')) - { - ADDC (buf, ch); - ch = *fp++; - } - else - { - if (ch == QSE_T('0')) - { - ADDC (buf, ch); - ch = *fp++; - } - - break; - } - } - - /* check the width */ - if (ch == QSE_T('*')) - { - ADDC (buf, ch); - ch = *fp++; - } - else - { - while (QSE_ISDIGIT(ch)) - { - ADDC (buf, ch); - ch = *fp++; - } - } - - /* precision */ - if (ch == QSE_T('.')) - { - ADDC (buf, ch); - ch = *fp++; - - if (ch == QSE_T('*')) - { - ADDC (buf, ch); - ch = *fp++; - } - else - { - while (QSE_ISDIGIT(ch)) - { - ADDC (buf, ch); - ch = *fp++; - } - } - } - - /* modifier */ - for (modifier = 0;;) - { - if (ch == QSE_T('h')) modifier = MOD_SHORT; - else if (ch == QSE_T('l')) - { - modifier = (modifier == MOD_LONG)? MOD_LONGLONG: MOD_LONG; - } - else break; - ch = *fp++; - } - - /* type */ - switch (ch) - { - case QSE_T('\0'): - goto done; - - case QSE_T('%'): - { - ADDC (buf, ch); - break; - } - - case QSE_T('c'): - case QSE_T('s'): - { - if (modifier == MOD_SHORT) - { - /* always multibyte */ - #if defined(QSE_CHAR_IS_MCHAR) - goto mchar_multi; - #else - ch = QSE_TOUPPER(ch); - goto wchar_multi; - #endif - } - else if (modifier == MOD_LONG) - { - /* always wide-character */ - #if defined(QSE_CHAR_IS_MCHAR) - ch = QSE_TOUPPER(ch); - goto mchar_wide; - #else - goto wchar_wide; - #endif - } - else - { - #if defined(QSE_CHAR_IS_MCHAR) - mchar_multi: - #if defined(_WIN32) && !defined(__WATCOMC__) - ADDC (buf, ch); - #else - ADDC (buf, ch); - #endif - #else - wchar_wide: - #if defined(_WIN32) && !defined(__WATCOMC__) - ADDC (buf, ch); - #else - ADDC (buf, QSE_WT('l')); - ADDC (buf, ch); - #endif - #endif - } - break; - } - - case QSE_T('C'): - case QSE_T('S'): - { - #if defined(QSE_CHAR_IS_MCHAR) - mchar_wide: - #if defined(_WIN32) && !defined(__WATCOMC__) - ADDC (buf, ch); - #else - ADDC (buf, QSE_MT('l')); - ADDC (buf, QSE_TOLOWER(ch)); - #endif - #else - wchar_multi: - #if defined(_WIN32) && !defined(__WATCOMC__) - ADDC (buf, ch); - #else - ADDC (buf, QSE_MT('h')); - ADDC (buf, QSE_TOLOWER(ch)); - #endif - #endif - - break; - } - - case QSE_T('d'): - case QSE_T('i'): - case QSE_T('o'): - case QSE_T('u'): - case QSE_T('x'): - case QSE_T('X'): - { - if (modifier == MOD_SHORT) - { - ADDC (buf, 'h'); - } - else if (modifier == MOD_LONG) - { - ADDC (buf, 'l'); - } - else if (modifier == MOD_LONGLONG) - { - #if defined(_WIN32) && !defined(__LCC__) - ADDC (buf, 'I'); - ADDC (buf, '6'); - ADDC (buf, '4'); - #else - ADDC (buf, 'l'); - ADDC (buf, 'l'); - #endif - } - ADDC (buf, ch); - break; - } - - default: - { - ADDC (buf, ch); - break; - } - } - } - -done: - buf.ptr[buf.len] = QSE_T('\0'); - return buf.ptr; -} - - -QSE_FILE* qse_fopen (const qse_char_t* path, const qse_char_t* mode) -{ -#if defined(QSE_CHAR_IS_MCHAR) - return (QSE_FILE*)fopen (path, mode); -#elif defined(_WIN32) || defined(__OS2__) - return (QSE_FILE*)_wfopen (path, mode); -#else - - FILE* fp = QSE_NULL; - qse_mchar_t* path_mb; - qse_mchar_t* mode_mb; - - path_mb = qse_wcstombsdup (path, QSE_NULL, QSE_MMGR_GETDFL()); - mode_mb = qse_wcstombsdup (mode, QSE_NULL, QSE_MMGR_GETDFL()); - - if (path_mb && mode_mb) - { - fp = fopen (path_mb, mode_mb); - } - - if (mode_mb) QSE_MMGR_FREE (QSE_MMGR_GETDFL(), mode_mb); - if (path_mb) QSE_MMGR_FREE (QSE_MMGR_GETDFL(), path_mb); - - return (QSE_FILE*)fp; - -#endif -} - -void qse_fclose (QSE_FILE* stream) -{ - FILE* fp; - fp = STREAM_TO_FILE (stream); - fclose (fp); -} - -int qse_fflush (QSE_FILE* stream) -{ - FILE* fp; - fp = STREAM_TO_FILE (stream); - return fflush (fp); -} - -void qse_clearerr (QSE_FILE* stream) -{ - FILE* fp; - fp = STREAM_TO_FILE (stream); - clearerr (fp); -} - -int qse_feof (QSE_FILE* stream) -{ - FILE* fp; - fp = STREAM_TO_FILE (stream); - return feof (fp); -} - -int qse_ferror (QSE_FILE* stream) -{ - FILE* fp; - fp = STREAM_TO_FILE (stream); - return ferror (fp); -} - -static int isnl (const qse_char_t* ptr, qse_size_t len, void* delim) -{ - return (ptr[len-1] == *(qse_char_t*)delim)? 1: 0; -} - -qse_ssize_t qse_getline (qse_char_t **buf, qse_size_t *n, QSE_FILE *stream) -{ - qse_char_t nl = QSE_T('\n'); - return qse_getdelim (buf, n, isnl, &nl, stream); -} - -qse_ssize_t qse_getdelim ( - qse_char_t **buf, qse_size_t *n, - qse_getdelim_t fn, void* fnarg, QSE_FILE *stream) -{ - qse_char_t* b; - qse_size_t capa; - qse_size_t len = 0; - int x; - FILE* fp; - - QSE_ASSERT (buf != QSE_NULL); - QSE_ASSERT (n != QSE_NULL); - - fp = STREAM_TO_FILE (stream); - - b = *buf; - capa = *n; - - if (b == QSE_NULL) - { - capa = 256; - b = (qse_char_t*) QSE_MMGR_ALLOC ( - QSE_MMGR_GETDFL(), QSE_SIZEOF(qse_char_t)*(capa+1)); - if (b == QSE_NULL) return -2; - } - - if (feof(fp)) - { - len = (qse_size_t)-1; - goto exit_task; - } - - while (1) - { - qse_cint_t c = FGETC (fp); - if (c == QSE_CHAR_EOF) - { - if (ferror(fp)) - { - len = (qse_size_t)-2; - goto exit_task; - } - if (len == 0) - { - len = (qse_size_t)-1; - goto exit_task; - } - - break; - } - - if (len+1 >= capa) - { - qse_size_t ncapa = capa + 256; - qse_char_t* nb; - - nb = QSE_MMGR_REALLOC ( - QSE_MMGR_GETDFL(), b, ncapa * QSE_SIZEOF(qse_char_t)); - if (nb == QSE_NULL) - { - len = (qse_size_t)-2; - goto exit_task; - } - - b = nb; - capa = ncapa; - } - - b[len++] = c; - - x = fn (b, len, fnarg); - if (x < 0) - { - len = (qse_size_t)-3; - goto exit_task; - } - if (x > 0) break; - } - b[len] = QSE_T('\0'); - -exit_task: - *buf = b; - *n = capa; - - return (qse_ssize_t)len; -} diff --git a/qse/lib/http/httpd.c b/qse/lib/http/httpd.c index 57cefe05..f7d4e0ad 100644 --- a/qse/lib/http/httpd.c +++ b/qse/lib/http/httpd.c @@ -23,8 +23,7 @@ #include #include #include - -#include +#include typedef struct htrd_xtn_t htrd_xtn_t; diff --git a/qse/lib/http/httpd.h b/qse/lib/http/httpd.h index e27fd492..0eb10382 100644 --- a/qse/lib/http/httpd.h +++ b/qse/lib/http/httpd.h @@ -25,8 +25,6 @@ #include -#include /* TODO: remove this.. only for debugging at this moment */ - struct qse_httpd_t { qse_mmgr_t* mmgr; diff --git a/qse/samples/sed/sed01.c b/qse/samples/sed/sed01.c index 83accdbd..3c8b8d56 100644 --- a/qse/samples/sed/sed01.c +++ b/qse/samples/sed/sed01.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include "sed00.h" static int sed_main (int argc, qse_char_t* argv[]) @@ -49,6 +49,10 @@ oops: int qse_main (int argc, qse_achar_t* argv[]) { + int x; + qse_openstdsios (); init_sed_sample_locale (); - return qse_runmain (argc, argv, sed_main); + x = qse_runmain (argc, argv, sed_main); + qse_closestdsios (); + return x; } diff --git a/qse/samples/sed/sed02.c b/qse/samples/sed/sed02.c index f5532718..0da6e0f1 100644 --- a/qse/samples/sed/sed02.c +++ b/qse/samples/sed/sed02.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include "sed00.h" static int sed_main (int argc, qse_char_t* argv[]) @@ -62,6 +62,10 @@ oops: int qse_main (int argc, qse_achar_t* argv[]) { + int x; + qse_openstdsios (); init_sed_sample_locale (); - return qse_runmain (argc, argv, sed_main); + x = qse_runmain (argc, argv, sed_main); + qse_closestdsios (); + return x; } diff --git a/qse/samples/sed/sed03.c b/qse/samples/sed/sed03.c index ecb136e3..62b9ccd2 100644 --- a/qse/samples/sed/sed03.c +++ b/qse/samples/sed/sed03.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include "sed00.h" static void trace_exec (qse_sed_t* sed, qse_sed_tracer_op_t op, qse_sed_cmd_t* cmd) @@ -71,6 +71,10 @@ oops: int qse_main (int argc, qse_achar_t* argv[]) { + int x; + qse_openstdsios (); init_sed_sample_locale (); - return qse_runmain (argc, argv, sed_main); + x = qse_runmain (argc, argv, sed_main); + qse_closestdsios (); + return x; } diff --git a/qse/samples/sed/sed21.cpp b/qse/samples/sed/sed21.cpp index e28bb739..1a3fd21d 100644 --- a/qse/samples/sed/sed21.cpp +++ b/qse/samples/sed/sed21.cpp @@ -52,6 +52,8 @@ int sed_main (int argc, qse_char_t* argv[]) int qse_main (int argc, qse_achar_t* argv[]) { + int x; init_sed_sample_locale (); - return qse_runmain (argc, argv, sed_main); + x = qse_runmain (argc, argv, sed_main); + return x; } diff --git a/qse/samples/sed/sed22.cpp b/qse/samples/sed/sed22.cpp index d831b4b0..90b924c3 100644 --- a/qse/samples/sed/sed22.cpp +++ b/qse/samples/sed/sed22.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include "sed00.h" @@ -67,6 +66,8 @@ int sed_main (int argc, qse_char_t* argv[]) int qse_main (int argc, qse_achar_t* argv[]) { + int x; init_sed_sample_locale (); - return qse_runmain (argc, argv, sed_main); + x = qse_runmain (argc, argv, sed_main); + return x; }