summaryrefslogtreecommitdiff
path: root/other/openssh-2.1.1p4/aux.c
diff options
context:
space:
mode:
authorSkyperTHC2026-03-03 06:28:55 +0000
committerSkyperTHC2026-03-03 06:28:55 +0000
commit5d3573ef7a109ee70416fe94db098fe6a769a798 (patch)
treedc2d5b294c9db8ab2db7433511f94e1c4bb8b698 /other/openssh-2.1.1p4/aux.c
parentc6c59dc73cc4586357f93ab38ecf459e98675cc5 (diff)
packetstorm sync
Diffstat (limited to 'other/openssh-2.1.1p4/aux.c')
-rw-r--r--other/openssh-2.1.1p4/aux.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/other/openssh-2.1.1p4/aux.c b/other/openssh-2.1.1p4/aux.c
new file mode 100644
index 0000000..709e245
--- /dev/null
+++ b/other/openssh-2.1.1p4/aux.c
@@ -0,0 +1,71 @@
1#include "includes.h"
2RCSID("$OpenBSD: aux.c,v 1.4 2000/07/13 22:53:21 provos 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 if (isatty(fd)) {
26 /* do not mess with tty's */
27 debug("no set_nonblock for tty fd %d", fd);
28 return;
29 }
30 val = fcntl(fd, F_GETFL, 0);
31 if (val < 0) {
32 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));
33 return;
34 }
35 if (val & O_NONBLOCK)
36 return;
37 debug("fd %d setting O_NONBLOCK", fd);
38 val |= O_NONBLOCK;
39 if (fcntl(fd, F_SETFL, val) == -1)
40 error("fcntl(%d, F_SETFL, O_NONBLOCK): %s", fd, strerror(errno));
41}
42
43/* Characters considered whitespace in strsep calls. */
44#define WHITESPACE " \t\r\n"
45
46char *
47strdelim(char **s)
48{
49 char *old;
50 int wspace = 0;
51
52 if (*s == NULL)
53 return NULL;
54
55 old = *s;
56
57 *s = strpbrk(*s, WHITESPACE "=");
58 if (*s == NULL)
59 return (old);
60
61 /* Allow only one '=' to be skipped */
62 if (*s[0] == '=')
63 wspace = 1;
64 *s[0] = '\0';
65
66 *s += strspn(*s + 1, WHITESPACE) + 1;
67 if (*s[0] == '=' && !wspace)
68 *s += strspn(*s + 1, WHITESPACE) + 1;
69
70 return (old);
71}