Commit d61e9df9 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent d91b8f64
......@@ -199,6 +199,10 @@ error errorf(const char *format, ...) {
// 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> r;
int psep_prev=-1, psep;
......
......@@ -143,6 +143,7 @@ error errorf (const char *format, ...)
// strings::
namespace strings {
bool has_prefix(const string &s, const string &prefix);
vector<string> split(const string &s, char sep);
} // strings::
......
......@@ -663,7 +663,7 @@ tuple</*rxq*/chan<rxPkt>, error> WatchLink::_sendReq(IContext *ctx, const string
}
// recvReq receives client <- server request.
error WatchLink::recvReq(IContext *ctx, PinReq *rx) {
error WatchLink::recvReq(IContext *ctx, PinReq *prx) {
WatchLink& wlink = *this;
rxPkt pkt;
......@@ -680,18 +680,27 @@ error WatchLink::recvReq(IContext *ctx, PinReq *rx) {
return rx
#endif
rx->stream = pkt.stream;
pkt.to_string();
stream, msg = rx
// XXX -> _parsePinReq
return PinReq(wlink, stream, msg)
err = _parsePinReq(prx, &pkt);
return err;
}
// _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>
msgv = strings::split(msg, ' ');
if
if (!strings::has_prefix(msg, "pin "))
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.
......
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