job.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00019 FILE_LICENCE ( GPL2_OR_LATER );
00020 
00021 #include <string.h>
00022 #include <errno.h>
00023 #include <gpxe/job.h>
00024 
00025 /** @file
00026  *
00027  * Job control interfaces
00028  *
00029  */
00030 
00031 void job_done ( struct job_interface *job, int rc ) {
00032         struct job_interface *dest = job_get_dest ( job );
00033 
00034         job_unplug ( job );
00035         dest->op->done ( dest, rc );
00036         job_put ( dest );
00037 }
00038 
00039 void job_kill ( struct job_interface *job ) {
00040         struct job_interface *dest = job_get_dest ( job );
00041 
00042         job_unplug ( job );
00043         dest->op->kill ( dest );
00044         job_put ( dest );
00045 }
00046 
00047 void job_progress ( struct job_interface *job,
00048                     struct job_progress *progress ) {
00049         struct job_interface *dest = job_get_dest ( job );
00050 
00051         dest->op->progress ( dest, progress );
00052         job_put ( dest );
00053 }
00054 
00055 /****************************************************************************
00056  *
00057  * Helper methods
00058  *
00059  * These functions are designed to be used as methods in the
00060  * job_interface_operations table.
00061  *
00062  */
00063 
00064 void ignore_job_done ( struct job_interface *job __unused, int rc __unused ) {
00065         /* Nothing to do */
00066 }
00067 
00068 void ignore_job_kill ( struct job_interface *job __unused ) {
00069         /* Nothing to do */
00070 }
00071 
00072 void ignore_job_progress ( struct job_interface *job __unused,
00073                            struct job_progress *progress ) {
00074         memset ( progress, 0, sizeof ( *progress ) );
00075 }
00076 
00077 /** Null job control interface operations */
00078 struct job_interface_operations null_job_ops = {
00079         .done           = ignore_job_done,
00080         .kill           = ignore_job_kill,
00081         .progress       = ignore_job_progress,
00082 };
00083 
00084 /**
00085  * Null job control interface
00086  *
00087  * This is the interface to which job control interfaces are connected
00088  * when unplugged.  It will never generate messages, and will silently
00089  * absorb all received messages.
00090  */
00091 struct job_interface null_job = {
00092         .intf = {
00093                 .dest = &null_job.intf,
00094                 .refcnt = NULL,
00095         },
00096         .op = &null_job_ops,
00097 };

Generated on Tue Apr 6 20:00:51 2010 for gPXE by  doxygen 1.5.7.1