Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

link.h

00001 /*
00002 Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
00003 Copyright (C) 2005- The University of Notre Dame
00004 This software is distributed under a BSD-style license.
00005 See the file COPYING for details.
00006 */
00007 
00008 #ifndef LINK_H
00009 #define LINK_H
00010 
00011 #include "int_sizes.h"
00012 
00013 #include <time.h>
00014 #include <limits.h>
00015 #include <stdio.h>
00016 #include <sys/types.h>
00017 
00018 /* Maximum number of characters in a link address */
00019 #define LINK_ADDRESS_MAX 17
00020 
00021 /* Value to usewhen any listen port is acceptable */
00022 #define LINK_PORT_ANY 0
00023 
00024 /* Stoptime to give when you wish to wait forever */
00025 #define LINK_FOREVER ((time_t)INT_MAX)
00026 
00027 struct link * link_attach( int fd );
00028 struct link * link_serve( int port );
00029 struct link * link_serve_address( const char *addr, int port );
00030 struct link * link_accept( struct link *master, time_t stoptime );
00031 struct link * link_connect( const char *addr, int port, time_t stoptime );
00032 
00033 int  link_read( struct link *link, char *data, int length, time_t stoptime );
00034 int  link_read_avail( struct link *link, char *data, int length, time_t stoptime );
00035 int  link_write( struct link *link, const char *data, int length, time_t stoptime );
00036 
00037 int  link_sleep( struct link *link, time_t stoptime, int reading, int writing );
00038 int  link_usleep( struct link *link, int usec, int reading, int writing );
00039 void link_close( struct link *link );
00040 int  link_fd( struct link *link );
00041 
00042 int  link_readline( struct link *link, char *line, int length, time_t stoptime );
00043 int  link_nonblocking( struct link *link, int onoff );
00044 
00045 int  link_address_local( struct link *link, char *addr, int *port );
00046 int  link_address_remote( struct link *link, char *addr, int *port );
00047 
00048 INT64_T link_stream_to_buffer( struct link *link, char **buffer, time_t stoptime );
00049 
00050 INT64_T link_stream_to_fd( struct link *link, int fd, INT64_T length, time_t stoptime );
00051 INT64_T link_stream_to_file( struct link *link, FILE *file, INT64_T length, time_t stoptime );
00052 
00053 INT64_T link_stream_from_fd( struct link *link, int fd, INT64_T length, time_t stoptime );
00054 INT64_T link_stream_from_file( struct link *link, FILE *file, INT64_T length, time_t stoptime );
00055 
00056 INT64_T link_soak( struct link *link, INT64_T length, time_t stoptime );
00057 
00058 typedef enum {
00059         LINK_TUNE_INTERACTIVE,
00060         LINK_TUNE_BULK
00061 } link_tune_t;
00062 
00063 int  link_tune( struct link *link, link_tune_t mode );
00064 
00065 #define LINK_READ 1
00066 #define LINK_WRITE 2
00067 
00068 struct link_info {
00069         struct link *link;
00070         int events;
00071         int revents;
00072 };
00073 
00074 int  link_poll( struct link_info *array, int nlinks, int usec );
00075 
00076 
00077 #endif
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 

Generated on Fri Oct 31 16:58:43 2008 for cctools by  doxygen 1.3.9.1