Mercurial > hg > xemacs-beta
annotate src/sysfile.h @ 5030:422b4b4fb2a6
Winclient updates
| author | Vin Shelton <acs@xemacs.org> |
|---|---|
| date | Thu, 11 Feb 2010 19:33:50 -0500 |
| parents | 4aebb0131297 |
| children | 308d34e9f07d |
| rev | line source |
|---|---|
| 428 | 1 /* |
| 2 Copyright (C) 1995 Free Software Foundation, Inc. | |
| 2421 | 3 Copyright (C) 2000, 2001, 2002, 2004 Ben Wing. |
| 428 | 4 |
| 5 This file is part of XEmacs. | |
| 6 | |
| 7 XEmacs is free software; you can redistribute it and/or modify it | |
| 8 under the terms of the GNU General Public License as published by the | |
| 9 Free Software Foundation; either version 2, or (at your option) any | |
| 10 later version. | |
| 11 | |
| 12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 15 for more details. | |
| 16 | |
| 17 You should have received a copy of the GNU General Public License | |
| 18 along with XEmacs; see the file COPYING. If not, write to | |
| 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 20 Boston, MA 02111-1307, USA. */ | |
| 21 | |
| 22 /* Synched up with: Not really in FSF. */ | |
| 23 | |
| 440 | 24 #ifndef INCLUDED_sysfile_h_ |
| 25 #define INCLUDED_sysfile_h_ | |
| 26 | |
| 771 | 27 /* The anonymous voice of the past says: |
| 28 Must come before sysfile.h | |
| 29 | |
| 30 So instead we just put it here. --ben */ | |
| 31 #ifdef HAVE_LIBGEN_H | |
| 32 #include <libgen.h> | |
| 33 #endif | |
| 34 | |
| 428 | 35 #include <errno.h> |
| 36 | |
| 442 | 37 #ifndef WIN32_NATIVE |
| 573 | 38 # include <sys/errno.h> /* <errno.h> does not always imply this */ |
| 428 | 39 #endif |
| 40 | |
|
4863
5ab6dc5d789e
Fix EOVERFLOW breakage under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
4854
diff
changeset
|
41 /* EOVERFLOW isn't defined on native Windows under VC6 */ |
|
5ab6dc5d789e
Fix EOVERFLOW breakage under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
4854
diff
changeset
|
42 #ifndef EOVERFLOW |
|
5ab6dc5d789e
Fix EOVERFLOW breakage under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
4854
diff
changeset
|
43 # define EOVERFLOW 10139 |
|
5ab6dc5d789e
Fix EOVERFLOW breakage under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
4854
diff
changeset
|
44 #endif |
|
5ab6dc5d789e
Fix EOVERFLOW breakage under Visual Studio 6
Vin Shelton <acs@xemacs.org>
parents:
4854
diff
changeset
|
45 |
| 428 | 46 #ifdef HAVE_UNISTD_H |
| 558 | 47 # include <unistd.h> |
| 428 | 48 #endif |
| 49 | |
| 50 #ifndef INCLUDED_FCNTL | |
| 51 # define INCLUDED_FCNTL | |
| 52 # include <fcntl.h> | |
| 53 #endif /* INCLUDED_FCNTL */ | |
| 54 | |
| 558 | 55 /* The anonymous voice of the past says: |
| 428 | 56 In some systems loading it twice is suicidal. */ |
| 558 | 57 #ifndef INCLUDED_SYS_TYPES |
| 58 # define INCLUDED_SYS_TYPES | |
| 59 # include <sys/types.h> /* some typedefs are used in sys/file.h */ | |
| 60 #endif /* INCLUDED_SYS_TYPES */ | |
| 442 | 61 |
| 62 #ifndef WIN32_NATIVE | |
| 558 | 63 # include <sys/file.h> |
| 442 | 64 #endif |
| 65 | |
| 1467 | 66 /* Some systems (SCO 3.2v5) do #define stat ... in this header. So it |
| 67 _must_ be included before any use of struct stat. Most emacs files | |
| 68 should include sysfile.h. The unex*.c include <sys/stat.h> directly. */ | |
| 428 | 69 #include <sys/stat.h> |
| 442 | 70 |
| 1315 | 71 #ifdef WIN32_ANY |
| 558 | 72 # include <io.h> |
| 73 #endif | |
| 74 | |
| 75 #ifdef WIN32_NATIVE | |
| 76 # include <direct.h> | |
| 77 #else | |
| 442 | 78 /* Some configuration files' definitions for the LOAD_AVE_CVT macro |
| 79 (like sparc.h's) use macros like FSCALE, defined here. */ | |
| 558 | 80 # ifdef HAVE_GTK |
| 462 | 81 /* I hate GTK */ |
| 558 | 82 # undef MIN |
| 83 # undef MAX | |
| 84 # endif /* HAVE_GTK */ | |
| 85 # include <sys/param.h> | |
| 609 | 86 /* As per Martin's recommendation, we do not include this. There was |
| 87 a comment stating that stuff from here was needed on NeXT, Cygwin, | |
| 88 and sunplay.c. However, Cygwin includes this automatically from | |
| 89 fcntl.h, and Martin says that a "conforming" system should never | |
| 90 need this. We will put it back if necessary on systems requiring it. */ | |
| 91 /* # include <sys/fcntl.h> */ | |
| 777 | 92 #endif /* WIN32_NATIVE */ |
| 428 | 93 |
|
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
94 /* Needed for ITEXT_TO_TSTR, MAX_XETCHAR_SIZE below; but syswindows.h |
| 4854 | 95 depends on lisp.h being previously included. */ |
| 96 #if defined (WIN32_ANY) && defined (emacs) | |
| 97 # include "syswindows.h" | |
| 98 #endif | |
| 99 | |
| 428 | 100 #ifndef STDERR_FILENO |
| 101 #define STDIN_FILENO 0 | |
| 102 #define STDOUT_FILENO 1 | |
| 103 #define STDERR_FILENO 2 | |
| 104 #endif | |
| 105 | |
| 106 #ifndef O_RDONLY | |
| 107 #define O_RDONLY 0 | |
| 108 #endif | |
| 109 | |
| 110 #ifndef O_WRONLY | |
| 111 #define O_WRONLY 1 | |
| 112 #endif | |
| 113 | |
| 114 #ifndef O_RDWR | |
| 115 #define O_RDWR 2 | |
| 116 #endif | |
| 117 | |
| 118 /* file opening defaults */ | |
| 119 #ifndef OPEN_BINARY | |
| 120 #ifdef O_BINARY | |
| 121 #define OPEN_BINARY O_BINARY | |
| 122 #else | |
| 123 #define OPEN_BINARY (0) | |
| 124 #endif | |
| 125 #endif | |
| 126 | |
| 127 #ifndef OPEN_TEXT | |
| 128 #ifdef O_TEXT | |
| 129 #define OPEN_TEXT O_TEXT | |
| 130 #else | |
| 131 #define OPEN_TEXT (0) | |
| 132 #endif | |
| 133 #endif | |
| 134 | |
| 135 #ifndef CREAT_MODE | |
| 442 | 136 #ifdef WIN32_NATIVE |
| 428 | 137 #define CREAT_MODE (S_IREAD | S_IWRITE) |
| 138 #else | |
| 139 #define CREAT_MODE (0666) | |
| 140 #endif | |
| 141 #endif | |
| 142 | |
| 143 #ifndef READ_TEXT | |
| 144 #ifdef O_TEXT | |
| 145 #define READ_TEXT "rt" | |
| 146 #else | |
| 147 #define READ_TEXT "r" | |
| 148 #endif | |
| 149 #endif | |
| 150 | |
| 151 #ifndef READ_BINARY | |
| 152 #ifdef O_BINARY | |
| 153 #define READ_BINARY "rb" | |
| 154 #else | |
| 155 #define READ_BINARY "r" | |
| 156 #endif | |
| 157 #endif | |
| 158 | |
| 442 | 159 #ifndef READ_PLUS_TEXT |
| 160 #ifdef O_TEXT | |
| 161 #define READ_PLUS_TEXT "r+t" | |
| 162 #else | |
| 163 #define READ_PLUS_TEXT "r+" | |
| 164 #endif | |
| 165 #endif | |
| 166 | |
| 167 #ifndef READ_PLUS_BINARY | |
| 168 #ifdef O_BINARY | |
| 169 #define READ_PLUS_BINARY "r+b" | |
| 170 #else | |
| 171 #define READ_PLUS_BINARY "r+" | |
| 172 #endif | |
| 173 #endif | |
| 174 | |
| 175 #ifndef WRITE_TEXT | |
| 176 #ifdef O_TEXT | |
| 177 #define WRITE_TEXT "wt" | |
| 178 #else | |
| 179 #define WRITE_TEXT "w" | |
| 180 #endif | |
| 181 #endif | |
| 182 | |
| 428 | 183 #ifndef WRITE_BINARY |
| 184 #ifdef O_BINARY | |
| 185 #define WRITE_BINARY "wb" | |
| 186 #else | |
| 187 #define WRITE_BINARY "w" | |
| 188 #endif | |
| 189 #endif | |
| 190 | |
| 771 | 191 #ifndef APPEND_TEXT |
| 192 #ifdef O_TEXT | |
| 193 #define APPEND_TEXT "at" | |
| 194 #else | |
| 195 #define APPEND_TEXT "a" | |
| 196 #endif | |
| 197 #endif | |
| 198 | |
| 199 #ifndef APPEND_BINARY | |
| 200 #ifdef O_BINARY | |
| 201 #define APPEND_BINARY "ab" | |
| 202 #else | |
| 203 #define APPEND_BINARY "a" | |
| 204 #endif | |
| 205 #endif | |
| 206 | |
| 428 | 207 #ifndef O_NONBLOCK |
| 208 #ifdef O_NDELAY | |
| 209 #define O_NONBLOCK O_NDELAY | |
| 210 #else | |
| 211 #define O_NONBLOCK 04000 | |
| 212 #endif | |
| 213 #endif | |
| 214 | |
| 215 #if !S_IRUSR | |
| 216 # if S_IREAD | |
| 217 # define S_IRUSR S_IREAD | |
| 218 # else | |
| 219 # define S_IRUSR 00400 | |
| 220 # endif | |
| 221 #endif | |
| 222 | |
| 223 #if !S_IWUSR | |
| 224 # if S_IWRITE | |
| 225 # define S_IWUSR S_IWRITE | |
| 226 # else | |
| 227 # define S_IWUSR 00200 | |
| 228 # endif | |
| 229 #endif | |
| 230 | |
| 231 #if !S_IXUSR | |
| 232 # if S_IEXEC | |
| 233 # define S_IXUSR S_IEXEC | |
| 234 # else | |
| 235 # define S_IXUSR 00100 | |
| 236 # endif | |
| 237 #endif | |
| 238 | |
| 239 #ifdef STAT_MACROS_BROKEN | |
| 240 #undef S_ISBLK | |
| 241 #undef S_ISCHR | |
| 242 #undef S_ISDIR | |
| 243 #undef S_ISFIFO | |
| 244 #undef S_ISLNK | |
| 245 #undef S_ISMPB | |
| 246 #undef S_ISMPC | |
| 247 #undef S_ISNWK | |
| 248 #undef S_ISREG | |
| 249 #undef S_ISSOCK | |
| 250 #endif /* STAT_MACROS_BROKEN. */ | |
| 251 | |
| 2526 | 252 #ifdef WIN32_NATIVE |
| 253 /* This is the standard value for S_IFLNK. All of the S_... flags that | |
| 254 exist in the MSVCRT have standard values, so their bit tests will | |
| 255 magically work. */ | |
| 256 #define S_IFLNK 0120000 | |
| 257 #endif | |
| 258 | |
| 428 | 259 #if !defined(S_ISBLK) && defined(S_IFBLK) |
| 260 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) | |
| 261 #endif | |
| 262 #if !defined(S_ISCHR) && defined(S_IFCHR) | |
| 263 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) | |
| 264 #endif | |
| 265 #if !defined(S_ISDIR) && defined(S_IFDIR) | |
| 266 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) | |
| 267 #endif | |
| 268 #if !defined(S_ISREG) && defined(S_IFREG) | |
| 269 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) | |
| 270 #endif | |
| 271 #if !defined(S_ISFIFO) && defined(S_IFIFO) | |
| 272 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) | |
| 273 #endif | |
| 274 #if !defined(S_ISLNK) && defined(S_IFLNK) | |
| 275 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) | |
| 276 #endif | |
| 277 #if !defined(S_ISSOCK) && defined(S_IFSOCK) | |
| 278 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) | |
| 279 #endif | |
| 280 #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */ | |
| 281 #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) | |
| 282 #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) | |
| 283 #endif | |
| 284 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */ | |
| 285 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) | |
| 286 #endif | |
| 287 | |
| 2421 | 288 /* Determining the maximum pathname length. |
| 289 | |
| 290 NOTE: IN GENERAL, YOU SHOULD NOT USE THIS. | |
| 291 If at all possible, avoid using fixed-length buffers of any sort. | |
| 292 You cannot guarantee on many systems that pathnames won't exceed | |
| 293 these limits for one reason or another. | |
| 294 | |
| 295 Unfortunately, there is no universal agreement over whether these | |
| 296 values should include a final null-terminator or not. Even recent | |
| 297 versions of Linux (circa 2002) are switching from the not-including- | |
| 298 terminator kind to the including-terminator kind. So we assume that | |
| 299 the including-terminator kind will be even (usually is), and round | |
| 300 up as necessary. */ | |
| 301 | |
| 302 #define ROUND_UP_TO_EVEN_NUMBER(val) (((val + 1) >> 1) << 1) | |
| 303 #ifdef PATH_MAX | |
| 304 # define QXE_PATH_MAX ROUND_UP_TO_EVEN_NUMBER (PATH_MAX) | |
| 305 #elif defined (_MAX_PATH) | |
| 558 | 306 /* MS Win -- and preferable to _POSIX_PATH_MAX, which is also defined */ |
| 2421 | 307 # define QXE_PATH_MAX ROUND_UP_TO_EVEN_NUMBER (_MAX_PATH) |
| 308 #elif defined (_POSIX_PATH_MAX) | |
| 309 # define QXE_PATH_MAX ROUND_UP_TO_EVEN_NUMBER (_POSIX_PATH_MAX) | |
| 310 #elif defined (MAXPATHLEN) | |
| 311 # define QXE_PATH_MAX ROUND_UP_TO_EVEN_NUMBER (MAXPATHLEN) | |
| 312 #else | |
| 313 # define QXE_PATH_MAX 1024 | |
| 442 | 314 #endif |
| 315 | |
| 4854 | 316 /* Client .c files should use PATH_MAX_INTERNAL or PATH_MAX_TCHAR |
| 2421 | 317 if they must use either one at all. */ |
| 318 | |
| 319 /* Use for internally formatted text, which can potentially have up to | |
| 320 four bytes per character */ | |
| 321 #define PATH_MAX_INTERNAL (QXE_PATH_MAX * MAX_ICHAR_LEN) | |
| 4854 | 322 #ifdef WIN32_ANY |
| 323 /* Use for externally formatted text in TCHAR's. */ | |
| 324 #define PATH_MAX_TCHAR (QXE_PATH_MAX * MAX_XETCHAR_SIZE) | |
| 325 #endif | |
| 2421 | 326 |
| 442 | 327 /* The following definitions are needed under Windows, at least */ |
| 328 #ifndef X_OK | |
| 329 # define X_OK 1 | |
| 330 #endif | |
| 428 | 331 |
| 442 | 332 #ifndef R_OK |
| 333 # define R_OK 4 | |
| 334 #endif | |
| 335 | |
| 771 | 336 #ifndef D_OK |
| 337 # define D_OK 8 | |
| 338 #endif | |
| 339 | |
| 442 | 340 #ifndef W_OK |
| 341 # define W_OK 2 | |
| 342 #endif | |
| 343 | |
| 344 #ifndef F_OK | |
| 345 # define F_OK 0 | |
| 428 | 346 #endif |
| 347 | |
| 348 #ifndef FD_CLOEXEC | |
| 349 # define FD_CLOEXEC 1 | |
| 350 #endif | |
| 351 | |
| 771 | 352 #ifdef emacs |
| 353 | |
| 428 | 354 /* Emacs needs to use its own definitions of certain system calls on |
| 355 some systems (like SunOS 4.1 and USG systems, where the read system | |
| 356 call is interruptible but Emacs expects it not to be; and under | |
| 357 MULE, where all filenames need to be converted to external format). | |
| 358 | |
| 771 | 359 We used to play preprocessor games, but in the long run that just leads |
| 360 you to ruin. So we explicitly put in the new calls, even if the source | |
| 361 gets marginally less pretty. | |
| 428 | 362 |
| 771 | 363 Current files where we don't use retry_ or qxe_ versions: |
| 428 | 364 |
| 771 | 365 -- all sound files except ntplay.c (includes esd.c libsst.[ch] libst.h |
| 366 linuxplay.c sgiplay.c sunplay.c | |
| 367 hpplay.c nas.c) | |
| 368 -- all unex* files | |
| 369 -- lib-src files | |
| 370 */ | |
| 428 | 371 |
| 771 | 372 ssize_t retry_read (int, void *, size_t); |
| 373 ssize_t retry_write (int, const void *, size_t); | |
| 374 int retry_open (const Extbyte *path, int oflag, ...); | |
| 867 | 375 int qxe_open (const Ibyte *path, int oflag, ...); |
| 376 int qxe_interruptible_open (const Ibyte *path, int oflag, int mode); | |
| 771 | 377 int retry_close (int); |
| 378 Bytecount read_allowing_quit (int fildes, void *buf, Bytecount size); | |
| 379 Bytecount write_allowing_quit (int fildes, const void *buf, | |
| 380 Bytecount size); | |
| 428 | 381 |
| 382 /* Now the stdio versions ... */ | |
| 383 | |
| 771 | 384 size_t retry_fread (void *, size_t, size_t, FILE *); |
| 385 size_t retry_fwrite (const void *, size_t, size_t, FILE *); | |
| 2367 | 386 FILE *retry_fopen (const Extbyte *path, const Ascbyte *mode); |
| 387 FILE *qxe_fopen (const Ibyte *path, const Ascbyte *mode); | |
| 771 | 388 int retry_fclose (FILE *); |
| 428 | 389 |
| 390 /* encapsulations: file-information calls */ | |
| 391 | |
| 867 | 392 int qxe_access (const Ibyte *path, int mode); |
| 393 int qxe_eaccess (const Ibyte *path, int mode); | |
| 394 int qxe_lstat (const Ibyte *path, struct stat *buf); | |
| 395 int qxe_readlink (const Ibyte *path, Ibyte *buf, size_t bufsiz); | |
| 771 | 396 int qxe_fstat (int fd, struct stat *buf); |
| 867 | 397 int qxe_stat (const Ibyte *path, struct stat *buf); |
| 2526 | 398 Ibyte *qxe_realpath (const Ibyte *path, Ibyte resolved_path [], |
| 399 Boolint links_only); | |
| 428 | 400 |
| 401 /* encapsulations: file-manipulation calls */ | |
| 402 | |
| 867 | 403 int qxe_chmod (const Ibyte *path, mode_t mode); |
| 771 | 404 |
| 405 #if defined (HAVE_LINK) | |
| 3025 | 406 int qxe_link (const Ibyte *existing, const Ibyte *new_); |
| 771 | 407 #endif /* defined (HAVE_LINK) */ |
| 408 | |
| 3025 | 409 int qxe_rename (const Ibyte *old, const Ibyte *new_); |
| 771 | 410 |
| 411 #if defined (HAVE_SYMLINK) | |
| 867 | 412 int qxe_symlink (const Ibyte *name1, const Ibyte *name2); |
| 771 | 413 #endif /* defined (HAVE_SYMLINK) */ |
| 414 | |
| 867 | 415 int qxe_unlink (const Ibyte *path); |
| 771 | 416 |
| 1467 | 417 /* definition in filemode.c |
| 418 must be declared here to ensure that struct stat is properly formed | |
| 419 on systems like SCO 3.2v5 */ | |
| 420 void filemodestring (struct stat *, char *); | |
| 421 | |
| 2526 | 422 #ifdef WIN32_ANY |
| 423 extern int mswindows_shortcuts_are_symlinks; | |
| 424 #endif | |
| 425 | |
| 771 | 426 #endif /* emacs */ |
| 427 | |
| 428 | |
| 429 #ifndef HAVE_H_ERRNO | |
| 430 extern int h_errno; | |
| 428 | 431 #endif |
| 432 | |
| 771 | 433 #ifndef HAVE_DUP2 |
| 434 int dup2 (int oldd, int newd); | |
| 428 | 435 #endif |
| 436 | |
| 771 | 437 #ifndef HAVE_STRERROR |
| 438 /* X11R6 defines strerror as a macro */ | |
| 439 # ifdef strerror | |
| 440 # undef strerror | |
| 441 # endif | |
| 442 const char *strerror (int); | |
| 428 | 443 #endif |
| 444 | |
| 771 | 445 |
| 446 | |
| 447 /* | |
| 448 DEFAULT_DIRECTORY_SEP is the default value of Vdirectory_sep_char. | |
| 449 DIRECTORY_SEP is the currently preferred separator between elements | |
| 450 of a path, when paths are canonicalized. | |
| 451 DEVICE_SEP is the separator between devices and paths (might not | |
| 452 be defined). | |
| 453 SEPCHAR is the separator between paths in a path search string | |
| 454 (e.g. the PATH environment variable). | |
| 455 IS_DIRECTORY_SEP() returns true if the character is any directory | |
| 456 separator (there might be more than one allowed on a system.). | |
| 457 IS_DEVICE_SEP() returns true if the character is a device separator. | |
| 458 IS_ANY_SEP() returns true if the character is a directory or device | |
| 459 separator. | |
| 460 */ | |
| 461 | |
| 462 /* We used to put some of this stuff in the s+m files for the various | |
| 463 types of MS Windows, but that's disingenuous. The various definitions | |
| 464 above were specifically created for MS Windows, and the "if not, then | |
| 465 let's define the defaults" stuff (formerly in lisp.h) specifically knows | |
| 466 about what is going to get redefined and how, and code all over the | |
| 467 place that works with filenames has to conditionalize on WIN32_NATIVE | |
| 468 anyway. It's much clearer if we put all related definitions in one | |
| 469 place. (In fact, I discovered a number of bugs in the process.) | |
| 470 | |
| 471 S+M files should be used for simple on-off or multiple-choice settings, | |
| 472 or possibly string settings. Anything that gets to the level of | |
| 473 programming should be elsewhere, and anything that ends up having | |
| 474 lots of complicated interactions scattered around in many files should | |
| 475 be consolidated. */ | |
| 476 | |
| 477 #ifdef WIN32_NATIVE | |
| 478 | |
| 479 #define SEPCHAR ';' | |
| 480 #define DEFAULT_DIRECTORY_SEP '\\' | |
| 428 | 481 |
| 3379 | 482 #ifdef emacs |
| 867 | 483 DECLARE_INLINE_HEADER (Ibyte sysfile_get_directory_sep (void)) |
| 771 | 484 { |
| 485 if (!CHARP (Vdirectory_sep_char) | |
| 486 || (XCHAR (Vdirectory_sep_char) != '/' | |
| 487 && XCHAR (Vdirectory_sep_char) != '\\')) | |
| 488 { | |
| 489 warn_when_safe | |
| 490 (Qfile_name, Qerror, | |
| 491 "`directory-sep-char' set to invalid %s: resetting to %c.", | |
| 492 DEFAULT_DIRECTORY_SEP); | |
| 493 Vdirectory_sep_char = make_char (DEFAULT_DIRECTORY_SEP); | |
| 494 } | |
| 495 | |
| 496 return XCHAR (Vdirectory_sep_char); | |
| 497 } | |
| 498 #define DIRECTORY_SEP sysfile_get_directory_sep() | |
| 499 | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4863
diff
changeset
|
500 #define DEFAULT_DIRECTORY_FALLBACK "C:\\" |
|
4736
d261888e5069
Fix Win32 native build after my DEFAULT_DIRECTORY_FALLBACK change, thanks Vin!
Aidan Kehoe <kehoea@parhasard.net>
parents:
4733
diff
changeset
|
501 |
|
d261888e5069
Fix Win32 native build after my DEFAULT_DIRECTORY_FALLBACK change, thanks Vin!
Aidan Kehoe <kehoea@parhasard.net>
parents:
4733
diff
changeset
|
502 #else /* not emacs */ |
| 3379 | 503 |
| 504 /* The above Lisp variables are not available to make-docfile, etc. */ | |
| 505 #define DIRECTORY_SEP DEFAULT_DIRECTORY_SEP | |
| 506 | |
| 507 #endif /* emacs */ | |
| 508 | |
| 771 | 509 #else /* not WIN32_NATIVE */ |
| 510 | |
| 511 #define SEPCHAR ':' | |
| 512 #define DEFAULT_DIRECTORY_SEP '/' | |
| 513 #define DIRECTORY_SEP '/' | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4863
diff
changeset
|
514 #define DEFAULT_DIRECTORY_FALLBACK "/" |
| 771 | 515 |
| 516 #endif /* WIN32_NATIVE */ | |
| 517 | |
| 428 | 518 |
| 1315 | 519 #ifdef WIN32_ANY |
| 771 | 520 |
| 521 #define DEVICE_SEP ':' | |
| 522 | |
| 523 #define IS_DEVICE_SEP(c) ((c) == DEVICE_SEP) | |
| 524 | |
| 3379 | 525 #ifdef emacs |
| 526 | |
| 867 | 527 DECLARE_INLINE_HEADER (int IS_DIRECTORY_SEP (Ichar c)) |
| 771 | 528 { |
| 529 return (c == '/' || c == '\\'); | |
| 530 } | |
| 531 | |
| 867 | 532 DECLARE_INLINE_HEADER (int IS_ANY_SEP (Ichar c)) |
| 771 | 533 { |
| 534 return (c == '/' || c == '\\' || c == ':'); | |
| 535 } | |
| 536 | |
| 3379 | 537 #else /* emacs */ |
| 538 | |
| 539 /* The Ichar typedef is not available to make-docfile, etc. */ | |
| 540 | |
| 541 DECLARE_INLINE_HEADER (int IS_DIRECTORY_SEP (int c)) | |
| 542 { | |
| 543 return (c == '/' || c == '\\'); | |
| 544 } | |
| 545 | |
| 546 DECLARE_INLINE_HEADER (int IS_ANY_SEP (int c)) | |
| 547 { | |
| 548 return (c == '/' || c == '\\' || c == ':'); | |
| 549 } | |
| 550 | |
| 551 #endif | |
| 552 | |
| 1315 | 553 #else /* not WIN32_ANY */ |
| 771 | 554 |
| 555 #define IS_DEVICE_SEP(c) 0 | |
| 556 #define IS_DIRECTORY_SEP(c) ((c) == DIRECTORY_SEP) | |
| 557 #define IS_ANY_SEP(c) IS_DIRECTORY_SEP (c) | |
| 558 | |
| 1315 | 559 #endif /* WIN32_ANY */ |
| 771 | 560 |
| 3368 | 561 /* How long can a source filename be in DOC (including "\037S" at the start |
| 562 and "\n" at the end) ? */ | |
| 563 #define DOC_MAX_FILENAME_LENGTH 2048 | |
| 564 | |
| 565 #ifdef emacs | |
| 566 | |
| 2526 | 567 #if defined (WIN32_NATIVE) |
| 568 #define PATHNAME_RESOLVE_LINKS(path, pathout) \ | |
| 569 do \ | |
| 570 { \ | |
| 571 if (mswindows_shortcuts_are_symlinks) \ | |
| 572 { \ | |
| 573 Ibyte *_prl_path_ = (Ibyte *) (path); \ | |
| 574 Ibyte _prl_path2_[PATH_MAX_INTERNAL]; \ | |
| 575 \ | |
| 576 if (!qxe_realpath (_prl_path_, _prl_path2_, 1)) \ | |
| 577 (pathout) = _prl_path_; \ | |
| 578 else \ | |
| 579 IBYTE_STRING_TO_ALLOCA (_prl_path2_, pathout); \ | |
| 580 } \ | |
| 581 else (pathout) = (Ibyte *) (path); \ | |
| 582 } while (0) | |
| 583 #else | |
| 584 #define PATHNAME_RESOLVE_LINKS(path, pathout) ((pathout) = (Ibyte *) (path)) | |
| 585 #endif | |
| 586 | |
| 587 #define LISP_PATHNAME_RESOLVE_LINKS(path, pathout) \ | |
| 588 PATHNAME_RESOLVE_LINKS (XSTRING_DATA (path), pathout) | |
| 589 | |
| 590 /* The documentation in VC++ claims that the pathname library functions | |
| 591 accept strings in the current locale-specific encoding, but that's | |
| 592 false, because they just call the native Win32 routines directly, which | |
| 593 always use the system-default encoding (which is what Qmswindows_tstr | |
| 594 will give us when not XEUNICODE_P). */ | |
|
4834
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
595 #define PATHNAME_CONVERT_OUT_TSTR(path, pathout) \ |
|
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
596 do \ |
|
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
597 { \ |
|
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
598 const Ibyte *_pco_path_; \ |
|
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
599 PATHNAME_RESOLVE_LINKS (path, _pco_path_); \ |
|
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
600 (pathout) = ITEXT_TO_TSTR (_pco_path_); \ |
|
4834
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
601 } while (0) |
|
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
602 |
|
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
603 #define PATHNAME_CONVERT_OUT_UTF_8(path, pathout) \ |
|
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
604 do \ |
|
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
605 { \ |
|
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
606 const Ibyte *_pco_path_; \ |
|
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
607 PATHNAME_RESOLVE_LINKS (path, _pco_path_); \ |
|
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
608 (pathout) = ITEXT_TO_EXTERNAL (_pco_path_, Qutf_8); \ |
|
4834
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
609 } while (0) |
|
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
610 |
| 2526 | 611 #ifdef WIN32_NATIVE |
|
4834
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
612 #define PATHNAME_CONVERT_OUT(path, pathout) \ |
|
b3ea9c582280
Use new cygwin_conv_path API with Cygwin 1.7 for converting names between Win32 and POSIX, UTF-8-aware, with attendant changes elsewhere
Ben Wing <ben@xemacs.org>
parents:
4759
diff
changeset
|
613 PATHNAME_CONVERT_OUT_TSTR (path, pathout) |
| 2526 | 614 #else |
|
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
615 # define PATHNAME_CONVERT_OUT(path, pathout) \ |
|
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
616 do \ |
|
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
617 { \ |
|
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
618 (pathout) = ITEXT_TO_EXTERNAL (path, Qfile_name); \ |
|
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
619 } while (0) |
| 2526 | 620 #endif |
| 621 | |
| 622 #define LISP_PATHNAME_CONVERT_OUT(path, pathout) \ | |
| 623 PATHNAME_CONVERT_OUT (XSTRING_DATA (path), pathout) | |
| 624 | |
| 771 | 625 #endif /* emacs */ |
| 626 | |
| 440 | 627 #endif /* INCLUDED_sysfile_h_ */ |
