/* * Copyright (c) 2020 AIIT XUOS Lab * XiUOS is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. * You may obtain a copy of Mulan PSL v2 at: * http://license.coscl.org.cn/MulanPSL2 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ #ifndef __INC_UTILITY_H__ #define __INC_UTILITY_H__ #include #ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif int IsPrefixedWith(char *str, char *prefix); char *RemoveUnsafePrefix(char *file_name); int IsSuffixedWith(char *file_name, char *suffix); int TruncateExtension(char *file_name, char *ext); unsigned char read8(int fd); uint16_t read16Le(int fd); uint32_t read32Le(int fd); uint64_t read64Le(int fd); #endif