monojob.c File Reference

Single foreground job. More...

#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <gpxe/process.h>
#include <console.h>
#include <gpxe/keys.h>
#include <gpxe/job.h>
#include <gpxe/monojob.h>
#include <gpxe/timer.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
static void monojob_done (struct job_interface *job __unused, int rc)
int monojob_wait (const char *string)
 Wait for single foreground job to complete.

Variables

static int monojob_rc
static struct
job_interface_operations 
monojob_operations
 Single foreground job operations.
struct job_interface monojob
 Single foreground job.


Detailed Description

Single foreground job.

Definition in file monojob.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

static void monojob_done ( struct job_interface *job  __unused,
int  rc 
) [static]

Definition at line 39 of file monojob.c.

References monojob_rc.

00039                                                                         {
00040         monojob_rc = rc;
00041 }

int monojob_wait ( const char *  string  ) 

Wait for single foreground job to complete.

Parameters:
string Job description to display
Return values:
rc Job final status code

Definition at line 65 of file monojob.c.

References CTRL_C, currticks(), ECANCELED, EINPROGRESS, getchar(), iskey(), job_done(), job_kill(), monojob_rc, printf(), step(), strerror(), and TICKS_PER_SEC.

Referenced by dhcp(), imgfetch(), and pxebs().

00065                                         {
00066         int key;
00067         int rc;
00068         unsigned long last_progress_dot;
00069         unsigned long elapsed;
00070 
00071         printf ( "%s.", string );
00072         monojob_rc = -EINPROGRESS;
00073         last_progress_dot = currticks();
00074         while ( monojob_rc == -EINPROGRESS ) {
00075                 step();
00076                 if ( iskey() ) {
00077                         key = getchar();
00078                         switch ( key ) {
00079                         case CTRL_C:
00080                                 job_kill ( &monojob );
00081                                 rc = -ECANCELED;
00082                                 goto done;
00083                         default:
00084                                 break;
00085                         }
00086                 }
00087                 elapsed = ( currticks() - last_progress_dot );
00088                 if ( elapsed >= TICKS_PER_SEC ) {
00089                         printf ( "." );
00090                         last_progress_dot = currticks();
00091                 }
00092         }
00093         rc = monojob_rc;
00094 
00095 done:
00096         job_done ( &monojob, rc );
00097         if ( rc ) {
00098                 printf ( " %s\n", strerror ( rc ) );
00099         } else {
00100                 printf ( " ok\n" );
00101         }
00102         return rc;
00103 }


Variable Documentation

int monojob_rc [static]

Definition at line 37 of file monojob.c.

Referenced by monojob_done(), and monojob_wait().

Initial value:

 {
        .done           = monojob_done,
        .kill           = ignore_job_kill,
        .progress       = ignore_job_progress,
}
Single foreground job operations.

Definition at line 44 of file monojob.c.

Initial value:

 {
        .intf = {
                .dest = &null_job.intf,
                .refcnt = NULL,
        },
        .op = &monojob_operations,
}
Single foreground job.

Definition at line 51 of file monojob.c.

Referenced by dhcp(), imgfetch(), and pxebs().


Generated on Tue Apr 6 20:01:14 2010 for gPXE by  doxygen 1.5.7.1