From 55601b2d38b9be8ccef782949a6ef97cc93faedc Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 30 Jan 2007 22:55:19 +0000 Subject: [PATCH] Placeholder --- src/net/stream.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/net/stream.c diff --git a/src/net/stream.c b/src/net/stream.c new file mode 100644 index 00000000..98716817 --- /dev/null +++ b/src/net/stream.c @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007 Michael Brown . + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or any later version. + * + * This program 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/** + * @file + * + * Stream API + */ + +#include +#include +#include +#include + +/** + * Send data via connection + * + * @v app Stream application + * @v data Data to send + * @v len Length of data + * @ret rc Return status code + * + * This method should be called only in the context of an + * application's senddata() method. + */ +int stream_send ( struct stream_application *app, void *data, size_t len ) { + struct stream_connection *conn = app->conn; + int rc; + + DBGC2 ( app, "Stream %p sending %zd bytes\n", app, len ); + + /* Check connection actually exists */ + if ( ! conn ) { + DBGC ( app, "Stream %p has no connection\n", app ); + return -ENOTCONN; + } + + /* Send data via connection */ + if ( ( rc = conn->op->send ( conn, data, len ) ) != 0 ) { + DBGC ( app, "Stream %p failed to send %zd bytes: %s\n", + app, len, strerror ( rc ) ); + return rc; + } + + return 0; +}