# # # patch "cmd_packet.cc" # from [ff0d753e667e71cb26fa883ba005bed5925ee092] # to [3ef7b7fc7cc5d7c8f51087e9c0813049559424f3] # # patch "key_store.cc" # from [851e64c0885d3b585e9559affc38c851a9c87c70] # to [0e4f22267b0990f012f2dcf72a1d46accc96b1b2] # # patch "packet.cc" # from [482cd5315e50cb118fddd5eb8dd770251dbfc155] # to [aabd210043a44940e281fab6b34b311623d9db41] # # patch "packet.hh" # from [e28b0bb77a6505bf4daf75d0f6f655d5b3f28e4d] # to [fe2e5aec17f2f6aaee6a81a55dff38b248e99880] # ============================================================ --- cmd_packet.cc ff0d753e667e71cb26fa883ba005bed5925ee092 +++ cmd_packet.cc 3ef7b7fc7cc5d7c8f51087e9c0813049559424f3 @@ -136,7 +136,7 @@ CMD(read, N_("packet i/o"), "[FILE1 [FIL size_t count = 0; if (args.empty()) { - count += read_packets(cin, dbw, app); + count += read_packets(cin, dbw, app.keys); N(count != 0, F("no packets found on stdin")); } else @@ -147,7 +147,7 @@ CMD(read, N_("packet i/o"), "[FILE1 [FIL data dat; read_data(system_path(*i), dat); istringstream ss(dat()); - count += read_packets(ss, dbw, app); + count += read_packets(ss, dbw, app.keys); } N(count != 0, FP("no packets found in given file", "no packets found in given files", ============================================================ --- key_store.cc 851e64c0885d3b585e9559affc38c851a9c87c70 +++ key_store.cc 0e4f22267b0990f012f2dcf72a1d46accc96b1b2 @@ -90,7 +90,7 @@ key_store::read_key_dir() data dat; read_data(key_dir / (*i)(), dat); istringstream is(dat()); - read_packets(is, kr, app); + read_packets(is, kr, *this); } } ============================================================ --- packet.cc 482cd5315e50cb118fddd5eb8dd770251dbfc155 +++ packet.cc aabd210043a44940e281fab6b34b311623d9db41 @@ -21,6 +21,7 @@ #include "transforms.hh" #include "simplestring_xform.hh" #include "keys.hh" +#include "key_store.hh" #include "cert.hh" using std::istream; @@ -110,7 +111,7 @@ feed_packet_consumer struct feed_packet_consumer { - app_state & app; + key_store & keys; size_t & count; packet_consumer & cons; string ident; @@ -118,8 +119,8 @@ feed_packet_consumer string certname; string base; string sp; - feed_packet_consumer(size_t & count, packet_consumer & c, app_state & app_) - : app(app_), count(count), cons(c), + feed_packet_consumer(size_t & count, packet_consumer & c, key_store & keys) + : keys(keys), count(count), cons(c), ident(constants::regex_legal_id_bytes), key(constants::regex_legal_key_name_bytes), certname(constants::regex_legal_cert_name_bytes), @@ -220,7 +221,7 @@ feed_packet_consumer require(regex_match(body, regex(base))); string contents(trim_ws(body)); keypair kp; - migrate_private_key(app.keys, + migrate_private_key(keys, rsa_keypair_id(args), base64 >(contents), kp); @@ -237,7 +238,7 @@ static size_t }; static size_t -extract_packets(string const & s, packet_consumer & cons, app_state & app) +extract_packets(string const & s, packet_consumer & cons, key_store & keys) { static string const head("\\[([a-z]+)[[:space:]]+([^\\[\\]]+)\\]"); static string const body("([^\\[\\]]+)"); @@ -245,13 +246,13 @@ extract_packets(string const & s, packet static string const whole = head + body + tail; regex expr(whole); size_t count = 0; - regex_grep(feed_packet_consumer(count, cons, app), s, expr, match_default); + regex_grep(feed_packet_consumer(count, cons, keys), s, expr, match_default); return count; } size_t -read_packets(istream & in, packet_consumer & cons, app_state & app) +read_packets(istream & in, packet_consumer & cons, key_store & keys) { string accum, tmp; size_t count = 0; @@ -268,7 +269,7 @@ read_packets(istream & in, packet_consum { endpos += end.size(); string tmp = accum.substr(0, endpos); - count += extract_packets(tmp, cons, app); + count += extract_packets(tmp, cons, keys); if (endpos < accum.size() - 1) accum = accum.substr(endpos+1); else @@ -358,7 +359,7 @@ UNIT_TEST(packet, roundabout) ostringstream oss; packet_writer pw(oss); istringstream iss(tmp); - read_packets(iss, pw, aaa); + read_packets(iss, pw, aaa.keys); BOOST_CHECK(oss.str() == tmp); tmp = oss.str(); } ============================================================ --- packet.hh e28b0bb77a6505bf4daf75d0f6f655d5b3f28e4d +++ packet.hh fe2e5aec17f2f6aaee6a81a55dff38b248e99880 @@ -13,7 +13,7 @@ #include #include "vocab.hh" -class app_state; +class key_store; struct cert; // the idea here is that monotone can produce and consume "packet streams", @@ -79,7 +79,7 @@ struct packet_writer : public packet_con keypair const & kp); }; -size_t read_packets(std::istream & in, packet_consumer & cons, app_state & app); +size_t read_packets(std::istream & in, packet_consumer & cons, key_store & keys); // Local Variables: // mode: C++