summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-05-03 23:39:53 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-05-03 23:39:53 +0000
commit4529b70b4ca28e6f2120a834c88b3ee2bc2e43f5 (patch)
tree26c2d88d7d8ccf6961373455b68e1e087c211c7b /misc.c
parent3524d697374a37d39e971d96c33080c307304820 (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.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/misc.c b/misc.c
index feeacb859..e949ded89 100644
--- a/misc.c
+++ b/misc.c
@@ -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"
28RCSID("$OpenBSD: misc.c,v 1.5 2001/04/12 20:09:37 stevesk Exp $"); 28RCSID("$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
134char *
135cleanhostname(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
144char *
145colon(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
134mysig_t 167mysig_t
135mysignal(int sig, mysig_t act) 168mysignal(int sig, mysig_t act)
136{ 169{