NAME

gbatch_jobdata - read a job's job script


SYNOPSIS

#include <stdio.h>
#include <gbatch.h>

FILE *gbatch_jobdata(const int fd, const int flags, const slotno_t slot)

int gbatch_jobdata(const int fd, const int outfile, int(*fn)(int,void*,unsigned), const unsigned, flags, const slotno_t slotno)


DESCRIPTION

The function gbatch_jobdata is used to retrieve the job script of a job. There are two versions, one for the Unix and Linux API and one for the Windows API. The second form is used under Windows as there is no acceptable substitute for the pipe(2) system call.

In both forms of the call, fd is a file descriptor which was previously returned by a successful call to gbatch_open(3).

flags is zero or GBATCH_FLAG_IGNORESEQ to ignore recent changes to the job list.

slot is the slot number corresponding to the job as returned by gbatch_joblist(3) or xb_jobfindslot(3).

The difference between the two versions of gbatch_jobadd is in the method of passing the job script.

Unix and Linux

The Unix and Linux API version returns a stdio file descriptor which may be used with the standard I/O functions getc(3), fread(3) etc to read the job script. The job script should always be read to the end and then using fclose(3) to ensure that all incoming data on the socket is collected.

If there is any kind of error, then gbatch_jobdata will return NULL, leaving the error code in the external variable gbatch_dataerror.

Windows

In the case of the Windows version, the specified function fn is invoked with parameters similar to write to read data to pass across as the job script, the argument outfile being passed as a file handle as the first argument to fn.

fn may very well be write. The reason for the routine not invoking write itself is partly flexibility but mostly because some versions of Windows DLLs do not allow read to be invoked directly from within it.

N.B. This routine is particularly susceptible to peculiar effects due to assignment of insufficient stack space.

The return value is zero for success, or an error code. The error code is also assigned to the external variable gbatch_dataerror for consistency with the Unix version.


RETURN VALUES

The Unix version of gbatch_jobdata returns NULL if unsuccessful, placing the error code in the external variable gbatch_dataerror.

The Windows version of gbatch_jobdata returns zero if successful, otherwise an error code.

The error codes which may be returned are defined in the include file \fBgbatch.h\fR.


EXAMPLE

 int fd, ret, ch;
 FILE *inf;
 slotno_t slot;
 /*  select a job assign it to slot */
 inf = gbatch_jobdata(fd, XBABI_IGNORESEQ, slot);
 if (!inf) { /* error in gbatch_dataerror */ 
     . . .
 }
 
 while ((ch = getc(inf)) != EOF)
     putchar(ch);
 fclose(inf);


SEE ALSO

gbatch_jobadd(3), gbatch_jobfind(3), gbatch_joblist(3), gbatch_jobmon(3), gbatch_jobop(3), gbatch_jobread(3), gbatch_open(3)


COPYRIGHT

Copyright (c) 2009 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law.


AUTHOR

John M Collins, Xi Software Ltd.