/* 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: dk4stat.ctr */ /** @file dk4stat.c The dk4stat module. */ #line 96 "dk4stat.ctr" #include "dk4conf.h" #include "dk4stat.h" #if DK4_CHAR_SIZE > 1 #include "dk4statw.h" #else #include "dk4stat8.h" #endif #if DK4_HAVE_ASSERT_H #ifndef ASSERT_H_INCLUDED #include #define ASSERT_H_INCLUDED 1 #endif #endif #line 115 "dk4stat.ctr" int dk4stat_is_regular(const dk4_stat_t *stb, dk4_er_t *erp) { int back = 0; #if DK4_USE_ASSERT assert(NULL != stb); #endif if (NULL != stb) { #if DK4_ON_WINDOWS if (((stb->st_mode) & _S_IFMT) == _S_IFREG) { back = 1; } #else if (((stb->st_mode) & S_IFMT) == S_IFREG) { back = 1; } #endif } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } return back; } int dk4stat_is_directory(const dk4_stat_t *stb, dk4_er_t *erp) { int back = 0; #if DK4_USE_ASSERT assert(NULL != stb); #endif if (NULL != stb) { #if DK4_ON_WINDOWS if (((stb->st_mode) & _S_IFMT) == _S_IFDIR) { back = 1; } #else if (((stb->st_mode) & S_IFMT) == S_IFDIR) { back = 1; } #endif } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } return back; } int dk4stat_is_symlink(const dk4_stat_t *stb, dk4_er_t *erp) { int back = 0; #if DK4_USE_ASSERT assert(NULL != stb); #endif if (NULL != stb) { #if DK4_ON_WINDOWS #else #if defined(S_IFMT) && defined(S_IFLNK) if (S_IFLNK == ((stb->st_mode) & S_IFMT)) { back = 1; } #endif #endif } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } return back; } int dk4stat_is_unix_domain_socket(const dk4_stat_t *stb, dk4_er_t *erp) { int back = 0; #if DK4_USE_ASSERT assert(NULL != stb); #endif if (NULL != stb) { #if DK4_ON_WINDOWS #else #if defined(S_IFMT) && defined(S_IFSOCK) if (S_IFSOCK == ((stb->st_mode) & S_IFMT)) { back = 1; } #endif #endif } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } return back; }