diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-05-03 23:39:53 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-05-03 23:39:53 +0000 |
commit | 4529b70b4ca28e6f2120a834c88b3ee2bc2e43f5 (patch) | |
tree | 26c2d88d7d8ccf6961373455b68e1e087c211c7b /misc.c | |
parent | 3524d697374a37d39e971d96c33080c307304820 (diff) |
- mouring@cvs.openbsd.org 2001/05/03 23:09:53
[misc.c misc.h scp.c sftp.c]
Move colon() and cleanhost() to misc.c where I should I have put it in
the first place
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 37 |
1 files changed, 35 insertions, 2 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: misc.c,v 1.5 2001/04/12 20:09:37 stevesk Exp $ */ | 1 | /* $OpenBSD: misc.c,v 1.6 2001/05/03 23:09:52 mouring Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Copyright (c) 2000 Markus Friedl. All rights reserved. | 4 | * Copyright (c) 2000 Markus Friedl. All rights reserved. |
@@ -25,7 +25,7 @@ | |||
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "includes.h" | 27 | #include "includes.h" |
28 | RCSID("$OpenBSD: misc.c,v 1.5 2001/04/12 20:09:37 stevesk Exp $"); | 28 | RCSID("$OpenBSD: misc.c,v 1.6 2001/05/03 23:09:52 mouring Exp $"); |
29 | 29 | ||
30 | #include "misc.h" | 30 | #include "misc.h" |
31 | #include "log.h" | 31 | #include "log.h" |
@@ -131,6 +131,39 @@ int a2port(const char *s) | |||
131 | return port; | 131 | return port; |
132 | } | 132 | } |
133 | 133 | ||
134 | char * | ||
135 | cleanhostname(char *host) | ||
136 | { | ||
137 | if (*host == '[' && host[strlen(host) - 1] == ']') { | ||
138 | host[strlen(host) - 1] = '\0'; | ||
139 | return (host + 1); | ||
140 | } else | ||
141 | return host; | ||
142 | } | ||
143 | |||
144 | char * | ||
145 | colon(char *cp) | ||
146 | { | ||
147 | int flag = 0; | ||
148 | |||
149 | if (*cp == ':') /* Leading colon is part of file name. */ | ||
150 | return (0); | ||
151 | if (*cp == '[') | ||
152 | flag = 1; | ||
153 | |||
154 | for (; *cp; ++cp) { | ||
155 | if (*cp == '@' && *(cp+1) == '[') | ||
156 | flag = 1; | ||
157 | if (*cp == ']' && *(cp+1) == ':' && flag) | ||
158 | return (cp+1); | ||
159 | if (*cp == ':' && !flag) | ||
160 | return (cp); | ||
161 | if (*cp == '/') | ||
162 | return (0); | ||
163 | } | ||
164 | return (0); | ||
165 | } | ||
166 | |||
134 | mysig_t | 167 | mysig_t |
135 | mysignal(int sig, mysig_t act) | 168 | mysignal(int sig, mysig_t act) |
136 | { | 169 | { |