/* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include "interface_utils.h" #include "parser.h" #include "service.h" #include "service_list.h" #include "subcontext.h" namespace android { namespace init { class ServiceParser : public SectionParser { public: ServiceParser( ServiceList* service_list, Subcontext* subcontext, const std::optional& interface_inheritance_hierarchy, bool from_apex = false) : service_list_(service_list), subcontext_(subcontext), interface_inheritance_hierarchy_(interface_inheritance_hierarchy), service_(nullptr), from_apex_(from_apex) {} Result ParseSection(std::vector&& args, const std::string& filename, int line) override; Result ParseLineSection(std::vector&& args, int line) override; Result EndSection() override; void EndFile() override { filename_ = ""; } private: using OptionParser = Result (ServiceParser::*)(std::vector&& args); const KeywordMap& GetParserMap() const; Result ParseCapabilities(std::vector&& args); Result ParseClass(std::vector&& args); Result ParseConsole(std::vector&& args); Result ParseCritical(std::vector&& args); Result ParseDisabled(std::vector&& args); Result ParseEnterNamespace(std::vector&& args); Result ParseGroup(std::vector&& args); Result ParsePriority(std::vector&& args); Result ParseInterface(std::vector&& args); Result ParseIoprio(std::vector&& args); Result ParseKeycodes(std::vector&& args); Result ParseOneshot(std::vector&& args); Result ParseOnrestart(std::vector&& args); Result ParseOomScoreAdjust(std::vector&& args); Result ParseOverride(std::vector&& args); Result ParseMemcgLimitInBytes(std::vector&& args); Result ParseMemcgLimitPercent(std::vector&& args); Result ParseMemcgLimitProperty(std::vector&& args); Result ParseMemcgSoftLimitInBytes(std::vector&& args); Result ParseMemcgSwappiness(std::vector&& args); Result ParseNamespace(std::vector&& args); Result ParseProcessRlimit(std::vector&& args); Result ParseRebootOnFailure(std::vector&& args); Result ParseRestartPeriod(std::vector&& args); Result ParseSeclabel(std::vector&& args); Result ParseSetenv(std::vector&& args); Result ParseShutdown(std::vector&& args); Result ParseSigstop(std::vector&& args); Result ParseSocket(std::vector&& args); Result ParseStdioToKmsg(std::vector&& args); Result ParseTaskProfiles(std::vector&& args); Result ParseTimeoutPeriod(std::vector&& args); Result ParseFile(std::vector&& args); Result ParseUser(std::vector&& args); Result ParseWritepid(std::vector&& args); Result ParseUpdatable(std::vector&& args); bool IsValidName(const std::string& name) const; ServiceList* service_list_; Subcontext* subcontext_; std::optional interface_inheritance_hierarchy_; std::unique_ptr service_; std::string filename_; bool from_apex_ = false; }; } // namespace init } // namespace android