1 /* wdefines.h
2  * This file belongs to Worker, a file manager for UN*X/X11.
3  * Copyright (C) 2001-2012 Ralf Hoffmann.
4  * You can contact me at: ralf@boomerangsworld.de
5  *   or http://www.boomerangsworld.de/worker
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef WDEFINES_H
23 #define WDEFINES_H
24 
25 #ifndef CONFIG_H_INCLUDED
26 #  include <aguix/aguixconfig.h>
27 #  define CONFIG_H_INCLUDED
28 #endif
29 
30 #include "worker_lfs.h"
31 
32 #ifdef HAVE_AVFS
33 extern "C" {
34 #  include <virtual.h>
35 }
36 #endif
37 
38 #include "worker_filefunc.h"
39 
40 /* this following include isn't really needed at all
41  * but the streambuf in (some?) stl implementations
42  * undefing open/close (for whatever reason)
43  * and this leads to problem on system supporting
44  * large files with open to open64 define
45  * including vector from stl (not streambuf directly
46  * because it's not available everywhere) here should
47  * avoid such problems but open in streambuf is not
48  * accessable anymore
49  * TODO: a better solution is highly wanted
50  */
51 #include <vector>
52 
53 #include <unistd.h>
54 #include <time.h>
55 #include <sys/types.h>
56 #include <sys/wait.h>
57 #include <fcntl.h>
58 
59 #ifdef HAVE_SYS_PARAM_H
60   #include <sys/param.h>
61 #endif
62 
63 #include <sys/stat.h>
64 #include <dirent.h>
65 #include <stdio.h>
66 #include <stdlib.h>
67 #include <string.h>
68 #include <strings.h>
69 #include <math.h>
70 #include <time.h>
71 #include <sys/time.h>
72 #include <errno.h>
73 #include <grp.h>
74 #include <pwd.h>
75 #include <fnmatch.h>
76 #include <ctype.h>
77 #include <utime.h>
78 
79 #if defined(HAVE_SYS_STATVFS_H)
80   #include <sys/statvfs.h>
81 #endif
82 #ifdef HAVE_SYS_VFS_H
83   #include <sys/vfs.h>
84 #endif
85 #ifdef HAVE_SYS_MOUNT_H
86   #include <sys/mount.h>
87 #endif
88 #if defined HAVE_SYS_SYSINFO_H && defined HAVE_SYSINFO
89   #include <sys/sysinfo.h>
90 #endif
91 
92 #ifdef HAVE_REGEX
93 #include <regex.h>
94 #endif
95 
96 #include "aguix/aguixdefs.h"
97 
98 #ifdef HAVE_LIBZ
99   #include <zlib.h>
100 #endif
101 
102 #ifdef HAVE_LIBBZ2
103   #include <bzlib.h>
104 #endif
105 
106 #define OUTPUT_BIN "xmessage -file %s"
107 #define TERMINAL_BIN "xterm -e %s"
108 
109 #ifndef LINUX
110   #ifndef ARG_MAX
111     #ifdef _POSIX_ARG_MAX
112       #define ARG_MAX _POSIX_ARG_MAX
113     #else
114       #define ARG_MAX MAXPATHLEN
115     #endif
116   #endif
117 #endif
118 
119 //#define EXE_STRING_LEN ARG_MAX
120 #if ! defined( MAX_CMD_LEN ) || MAX_CMD_LEN < 0
121 #  define EXE_STRING_LEN ( 1024 * 1024 )
122 #elif ( MAX_CMD_LEN < 4096 ) && ( MAX_CMD_LEN < ARG_MAX )
123 #  define EXE_STRING_LEN ARG_MAX
124 #elif MAX_CMD_LEN < ( 10 * 1024 * 1024 )
125 #  define EXE_STRING_LEN MAX_CMD_LEN
126 #else
127 // use this upper limit right now since sometimes the autoconf test gives very large values (like 4GB)
128 #  define EXE_STRING_LEN ( 10 * 1024 * 1024 )
129 #endif
130 
131 #ifdef DEVELOPER
132   #define USEOWNCONFIGFILES
133 #endif
134 
135 #define w_max(a,b) (((a)>(b))?(a):(b))
136 #define w_min(a,b) (((a)<(b))?(a):(b))
137 
138 #if ( ! defined S_ISSOCK  ) && defined S_IFSOCK
139 #  define S_ISSOCK(mode) ( ( (mode) & S_IFMT ) == S_IFSOCK )
140 #endif
141 
142 #if ( ! defined S_ISLNK  ) && defined S_IFLNK
143 #  define S_ISLNK(mode) ( ( (mode) & S_IFMT ) == S_IFLNK )
144 #endif
145 
146 #ifndef HW_VM_FSTAB
147 #define HW_VM_FSTAB "/etc/fstab"
148 #endif
149 #ifndef HW_VM_MTAB
150 #define HW_VM_MTAB "/etc/mtab"
151 #endif
152 #ifndef HW_VM_MOUNT_CMD
153 #define HW_VM_MOUNT_CMD "/bin/mount {f}"
154 #endif
155 #ifndef HW_VM_UNMOUNT_CMD
156 #define HW_VM_UNMOUNT_CMD "/bin/umount {f}"
157 #endif
158 #ifndef HW_VM_EJECT_CMD
159 #define HW_VM_EJECT_CMD "/usr/bin/eject {d}"
160 #endif
161 #ifndef HW_VM_CLOSETRAY_CMD
162 #define HW_VM_CLOSETRAY_CMD "/usr/bin/eject -t {d}"
163 #endif
164 #ifndef HW_VM_PARTS
165 #define HW_VM_PARTS "/proc/partitions"
166 #endif
167 
168 #endif
169