1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef _LOGD_LOG_WHITE_BLACK_LIST_H__ 18 #define _LOGD_LOG_WHITE_BLACK_LIST_H__ 19 20 #include <sys/types.h> 21 22 #include <utils/List.h> 23 24 #include <LogBufferElement.h> 25 26 // White and Blacklist 27 28 class Prune { 29 friend class PruneList; 30 31 const uid_t mUid; 32 const pid_t mPid; 33 int cmp(uid_t uid, pid_t pid) const; 34 35 public: 36 static const uid_t uid_all = (uid_t) -1; 37 static const pid_t pid_all = (pid_t) -1; 38 39 Prune(uid_t uid, pid_t pid); 40 getUid()41 uid_t getUid() const { return mUid; } getPid()42 pid_t getPid() const { return mPid; } 43 cmp(LogBufferElement * e)44 int cmp(LogBufferElement *e) const { return cmp(e->getUid(), e->getPid()); } 45 46 // *strp is malloc'd, use free to release 47 void format(char **strp); 48 }; 49 50 typedef android::List<Prune *> PruneCollection; 51 52 class PruneList { 53 PruneCollection mNaughty; 54 PruneCollection mNice; 55 bool mWorstUidEnabled; 56 57 public: 58 PruneList(); 59 ~PruneList(); 60 61 int init(char *str); 62 63 bool naughty(LogBufferElement *element); 64 bool nice(LogBufferElement *element); worstUidEnabled()65 bool worstUidEnabled() const { return mWorstUidEnabled; } 66 67 // *strp is malloc'd, use free to release 68 void format(char **strp); 69 }; 70 71 #endif // _LOGD_LOG_WHITE_BLACK_LIST_H__ 72