I am playing with the Swift for z/OS beta.  Swift itself supports little in the 
way of I/O, and instead depends on the underlying C runtime.  Below is a small 
program that opens a file, reads 4 bytes in to a buffer and writes out the 
results as an integer.

import Libc

func fwx(file filename: String, access: String) {
    if let fwf = fopen(filename, access) {
        defer { fclose(fwf) }
        let buffer = UnsafeMutablePointer<UInt32>.allocate(capacity: 1)
        defer { buffer.deallocate(capacity: 1) }
        let _ = fread(buffer, MemoryLayout<UInt32>.size, 1, fwf)
        print("from \(filename): \(buffer.pointee)")
    }
    else {
        print("error opening file \(filename): \(errno)")
    }
}

fwx(file: "/u/dvfjs/fw.bin", access: "rb")
fwx(file: "//'DVFJS.FW'", access: "rb")
fwx(file: "dd:FW", access: "rb")

The last three statements are the "mainline" of the program.  For the first one 
the file is a Unix file.  For the second one its a VSAM ESDS called 'DVFJS.FW'. 
 Both of these work.  I can't figure out how to specify a DD reference to make 
that last one work.  I've tried both using "dd:FW" and "//dd:FW".  Is it 
perhaps a problem with the DD itself?  When running it under BPXBATCH I am 
specifying the FW DD like I would for any other batch job:

//SHELL  JOB NOTIFY=&SYSUID,REGION=2000M
//UNIXSH  EXEC PGM=BPXBATCH,PARMDD=PARMSIN
//FW      DD DISP=SHR,DSN=DVFJS.FW
//PARMSIN DD *
SH /u/dvfjs/src/fw
/*
//STDIN   DD DUMMY
//STDOUT  DD SYSOUT=*
//STDERR  DD SYSOUT=*
//STDENV  DD DUMMY
//

Does the Unix environment for BPXBATCH not have access to the JCL DD?

We don't have a license for the C compiler, so I've never used C for z/OS.

Frank

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to