%% options copyright owner = Dirk Krause copyright year = 2015-xxxx license = bsd %% module #include "dk4sock.h" #include "dk4rec24.h" $!trace-include int dk4socket_wc_inet_pton( void *pAddr, size_t szAddr, int afam, const wchar_t *src, dk4_er_t *erp ) { #if DK4_ON_WINDOWS && DK4_HAVE_INET_PTON int back = DK4_SOCKET_RESULT_FAILED; int res; if ((NULL != pAddr) && (NULL != src) && (0 < szAddr)) { dk4socket_error_reset(); res = InetPtonW(afam, src, pAddr); if (0 < res) { back = DK4_SOCKET_RESULT_SUCCESS; } else { if (0 > res) { dk4socket_error_report(erp, DK4_E_SOCKET_INET_PTON); } else { dk4error_set_simple_error_code(erp, DK4_E_SYNTAX); } } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } return back; #else char buf[128]; int back = DK4_SOCKET_RESULT_FAILED; if ((NULL != pAddr) && (NULL != src) && (0 < szAddr)) { if (0 != dk4recode_wchar_t_to_char(buf, sizeof(buf), src, erp)) { back = dk4socket_c8_inet_pton(pAddr, szAddr, afam, buf, erp); } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } return back; #endif }