Back to index

glibc  2.9
ioctl.c
Go to the documentation of this file.
00001 /* Copyright (C) 1998, 2002, 2003, 2004 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #include <stdarg.h>
00020 #include <termios.h>
00021 #include <unistd.h>
00022 #include <sys/ioctl.h>
00023 #include <sysdep.h>
00024 
00025 /* The user-visible size of struct termios has changed.  Catch ioctl calls
00026    using the new-style struct termios, and translate them to old-style.  */
00027 
00028 int
00029 __ioctl (int fd, unsigned long int request, ...)
00030 {
00031   void *arg;
00032   va_list ap;
00033   int result;
00034 
00035   va_start (ap, request);
00036   arg = va_arg (ap, void *);
00037 
00038   switch (request)
00039     {
00040     case TCGETS:
00041       result = __tcgetattr (fd, (struct termios *) arg);
00042       break;
00043 
00044     case TCSETS:
00045       result = tcsetattr (fd, TCSANOW, (struct termios *) arg);
00046       break;
00047 
00048     case TCSETSW:
00049       result = tcsetattr (fd, TCSADRAIN, (struct termios *) arg);
00050       break;
00051 
00052     case TCSETSF:
00053       result = tcsetattr (fd, TCSAFLUSH, (struct termios *) arg);
00054       break;
00055 
00056     default:
00057       result = INLINE_SYSCALL (ioctl, 3, fd, request, arg);
00058       break;
00059     }
00060 
00061   va_end (ap);
00062 
00063   return result;
00064 }
00065 weak_alias (__ioctl, ioctl)