X-Git-Url: https://gapil.gnulinux.it/gitweb/?p=gapil.git;a=blobdiff_plain;f=sources%2FSetTermAttr.c;fp=sources%2FSetTermAttr.c;h=96aef88abc86a77c12ef12ce98791bea3f88ddaf;hp=0000000000000000000000000000000000000000;hb=b1ead1b930038e4f7cd6ee7f737d7ee4699a068c;hpb=d12bc3e1e4b3ee762036d1c226c3b2ba1a720fb9 diff --git a/sources/SetTermAttr.c b/sources/SetTermAttr.c new file mode 100644 index 0000000..96aef88 --- /dev/null +++ b/sources/SetTermAttr.c @@ -0,0 +1,70 @@ +/* SetTermAttr.c + * + * Copyright (C) 2002 Simone Piccardi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/**************************************************************** + * + * Routine SetTermAttr + * Routine to set a local attribute for a terminal + * + * Author: Simone Piccardi + * Jun. 2001 + * + * $Id: SetTermAttr.c,v 1.3 2003/05/02 09:55:14 piccardi Exp $ + * + ****************************************************************/ +#include +#include +#include + +int SetTermAttr(int fd, tcflag_t flag) +{ + struct termios values; + int res; + + res = tcgetattr (desc, &values); + if (res) { + perror("Cannot get attributes"); + return res; + } + values.c_lflag |= flag; + res = tcsetattr (desc, TCSANOW, &values); + if (res) { + perror("Cannot set attributes"); + return res; + } + return 0; +} +int UnSetTermAttr(int fd, tcflag_t flag) +{ + struct termios values; + int res; + + res = tcgetattr (desc, &values); + if (res) { + perror("Cannot get attributes"); + return res; + } + values.c_lflag &= (~flag); + res = tcsetattr (desc, TCSANOW, &values); + if (res) { + perror("Cannot set attributes"); + return res; + } + return 0; +} +