MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / RPCParseCommandLine

Method RPCParseCommandLine

src/qt/rpcconsole.cpp:142–380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140 */
141
142bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, const bool fExecute, std::string * const pstrFilteredOut, const QString& wallet_name)
143{
144 std::vector< std::vector<std::string> > stack;
145 stack.emplace_back();
146
147 enum CmdParseState
148 {
149 STATE_EATING_SPACES,
150 STATE_EATING_SPACES_IN_ARG,
151 STATE_EATING_SPACES_IN_BRACKETS,
152 STATE_ARGUMENT,
153 STATE_SINGLEQUOTED,
154 STATE_DOUBLEQUOTED,
155 STATE_ESCAPE_OUTER,
156 STATE_ESCAPE_DOUBLEQUOTED,
157 STATE_COMMAND_EXECUTED,
158 STATE_COMMAND_EXECUTED_INNER
159 } state = STATE_EATING_SPACES;
160 std::string curarg;
161 UniValue lastResult;
162 unsigned nDepthInsideSensitive = 0;
163 size_t filter_begin_pos = 0, chpos;
164 std::vector<std::pair<size_t, size_t>> filter_ranges;
165
166 auto add_to_current_stack = [&](const std::string& strArg) {
167 if (stack.back().empty() && (!nDepthInsideSensitive) && historyFilter.contains(QString::fromStdString(strArg), Qt::CaseInsensitive)) {
168 nDepthInsideSensitive = 1;
169 filter_begin_pos = chpos;
170 }
171 // Make sure stack is not empty before adding something
172 if (stack.empty()) {
173 stack.emplace_back();
174 }
175 stack.back().push_back(strArg);
176 };
177
178 auto close_out_params = [&]() {
179 if (nDepthInsideSensitive) {
180 if (!--nDepthInsideSensitive) {
181 assert(filter_begin_pos);
182 filter_ranges.emplace_back(filter_begin_pos, chpos);
183 filter_begin_pos = 0;
184 }
185 }
186 stack.pop_back();
187 };
188
189 std::string strCommandTerminated = strCommand;
190 if (strCommandTerminated.back() != '\n')
191 strCommandTerminated += "\n";
192 for (chpos = 0; chpos < strCommandTerminated.size(); ++chpos)
193 {
194 char ch = strCommandTerminated[chpos];
195 switch(state)
196 {
197 case STATE_COMMAND_EXECUTED_INNER:
198 case STATE_COMMAND_EXECUTED:
199 {

Callers

nothing calls this directly

Calls 15

RPCConvertValuesFunction · 0.85
isArrayMethod · 0.80
isObjectMethod · 0.80
isStrMethod · 0.80
rbeginMethod · 0.80
rendMethod · 0.80
emplace_backMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
containsMethod · 0.45
push_backMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected