]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #948 in SNORT/snort3 from extrabuild to master
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Tue, 11 Jul 2017 16:57:07 +0000 (12:57 -0400)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Tue, 11 Jul 2017 16:57:07 +0000 (12:57 -0400)
Squashed commit of the following:

commit 4d7e8a276f0d2e0e901b548d781de6af83fd9d07
Author: Michael Altizer <mialtize@cisco.com>
Date:   Fri Jul 7 13:56:26 2017 -0400

    build: Add support for appending EXTRABUILD to the BUILD string

    If EXTRABUILD is defined in the preprocessor flags, it will be appended
    to the BUILD string and reported in all such places that use it like
    snort -V.

    For example, if one configures with CPPFLAGS="-DEXTRABUILD=.1", the
    resulting snort -V output will look something like this:

       ,,_     -*> Snort++ <*-
      o"  )~   Version 3.0.0-a4 (Build 236.1) from 2.9.8-383
       ''''    By Martin Roesch & The Snort Team

src/framework/codec.h
src/main/build.h
src/utils/cpp_macros.h

index 28650ee2ec3a6f0fc662ef0b2e4ca61cbb31b107..6f244cc8f2a0065cdb42cb3fd33cd329b3b101e1 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "framework/base_api.h"
 #include "framework/decode_data.h"
+#include "utils/cpp_macros.h"
 
 struct TextLog;
 struct _daq_pkthdr;
@@ -54,9 +55,7 @@ struct ICMPHdr;
 }
 
 // Used by root codecs to add their DLT to their HELP string
-#define STRINGIFY(x) #x
-#define ARG_STRINGIFY(x) STRINGIFY(x)
-#define ADD_DLT(help, x) help " (DLT " ARG_STRINGIFY(x) ")"
+#define ADD_DLT(help, x) help " (DLT " STRINGIFY_MX(x) ")"
 
 constexpr uint8_t MIN_TTL = 64;
 constexpr uint8_t MAX_TTL = 255;
index 433e7830cbe50fb137f9357de7585e1076566ce6..823dffdd7840e5cb7e1cb16e880793cd31c93b88 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef BUILD_H
 #define BUILD_H
 
+#include "utils/cpp_macros.h"
+
 //-----------------------------------------------//
 //     ____                   _                  //
 //    / ___| _ __   ___  _ __| |_  _     _       //
 //                                               //
 //-----------------------------------------------//
 
-#define BUILD "236"
+#define BUILD_NUMBER 236
+
+#ifndef EXTRABUILD
+#define BUILD STRINGIFY_MX(BUILD_NUMBER)
+#else
+#define BUILD STRINGIFY_MX(PPCAT_MX(BUILD_NUMBER, EXTRABUILD))
+#endif
 
 #endif
 
index c68f4627d2be86ca84ab81891a19239db4bb919c..43472159882eff150e832b4c45944ee31b0a9134 100644 (file)
 
 // Miscellaneous C preprocessor macros
 
+// Turn x into a string literal without expanding macro definitions
+// Example:
+//      #define BUILD 123
+//      STRINGIFY(BUILD)
+// Result:
+//      "BUILD"
 #define STRINGIFY(x) #x
 
+// Turn x into a string literal after macro-expanding it
+// Example:
+//      #define BUILD 123
+//      STRINGIFY_MX(BUILD)
+// Result:
+//      "123"
+#define STRINGIFY_MX(x) STRINGIFY(x)
+
+// Concatenate preprocessor tokens x and y without expanding macro definitions
+// Example:
+//      #define ice snow
+//      #define cream cone
+//      PPCAT(ice, cream)
+// Result:
+//      icecream
+#define PPCAT(x, y) x ## y
+
+// Concatenate preprocessor tokens x and y after macro-expanding them
+// Example:
+//      #define ice snow
+//      #define cream cone
+//      PPCAT_MX(ice, cream)
+// Result:
+//      snowcone
+#define PPCAT_MX(x, y) PPCAT(x, y)
+
 // Pair of macros to temporarily enable and then disable warnings for structures
 // being automatically padded.  Currently implemented for Clang and GCC >= 5.0.
 #if defined(__clang__) && !defined(__ICC)