blob: 899142da7167129e21c3fe0075f082fc8ad43970 [file] [log] [blame]
Damien Millerdcb6ecd2000-05-17 22:34:22 +10001#include "includes.h"
2RCSID("$OpenBSD: aux.c,v 1.2 2000/05/17 09:47:59 markus Exp $");
3
4#include "ssh.h"
5
6char *
7chop(char *s)
8{
9 char *t = s;
10 while (*t) {
11 if(*t == '\n' || *t == '\r') {
12 *t = '\0';
13 return s;
14 }
15 t++;
16 }
17 return s;
18
19}
20
21void
22set_nonblock(int fd)
23{
24 int val;
25 val = fcntl(fd, F_GETFL, 0);
26 if (val < 0) {
27 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));
28 return;
29 }
30 if (val & O_NONBLOCK)
31 return;
32 debug("fd %d setting O_NONBLOCK", fd);
33 val |= O_NONBLOCK;
34 if (fcntl(fd, F_SETFL, val) == -1)
35 error("fcntl(%d, F_SETFL, O_NONBLOCK): %s", fd, strerror(errno));
36}