/* 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: dk4membs.ctr */ /** @file dk4membs.c The dk4membs module. */ #line 71 "dk4membs.ctr" #include "dk4conf.h" #include "dk4membs.h" #if DK4_HAVE_ASSERT_H #ifndef ASSERT_H_INCLUDED #include #define ASSERT_H_INCLUDED 1 #endif #endif int dk4membuf_to_stream( dk4_stream_t *strm, dk4_membuf_t const *mbptr, dk4_er_t *erp ) { dk4_membuf_cell_t *pc = NULL; dk4_membuf_cell_t *pn = NULL; int back = 0; #if DK4_USE_ASSERT assert(NULL != strm); assert(NULL != mbptr); #endif if ((NULL != strm) && (NULL != mbptr)) { back = 1; pc = mbptr->first; while (NULL != pc) { pn = pc->next; if (0 < pc->used) { if (0 == dk4stream_write(strm, pc->buf, pc->used, erp)) { back = 0; } } pc = pn; } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } return back; }