1 /** 2 * Pipe I/O for Unix 3 * 4 * Copyright: 5 * (C) 1999-2007 Jack Lloyd 6 * (C) 2014-2015 Etienne Cimon 7 * 8 * License: 9 * Botan is released under the Simplified BSD License (see LICENSE.md) 10 */ 11 module botan.filters.fd_unix; 12 version(none): 13 import botan.filters.pipe; 14 import botan.utils.exceptn; 15 import core.sys.posix.unistd; 16 17 // TODO: make this work? 18 19 20 /* 21 * Stream output operator; dumps the results from pipe's default 22 * message to the output stream. 23 * Params: 24 * output = file descriptor for an open output stream 25 * pipe = the pipe 26 */ 27 /*int operator<<(int fd, Pipe& pipe) 28 { 29 SecureVector!ubyte buffer = SecureVector!ubyte(DEFAULT_BUFFERSIZE); 30 while (pipe.remaining()) 31 { 32 size_t got = pipe.read(buffer.ptr, buffer.length); 33 size_t position = 0; 34 while (got) 35 { 36 ssize_t ret = write(fd, &buffer[position], got); 37 if (ret == -1) 38 throw new Stream_IO_Error("Pipe output operator (unixfd) has failed"); 39 position += ret; 40 got -= ret; 41 } 42 } 43 return fd; 44 }*/ 45 46 /* 47 * File descriptor input operator; dumps the remaining bytes of input 48 * to the (assumed open) pipe message. 49 * Params: 50 * input = file descriptor for an open input stream 51 * pipe = the pipe 52 */ 53 /*int opBinary(string op)(int fd, ref Pipe pipe) 54 { 55 SecureVector!ubyte buffer = SecureVector!ubyte(DEFAULT_BUFFERSIZE); 56 while (true) 57 { 58 ssize_t ret = read(fd, buffer.ptr, buffer.length); 59 if (ret == 0) break; 60 if (ret == -1) 61 throw new Stream_IO_Error("Pipe input operator (unixfd) has failed"); 62 pipe.write(buffer.ptr, ret); 63 } 64 return fd; 65 } 66 */