]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/contrib/thrift_dump.cpp
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
23 #include <thrift/transport/TBufferTransports.h>
24 #include <thrift/transport/TFDTransport.h>
25 #include <thrift/protocol/TBinaryProtocol.h>
26 #include <thrift/protocol/TDebugProtocol.h>
27 #include <thrift/protocol/TProtocolTap.h>
30 using boost::shared_ptr
;
31 using namespace apache::thrift::transport
;
32 using namespace apache::thrift::protocol
;
36 "usage: thrift_dump {-b|-f|-s} < input > ouput\n"
37 " -b TBufferedTransport messages\n"
38 " -f TFramedTransport messages\n"
39 " -s Raw structures\n");
43 int main(int argc
, char *argv
[]) {
48 shared_ptr
<TTransport
> stdin_trans(new TFDTransport(STDIN_FILENO
));
49 shared_ptr
<TTransport
> itrans
;
51 if (argv
[1] == std::string("-b") || argv
[1] == std::string("-s")) {
52 itrans
.reset(new TBufferedTransport(stdin_trans
));
53 } else if (argv
[1] == std::string("-f")) {
54 itrans
.reset(new TFramedTransport(stdin_trans
));
59 shared_ptr
<TProtocol
> iprot(new TBinaryProtocol(itrans
));
60 shared_ptr
<TProtocol
> oprot(
62 shared_ptr
<TTransport
>(new TBufferedTransport(
63 shared_ptr
<TTransport
>(new TFDTransport(STDOUT_FILENO
))))));
65 TProtocolTap
tap(iprot
, oprot
);
68 if (argv
[1] == std::string("-s")) {
74 TMessageType messageType
;
77 tap
.readMessageBegin(name
, messageType
, seqid
);
82 } catch (TProtocolException exn
) {
83 cout
<< "Protocol Exception: " << exn
.what() << endl
;
85 oprot
->getTransport()->flush();