comparison osdep/osdep.h @ 36253:5c8339df2496

Check if path is too long Some buggy libc such as OS/2 kLIBC crashes if path is too long.
author komh
date Mon, 17 Jun 2013 12:27:36 +0000
parents 24c1cedb1de2
children
comparison
equal deleted inserted replaced
36252:2af48d236902 36253:5c8339df2496
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */ 21 */
22 22
23 #ifndef MPLAYER_OSDEP_H 23 #ifndef MPLAYER_OSDEP_H
24 #define MPLAYER_OSDEP_H 24 #define MPLAYER_OSDEP_H
25
26 #include "config.h"
27
28 #if CONFIG_PATH_MAX_CHECK
29 #include <stdio.h> /* fopen() */
30 #include <dirent.h> /* opendir() */
31 #include <io.h> /* open() */
32 #include <fcntl.h> /* open() */
33 #include <string.h> /* strlen() */
34 #include <limits.h> /* PATH_MAX */
35 #include <errno.h> /* errno */
36
37 #define fopen(n, m) \
38 (strlen(n) >= PATH_MAX ? (errno = ENAMETOOLONG, NULL) : (fopen)(n, m))
39
40 #define opendir(n) \
41 (strlen(n) >= PATH_MAX ? (errno = ENOENT, NULL) : (opendir)(n))
42
43 #define open(n, ...) \
44 (strlen(n) >= PATH_MAX ? (errno = ENAMETOOLONG, -1) : \
45 (open)(n, __VA_ARGS__))
46 #endif /* CONFIG_PATH_MAX_CHECK */
25 47
26 #ifdef __OS2__ 48 #ifdef __OS2__
27 #define INCL_DOS 49 #define INCL_DOS
28 #define INCL_DOSDEVIOCTL 50 #define INCL_DOSDEVIOCTL
29 #include <os2.h> 51 #include <os2.h>