Hi,
I’m trying to implement some routines from termios in clib. I have created the constants to represent the many #defines in the c header file, but I need help with a couple items (please). So, here’s a bit of the code:
@ctypedef tcflag_t Culong
@ctypedef cc_t Cuchar
@ctypedef speed_t Clong
struct termios
c_iflag::tcflag_t #input flags
c_oflag::tcflag_t #output flags
c_cflag::tcflag_t #control flags
c_lflag::tcflag_t #local flags
c_cc::Ptr{cc_t} #control chars #this is what it looks like in C - cc_t c_cc[NCCS];
c_ispeed::speed_t #input speed
c_ospeed::speed_t #output speed
end
So, the first question is - am I translating an array of integers correctly in the struct?
The second question is - how do I initialize the struct (since it has an array in it)?
The C code looks like this:
struct termios tty;
memset(&tty, 0, sizeof(tty));
this would be followed by:
if (tcgetattrib(fd, &tty) != 0)
{
printf("error from tcgetattrib");
return -1;
}
I translated that to:
tty = termios(0,0,0,0,0,0,0) #I think the initialization is wrong
ret = ccall((:tcgetattr, "libc"), Int32, (Int32, Ref{termios}), fd, tty)
if (ret != 0)
println("error from tcgetattr")
return -1
end
Can someone help me along, here?
Frank