summaryrefslogtreecommitdiff
path: root/support/dktools/dk4svbuf.ctr
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-09-20 03:03:26 +0000
committerNorbert Preining <norbert@preining.info>2020-09-20 03:03:26 +0000
commit1f457376b478257b88d4a857f5ec1b6155442dd7 (patch)
tree2a06a60551dea362cf8cb0cb0ba66c78608717c4 /support/dktools/dk4svbuf.ctr
parentac690ca29ad5bf8a5203a65fd6252f7b564f4727 (diff)
CTAN sync 202009200303
Diffstat (limited to 'support/dktools/dk4svbuf.ctr')
-rw-r--r--support/dktools/dk4svbuf.ctr39
1 files changed, 37 insertions, 2 deletions
diff --git a/support/dktools/dk4svbuf.ctr b/support/dktools/dk4svbuf.ctr
index 4bba80db63..7abd3768fd 100644
--- a/support/dktools/dk4svbuf.ctr
+++ b/support/dktools/dk4svbuf.ctr
@@ -2,7 +2,7 @@
copyright owner = Dirk Krause
copyright year = 2016-xxxx
-license = bsd
+SPDX-License-Identifier: BSD-3-Clause
%% header
@@ -10,7 +10,11 @@ license = bsd
*/
#ifndef DK4CONF_H_INCLUDED
+#if DK4_BUILDING_DKTOOLS4
#include "dk4conf.h"
+#else
+#include <dktools-4/dk4conf.h>
+#endif
#endif
#ifndef STDIO_H_INCLUDED
@@ -19,7 +23,11 @@ license = bsd
#endif
#ifndef DK4ERROR_H_INCLUDED
+#if DK4_BUILDING_DKTOOLS4
#include "dk4error.h"
+#else
+#include <dktools-4/dk4error.h>
+#endif
#endif
/** How to buffer a file.
@@ -41,6 +49,15 @@ extern "C" {
@param szbuf Size of buffer, may be 0.
@param erp Error report, may be NULL.
@return 1 on success, 0 on error.
+
+ Error codes:
+ - DK4_E_INVALID_ARGUMENTS<br>
+ if fipo is NULL,
+ - DK4_E_NOT_SUPPORTED<br>
+ if neither the setbuffer function nor the setvbuf() function
+ is available on the system.
+ - DK4_E_SYSTEM<br>
+ if setvbuf() indicated an error.
*/
int
dk4setvbuf(
@@ -59,8 +76,22 @@ dk4setvbuf(
%% module
+#include "dk4conf.h"
#include "dk4svbuf.h"
+#if DK4_HAVE_ERRNO_H
+#ifndef ERRNO_H_INCLUDED
+#include <errno.h>
+#define ERRNO_H_INCLUDED 1
+#endif
+#endif
+
+#if DK4_HAVE_ASSERT_H
+#ifndef ASSERT_H_INCLUDED
+#include <assert.h>
+#define ASSERT_H_INCLUDED 1
+#endif
+#endif
$!trace-include
@@ -88,6 +119,9 @@ dk4setvbuf(
#endif
int btp;
+#if DK4_USE_ASSERT
+ assert(NULL != fipo);
+#endif
if (NULL != fipo) {
btp = (
((0 <= (int)tp) && (3 > (int)tp))
@@ -95,6 +129,7 @@ dk4setvbuf(
: (buffering_types[2])
);
#if DK4_HAVE_SETVBUF
+ errno = 0;
svbres = setvbuf(
fipo,
((0 < szbuf) ? (pbuf) : (NULL)),
@@ -105,7 +140,7 @@ dk4setvbuf(
back = 1;
}
else {
- dk4error_set_simple_error_code(erp, DK4_E_SYSTEM);
+ dk4error_set_idetails(erp, DK4_E_SYSTEM, errno);
}
#else
#if DK4_HAVE_SETBUFFER