summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-07-22 09:20:58 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-22 09:20:58 +0100
commit455475575bcfa30aa60a377235bfaf2fd7bc2da7 (patch)
tree691c69e3e25722a4fa6ffe632179243907be8240 /src
parent1eb9ba017214698de3fd41de5291604b4fe839c5 (diff)
Use locked_sstream. Replace once parse_stream with parse_memory.
Diffstat (limited to 'src')
-rw-r--r--src/certificate.cc3
-rw-r--r--src/certificate_chain.cc12
-rw-r--r--src/compose.hpp32
-rw-r--r--src/dcp_time.cc2
-rw-r--r--src/decrypted_kdm.cc7
-rw-r--r--src/key.cc5
-rw-r--r--src/raw_convert.h4
-rw-r--r--src/types.cc2
8 files changed, 31 insertions, 36 deletions
diff --git a/src/certificate.cc b/src/certificate.cc
index 18249a58..34f79754 100644
--- a/src/certificate.cc
+++ b/src/certificate.cc
@@ -55,7 +55,6 @@ using std::list;
using std::string;
using std::ostream;
using std::min;
-using std::stringstream;
using namespace dcp;
static string const begin_certificate = "-----BEGIN CERTIFICATE-----";
@@ -104,7 +103,7 @@ Certificate::read_string (string cert)
See http://comments.gmane.org/gmane.comp.encryption.openssl.user/55593
*/
- stringstream s (cert);
+ locked_stringstream s (cert);
string line;
/* BEGIN */
diff --git a/src/certificate_chain.cc b/src/certificate_chain.cc
index 0046fe75..2ba70183 100644
--- a/src/certificate_chain.cc
+++ b/src/certificate_chain.cc
@@ -55,13 +55,11 @@
#include <boost/algorithm/string.hpp>
#include <boost/foreach.hpp>
#include <fstream>
-#include <sstream>
using std::string;
using std::ofstream;
using std::ifstream;
using std::runtime_error;
-using std::stringstream;
using namespace dcp;
/** Run a shell command.
@@ -108,7 +106,7 @@ command (string cmd)
int const code = WEXITSTATUS (r);
#endif
if (code) {
- stringstream s;
+ locked_stringstream s;
s << "error " << code << " in " << cmd << " within " << boost::filesystem::current_path();
throw dcp::MiscError (s.str());
}
@@ -125,7 +123,7 @@ public_key_digest (boost::filesystem::path private_key, boost::filesystem::path
boost::filesystem::path public_name = private_key.string() + ".public";
/* Create the public key from the private key */
- stringstream s;
+ locked_stringstream s;
s << "\"" << openssl.string() << "\" rsa -outform PEM -pubout -in " << private_key.string() << " -out " << public_name.string ();
command (s.str().c_str ());
@@ -222,7 +220,7 @@ CertificateChain::CertificateChain (
"/dnQualifier=" + public_key_digest ("ca.key", openssl);
{
- stringstream c;
+ locked_stringstream c;
c << quoted_openssl
<< " req -new -x509 -sha256 -config ca.cnf -days 3650 -set_serial 5"
<< " -subj \"" << ca_subject << "\" -key ca.key -outform PEM -out ca.self-signed.pem";
@@ -253,7 +251,7 @@ CertificateChain::CertificateChain (
"/dnQualifier=" + public_key_digest ("intermediate.key", openssl);
{
- stringstream s;
+ locked_stringstream s;
s << quoted_openssl
<< " req -new -config intermediate.cnf -days 3649 -subj \"" << inter_subject << "\" -key intermediate.key -out intermediate.csr";
command (s.str().c_str());
@@ -290,7 +288,7 @@ CertificateChain::CertificateChain (
"/dnQualifier=" + public_key_digest ("leaf.key", openssl);
{
- stringstream s;
+ locked_stringstream s;
s << quoted_openssl << " req -new -config leaf.cnf -days 3648 -subj \"" << leaf_subject << "\" -key leaf.key -outform PEM -out leaf.csr";
command (s.str().c_str());
}
diff --git a/src/compose.hpp b/src/compose.hpp
index f7bd4282..185e00a4 100644
--- a/src/compose.hpp
+++ b/src/compose.hpp
@@ -33,7 +33,7 @@
#ifndef STRING_COMPOSE_H
#define STRING_COMPOSE_H
-#include <sstream>
+#include <locked_sstream.h>
#include <string>
#include <list>
#include <map> // for multimap
@@ -58,7 +58,7 @@ namespace StringPrivate
std::string str() const;
private:
- std::ostringstream os;
+ locked_stringstream os;
int arg_no;
// we store the output as a list - when the output string is requested, the
@@ -106,7 +106,7 @@ namespace StringPrivate
case '8':
case '9':
return true;
-
+
default:
return false;
}
@@ -120,21 +120,21 @@ namespace StringPrivate
os << obj;
std::string rep = os.str();
-
+
if (!rep.empty()) { // manipulators don't produce output
for (specification_map::const_iterator i = specs.lower_bound(arg_no),
end = specs.upper_bound(arg_no); i != end; ++i) {
output_list::iterator pos = i->second;
++pos;
-
+
output.insert(pos, rep);
}
-
+
os.str(std::string());
//os.clear();
++arg_no;
}
-
+
return *this;
}
@@ -142,7 +142,7 @@ namespace StringPrivate
: arg_no(1)
{
std::string::size_type b = 0, i = 0;
-
+
// fill in output with the strings between the %1 %2 %3 etc. and
// fill in specs with the positions
while (i < fmt.length()) {
@@ -154,7 +154,7 @@ namespace StringPrivate
else if (is_number(fmt[i + 1])) { // aha! a spec!
// save string
output.push_back(fmt.substr(b, i - b));
-
+
int n = 1; // number of digits
int spec_no = 0;
@@ -167,9 +167,9 @@ namespace StringPrivate
spec_no /= 10;
output_list::iterator pos = output.end();
--pos; // safe since we have just inserted a string>
-
+
specs.insert(specification_map::value_type(spec_no, pos));
-
+
// jump over spec string
i += n;
b = i;
@@ -180,7 +180,7 @@ namespace StringPrivate
else
++i;
}
-
+
if (i - b > 0) // add the rest of the string
output.push_back(fmt.substr(b, i - b));
}
@@ -189,17 +189,17 @@ namespace StringPrivate
{
// assemble string
std::string str;
-
+
for (output_list::const_iterator i = output.begin(), end = output.end();
i != end; ++i)
str += *i;
-
+
return str;
}
}
// now for the real thing(s)
-namespace String
+namespace String
{
// a series of functions which accept a format string on the form "text %1
// more %2 less %3" and a number of templated parameters and spits out the
@@ -310,7 +310,7 @@ namespace String
.arg(o10);
return c.str();
}
-
+
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10,
typename T11>
diff --git a/src/dcp_time.cc b/src/dcp_time.cc
index 401abb3c..526c784c 100644
--- a/src/dcp_time.cc
+++ b/src/dcp_time.cc
@@ -330,7 +330,7 @@ dcp::operator/ (Time a, Time const & b)
string
Time::as_string (Standard standard) const
{
- stringstream str;
+ locked_stringstream str;
str << setw(2) << setfill('0') << h << ":"
<< setw(2) << setfill('0') << m << ":"
<< setw(2) << setfill('0') << s << ":";
diff --git a/src/decrypted_kdm.cc b/src/decrypted_kdm.cc
index abe12a32..4ffad923 100644
--- a/src/decrypted_kdm.cc
+++ b/src/decrypted_kdm.cc
@@ -52,7 +52,6 @@
using std::list;
using std::vector;
using std::string;
-using std::stringstream;
using std::setw;
using std::setfill;
using std::hex;
@@ -79,7 +78,7 @@ put_uuid (uint8_t ** d, string id)
{
id.erase (std::remove (id.begin(), id.end(), '-'));
for (int i = 0; i < 32; i += 2) {
- stringstream s;
+ locked_stringstream s;
s << id[i] << id[i + 1];
int h;
s >> hex >> h;
@@ -91,7 +90,7 @@ put_uuid (uint8_t ** d, string id)
static string
get_uuid (unsigned char ** p)
{
- stringstream g;
+ locked_stringstream g;
for (int i = 0; i < 16; ++i) {
g << setw(2) << setfill('0') << hex << static_cast<int> (**p);
@@ -301,7 +300,7 @@ DecryptedKDM::encrypt (shared_ptr<const CertificateChain> signer, Certificate re
char out[encrypted_len * 2];
Kumu::base64encode (encrypted, encrypted_len, out, encrypted_len * 2);
int const N = strlen (out);
- stringstream lines;
+ locked_stringstream lines;
for (int i = 0; i < N; ++i) {
if (i > 0 && (i % 64) == 0) {
lines << "\n";
diff --git a/src/key.cc b/src/key.cc
index d2417a09..cf7b4d6d 100644
--- a/src/key.cc
+++ b/src/key.cc
@@ -36,15 +36,14 @@
*/
#include "key.h"
+#include <locked_sstream.h>
#include <asdcp/AS_DCP.h>
#include <asdcp/KM_prng.h>
#include <asdcp/KM_util.h>
-#include <sstream>
#include <string>
#include <iomanip>
using std::string;
-using std::stringstream;
using std::setw;
using std::setfill;
using namespace dcp;
@@ -94,7 +93,7 @@ Key::operator= (Key const & other)
string
Key::hex () const
{
- stringstream g;
+ locked_stringstream g;
for (unsigned int i = 0; i < ASDCP::KeyLen; ++i) {
g << setw(2) << setfill('0') << std::hex << static_cast<int> (_value[i]);
diff --git a/src/raw_convert.h b/src/raw_convert.h
index 36d578b4..5fc05c12 100644
--- a/src/raw_convert.h
+++ b/src/raw_convert.h
@@ -34,7 +34,7 @@
#ifndef LIBDCP_RAW_CONVERT_H
#define LIBDCP_RAW_CONVERT_H
-#include <sstream>
+#include <locked_sstream.h>
#include <iomanip>
namespace dcp {
@@ -46,7 +46,7 @@ template <typename P, typename Q>
P
raw_convert (Q v, int precision = 16, bool fixed = false)
{
- std::stringstream s;
+ locked_stringstream s;
s.imbue (std::locale::classic ());
s << std::setprecision (precision);
if (fixed) {
diff --git a/src/types.cc b/src/types.cc
index cbb56e7f..cf3229df 100644
--- a/src/types.cc
+++ b/src/types.cc
@@ -121,7 +121,7 @@ Colour::Colour (string argb_hex)
string
Colour::to_argb_string () const
{
- stringstream s;
+ locked_stringstream s;
s << "FF";
s << hex
<< setw(2) << setfill('0') << r