changeset 31912:c8935911ca00

Simplify searching for discid by comparing the string representations.
author reimar
date Sat, 21 Aug 2010 09:46:06 +0000
parents 0a5093edd406
children 0aaca064dd5c
files stream/stream_bd.c
diffstat 1 files changed, 3 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/stream/stream_bd.c	Sat Aug 21 09:41:15 2010 +0000
+++ b/stream/stream_bd.c	Sat Aug 21 09:46:06 2010 +0000
@@ -146,6 +146,7 @@
     const char *home;
     int vukfound = 0;
     stream_t *file;
+    char idstr[ID_STR_LEN];
 
     // look up discid in KEYDB.cfg to get VUK
     home = getenv("HOME");
@@ -156,10 +157,10 @@
                "Cannot open VUK database file %s\n", filename);
         return 0;
     }
+    id2str(discid, 20, idstr);
     while (!stream_eof(file)) {
         int i;
         char line[1024];
-        uint8_t id[20];
         char d[200];
         char *vst;
         unsigned int byte;
@@ -175,14 +176,7 @@
         // or         I | I-Key
         // can be followed by ; and comment
 
-        //This means: first string up to whitespace is discid
-        sscanf(line, "%40s", d);
-        for (i = 0; i < 20; ++i) {
-            if (sscanf(&d[i*2], "%2x", &byte) != 1)
-                break;
-            id[i] = byte;
-        }
-        if (memcmp(id, discid, 20) != 0)
+        if (strncasecmp(line, idstr, 40))
             continue;
         mp_msg(MSGT_OPEN, MSGL_V, "KeyDB found Entry for DiscID:\n%s\n", line);