00001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00002 * Copyright by The HDF Group. * 00003 * Copyright by the Board of Trustees of the University of Illinois. * 00004 * All rights reserved. * 00005 * * 00006 * This file is part of HDF5. The full HDF5 copyright notice, including * 00007 * terms governing use, modification, and redistribution, is contained in * 00008 * the files COPYING and Copyright.html. COPYING can be found at the root * 00009 * of the source code distribution tree; Copyright.html can be found at the * 00010 * root level of an installed copy of the electronic HDF5 document set and * 00011 * is linked from the top-level documents page. It can also be found at * 00012 * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * 00013 * access to either file, you may request a copy from help@hdfgroup.org. * 00014 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 00015 00016 /* 00017 * Copyright © 2000 The author. 00018 * The author prefers this code not be used for military purposes. 00019 * 00020 * 00021 * Author: Thomas Radke <tradke@aei-potsdam.mpg.de> 00022 * Tuesday, September 12, 2000 00023 * 00024 * Purpose: The public header file for the Stream Virtual File Driver. 00025 * 00026 * Modifications: 00027 * Thomas Radke, Thursday, October 26, 2000 00028 * Added support for Windows. 00029 * 00030 */ 00031 #ifndef H5FDstream_H 00032 #define H5FDstream_H 00033 00034 #include <hdf5.h> 00035 #include "hdf5stream_config.h" 00036 00037 #include "H5FDstreamDllApi.h" 00038 00039 #ifdef H5_HAVE_STREAM 00040 # define H5FD_STREAM (H5FD_stream_init()) 00041 #else 00042 # define H5FD_STREAM (-1) 00043 #endif /*H5_HAVE_STREAM */ 00044 00045 #ifdef H5_HAVE_STREAM 00046 /* check what sockets type we have (Unix or Windows sockets) 00047 Note that only MS compilers require to use Windows sockets 00048 but gcc under Windows does not. */ 00049 #if ! defined(H5_HAVE_WINSOCK_H) || defined(__GNUC__) 00050 #define H5FD_STREAM_HAVE_UNIX_SOCKETS 1 00051 #endif 00052 00053 /* define the data type for socket descriptors 00054 and the constant indicating an invalid descriptor */ 00055 #ifdef H5FD_STREAM_HAVE_UNIX_SOCKETS 00056 #define H5FD_STREAM_SOCKET_TYPE int 00057 #define H5FD_STREAM_INVALID_SOCKET -1 00058 00059 #else 00060 #include <winsock.h> 00061 00062 #define H5FD_STREAM_SOCKET_TYPE SOCKET 00063 #define H5FD_STREAM_INVALID_SOCKET INVALID_SOCKET 00064 00065 #endif 00066 00067 00068 #ifdef __cplusplus 00069 extern "C" { 00070 #endif 00071 00072 /* prototype for read broadcast callback routine */ 00073 typedef int (*H5FD_stream_broadcast_t) (unsigned char **file, 00074 haddr_t *len, 00075 void *arg); 00076 00077 /* 00078 Prototype of a function that is called by the streaming file driver when 00079 it cannot send all data at once. This function might display a progress bar 00080 or perform some small computations until the data have left the local machine 00081 via the network connection. 00082 */ 00083 typedef int (*H5FDsendloop_callback_t)(size_t sent, size_t total, void*arg); 00084 00085 /* 00086 Prototype of a function that may modify the userblock of an HDF5 file. 00087 This functionality may be used to transport any additional information on 00088 an hdf5 file, e.g. to specify its content-type and file size in an application-defined 00089 manner. Still, any user client code that can read an HDF5 file via streams is able 00090 to read the streamed file independent from this userblock information. 00091 Nevertheless it may contain additional, hdf5-independent application-specific informaion. 00092 Note that the userblock must first be set by an appropriate HDF5 call, and this 00093 function MUST know about the size that has been set there. It cannot find out 00094 (at least I don't know how - WB) how large the userblock actually is, so consistency 00095 must be ensured by user code. 00096 */ 00097 typedef void (*H5FDmodify_userblock_callback_t)(void*ptr, size_t filesize, void*arg, H5FD_STREAM_SOCKET_TYPE socket); 00098 00099 #define H5FD_STREAMVFD_VERSION 2 00100 00101 /* driver-specific file access properties */ 00102 typedef struct H5FD_stream_fapl_t 00103 { 00104 size_t increment; /* how much to grow memory in reallocs */ 00105 H5FD_STREAM_SOCKET_TYPE socket; /* externally provided socket descriptor*/ 00106 hbool_t do_socket_io; /* do I/O on socket */ 00107 hbool_t have_master_socket; /* on write, a master socket is provided, not a client socket */ 00108 int backlog; /* backlog argument for listen call */ 00109 H5FD_stream_broadcast_t broadcast_fn; /* READ broadcast callback */ 00110 void *broadcast_arg; /* READ broadcast callback user argument*/ 00111 unsigned int maxhunt; /* how many more ports to try to bind to*/ 00112 unsigned short int port; /* port a socket was bound/connected to */ 00113 H5FDsendloop_callback_t sendloop_callback_fn; 00114 /* Idle function to be called when data are written to a client. 00115 It may issue some other task, or at least call sleep(0) to 00116 enable task switching in a multitasking environment. 00117 May be NULL. */ 00118 void *sendloop_arg; /* sendloop callback user argument */ 00119 H5FDmodify_userblock_callback_t modify_userblock_callback_fn; 00120 /* callback function that may modify the userblock. May be NULL. */ 00121 void *modify_userblock_args; /* any user parameters for the modify userblock callback function */ 00122 } H5FD_stream_fapl_t; 00123 00124 00125 /* prototypes of exported functions */ 00126 H5FDstream_API hid_t H5FD_stream_init (void); 00127 /* Sets reasonable default values for an streaming FAPL. 00128 It is recommended to use this function on empty H5FD_stream_fapl_t objects 00129 before any user values are set, because it initializes any members to 00130 values that ensure the default behaviour and is thus future-save in 00131 case of any future additions to the fapl structure. */ 00132 H5FDstream_API void H5Pinit_fapl_stream (H5FD_stream_fapl_t *fapl); 00133 00134 H5FDstream_API herr_t H5Pset_fapl_stream (hid_t fapl_id, 00135 H5FD_stream_fapl_t *fapl); 00136 00137 H5FDstream_API herr_t H5Pget_fapl_stream (hid_t fapl_id, 00138 H5FD_stream_fapl_t *fapl /*out*/ ); 00139 00140 #ifdef __cplusplus 00141 } 00142 #endif 00143 00144 #endif /* H5_HAVE_STREAM */ 00145 00146 #endif /* H5FDstream_H */