summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-07-04 04:46:56 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-07-04 04:46:56 +0000
commit4cc240dabbd81a308f06f2717b1942041fe0e205 (patch)
tree07291c8c2c467fc2ecec9166ed0d8ec1e75631a3 /misc.c
parent5bf5d67d497ed91c19851db6b904d54003afe67e (diff)
- markus@cvs.openbsd.org 2001/06/26 17:27:25
[authfd.h authfile.h auth.h auth-options.h bufaux.h buffer.h canohost.h channels.h cipher.h clientloop.h compat.h compress.h crc32.h deattack.h dh.h dispatch.h groupaccess.c groupaccess.h hostfile.h kex.h key.h log.c log.h mac.h misc.c misc.h mpaux.h packet.h radix.h readconf.h readpass.h rsa.h servconf.h serverloop.h session.h sftp-common.c sftp-common.h sftp-glob.h sftp-int.h sshconnect.h ssh-dss.h sshlogin.h sshpty.h ssh-rsa.h sshtty.h tildexpand.h uidswap.h uuencode.h xmalloc.h] remove comments from .h, since they are cut&paste from the .c files and out of sync
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/misc.c b/misc.c
index db9c2e48..620121fd 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.11 2001/06/16 08:58:34 markus Exp $ */
+/* $OpenBSD: misc.c,v 1.12 2001/06/26 17:27:24 markus Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -25,12 +25,13 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: misc.c,v 1.11 2001/06/16 08:58:34 markus Exp $");
+RCSID("$OpenBSD: misc.c,v 1.12 2001/06/26 17:27:24 markus Exp $");
#include "misc.h"
#include "log.h"
#include "xmalloc.h"
+/* remove newline at end of string */
char *
chop(char *s)
{
@@ -46,6 +47,7 @@ chop(char *s)
}
+/* set/unset filedescriptor to non-blocking */
void
set_nonblock(int fd)
{
@@ -93,6 +95,7 @@ unset_nonblock(int fd)
/* Characters considered whitespace in strsep calls. */
#define WHITESPACE " \t\r\n"
+/* return next token in configuration line */
char *
strdelim(char **s)
{
@@ -145,7 +148,13 @@ pwcopy(struct passwd *pw)
return copy;
}
-int a2port(const char *s)
+/*
+ * Convert ASCII string to TCP/IP port number.
+ * Port must be >0 and <=65535.
+ * Return 0 if invalid.
+ */
+int
+a2port(const char *s)
{
long port;
char *endp;
@@ -166,7 +175,29 @@ int a2port(const char *s)
#define DAYS (HOURS * 24)
#define WEEKS (DAYS * 7)
-long convtime(const char *s)
+/*
+ * Convert a time string into seconds; format is
+ * a sequence of:
+ * time[qualifier]
+ *
+ * Valid time qualifiers are:
+ * <none> seconds
+ * s|S seconds
+ * m|M minutes
+ * h|H hours
+ * d|D days
+ * w|W weeks
+ *
+ * Examples:
+ * 90m 90 minutes
+ * 1h30m 90 minutes
+ * 2d 2 days
+ * 1w 1 week
+ *
+ * Return -1 if time string is invalid.
+ */
+long
+convtime(const char *s)
{
long total, secs;
const char *p;
@@ -253,6 +284,7 @@ colon(char *cp)
return (0);
}
+/* function to assist building execv() arguments */
void
addargs(arglist *args, char *fmt, ...)
{