home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / libbsd / cfsetspeed.c next >
Encoding:
C/C++ Source or Header  |  1994-11-24  |  667 b   |  48 lines

  1. /* cfsetspeed.c - emulate BSD cfsetspeed with cfset[io]speed - rick sladkey */
  2.  
  3. #include <termios.h>
  4.  
  5. struct {
  6.     int flag, val;
  7. } xref[] = {
  8.     B0,    0,
  9.     B50,    50,
  10.     B75,    75,
  11.     B110,    110,
  12.     B134,    134,
  13.     B150,    150,
  14.     B200,    200,
  15.     B300,    300,
  16.     B600,    600,
  17.     B1200,    1200,
  18.     B1800,    1800,
  19.     B2400,    2400,
  20.     B4800,    4800,
  21.     B9600,    9600,
  22.     B19200,    19200,
  23.     B38400,    38400,
  24. #ifdef B57600
  25.     B57600, 57600,
  26. #endif
  27. #ifdef B115200
  28.     B115200,115200,
  29. #endif
  30.     0,    -1,
  31. };
  32.  
  33. int cfsetspeed(struct termios *p, int speed)
  34. {
  35.     int i;
  36.  
  37.     for (i = 0; xref[i].val != -1; i++) {
  38.         if (xref[i].val == speed) {
  39.             speed = xref[i].flag;
  40.             cfsetispeed(p, speed);
  41.             cfsetospeed(p, speed);
  42.             return 0;
  43.         }
  44.     }
  45.     return -1;
  46. }
  47.  
  48.