mirror of
https://github.com/xcat2/xNBA.git
synced 2025-01-11 10:17:49 +00:00
Add start() event
Add "xfer" to all xfer functions and "job" to all job functions.
This commit is contained in:
parent
a90a9adbd7
commit
e3dcb9a1ad
@ -26,10 +26,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
void done ( struct job_interface *job, int rc ) {
|
||||
void job_done ( struct job_interface *job, int rc ) {
|
||||
struct job_interface *dest = job_dest ( job );
|
||||
|
||||
dest->op->done ( dest, rc );
|
||||
job_unplug ( job );
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -41,24 +42,29 @@ void done ( struct job_interface *job, int rc ) {
|
||||
*
|
||||
*/
|
||||
|
||||
void ignore_done ( struct job_interface *job __unused, int rc __unused ) {
|
||||
void ignore_job_start ( struct job_interface *job __unused ) {
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
void ignore_kill ( struct job_interface *job __unused ) {
|
||||
void ignore_job_done ( struct job_interface *job __unused, int rc __unused ) {
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
void ignore_progress ( struct job_interface *job __unused,
|
||||
struct job_progress *progress ) {
|
||||
void ignore_job_kill ( struct job_interface *job __unused ) {
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
void ignore_job_progress ( struct job_interface *job __unused,
|
||||
struct job_progress *progress ) {
|
||||
memset ( progress, 0, sizeof ( *progress ) );
|
||||
}
|
||||
|
||||
/** Null job control interface operations */
|
||||
struct job_interface_operations null_job_ops = {
|
||||
.done = ignore_done,
|
||||
.kill = ignore_kill,
|
||||
.progress = ignore_progress,
|
||||
.start = ignore_job_start,
|
||||
.done = ignore_job_done,
|
||||
.kill = ignore_job_kill,
|
||||
.progress = ignore_job_progress,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -32,7 +32,7 @@
|
||||
* @v xfer Data transfer interface
|
||||
* @v rc Reason for close
|
||||
*/
|
||||
void close ( struct xfer_interface *xfer, int rc ) {
|
||||
void xfer_close ( struct xfer_interface *xfer, int rc ) {
|
||||
struct xfer_interface *dest = xfer_dest ( xfer );
|
||||
|
||||
dest->op->close ( dest, rc );
|
||||
@ -46,7 +46,7 @@ void close ( struct xfer_interface *xfer, int rc ) {
|
||||
* @v pos New position
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int seek ( struct xfer_interface *xfer, size_t pos ) {
|
||||
int xfer_seek ( struct xfer_interface *xfer, size_t pos ) {
|
||||
struct xfer_interface *dest = xfer_dest ( xfer );
|
||||
|
||||
return dest->op->seek ( dest, pos );
|
||||
@ -60,7 +60,7 @@ int seek ( struct xfer_interface *xfer, size_t pos ) {
|
||||
* @v args Remaining arguments depend upon location type
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int vredirect ( struct xfer_interface *xfer, int type, va_list args ) {
|
||||
int xfer_vredirect ( struct xfer_interface *xfer, int type, va_list args ) {
|
||||
struct xfer_interface *dest = xfer_dest ( xfer );
|
||||
|
||||
return dest->op->vredirect ( dest, type, args );
|
||||
@ -74,12 +74,12 @@ int vredirect ( struct xfer_interface *xfer, int type, va_list args ) {
|
||||
* @v ... Remaining arguments depend upon location type
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int redirect ( struct xfer_interface *xfer, int type, ... ) {
|
||||
int xfer_redirect ( struct xfer_interface *xfer, int type, ... ) {
|
||||
va_list args;
|
||||
int rc;
|
||||
|
||||
va_start ( args, type );
|
||||
rc = vredirect ( xfer, type, args );
|
||||
rc = xfer_vredirect ( xfer, type, args );
|
||||
va_end ( args );
|
||||
return rc;
|
||||
}
|
||||
@ -91,7 +91,7 @@ int redirect ( struct xfer_interface *xfer, int type, ... ) {
|
||||
* @v iobuf Datagram I/O buffer
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int deliver ( struct xfer_interface *xfer, struct io_buffer *iobuf ) {
|
||||
int xfer_deliver ( struct xfer_interface *xfer, struct io_buffer *iobuf ) {
|
||||
struct xfer_interface *dest = xfer_dest ( xfer );
|
||||
|
||||
return dest->op->deliver ( dest, iobuf );
|
||||
@ -104,7 +104,8 @@ int deliver ( struct xfer_interface *xfer, struct io_buffer *iobuf ) {
|
||||
* @v iobuf Datagram I/O buffer
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int deliver_raw ( struct xfer_interface *xfer, const void *data, size_t len ) {
|
||||
int xfer_deliver_raw ( struct xfer_interface *xfer,
|
||||
const void *data, size_t len ) {
|
||||
struct xfer_interface *dest = xfer_dest ( xfer );
|
||||
|
||||
return dest->op->deliver_raw ( dest, data, len );
|
||||
@ -120,36 +121,47 @@ int deliver_raw ( struct xfer_interface *xfer, const void *data, size_t len ) {
|
||||
*/
|
||||
|
||||
/**
|
||||
* Ignore close()
|
||||
* Ignore start() event
|
||||
*
|
||||
* @v xfer Data transfer interface
|
||||
* @v rc Reason for close
|
||||
*/
|
||||
void ignore_close ( struct xfer_interface *xfer __unused, int rc __unused ) {
|
||||
void ignore_xfer_start ( struct xfer_interface *xfer __unused ) {
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignore vredirect()
|
||||
* Ignore close() event
|
||||
*
|
||||
* @v xfer Data transfer interface
|
||||
* @v rc Reason for close
|
||||
*/
|
||||
void ignore_xfer_close ( struct xfer_interface *xfer __unused,
|
||||
int rc __unused ) {
|
||||
/* Nothing to do */
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignore vredirect() event
|
||||
*
|
||||
* @v xfer Data transfer interface
|
||||
* @v type New location type
|
||||
* @v args Remaining arguments depend upon location type
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int ignore_vredirect ( struct xfer_interface *xfer __unused,
|
||||
int type __unused, va_list args __unused ) {
|
||||
int ignore_xfer_vredirect ( struct xfer_interface *xfer __unused,
|
||||
int type __unused, va_list args __unused ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignore seek()
|
||||
* Ignore seek() event
|
||||
*
|
||||
* @v xfer Data transfer interface
|
||||
* @v pos New position
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int ignore_seek ( struct xfer_interface *xfer __unused, size_t pos __unused ) {
|
||||
int ignore_xfer_seek ( struct xfer_interface *xfer __unused,
|
||||
size_t pos __unused ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -163,8 +175,8 @@ int ignore_seek ( struct xfer_interface *xfer __unused, size_t pos __unused ) {
|
||||
* This function is intended to be used as the deliver() method for
|
||||
* data transfer interfaces that prefer to handle raw data.
|
||||
*/
|
||||
int deliver_as_raw ( struct xfer_interface *xfer,
|
||||
struct io_buffer *iobuf ) {
|
||||
int xfer_deliver_as_raw ( struct xfer_interface *xfer,
|
||||
struct io_buffer *iobuf ) {
|
||||
int rc;
|
||||
|
||||
rc = xfer->op->deliver_raw ( xfer, iobuf->data, iob_len ( iobuf ) );
|
||||
@ -183,8 +195,8 @@ int deliver_as_raw ( struct xfer_interface *xfer,
|
||||
* This function is intended to be used as the deliver_raw() method
|
||||
* for data transfer interfaces that prefer to handle I/O buffers.
|
||||
*/
|
||||
int deliver_as_iobuf ( struct xfer_interface *xfer,
|
||||
const void *data, size_t len ) {
|
||||
int xfer_deliver_as_iobuf ( struct xfer_interface *xfer,
|
||||
const void *data, size_t len ) {
|
||||
struct io_buffer *iobuf;
|
||||
|
||||
iobuf = alloc_iob ( len );
|
||||
@ -196,15 +208,15 @@ int deliver_as_iobuf ( struct xfer_interface *xfer,
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignore datagram as raw data
|
||||
* Ignore datagram as raw data event
|
||||
*
|
||||
* @v xfer Data transfer interface
|
||||
* @v data Data buffer
|
||||
* @v len Length of data buffer
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int ignore_deliver_raw ( struct xfer_interface *xfer,
|
||||
const void *data __unused, size_t len ) {
|
||||
int ignore_xfer_deliver_raw ( struct xfer_interface *xfer,
|
||||
const void *data __unused, size_t len ) {
|
||||
DBGC ( xfer, "XFER %p %zd bytes delivered %s\n", xfer, len,
|
||||
( ( xfer == &null_xfer ) ?
|
||||
"before connection" : "after termination" ) );
|
||||
@ -213,11 +225,12 @@ int ignore_deliver_raw ( struct xfer_interface *xfer,
|
||||
|
||||
/** Null data transfer interface operations */
|
||||
struct xfer_interface_operations null_xfer_ops = {
|
||||
.close = ignore_close,
|
||||
.vredirect = ignore_vredirect,
|
||||
.seek = ignore_seek,
|
||||
.deliver = deliver_as_raw,
|
||||
.deliver_raw = ignore_deliver_raw,
|
||||
.start = ignore_xfer_start,
|
||||
.close = ignore_xfer_close,
|
||||
.vredirect = ignore_xfer_vredirect,
|
||||
.seek = ignore_xfer_seek,
|
||||
.deliver = xfer_deliver_as_raw,
|
||||
.deliver_raw = ignore_xfer_deliver_raw,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -33,6 +33,11 @@ struct job_interface;
|
||||
|
||||
/** Job control interface operations */
|
||||
struct job_interface_operations {
|
||||
/** Start job
|
||||
*
|
||||
* @v job Job control interface
|
||||
*/
|
||||
void ( * start ) ( struct job_interface *job );
|
||||
/** Job completed
|
||||
*
|
||||
* @v job Job control interface
|
||||
@ -64,12 +69,13 @@ struct job_interface {
|
||||
extern struct job_interface null_job;
|
||||
extern struct job_interface_operations null_job_ops;
|
||||
|
||||
extern void done ( struct job_interface *job, int rc );
|
||||
extern void job_done ( struct job_interface *job, int rc );
|
||||
|
||||
extern void ignore_done ( struct job_interface *job, int rc );
|
||||
extern void ignore_kill ( struct job_interface *job );
|
||||
extern void ignore_progress ( struct job_interface *job,
|
||||
struct job_progress *progress );
|
||||
extern void ignore_job_start ( struct job_interface *job );
|
||||
extern void ignore_job_done ( struct job_interface *job, int rc );
|
||||
extern void ignore_job_kill ( struct job_interface *job );
|
||||
extern void ignore_job_progress ( struct job_interface *job,
|
||||
struct job_progress *progress );
|
||||
|
||||
/**
|
||||
* Initialise a job control interface
|
||||
@ -108,6 +114,37 @@ job_dest ( struct job_interface *job ) {
|
||||
return intf_to_job ( job->intf.dest );
|
||||
}
|
||||
|
||||
/**
|
||||
* Plug a job control interface into a new destination interface
|
||||
*
|
||||
* @v job Job control interface
|
||||
* @v dest New destination interface
|
||||
*/
|
||||
static inline void job_plug ( struct job_interface *job,
|
||||
struct job_interface *dest ) {
|
||||
plug ( &job->intf, &dest->intf );
|
||||
}
|
||||
|
||||
/**
|
||||
* Plug two job control interfaces together
|
||||
*
|
||||
* @v a Job control interface A
|
||||
* @v b Job control interface B
|
||||
*/
|
||||
static inline void job_plug_plug ( struct job_interface *a,
|
||||
struct job_interface *b ) {
|
||||
plug_plug ( &a->intf, &b->intf );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unplug a job control interface
|
||||
*
|
||||
* @v job Job control interface
|
||||
*/
|
||||
static inline void job_unplug ( struct job_interface *job ) {
|
||||
plug ( &job->intf, &null_job.intf );
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop using a job control interface
|
||||
*
|
||||
|
@ -21,15 +21,17 @@ struct xfer_interface_operations {
|
||||
*
|
||||
* notification of non-close status - e.g. connected/opened, ...
|
||||
*
|
||||
* seek
|
||||
*
|
||||
* prompt for data delivery
|
||||
*
|
||||
* I/O buffer preparation
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/** Start data transfer
|
||||
*
|
||||
* @v xfer Data transfer interface
|
||||
*/
|
||||
void ( * start ) ( struct xfer_interface *xfer );
|
||||
/** Close interface
|
||||
*
|
||||
* @v xfer Data transfer interface
|
||||
@ -60,7 +62,7 @@ struct xfer_interface_operations {
|
||||
*
|
||||
* A data transfer interface that wishes to support only raw
|
||||
* data delivery should set this method to
|
||||
* deliver_as_raw().
|
||||
* xfer_deliver_as_raw().
|
||||
*/
|
||||
int ( * deliver ) ( struct xfer_interface *xfer,
|
||||
struct io_buffer *iobuf );
|
||||
@ -73,7 +75,7 @@ struct xfer_interface_operations {
|
||||
*
|
||||
* A data transfer interface that wishes to support only I/O
|
||||
* buffer delivery should set this method to
|
||||
* deliver_as_iobuf().
|
||||
* xfer_deliver_as_iobuf().
|
||||
*/
|
||||
int ( * deliver_raw ) ( struct xfer_interface *xfer,
|
||||
const void *data, size_t len );
|
||||
@ -90,24 +92,30 @@ struct xfer_interface {
|
||||
extern struct xfer_interface null_xfer;
|
||||
extern struct xfer_interface_operations null_xfer_ops;
|
||||
|
||||
extern void close ( struct xfer_interface *xfer, int rc );
|
||||
extern int seek ( struct xfer_interface *xfer, size_t pos );
|
||||
extern int vredirect ( struct xfer_interface *xfer, int type, va_list args );
|
||||
extern int redirect ( struct xfer_interface *xfer, int type, ... );
|
||||
extern int deliver ( struct xfer_interface *xfer, struct io_buffer *iobuf );
|
||||
extern int deliver_raw ( struct xfer_interface *xfer,
|
||||
const void *data, size_t len );
|
||||
|
||||
extern void ignore_close ( struct xfer_interface *xfer, int rc );
|
||||
extern int ignore_vredirect ( struct xfer_interface *xfer,
|
||||
int type, va_list args );
|
||||
extern int ignore_seek ( struct xfer_interface *xfer, size_t pos );
|
||||
extern int deliver_as_raw ( struct xfer_interface *xfer,
|
||||
struct io_buffer *iobuf );
|
||||
extern int deliver_as_iobuf ( struct xfer_interface *xfer,
|
||||
extern void xfer_start ( struct xfer_interface *xfer );
|
||||
extern void xfer_close ( struct xfer_interface *xfer, int rc );
|
||||
extern int xfer_seek ( struct xfer_interface *xfer, size_t pos );
|
||||
extern int xfer_vredirect ( struct xfer_interface *xfer, int type,
|
||||
va_list args );
|
||||
extern int xfer_redirect ( struct xfer_interface *xfer, int type, ... );
|
||||
extern int xfer_deliver ( struct xfer_interface *xfer,
|
||||
struct io_buffer *iobuf );
|
||||
extern int xfer_deliver_raw ( struct xfer_interface *xfer,
|
||||
const void *data, size_t len );
|
||||
extern int ignore_deliver_raw ( struct xfer_interface *xfer,
|
||||
const void *data __unused, size_t len );
|
||||
|
||||
extern void ignore_xfer_start ( struct xfer_interface *xfer );
|
||||
extern void ignore_xfer_close ( struct xfer_interface *xfer, int rc );
|
||||
extern int ignore_xfer_vredirect ( struct xfer_interface *xfer,
|
||||
int type, va_list args );
|
||||
extern int default_xfer_vredirect ( struct xfer_interface *xfer,
|
||||
int type, va_list args );
|
||||
extern int ignore_xfer_seek ( struct xfer_interface *xfer, size_t pos );
|
||||
extern int xfer_deliver_as_raw ( struct xfer_interface *xfer,
|
||||
struct io_buffer *iobuf );
|
||||
extern int xfer_deliver_as_iobuf ( struct xfer_interface *xfer,
|
||||
const void *data, size_t len );
|
||||
extern int ignore_xfer_deliver_raw ( struct xfer_interface *xfer,
|
||||
const void *data __unused, size_t len );
|
||||
|
||||
/**
|
||||
* Initialise a data transfer interface
|
||||
@ -157,6 +165,17 @@ static inline void xfer_plug ( struct xfer_interface *xfer,
|
||||
plug ( &xfer->intf, &dest->intf );
|
||||
}
|
||||
|
||||
/**
|
||||
* Plug two data transfer interfaces together
|
||||
*
|
||||
* @v a Data transfer interface A
|
||||
* @v b Data transfer interface B
|
||||
*/
|
||||
static inline void xfer_plug_plug ( struct xfer_interface *a,
|
||||
struct xfer_interface *b ) {
|
||||
plug_plug ( &a->intf, &b->intf );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unplug a data transfer interface
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user