2007-04-29 02:08:39 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <gpxe/job.h>
|
|
|
|
|
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* Job control interfaces
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-05-01 00:07:57 +00:00
|
|
|
void job_done ( struct job_interface *job, int rc ) {
|
2007-05-15 16:53:46 +00:00
|
|
|
struct job_interface *dest = job_get_dest ( job );
|
2007-04-29 02:08:39 +00:00
|
|
|
|
2007-05-01 00:07:57 +00:00
|
|
|
job_unplug ( job );
|
2007-07-10 06:25:30 +01:00
|
|
|
dest->op->done ( dest, rc );
|
2007-05-15 16:53:46 +00:00
|
|
|
job_put ( dest );
|
2007-04-29 02:08:39 +00:00
|
|
|
}
|
|
|
|
|
2007-06-28 14:53:12 +01:00
|
|
|
void job_kill ( struct job_interface *job ) {
|
|
|
|
struct job_interface *dest = job_get_dest ( job );
|
|
|
|
|
|
|
|
job_unplug ( job );
|
2007-07-10 06:25:30 +01:00
|
|
|
dest->op->kill ( dest );
|
2007-06-28 14:53:12 +01:00
|
|
|
job_put ( dest );
|
|
|
|
}
|
|
|
|
|
2007-04-29 02:08:39 +00:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* Helper methods
|
|
|
|
*
|
|
|
|
* These functions are designed to be used as methods in the
|
|
|
|
* job_interface_operations table.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-05-01 00:07:57 +00:00
|
|
|
void ignore_job_done ( struct job_interface *job __unused, int rc __unused ) {
|
2007-04-29 02:08:39 +00:00
|
|
|
/* Nothing to do */
|
|
|
|
}
|
|
|
|
|
2007-05-01 00:07:57 +00:00
|
|
|
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 ) {
|
2007-04-29 02:08:39 +00:00
|
|
|
memset ( progress, 0, sizeof ( *progress ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Null job control interface operations */
|
|
|
|
struct job_interface_operations null_job_ops = {
|
2007-05-01 00:07:57 +00:00
|
|
|
.done = ignore_job_done,
|
|
|
|
.kill = ignore_job_kill,
|
|
|
|
.progress = ignore_job_progress,
|
2007-04-29 02:08:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Null job control interface
|
|
|
|
*
|
|
|
|
* This is the interface to which job control interfaces are connected
|
|
|
|
* when unplugged. It will never generate messages, and will silently
|
|
|
|
* absorb all received messages.
|
|
|
|
*/
|
|
|
|
struct job_interface null_job = {
|
|
|
|
.intf = {
|
|
|
|
.dest = &null_job.intf,
|
2007-04-29 23:53:39 +00:00
|
|
|
.refcnt = NULL,
|
2007-04-29 02:08:39 +00:00
|
|
|
},
|
|
|
|
.op = &null_job_ops,
|
|
|
|
};
|