Commit d61e9df9 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d91b8f64
...@@ -199,6 +199,10 @@ error errorf(const char *format, ...) { ...@@ -199,6 +199,10 @@ error errorf(const char *format, ...) {
// strings:: // strings::
namespace strings { namespace strings {
bool has_prefix(const string &s, const string &prefix) {
return s.compare(0, prefix.size(), prefix);
}
vector<string> split(const string &s, char sep) { vector<string> split(const string &s, char sep) {
vector<string> r; vector<string> r;
int psep_prev=-1, psep; int psep_prev=-1, psep;
......
...@@ -143,6 +143,7 @@ error errorf (const char *format, ...) ...@@ -143,6 +143,7 @@ error errorf (const char *format, ...)
// strings:: // strings::
namespace strings { namespace strings {
bool has_prefix(const string &s, const string &prefix);
vector<string> split(const string &s, char sep); vector<string> split(const string &s, char sep);
} // strings:: } // strings::
......
...@@ -663,7 +663,7 @@ tuple</*rxq*/chan<rxPkt>, error> WatchLink::_sendReq(IContext *ctx, const string ...@@ -663,7 +663,7 @@ tuple</*rxq*/chan<rxPkt>, error> WatchLink::_sendReq(IContext *ctx, const string
} }
// recvReq receives client <- server request. // recvReq receives client <- server request.
error WatchLink::recvReq(IContext *ctx, PinReq *rx) { error WatchLink::recvReq(IContext *ctx, PinReq *prx) {
WatchLink& wlink = *this; WatchLink& wlink = *this;
rxPkt pkt; rxPkt pkt;
...@@ -680,18 +680,27 @@ error WatchLink::recvReq(IContext *ctx, PinReq *rx) { ...@@ -680,18 +680,27 @@ error WatchLink::recvReq(IContext *ctx, PinReq *rx) {
return rx return rx
#endif #endif
rx->stream = pkt.stream;
pkt.to_string(); pkt.to_string();
stream, msg = rx err = _parsePinReq(prx, &pkt);
// XXX -> _parsePinReq return err;
return PinReq(wlink, stream, msg)
} }
// _parsePinReq parses message into PinReq according to wcfs invalidation protocol. // _parsePinReq parses message into PinReq according to wcfs invalidation protocol.
error _parsePinReq(PinReq *out, const string &msg) { error _parsePinReq(PinReq *pin, const rxPkt *pkt) {
// XXX err ctx "bad pin"
pin->stream = pkt->stream;
// pin <foid>) #<blk> @<at> // pin <foid>) #<blk> @<at>
msgv = strings::split(msg, ' '); if (!strings::has_prefix(msg, "pin "))
if return fmt::errorf("not a pin request"); // XXX +msg?
argv = strings::split(msg.substr(4), ' ');
if (msgv.len() != 3)
return fmt::errorf("expected 3 arguments, got %d", msgv.len());
// XXX
return nil;
} }
// _readline reads next raw line sent from wcfs. // _readline reads next raw line sent from wcfs.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment