Hi Gang,
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 ;
/etc/mknod myfifofile
ftp remote-host
put "| cftp /de/vme/MYFILE" remote-file
C program 'cftp' contains
£include <stdlib.h>
£include <stdio.h>
£include <limits.h>
£include <vmeio.h>
£include <fcntl.h>
£include <sys/types.h>
£include <sys/stat.h>
£include <unistd.h>
void main(argc,argv)
int argc;
char *argv[];
{
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" );
exit(1);
}
if ( ( in_file = open ( argv[1], O_RDONLY ) ) < 0 )
{
fprintf ( stderr, "Error (%i) : Unable to open %s\n", in_file, argv[1] )
;
exit(1);
}
if ( ioctl ( in_file, VMESETMODE, &i_nul ) < 0 )
{
fprintf ( stderr, "Error : Could not VMESETMODE on %s\n", argv[1] );
exit(1);
}
while ((c = read (in_file, buff, LINE_MAX)) >0 )
{
if( printf( stdout, buff, c ) != c )
{
fprintf ( stderr, "Error : Writing to stdout\n" );
exit(1);
}
}
if ( c < 0 )
{
fprintf ( stderr, "Error : Reading from %s\n", argv[1] );
exit(1);
}
close(in_file); /* No error checking */
}
Yours hopelessly out of depth,
Al