summaryrefslogtreecommitdiffstats
path: root/src/utils.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-11-12 16:30:30 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-11-12 16:30:30 +0100
commit96b4dc4efca1b164f79a7f7394449866f034ac31 (patch)
tree101b796f40fee444c8193ccc3e13cf5644c83d5f /src/utils.cpp
parent5132756f09c7a0dafe4644db92718ee3d1a58d6c (diff)
parentfedab89cd4625617b3e481f1f59ba0fc97b7305b (diff)
downloaddabmux-96b4dc4efca1b164f79a7f7394449866f034ac31.tar.gz
dabmux-96b4dc4efca1b164f79a7f7394449866f034ac31.tar.bz2
dabmux-96b4dc4efca1b164f79a7f7394449866f034ac31.zip
Merge branch 'next' into servicelinking
Diffstat (limited to 'src/utils.cpp')
-rw-r--r--src/utils.cpp52
1 files changed, 26 insertions, 26 deletions
diff --git a/src/utils.cpp b/src/utils.cpp
index 0399467..4431407 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -103,42 +103,16 @@ void header_message()
std::cerr << "Input URLs supported:" << std::endl <<
" prbs" <<
-#if defined(HAVE_INPUT_TEST)
- " test" <<
-#endif
-#if defined(HAVE_INPUT_UDP)
" udp" <<
-#endif
-#if defined(HAVE_INPUT_FIFO)
- " fifo" <<
-#endif
-#if defined(HAVE_INPUT_FILE)
" file" <<
-#endif
-#if defined(HAVE_INPUT_ZEROMQ)
" zmq" <<
-#endif
std::endl;
std::cerr << "Inputs format supported:" << std::endl <<
-#if defined(HAVE_FORMAT_RAW)
" raw" <<
-#endif
-#if defined(HAVE_FORMAT_BRIDGE)
- " bridge" <<
-#endif
-#if defined(HAVE_FORMAT_MPEG)
" mpeg" <<
-#endif
-#if defined(HAVE_FORMAT_PACKET)
" packet" <<
-#endif
-#if defined(HAVE_FORMAT_DMB)
- " dmb" <<
-#endif
-#if defined(HAVE_FORMAT_EPM)
" epm" <<
-#endif
std::endl;
std::cerr << "Output URLs supported:" << std::endl <<
@@ -465,3 +439,29 @@ void printEnsemble(const shared_ptr<dabEnsemble> ensemble)
printLinking(ensemble);
}
+long hexparse(const std::string& input)
+{
+ long value = 0;
+ errno = 0;
+
+ // Do not use strtol's base=0 because
+ // we do not want to accept octal.
+ if (input.find("0x") == 0) {
+ value = strtol(input.c_str() + 2, nullptr, 16);
+ }
+ else {
+ value = strtol(input.c_str(), nullptr, 10);
+ }
+
+ if ((value == LONG_MIN or value == LONG_MAX) and errno == ERANGE) {
+ throw out_of_range("hexparse: value out of range");
+ }
+ else if (value == 0 and errno != 0) {
+ stringstream ss;
+ ss << "hexparse: " << strerror(errno);
+ throw invalid_argument(ss.str());
+ }
+
+ return value;
+}
+