changeset 1879:ec322c22ed59

Get rid of the "clean chars" option, just hardcode them.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 04 Nov 2017 20:24:17 +0200
parents a5b86414303c
children 6d42169d60aa
files mapsearch.c
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mapsearch.c	Sat Nov 04 20:10:05 2017 +0200
+++ b/mapsearch.c	Sat Nov 04 20:24:17 2017 +0200
@@ -86,7 +86,6 @@
 MAPListenerCtx *optListenTo[SET_MAX_LISTEN];
 int     optNMaps = 0;
 int     optNListenTo = 0;
-char    *optCleanChars = " *@?%C";
 char    *optSSLCipherList = SET_DEF_CIPHERS;
 struct lws_context *setLWSContext = NULL;
 int     optWorldXC = 0, optWorldYC = 0;
@@ -106,7 +105,6 @@
     { 1, 'v', "verbose",       "Be more verbose", OPT_NONE },
     { 2, 'l', "listen",        "Listen to interface (see below)", OPT_ARGREQ },
     { 3,   0, "ssl-ciphers",   "Specify list of SSL/TLS ciphers", OPT_ARGREQ },
-    { 4,   0, "clean-chars",   "String of characters to 'clean up' from map blocks", OPT_ARGREQ },
     { 5, 'w', "world-origin",  "Specify the world origin <x:y> which map offsets relate to", OPT_ARGREQ },
     { 6, 'T', "test",          "Test search with given file input", OPT_ARGREQ },
     { 7, 'U', "uid",           "Run as UID", OPT_ARGREQ },
@@ -476,10 +474,6 @@
         optSSLCipherList = optArg;
         break;
 
-    case 4:
-        optCleanChars = optArg;
-        break;
-
     case 5:
         if (!mapParseCoordPair(optArg, &optWorldXC, &optWorldYC))
         {
@@ -737,6 +731,8 @@
 
 void mapPerformSearch(struct lws *wsi, unsigned char *data, const size_t len, char **verr)
 {
+    static const char *cleanChars = " *@?%C";
+    size_t ncleanChars = strlen(cleanChars);
     int width, height, centerX, centerY;
     MapBlock *pattern = NULL;
     BOOL mapList[SET_MAX_MAPS];
@@ -860,7 +856,7 @@
     }
 
     // Entropy check
-    int entropy = mapBlockGetEntropy(pattern, optCleanChars, strlen(optCleanChars));
+    int entropy = mapBlockGetEntropy(pattern, cleanChars, ncleanChars);
     mapMSG(2, "Block entropy %d\n", entropy);
 
     if ((entropy < 2 && width < 4 && height < 4) ||
@@ -877,7 +873,7 @@
         mapMSG(2, "Center @ %d, %d\n", centerX, centerY);
 
     // Clean the pattern from characters we do not want to match
-    mapBlockClean(pattern, (unsigned char *) optCleanChars, strlen(optCleanChars));
+    mapBlockClean(pattern, (unsigned char *) cleanChars, ncleanChars);
 
     //
     // Search the maps .. enabled or if none specified, all of them