rawtty

run program under raw tty
git clone https://logand.com/git/rawtty.git/
Log | Files | Refs

rawttytestchild.c (1398B)


      1 /*
      2 
      3   rawttytestchild -- test program to be run with rawtty
      4 
      5   Copyright (C) 2013 Tomas Hlavaty <tom at logand.com>
      6 
      7   Permission is hereby granted, free of charge, to any person
      8   obtaining a copy of this software and associated documentation files
      9   (the "Software"), to deal in the Software without restriction,
     10   including without limitation the rights to use, copy, modify, merge,
     11   publish, distribute, sublicense, and/or sell copies of the Software,
     12   and to permit persons to whom the Software is furnished to do so,
     13   subject to the following conditions:
     14 
     15   The above copyright notice and this permission notice shall be
     16   included in all copies or substantial portions of the Software.
     17 
     18   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     19   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     20   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     21   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
     22   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
     23   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
     24   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     25   SOFTWARE.
     26 
     27 */
     28 
     29 #include <unistd.h>
     30 #include <stdlib.h>
     31 
     32 int main() {
     33   unsigned char c;
     34   while(0 < read(STDIN_FILENO, &c, 1)) {
     35     if(c < 'a' || 'z' < c) break;
     36     c += 'A' - 'a';
     37     write(STDOUT_FILENO, &c, 1);
     38   }
     39   return 0;
     40 }