/* Copyright (C) 2015-2020, Dirk Krause SPDX-License-Identifier: BSD-3-Clause */ /* WARNING: This file was generated by the dkct program (see http://dktools.sourceforge.net/ for details). Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: dk4sock07.ctr */ /** @file dk4sock07.c The dk4sock07 module. */ #line 10 "dk4sock07.ctr" #include "dk4conf.h" #include "dk4sock.h" #include "dk4rec24.h" #if DK4_HAVE_ASSERT_H #ifndef ASSERT_H_INCLUDED #include #define ASSERT_H_INCLUDED 1 #endif #endif #line 24 "dk4sock07.ctr" 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 DK4_USE_ASSERT assert(NULL != pAddr); assert(NULL != src); assert(0 < szAddr); #endif 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 DK4_USE_ASSERT assert(NULL != pAddr); assert(NULL != src); assert(0 < szAddr); #endif 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 }