18.10.2014 Views

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

Object-oriented Software in Ada 95

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Mixed language programm<strong>in</strong>g 365<br />

/*<br />

* Set the term<strong>in</strong>al mode to -echo -icanon<br />

* Term<strong>in</strong>al mode reset when the character ^E is received<br />

*/<br />

#<strong>in</strong>clude <br />

#<strong>in</strong>clude <br />

static tcflag_t c_lflag;<br />

static <strong>in</strong>t fd = 1; /* STDOUT_FILENO; */<br />

static struct termios termios_data;<br />

void c_no_echo()<br />

{<br />

tcgetattr( fd, &termios_data );<br />

c_lflag = termios_data.c_lflag;<br />

termios_data.c_lflag = termios_data.c_lflag & ( ~(ECHO|ICANON|ECHOCTL) );<br />

tcsetattr( fd, TCSANOW, &termios_data );<br />

}<br />

The function c_get_char is a C function that returns the next character <strong>in</strong>put by the user. When the character<br />

^E is received subsequent characters <strong>in</strong>put will be echoed. The implementation <strong>in</strong> C of this function is as follows:<br />

char c_get_char()<br />

{<br />

char c;<br />

}<br />

c = getchar();<br />

if ( c == '\005')<br />

{<br />

termios_data.c_lflag = c_lflag;<br />

tcsetattr( fd, TCSANOW, &termios_data );<br />

}<br />

return (char) (c & 0xFF); /* Ord<strong>in</strong>ary character */<br />

Note:<br />

The use of control-e to return the stream back to its normal state.<br />

25.5 L<strong>in</strong>k<strong>in</strong>g to FORTRAN and COBOL code<br />

By us<strong>in</strong>g the package Interface.Fortran, subprograms written <strong>in</strong> FORTRAN may be called. By us<strong>in</strong>g the<br />

package Interface.COBOL subprograms written <strong>in</strong> COBOL may be called.<br />

© M A Smith - May not be reproduced without permission

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!