00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2.1 of the GNU Lesser General Public License 00007 as published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this program; if not, write the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, 00023 USA. 00024 00025 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00026 Mountain View, CA 94043, or: 00027 00028 http://www.sgi.com 00029 00030 For further information regarding this notice, see: 00031 00032 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00033 00034 */ 00035 00036 00037 #pragma ident "@(#) libf/pxf/pxftcgetattr.c 92.2 06/29/99 11:36:06" 00038 00039 /* 00040 * PXFTCGETATTR -- get state 00041 * PXFTCSETATTR -- set state 00042 * (section 7.2.1 of Posix 1003.9-1992) 00043 * 00044 * Synopsis: 00045 * 00046 * SUBROUTINE PXFTCGETATTR(ifildes, jtermios, ierror) 00047 * INTEGER ifildes, jtermios, ierror 00048 * 00049 * SUBROUTINE PXFTCSETATTR(ifildes, ioptacts, jtermios, ierror) 00050 * INTEGER ifildes, ioptacts, jtermios, ierror 00051 * 00052 * Description: 00053 * 00054 * PXFTCGETATTR uses the c function tcgetattr() to get parameters 00055 * associated with a file descriptor and stores them in the termios 00056 * structure. 00057 * 00058 * PXFTCGETATTR uses the c function tcsetattr() to set the parameters 00059 * associated with a terminal from the termios structure. 00060 * 00061 * The arguments are: 00062 * 00063 * ifildes - default integer input variable containing a file 00064 * descriptor. 00065 * ioptacts - default input integer variable for an optional 00066 * action. Use PXFCONST to retrieve the values of 00067 * the optional actions. 00068 * jtermios - default integer input variable containing a handle 00069 * created by PXFSTRUCTCREATE('termios',...). 00070 * ierror - default integer output variable that contains zero 00071 * if the operation was successful or nonzero if the 00072 * operation was not successful. 00073 * 00074 * PXFTCGETATTR and PXFTCSETATTR may return one of the following 00075 * error values: 00076 * 00077 * EBADF If ifildes is not a valid file descriptor. 00078 * 00079 * EBADHANDLE The jtermios argument is invalid. 00080 * 00081 * EINTR A signal interrupted the tcsetattr() function. 00082 * 00083 * EINVAL The ioptacts argument is invalid. 00084 * 00085 * ENOTTY The file associated with ifilldes is not a terminal. 00086 * 00087 */ 00088 00089 #include <errno.h> 00090 #include <fortran.h> 00091 #include <liberrno.h> 00092 #include <string.h> 00093 #include <sys/errno.h> 00094 #include <sys/termios.h> 00095 #include <termios.h> 00096 #include "pxfstruct.h" 00097 #include "table.h" 00098 00099 #ifdef _UNICOS 00100 void 00101 PXFTCGETATTR( 00102 #else /* _UNICOS */ 00103 void 00104 pxftcgetattr_( 00105 #endif /* _UNICOS */ 00106 _f_int *ifildes, 00107 _f_int *jtermios, 00108 _f_int *ierror) 00109 { 00110 int fildes; 00111 int stat; 00112 struct pxfhandle pxfhand; 00113 struct termios *trmios; 00114 fildes = *ifildes; 00115 *ierror = 0; 00116 pxfhand = _pxfhandle_table_lookup(&_pxfhandle_table, *jtermios); 00117 if (pxfhand.pxfstructptr == NULL || pxfhand.pxftype != PXF_TERMIOS) { 00118 *ierror = EBADHANDLE; 00119 return; 00120 } 00121 00122 trmios = pxfhand.pxfstructptr; 00123 if (stat = tcgetattr(fildes, trmios) == -1) 00124 *ierror = errno; 00125 return; 00126 } 00127 00128 #ifdef _UNICOS 00129 void 00130 PXFTCSETATTR( 00131 #else /* _UNICOS */ 00132 void 00133 pxftcsetattr_( 00134 #endif /* _UNICOS */ 00135 _f_int *ifildes, 00136 _f_int *jtermios, 00137 _f_int *ioptacts, 00138 _f_int *ierror) 00139 { 00140 int fildes; 00141 int stat; 00142 int optact; 00143 struct pxfhandle pxfhand; 00144 struct termios *trmios; 00145 fildes = *ifildes; 00146 *ierror = 0; 00147 optact = *ioptacts; 00148 pxfhand = _pxfhandle_table_lookup(&_pxfhandle_table, *jtermios); 00149 if (pxfhand.pxfstructptr == NULL || pxfhand.pxftype != PXF_TERMIOS) { 00150 *ierror = EBADHANDLE; 00151 return; 00152 } 00153 00154 trmios = pxfhand.pxfstructptr; 00155 if (stat = tcsetattr(fildes,optact,trmios) == -1) 00156 *ierror = errno; 00157 return; 00158 } 00159
1.5.6