I need to be able to read a mainframe file from special device /dev/vme and ftp the file using a fifo file to a remote host.
The reason behind this is because the file is Ebcdic binary which needs to be sent unchanged.
I know Unix but am not a C programmer so I've had to 'make it up' as I go along - a C program has to be used to call the special function VMESETMODE which tells is not to convert from Ebcdic to Ascii. I have spent many an hour cobbling together the code below - it compiles and runs but the resultant file on the remote host is empty.
If anyone can show me where I am going wrong with the C program I will be very grateful.
Unix does ;
put "| cftp /de/vme/MYFILE" remote-file
C program 'cftp' contains
char buff[LINE_MAX]; /* Input buffer. */
int c, in_file, out_file, i_nul = 0;
if ( ! ( argc > 1 ) )
fprintf ( stderr, "Error : Filename not specified\n" );
if ( ( in_file = open ( argv, O_RDONLY ) ) < 0 )
fprintf ( stderr, "Error (%i) : Unable to open %s\n", in_file, argv )
if ( ioctl ( in_file, VMESETMODE, &i_nul ) < 0 )
fprintf ( stderr, "Error : Could not VMESETMODE on %s\n", argv );
while ((c = read (in_file, buff, LINE_MAX)) >0 )
if( printf( stdout, buff, c ) != c )
fprintf ( stderr, "Error : Writing to stdout\n" );
if ( c < 0 )
fprintf ( stderr, "Error : Reading from %s\n", argv );
close(in_file); /* No error checking */
Yours hopelessly out of depth,