diff options
Diffstat (limited to 'cmds/incident_helper')
-rw-r--r-- | cmds/incident_helper/IncidentHelper.cpp | 17 | ||||
-rw-r--r-- | cmds/incident_helper/IncidentHelper.h | 11 | ||||
-rw-r--r-- | cmds/incident_helper/main.cpp | 4 |
3 files changed, 30 insertions, 2 deletions
diff --git a/cmds/incident_helper/IncidentHelper.cpp b/cmds/incident_helper/IncidentHelper.cpp index fba5e662b7c1..787d3a1557d6 100644 --- a/cmds/incident_helper/IncidentHelper.cpp +++ b/cmds/incident_helper/IncidentHelper.cpp @@ -61,6 +61,21 @@ SetTableField(::google::protobuf::Message* message, string field_name, string fi } // ================================================================================ +status_t NoopParser::Parse(const int in, const int out) const +{ + string content; + if (!ReadFdToString(in, &content)) { + fprintf(stderr, "[%s]Failed to read data from incidentd\n", this->name.string()); + return -1; + } + if (!WriteStringToFd(content, out)) { + fprintf(stderr, "[%s]Failed to write data to incidentd\n", this->name.string()); + return -1; + } + return NO_ERROR; +} + +// ================================================================================ status_t ReverseParser::Parse(const int in, const int out) const { string content; @@ -189,4 +204,4 @@ status_t ProcrankParser::Parse(const int in, const int out) const { } fprintf(stderr, "[%s]Proto size: %d bytes\n", this->name.string(), proto.ByteSize()); return NO_ERROR; -}
\ No newline at end of file +} diff --git a/cmds/incident_helper/IncidentHelper.h b/cmds/incident_helper/IncidentHelper.h index f319c419fcd6..f6579a2d3736 100644 --- a/cmds/incident_helper/IncidentHelper.h +++ b/cmds/incident_helper/IncidentHelper.h @@ -36,6 +36,17 @@ public: }; /** + * No op parser returns what it reads + */ +class NoopParser : public TextParserBase { +public: + NoopParser() : TextParserBase(String8("NoopParser")) {}; + ~NoopParser() {}; + + virtual status_t Parse(const int in, const int out) const; +}; + +/** * This parser is used for testing only, results in timeout. */ class TimeoutParser : public TextParserBase { diff --git a/cmds/incident_helper/main.cpp b/cmds/incident_helper/main.cpp index 333344b8ce86..296d3001b7bb 100644 --- a/cmds/incident_helper/main.cpp +++ b/cmds/incident_helper/main.cpp @@ -41,9 +41,11 @@ static TextParserBase* selectParser(int section) { case -1: return new TimeoutParser(); case 0: + return new NoopParser(); + case 1: // 1 is reserved for incident header so it won't be section id return new ReverseParser(); /* ========================================================================= */ - // IDs larger than 0 are reserved in incident.proto + // IDs larger than 1 are section ids reserved in incident.proto case 2000: return new ProcrankParser(); case 2002: |