]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/extra/m_geoip.cpp
Merge pull request #1222 from SaberUK/master+warnings
[user/henk/code/inspircd.git] / src / modules / extra / m_geoip.cpp
index d21a82149b423cbbe84fca796fff24f5dbddff5f..b350ede904f0999b49831dc39c3aaf4bbe9f4237 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/// $CompilerFlags: find_compiler_flags("geoip" "")
+/// $LinkerFlags: find_linker_flags("geoip" "-lGeoIP")
+
+/// $PackageInfo: require_system("darwin") geoip pkg-config
+/// $PackageInfo: require_system("ubuntu") libgeoip-dev pkg-config
 
 #include "inspircd.h"
 #include "xline.h"
 
+// Fix warnings about the use of commas at end of enumerator lists on C++03.
+#if defined __clang__
+# pragma clang diagnostic ignored "-Wc++11-extensions"
+#elif defined __GNUC__
+# pragma GCC diagnostic ignored "-pedantic"
+#endif
+
 #include <GeoIP.h>
 
 #ifdef _WIN32
 # pragma comment(lib, "GeoIP.lib")
 #endif
 
-/* $LinkerFlags: -lGeoIP */
-
 class ModuleGeoIP : public Module
 {
        LocalStringExt ext;
@@ -97,9 +107,9 @@ class ModuleGeoIP : public Module
                return MOD_RES_DENY;
        }
 
-       ModResult OnStats(char symbol, User* user, string_list &out) CXX11_OVERRIDE
+       ModResult OnStats(Stats::Context& stats) CXX11_OVERRIDE
        {
-               if (symbol != 'G')
+               if (stats.GetSymbol() != 'G')
                        return MOD_RES_PASSTHRU;
 
                unsigned int unknown = 0;
@@ -115,14 +125,13 @@ class ModuleGeoIP : public Module
                                unknown++;
                }
 
-               std::string p = "801 " + user->nick + " :GeoIPSTATS ";
                for (std::map<std::string, unsigned int>::const_iterator i = results.begin(); i != results.end(); ++i)
                {
-                       out.push_back(p + i->first + " " + ConvToStr(i->second));
+                       stats.AddRow(801, "GeoIPSTATS " + i->first + " " + ConvToStr(i->second));
                }
 
                if (unknown)
-                       out.push_back(p + "Unknown " + ConvToStr(unknown));
+                       stats.AddRow(801, "GeoIPSTATS Unknown " + ConvToStr(unknown));
 
                return MOD_RES_DENY;
        }