| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- /**
- * @file PRStreamSink.h
- * @author Ambroz Bizjak <ambrop7@gmail.com>
- *
- * @section LICENSE
- *
- * This file is part of BadVPN.
- *
- * BadVPN is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2
- * as published by the Free Software Foundation.
- *
- * BadVPN is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * @section DESCRIPTION
- *
- * A {@link StreamPassInterface} sink for a NSPR file descriptor (PRFileDesc) via {@link BPRFileDesc}.
- */
- #ifndef BADVPN_NSPRSUPPORT_PRSTREAMSINK_H
- #define BADVPN_NSPRSUPPORT_PRSTREAMSINK_H
- #include <stdint.h>
- #include <misc/dead.h>
- #include <system/DebugObject.h>
- #include <flow/error.h>
- #include <flow/StreamPassInterface.h>
- #include <nspr_support/BPRFileDesc.h>
- #define PRSTREAMSINK_ERROR_NSPR 1
- /**
- * A {@link StreamPassInterface} sink for a NSPR file descriptor (PRFileDesc) via {@link BPRFileDesc}.
- */
- typedef struct {
- DebugObject d_obj;
- dead_t dead;
- FlowErrorReporter rep;
- BPRFileDesc *bprfd;
- StreamPassInterface input;
- int in_len;
- uint8_t *in;
- #ifndef NDEBUG
- int in_error;
- #endif
- } PRStreamSink;
- /**
- * Initializes the object.
- *
- * @param s the object
- * @param rep error reporting data. Error code is an int. Possible error codes:
- * - PRSTREAMSINK_ERROR_NSPR: {@link PR_Write} failed
- * with an unhandled error code
- * The object must be freed from the error handler.
- * @param bprfd the {@link BPRFileDesc} object to write data to. Registers a
- * PR_POLL_WRITE handler which must not be registered.
- */
- void PRStreamSink_Init (PRStreamSink *s, FlowErrorReporter rep, BPRFileDesc *bprfd);
- /**
- * Frees the object.
- *
- * @param s the object
- */
- void PRStreamSink_Free (PRStreamSink *s);
- /**
- * Returns the input interface.
- *
- * @param s the object
- * @return input interface
- */
- StreamPassInterface * PRStreamSink_GetInput (PRStreamSink *s);
- #endif
|