]> andersk Git - gssapi-openssh.git/blobdiff - openssh/misc.c
o Bump version to 2.7.
[gssapi-openssh.git] / openssh / misc.c
index 620121fdca29f7e2fbf915c764a2e4bfb73e7949..eac6ccd5802fc95e318a54f8e7abd6ed5f6c2f02 100644 (file)
@@ -1,5 +1,3 @@
-/*     $OpenBSD: misc.c,v 1.12 2001/06/26 17:27:24 markus Exp $        */
-
 /*
  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
  *
@@ -25,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: misc.c,v 1.12 2001/06/26 17:27:24 markus Exp $");
+RCSID("$OpenBSD: misc.c,v 1.20 2002/12/13 10:03:15 markus Exp $");
 
 #include "misc.h"
 #include "log.h"
@@ -37,7 +35,7 @@ chop(char *s)
 {
        char *t = s;
        while (*t) {
-               if(*t == '\n' || *t == '\r') {
+               if (*t == '\n' || *t == '\r') {
                        *t = '\0';
                        return s;
                }
@@ -65,9 +63,8 @@ set_nonblock(int fd)
        debug("fd %d setting O_NONBLOCK", fd);
        val |= O_NONBLOCK;
        if (fcntl(fd, F_SETFL, val) == -1)
-               if (errno != ENODEV)
-                       error("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
-                           fd, strerror(errno));
+               debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
+                   fd, strerror(errno));
 }
 
 void
@@ -87,19 +84,43 @@ unset_nonblock(int fd)
        debug("fd %d clearing O_NONBLOCK", fd);
        val &= ~O_NONBLOCK;
        if (fcntl(fd, F_SETFL, val) == -1)
-               if (errno != ENODEV)
-                       error("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
-                           fd, strerror(errno));
+               debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
+                   fd, strerror(errno));
+}
+
+/* disable nagle on socket */
+void
+set_nodelay(int fd)
+{
+       int opt;
+       socklen_t optlen;
+
+       optlen = sizeof opt;
+       if (getsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, &optlen) == -1) {
+               error("getsockopt TCP_NODELAY: %.100s", strerror(errno));
+               return;
+       }
+       if (opt == 1) {
+               debug2("fd %d is TCP_NODELAY", fd);
+               return;
+       }
+       opt = 1;
+       debug2("fd %d setting TCP_NODELAY", fd);
+       if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof opt) == -1)
+               error("setsockopt TCP_NODELAY: %.100s", strerror(errno));
 }
 
 /* Characters considered whitespace in strsep calls. */
 #define WHITESPACE " \t\r\n"
 
+/* Characters considered as quotations. */
+#define QUOTES "'\""
+
 /* return next token in configuration line */
 char *
 strdelim(char **s)
 {
-       char *old;
+       char *old, *p, *q;
        int wspace = 0;
 
        if (*s == NULL)
@@ -107,7 +128,22 @@ strdelim(char **s)
 
        old = *s;
 
-       *s = strpbrk(*s, WHITESPACE "=");
+        if ((q=strchr(QUOTES, (int) *old)) && *q)
+        {
+            /* find next quote character, point old to start of quoted
+             * string */
+            for (p = ++old;*p && *p!=*q; p++)
+                 ;
+            
+            /* find start of next token */
+            *s = (*p) ? p + strspn(p + 1, WHITESPACE) + 1 : NULL;
+            
+            /* terminate 'old' token */
+            *p = '\0';
+            return (old);
+        }
+
+        *s = strpbrk(*s, WHITESPACE "=");
        if (*s == NULL)
                return (old);
 
@@ -298,7 +334,7 @@ addargs(arglist *args, char *fmt, ...)
        if (args->list == NULL) {
                args->nalloc = 32;
                args->num = 0;
-       } else if (args->num+2 >= args->nalloc) 
+       } else if (args->num+2 >= args->nalloc)
                args->nalloc *= 2;
 
        args->list = xrealloc(args->list, args->nalloc * sizeof(char *));
This page took 0.089366 seconds and 4 git commands to generate.