1 /* 2 * util-common.h 3 * 4 * Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef PM_UTIL_COMMON_H 21 #define PM_UTIL_COMMON_H 22 23 #include <stdio.h> 24 #include <sys/stat.h> /* struct stat */ 25 26 const char *mbasename(const char *path); 27 char *mdirname(const char *path); 28 29 int llstat(char *path, struct stat *buf); 30 31 char *safe_fgets(char *s, int size, FILE *stream); 32 33 size_t strtrim(char *str); 34 35 #ifndef HAVE_STRNDUP 36 char *strndup(const char *s, size_t n); 37 #endif 38 39 #define ARRAYSIZE(a) (sizeof (a) / sizeof (a[0])) 40 41 #endif /* PM_UTIL_COMMON_H */ 42