- java.lang.Object
- 
- com.ibm.dtfj.corereaders.zos.util.Clib
 
- 
 public class Clib extends Object This class provides a low level interface to some of the z/OS C library. This approach was inspired by the SWT design in that we have a one-to-one mapping between JNI calls and C library calls: no extra work is done in the native functions. This is much easier to maintain because this library should rarely need recompiling.Please refer to the C library documentation for more details about arguments to these calls. 
- 
- 
Field SummaryFields Modifier and Type Field Description static intSEEK_CURfseek whence argument to indicate that offset is from the current position of the file pointerstatic intSEEK_ENDfseek whence argument to indicate that offset is from the end of the filestatic intSEEK_SETfseek whence argument to indicate that offset is from the beginning of the file
 - 
Constructor SummaryConstructors Constructor Description Clib()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static intfgetpos(long fp, int[] pos)This method is a wrapper around fgetpos.static longfopen(byte[] filename, byte[] mode)This method is a wrapper around fopen.static longfopen(String filename, String mode)This method is a slightly friendlier version of the native fopen call (the parameters are Strings rather than byte arrays otherwise everything is the same).static intfread(byte[] buf, int size, int count, long fp)This method is a wrapper around fread.static intfseek(long fp, long offset, int whence)This method is a wrapper around fseek.static intfsetpos(long fp, int[] pos)This method is a wrapper around fsetpos.static voidperror(byte[] prefix)This method is a wrapper around perror.static voidperror(String prefix)Friendlier version of the native perror call that accepts a String parameter.
 
- 
- 
- 
Field Detail- 
SEEK_SETpublic static final int SEEK_SET fseek whence argument to indicate that offset is from the beginning of the file- See Also:
- Constant Field Values
 
 - 
SEEK_CURpublic static final int SEEK_CUR fseek whence argument to indicate that offset is from the current position of the file pointer- See Also:
- Constant Field Values
 
 - 
SEEK_ENDpublic static final int SEEK_END fseek whence argument to indicate that offset is from the end of the file- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
fopenpublic static long fopen(byte[] filename, byte[] mode)This method is a wrapper around fopen.- Parameters:
- filename- the name of the file to open as a null-terminated ebcdic byte array
- mode- the open mode which must be a null-terminated ebcdic byte array. See the C library fopen documentation for more details
- Returns:
- the FILE stream pointer from fopen cast to a long
 
 - 
fopenpublic static long fopen(String filename, String mode) This method is a slightly friendlier version of the native fopen call (the parameters are Strings rather than byte arrays otherwise everything is the same).
 - 
fgetpospublic static int fgetpos(long fp, int[] pos)This method is a wrapper around fgetpos. Here we make use of the knowledge that a C fpos_t on z/OS is actually an array of 8 ints.- Parameters:
- fp- the stream obtained from an earlier call to fopen
- pos- this must be an array of 8 ints. The position indicator is stored in this array. The same array contents may be passed to a subsequent fsetpos call.
- Returns:
- the return code from the fgetpos call (zero if successful)
 
 - 
fsetpospublic static int fsetpos(long fp, int[] pos)This method is a wrapper around fsetpos.- Parameters:
- fp- the stream obtained from an earlier call to fopen
- pos- this must be an array of 8 ints whose contents were obtained in a previous call to fgetpos.
- Returns:
- the return code from the fsetpos call (zero if successful)
 
 - 
fseekpublic static int fseek(long fp, long offset, int whence)This method is a wrapper around fseek. (Note: this hasn't been tested for seeks over 2GB yet).- Parameters:
- fp- the stream obtained from an earlier call to fopen
- offset- the offset to seek to
- whence- specifies where to seek from
- Returns:
- the return code from the fseek call (zero if successful)
 
 - 
freadpublic static int fread(byte[] buf, int size, int count, long fp)This method is a wrapper around fread.- Parameters:
- buf- the buffer to contain the read data
- size- the size of each element
- count- the number of elements to read
- fp- the stream obtained from an earlier call to fopen
- Returns:
- the number of elements read
 
 - 
perrorpublic static void perror(byte[] prefix) This method is a wrapper around perror.- Parameters:
- prefix- the message prefix as a null-terminated ebcdic byte array
 
 - 
perrorpublic static void perror(String prefix) Friendlier version of the native perror call that accepts a String parameter.
 
- 
 
-