[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/kdm/backend
From:       Oswald Buddenhagen <ossi () kde ! org>
Date:       2009-10-25 10:29:40
Message-ID: 1256466580.804237.9668.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1040017 by ossi:

move hexToBinary() to util.c and make its return value more useful

 M  +1 -0      dm.h  
 M  +25 -0     util.c  
 M  +5 -31     xdmauth.c  


--- trunk/KDE/kdebase/workspace/kdm/backend/dm.h #1040016:1040017
@@ -559,6 +559,7 @@
 int writer( int fd, const void *buf, int len );
 int fGets( char *buf, int max, FILE *f );
 time_t mTime( const char *fn );
+int hexToBinary( char *out, const char *in );
 void listSessions( int flags, struct display *d, void *ctx,
                    void (*emitXSess)( struct display *, struct display *, void * ),
                    void (*emitTTYSess)( STRUCTUTMP *, struct display *, void * ) );
--- trunk/KDE/kdebase/workspace/kdm/backend/util.c #1040016:1040017
@@ -581,6 +581,31 @@
 	return cnt;
 }
 
+#define atox(c) ('0' <= c && c <= '9' ? c - '0' : \
+				 'a' <= c && c <= 'f' ? c - 'a' + 10 : \
+				 'A' <= c && c <= 'F' ? c - 'A' + 10 : -1)
+
+int
+hexToBinary( char *out, const char *in )
+{
+	int top, bottom;
+	char c;
+	char *oout;
+
+	for (oout = out; (c = *in++); ) {
+		if ((top = atox( c )) < 0)
+			return 0;
+		if (!(c = *in++))
+			return 0;
+		if ((bottom = atox( c )) < 0)
+			return 0;
+		*out++ = (top << 4) | bottom;
+	}
+	return out - oout;
+}
+
+#undef atox
+
 /* X -from ip6-addr does not work here, so i don't know whether this is needed.
 #define IP6_MAGIC
 */
--- trunk/KDE/kdebase/workspace/kdm/backend/xdmauth.c #1040016:1040017
@@ -119,34 +119,6 @@
 	pdpy->xdmcpAuthorization = xdmcpauth;
 }
 
-#define atox(c) ('0' <= c && c <= '9' ? c - '0' : \
-				 'a' <= c && c <= 'f' ? c - 'a' + 10 : \
-				 'A' <= c && c <= 'F' ? c - 'A' + 10 : -1)
-
-static int
-hexToBinary( char *key )
-{
-	char *out, *in;
-	int top, bottom;
-
-	in = key + 2;
-	out= key;
-	while (in[0] && in[1]) {
-		top = atox( in[0] );
-		if (top == -1)
-			return False;
-		bottom = atox( in[1] );
-		if (bottom == -1)
-			return False;
-		*out++ = (top << 4) | bottom;
-		in += 2;
-	}
-	if (in[0])
-		return False;
-	*out++ = '\0';
-	return True;
-}
-
 /*
  * Search the Keys file for the entry matching this display.  This
  * routine accepts either plain ascii strings for keys, or hex-encoded numbers
@@ -171,10 +143,12 @@
 		if (strlen( id ) == displayID->length &&
 		    !strncmp( id, (char *)displayID->data, displayID->length ))
 		{
-			if (!strncmp( key, "0x", 2 ) || !strncmp( key, "0X", 2 ))
-				if (!hexToBinary( key ))
+			if (!strncmp( key, "0x", 2 ) || !strncmp( key, "0X", 2 )) {
+				if (!(keylen = hexToBinary( key, key + 2 )))
 					break;
-			keylen = strlen( key );
+			} else {
+				keylen = strlen( key );
+			}
 			while (keylen < 7)
 				key[keylen++] = '\0';
 			pdpy->key.data[0] = '\0';
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic