comparison src/nt.c @ 867:804517e16990

[xemacs-hg @ 2002-06-05 09:54:39 by ben] Textual renaming: text/char names abbrev.c, alloc.c, buffer.c, buffer.h, bytecode.c, callint.c, casefiddle.c, casetab.c, charset.h, chartab.c, chartab.h, cmds.c, console-gtk.h, console-msw.c, console-msw.h, console-stream.c, console-tty.c, console-x.c, console-x.h, console.h, data.c, device-msw.c, device-x.c, dialog-msw.c, dired-msw.c, dired.c, doc.c, doprnt.c, editfns.c, eldap.c, emodules.c, eval.c, event-Xt.c, event-gtk.c, event-msw.c, event-stream.c, event-unixoid.c, events.c, events.h, file-coding.c, file-coding.h, fileio.c, filelock.c, fns.c, font-lock.c, frame-gtk.c, frame-msw.c, frame-x.c, frame.c, glyphs-eimage.c, glyphs-msw.c, glyphs-x.c, glyphs.c, glyphs.h, gpmevent.c, gui-x.c, gui-x.h, gui.c, gui.h, hpplay.c, indent.c, insdel.c, insdel.h, intl-win32.c, keymap.c, line-number.c, line-number.h, lisp-disunion.h, lisp-union.h, lisp.h, lread.c, lrecord.h, lstream.c, lstream.h, md5.c, menubar-msw.c, menubar-x.c, menubar.c, minibuf.c, mule-ccl.c, mule-charset.c, mule-coding.c, mule-wnnfns.c, ndir.h, nt.c, objects-gtk.c, objects-gtk.h, objects-msw.c, objects-tty.c, objects-x.c, objects.c, objects.h, postgresql.c, print.c, process-nt.c, process-unix.c, process.c, procimpl.h, realpath.c, redisplay-gtk.c, redisplay-msw.c, redisplay-output.c, redisplay-tty.c, redisplay-x.c, redisplay.c, redisplay.h, regex.c, search.c, select-common.h, select-gtk.c, select-x.c, sound.h, symbols.c, syntax.c, syntax.h, sysdep.c, sysdep.h, sysdir.h, sysfile.h, sysproc.h, syspwd.h, systime.h, syswindows.h, termcap.c, tests.c, text.c, text.h, toolbar-common.c, tooltalk.c, ui-gtk.c, unexnt.c, unicode.c, win32.c: Text/char naming rationalization. [a] distinguish between "charptr" when it refers to operations on the pointer itself and when it refers to operations on text; and [b] use consistent naming for everything referring to internal format, i.e. Itext == text in internal format Ibyte == a byte in such text Ichar == a char as represented in internal character format thus e.g. set_charptr_emchar -> set_itext_ichar The pre and post tags on either side of this change are: pre-internal-format-textual-renaming post-internal-format-textual-renaming See the Internals Manual for details of exactly how this was done, how to handle the change in your workspace, etc.
author ben
date Wed, 05 Jun 2002 09:58:45 +0000
parents 84762348c6f9
children 79c6ff3eef26
comparison
equal deleted inserted replaced
866:613552a02607 867:804517e16990
111 else 111 else
112 return NULL; 112 return NULL;
113 } 113 }
114 114
115 struct passwd * 115 struct passwd *
116 getpwnam (const Intbyte *name) 116 getpwnam (const Ibyte *name)
117 { 117 {
118 struct passwd *pw; 118 struct passwd *pw;
119 119
120 pw = getpwuid (getuid ()); 120 pw = getpwuid (getuid ());
121 if (!pw) 121 if (!pw)
242 initted in process.c, called later in the init process) and pw_shell 242 initted in process.c, called later in the init process) and pw_shell
243 is not used anywhere. */ 243 is not used anywhere. */
244 } 244 }
245 245
246 /* Parse the root part of file name, if present. Return length and 246 /* Parse the root part of file name, if present. Return length and
247 optionally store pointer to Intbyte after root. */ 247 optionally store pointer to Ibyte after root. */
248 static Bytecount 248 static Bytecount
249 parse_root (Intbyte *name, Intbyte **pPath) 249 parse_root (Ibyte *name, Ibyte **pPath)
250 { 250 {
251 Intbyte *start = name; 251 Ibyte *start = name;
252 252
253 if (name == NULL) 253 if (name == NULL)
254 return 0; 254 return 0;
255 255
256 /* find the root name of the volume if given */ 256 /* find the root name of the volume if given */
281 281
282 return name - start; 282 return name - start;
283 } 283 }
284 284
285 /* Get long base name for name; name is assumed to be absolute. */ 285 /* Get long base name for name; name is assumed to be absolute. */
286 static Intbyte * 286 static Ibyte *
287 get_long_basename (Intbyte *name) 287 get_long_basename (Ibyte *name)
288 { 288 {
289 WIN32_FIND_DATAW find_data; 289 WIN32_FIND_DATAW find_data;
290 HANDLE dir_handle; 290 HANDLE dir_handle;
291 Extbyte *nameext; 291 Extbyte *nameext;
292 292
296 296
297 C_STRING_TO_TSTR (name, nameext); 297 C_STRING_TO_TSTR (name, nameext);
298 dir_handle = qxeFindFirstFile (nameext, &find_data); 298 dir_handle = qxeFindFirstFile (nameext, &find_data);
299 if (dir_handle != INVALID_HANDLE_VALUE) 299 if (dir_handle != INVALID_HANDLE_VALUE)
300 { 300 {
301 Intbyte *fileint; 301 Ibyte *fileint;
302 302
303 TSTR_TO_C_STRING_MALLOC (find_data.cFileName, fileint); 303 TSTR_TO_C_STRING_MALLOC (find_data.cFileName, fileint);
304 FindClose (dir_handle); 304 FindClose (dir_handle);
305 return fileint; 305 return fileint;
306 } 306 }
307 return 0; 307 return 0;
308 } 308 }
309 309
310 /* Get long name for file, if possible (assumed to be absolute). */ 310 /* Get long name for file, if possible (assumed to be absolute). */
311 Intbyte * 311 Ibyte *
312 mswindows_get_long_filename (Intbyte *name) 312 mswindows_get_long_filename (Ibyte *name)
313 { 313 {
314 Intbyte *full = mswindows_canonicalize_filename (name); 314 Ibyte *full = mswindows_canonicalize_filename (name);
315 Intbyte *p; 315 Ibyte *p;
316 Intbyte *q; 316 Ibyte *q;
317 DECLARE_EISTRING (o); 317 DECLARE_EISTRING (o);
318 Bytecount len; 318 Bytecount len;
319 319
320 /* Copy root part verbatim. */ 320 /* Copy root part verbatim. */
321 len = parse_root (full, &p); 321 len = parse_root (full, &p);
322 eicpy_raw (o, full, len); 322 eicpy_raw (o, full, len);
323 323
324 while (p != NULL && *p) 324 while (p != NULL && *p)
325 { 325 {
326 Intbyte *component; 326 Ibyte *component;
327 327
328 q = p; 328 q = p;
329 p = qxestrchr (q, '\\'); 329 p = qxestrchr (q, '\\');
330 if (p) *p = '\0'; 330 if (p) *p = '\0';
331 component = get_long_basename (full); 331 component = get_long_basename (full);
349 xfree (full); 349 xfree (full);
350 return eicpyout_malloc (o, 0); 350 return eicpyout_malloc (o, 0);
351 } 351 }
352 352
353 static int 353 static int
354 is_unc_volume (const Intbyte *filename) 354 is_unc_volume (const Ibyte *filename)
355 { 355 {
356 const Intbyte *ptr = filename; 356 const Ibyte *ptr = filename;
357 357
358 if (!IS_DIRECTORY_SEP (ptr[0]) || !IS_DIRECTORY_SEP (ptr[1]) || !ptr[2]) 358 if (!IS_DIRECTORY_SEP (ptr[0]) || !IS_DIRECTORY_SEP (ptr[1]) || !ptr[2])
359 return 0; 359 return 0;
360 360
361 if (qxestrpbrk (ptr + 2, "*?|<>\"\\/")) 361 if (qxestrpbrk (ptr + 2, "*?|<>\"\\/"))
367 /* NOTE: Value returned is still in external format. Callers need to 367 /* NOTE: Value returned is still in external format. Callers need to
368 convert. */ 368 convert. */
369 #define REG_ROOT "SOFTWARE\\XEmacs\\XEmacs" 369 #define REG_ROOT "SOFTWARE\\XEmacs\\XEmacs"
370 370
371 static LPBYTE 371 static LPBYTE
372 nt_get_resource (Intbyte *key, LPDWORD lpdwtype) 372 nt_get_resource (Ibyte *key, LPDWORD lpdwtype)
373 { 373 {
374 LPBYTE lpvalue; 374 LPBYTE lpvalue;
375 HKEY hrootkey = NULL; 375 HKEY hrootkey = NULL;
376 DWORD cbData; 376 DWORD cbData;
377 Extbyte *keyext; 377 Extbyte *keyext;
474 (lpval = nt_get_resource (env_vars[i], &dwType)) != NULL) 474 (lpval = nt_get_resource (env_vars[i], &dwType)) != NULL)
475 { 475 {
476 if (dwType == REG_EXPAND_SZ) 476 if (dwType == REG_EXPAND_SZ)
477 { 477 {
478 Extbyte *buf = NULL; 478 Extbyte *buf = NULL;
479 Intbyte *envval; 479 Ibyte *envval;
480 Charcount cch; 480 Charcount cch;
481 481
482 cch = qxeExpandEnvironmentStrings ((Extbyte *) lpval, buf, 0); 482 cch = qxeExpandEnvironmentStrings ((Extbyte *) lpval, buf, 0);
483 buf = (Extbyte *) ALLOCA (cch * XETCHAR_SIZE); 483 buf = (Extbyte *) ALLOCA (cch * XETCHAR_SIZE);
484 qxeExpandEnvironmentStrings ((Extbyte *) lpval, buf, cch); 484 qxeExpandEnvironmentStrings ((Extbyte *) lpval, buf, cch);
485 TSTR_TO_C_STRING (buf, envval); 485 TSTR_TO_C_STRING (buf, envval);
486 eputenv (env_vars[i], envval); 486 eputenv (env_vars[i], envval);
487 } 487 }
488 else if (dwType == REG_SZ) 488 else if (dwType == REG_SZ)
489 { 489 {
490 Intbyte *envval; 490 Ibyte *envval;
491 491
492 TSTR_TO_C_STRING (lpval, envval); 492 TSTR_TO_C_STRING (lpval, envval);
493 eputenv (env_vars[i], envval); 493 eputenv (env_vars[i], envval);
494 } 494 }
495 495
512 EXTERNAL_LIST_LOOP (tail, Vprocess_environment) 512 EXTERNAL_LIST_LOOP (tail, Vprocess_environment)
513 { 513 {
514 Lisp_Object str = XCAR (tail); 514 Lisp_Object str = XCAR (tail);
515 if (STRINGP (str)) 515 if (STRINGP (str))
516 { 516 {
517 Intbyte *dat = XSTRING_DATA (str); 517 Ibyte *dat = XSTRING_DATA (str);
518 if (qxestrncasecmp (dat, "PATH=", 5) == 0) 518 if (qxestrncasecmp (dat, "PATH=", 5) == 0)
519 memcpy (dat, "PATH=", 5); 519 memcpy (dat, "PATH=", 5);
520 else if (qxestrncasecmp (dat, "COMSPEC=", 8) == 0) 520 else if (qxestrncasecmp (dat, "COMSPEC=", 8) == 0)
521 memcpy (dat, "COMSPEC=", 8); 521 memcpy (dat, "COMSPEC=", 8);
522 } 522 }
562 562
563 /* time when info was obtained */ 563 /* time when info was obtained */
564 DWORD timestamp; 564 DWORD timestamp;
565 565
566 /* actual volume info */ 566 /* actual volume info */
567 Intbyte *root_dir; 567 Ibyte *root_dir;
568 DWORD serialnum; 568 DWORD serialnum;
569 DWORD maxcomp; 569 DWORD maxcomp;
570 DWORD flags; 570 DWORD flags;
571 Intbyte *name; 571 Ibyte *name;
572 Intbyte *type; 572 Ibyte *type;
573 } volume_info_data; 573 } volume_info_data;
574 574
575 /* Global referenced by various functions. */ 575 /* Global referenced by various functions. */
576 static volume_info_data volume_info; 576 static volume_info_data volume_info;
577 577
591 591
592 /* Simple linked list with linear search is sufficient. */ 592 /* Simple linked list with linear search is sufficient. */
593 static volume_info_data *volume_cache = NULL; 593 static volume_info_data *volume_cache = NULL;
594 594
595 static volume_info_data * 595 static volume_info_data *
596 lookup_volume_info (Intbyte *root_dir) 596 lookup_volume_info (Ibyte *root_dir)
597 { 597 {
598 volume_info_data *info; 598 volume_info_data *info;
599 599
600 for (info = volume_cache; info; info = info->next) 600 for (info = volume_cache; info; info = info->next)
601 if (qxestrcasecmp_i18n (info->root_dir, root_dir) == 0) 601 if (qxestrcasecmp_i18n (info->root_dir, root_dir) == 0)
602 break; 602 break;
603 return info; 603 return info;
604 } 604 }
605 605
606 static void 606 static void
607 add_volume_info (Intbyte *root_dir, volume_info_data *info) 607 add_volume_info (Ibyte *root_dir, volume_info_data *info)
608 { 608 {
609 info->root_dir = qxestrdup (root_dir); 609 info->root_dir = qxestrdup (root_dir);
610 info->next = volume_cache; 610 info->next = volume_cache;
611 volume_cache = info; 611 volume_cache = info;
612 } 612 }
614 614
615 /* Wrapper for GetVolumeInformation, which uses caching to avoid 615 /* Wrapper for GetVolumeInformation, which uses caching to avoid
616 performance penalty (~2ms on 486 for local drives, 7.5ms for local 616 performance penalty (~2ms on 486 for local drives, 7.5ms for local
617 cdrom drive, ~5-10ms or more for remote drives on LAN). */ 617 cdrom drive, ~5-10ms or more for remote drives on LAN). */
618 static volume_info_data * 618 static volume_info_data *
619 get_cached_volume_information (Intbyte *root_dir) 619 get_cached_volume_information (Ibyte *root_dir)
620 { 620 {
621 volume_info_data *info; 621 volume_info_data *info;
622 Intbyte *default_root; 622 Ibyte *default_root;
623 623
624 /* NULL for root_dir means use root from current directory. */ 624 /* NULL for root_dir means use root from current directory. */
625 if (root_dir == NULL) 625 if (root_dir == NULL)
626 { 626 {
627 Charcount nchars = qxeGetCurrentDirectory (0, NULL); 627 Charcount nchars = qxeGetCurrentDirectory (0, NULL);
658 658
659 /* Map drive letter to UNC if remote. */ 659 /* Map drive letter to UNC if remote. */
660 if (isalpha (root_dir[0]) && !fixed [DRIVE_INDEX (root_dir[0])]) 660 if (isalpha (root_dir[0]) && !fixed [DRIVE_INDEX (root_dir[0])])
661 { 661 {
662 Extbyte remote_name[256 * XETCHAR_SIZE]; 662 Extbyte remote_name[256 * XETCHAR_SIZE];
663 Intbyte drive[3] = { root_dir[0], ':' }; 663 Ibyte drive[3] = { root_dir[0], ':' };
664 Extbyte *driveext; 664 Extbyte *driveext;
665 665
666 C_STRING_TO_TSTR (drive, driveext); 666 C_STRING_TO_TSTR (drive, driveext);
667 if (qxeWNetGetConnection (driveext, remote_name, 667 if (qxeWNetGetConnection (driveext, remote_name,
668 sizeof (remote_name) / XETCHAR_SIZE) 668 sizeof (remote_name) / XETCHAR_SIZE)
715 } 715 }
716 716
717 /* Get information on the volume where name is held; set path pointer to 717 /* Get information on the volume where name is held; set path pointer to
718 start of pathname in name (past UNC header\volume header if present). */ 718 start of pathname in name (past UNC header\volume header if present). */
719 static int 719 static int
720 get_volume_info (const Intbyte *name, const Intbyte **pPath) 720 get_volume_info (const Ibyte *name, const Ibyte **pPath)
721 { 721 {
722 /* We probably only need a couple of bytes, but let's be generous in 722 /* We probably only need a couple of bytes, but let's be generous in
723 case this function gets changed */ 723 case this function gets changed */
724 Intbyte *temp = alloca_array (Intbyte, qxestrlen (name) + 10); 724 Ibyte *temp = alloca_array (Ibyte, qxestrlen (name) + 10);
725 Intbyte *rootname = NULL; /* default to current volume */ 725 Ibyte *rootname = NULL; /* default to current volume */
726 volume_info_data *info; 726 volume_info_data *info;
727 727
728 if (name == NULL) 728 if (name == NULL)
729 return FALSE; 729 return FALSE;
730 730
737 temp[2] = '\\'; 737 temp[2] = '\\';
738 temp[3] = 0; 738 temp[3] = 0;
739 } 739 }
740 else if (IS_DIRECTORY_SEP (name[0]) && IS_DIRECTORY_SEP (name[1])) 740 else if (IS_DIRECTORY_SEP (name[0]) && IS_DIRECTORY_SEP (name[1]))
741 { 741 {
742 Intbyte *str = temp; 742 Ibyte *str = temp;
743 int slashes = 4; 743 int slashes = 4;
744 rootname = temp; 744 rootname = temp;
745 do 745 do
746 { 746 {
747 if (IS_DIRECTORY_SEP (*name) && --slashes == 0) 747 if (IS_DIRECTORY_SEP (*name) && --slashes == 0)
770 /* XEmacs: Everything referring to map_win32_filename() aka map_w32_filename() 770 /* XEmacs: Everything referring to map_win32_filename() aka map_w32_filename()
771 removed; it was only for NT 3.1, which we hereby do not support. (NT 3.5 771 removed; it was only for NT 3.1, which we hereby do not support. (NT 3.5
772 predates Windows 95!) */ 772 predates Windows 95!) */
773 773
774 static int 774 static int
775 is_exec (const Intbyte *name) 775 is_exec (const Ibyte *name)
776 { 776 {
777 Intbyte *p = qxestrrchr (name, '.'); 777 Ibyte *p = qxestrrchr (name, '.');
778 return (p != NULL && (qxestrcasecmp (p, ".exe") == 0 || 778 return (p != NULL && (qxestrcasecmp (p, ".exe") == 0 ||
779 qxestrcasecmp (p, ".com") == 0 || 779 qxestrcasecmp (p, ".com") == 0 ||
780 qxestrcasecmp (p, ".bat") == 0 || 780 qxestrcasecmp (p, ".bat") == 0 ||
781 qxestrcasecmp (p, ".cmd") == 0)); 781 qxestrcasecmp (p, ".cmd") == 0));
782 } 782 }
786 so we provide them here. */ 786 so we provide them here. */
787 787
788 struct direct dir_static; /* simulated directory contents */ 788 struct direct dir_static; /* simulated directory contents */
789 static HANDLE dir_find_handle = INVALID_HANDLE_VALUE; 789 static HANDLE dir_find_handle = INVALID_HANDLE_VALUE;
790 /* dir_is_fat deleted */ 790 /* dir_is_fat deleted */
791 static Intbyte *dir_pathname; 791 static Ibyte *dir_pathname;
792 static WIN32_FIND_DATAW dir_find_data; 792 static WIN32_FIND_DATAW dir_find_data;
793 793
794 /* Support shares on a network resource as subdirectories of a read-only 794 /* Support shares on a network resource as subdirectories of a read-only
795 root directory. */ 795 root directory. */
796 static HANDLE wnet_enum_handle = INVALID_HANDLE_VALUE; 796 static HANDLE wnet_enum_handle = INVALID_HANDLE_VALUE;
797 static HANDLE open_unc_volume (const Intbyte *); 797 static HANDLE open_unc_volume (const Ibyte *);
798 static Intbyte *read_unc_volume (HANDLE); 798 static Ibyte *read_unc_volume (HANDLE);
799 static int close_unc_volume (HANDLE); 799 static int close_unc_volume (HANDLE);
800 800
801 DIR * 801 DIR *
802 mswindows_opendir (const Intbyte *filename) 802 mswindows_opendir (const Ibyte *filename)
803 { 803 {
804 DIR *dirp; 804 DIR *dirp;
805 805
806 /* Opening is done by FindFirstFile. However, a read is inherent to 806 /* Opening is done by FindFirstFile. However, a read is inherent to
807 this operation, so we defer the open until read time. */ 807 this operation, so we defer the open until read time. */
850 } 850 }
851 851
852 struct direct * 852 struct direct *
853 mswindows_readdir (DIR *dirp) 853 mswindows_readdir (DIR *dirp)
854 { 854 {
855 Intbyte *val; 855 Ibyte *val;
856 int need_to_free = 0; 856 int need_to_free = 0;
857 857
858 if (wnet_enum_handle != INVALID_HANDLE_VALUE) 858 if (wnet_enum_handle != INVALID_HANDLE_VALUE)
859 { 859 {
860 if (!(val = read_unc_volume (wnet_enum_handle))) 860 if (!(val = read_unc_volume (wnet_enum_handle)))
863 } 863 }
864 /* If we aren't dir_finding, do a find-first, otherwise do a find-next. */ 864 /* If we aren't dir_finding, do a find-first, otherwise do a find-next. */
865 else if (dir_find_handle == INVALID_HANDLE_VALUE) 865 else if (dir_find_handle == INVALID_HANDLE_VALUE)
866 { 866 {
867 DECLARE_EISTRING (filename); 867 DECLARE_EISTRING (filename);
868 Emchar lastch; 868 Ichar lastch;
869 869
870 eicpy_rawz (filename, dir_pathname); 870 eicpy_rawz (filename, dir_pathname);
871 lastch = eigetch_char (filename, eicharlen (filename) - 1); 871 lastch = eigetch_char (filename, eicharlen (filename) - 1);
872 if (!IS_DIRECTORY_SEP (lastch)) 872 if (!IS_DIRECTORY_SEP (lastch))
873 eicat_ch (filename, '\\'); 873 eicat_ch (filename, '\\');
914 914
915 return &dir_static; 915 return &dir_static;
916 } 916 }
917 917
918 static HANDLE 918 static HANDLE
919 open_unc_volume (const Intbyte *path) 919 open_unc_volume (const Ibyte *path)
920 { 920 {
921 NETRESOURCEW nr; 921 NETRESOURCEW nr;
922 HANDLE henum; 922 HANDLE henum;
923 int result; 923 int result;
924 924
938 return henum; 938 return henum;
939 else 939 else
940 return INVALID_HANDLE_VALUE; 940 return INVALID_HANDLE_VALUE;
941 } 941 }
942 942
943 static Intbyte * 943 static Ibyte *
944 read_unc_volume (HANDLE henum) 944 read_unc_volume (HANDLE henum)
945 { 945 {
946 int count; 946 int count;
947 int result; 947 int result;
948 Extbyte buf[16384]; 948 Extbyte buf[16384];
949 Intbyte *ptr; 949 Ibyte *ptr;
950 Bytecount bufsize = sizeof (buf); 950 Bytecount bufsize = sizeof (buf);
951 951
952 count = 1; 952 count = 1;
953 /* #### we should just be querying the size and then allocating the 953 /* #### we should just be querying the size and then allocating the
954 right amount, like for all similar API's. but the docs say this ?! 954 right amount, like for all similar API's. but the docs say this ?!
964 if (result != NO_ERROR) 964 if (result != NO_ERROR)
965 return NULL; 965 return NULL;
966 966
967 /* WNetEnumResource returns \\resource\share...skip forward to "share". */ 967 /* WNetEnumResource returns \\resource\share...skip forward to "share". */
968 TSTR_TO_C_STRING (((LPNETRESOURCEW) buf)->lpRemoteName, ptr); 968 TSTR_TO_C_STRING (((LPNETRESOURCEW) buf)->lpRemoteName, ptr);
969 INC_CHARPTR (ptr); 969 INC_IBYTEPTR (ptr);
970 INC_CHARPTR (ptr); 970 INC_IBYTEPTR (ptr);
971 while (*ptr && !IS_DIRECTORY_SEP (charptr_emchar (ptr))) 971 while (*ptr && !IS_DIRECTORY_SEP (itext_ichar (ptr)))
972 INC_CHARPTR (ptr); 972 INC_IBYTEPTR (ptr);
973 INC_CHARPTR (ptr); 973 INC_IBYTEPTR (ptr);
974 974
975 return qxestrdup (ptr); 975 return qxestrdup (ptr);
976 } 976 }
977 977
978 static int 978 static int
983 else 983 else
984 return -1; 984 return -1;
985 } 985 }
986 986
987 static DWORD 987 static DWORD
988 unc_volume_file_attributes (const Intbyte *path) 988 unc_volume_file_attributes (const Ibyte *path)
989 { 989 {
990 HANDLE henum; 990 HANDLE henum;
991 DWORD attrs; 991 DWORD attrs;
992 992
993 henum = open_unc_volume (path); 993 henum = open_unc_volume (path);
1000 1000
1001 return attrs; 1001 return attrs;
1002 } 1002 }
1003 1003
1004 int 1004 int
1005 mswindows_access (const Intbyte *path, int mode) 1005 mswindows_access (const Ibyte *path, int mode)
1006 { 1006 {
1007 DWORD attributes; 1007 DWORD attributes;
1008 1008
1009 /* MSVC implementation doesn't recognize D_OK. */ 1009 /* MSVC implementation doesn't recognize D_OK. */
1010 if (is_unc_volume (path)) 1010 if (is_unc_volume (path))
1049 1049
1050 /* This only works on NTFS volumes, but is useful to have. */ 1050 /* This only works on NTFS volumes, but is useful to have. */
1051 /* #### NT 5.0 has a function CreateHardLink to do this directly, 1051 /* #### NT 5.0 has a function CreateHardLink to do this directly,
1052 and it may do more things. */ 1052 and it may do more things. */
1053 int 1053 int
1054 mswindows_link (const Intbyte *old, const Intbyte *new) 1054 mswindows_link (const Ibyte *old, const Ibyte *new)
1055 { 1055 {
1056 HANDLE fileh; 1056 HANDLE fileh;
1057 int result = -1; 1057 int result = -1;
1058 1058
1059 if (old == NULL || new == NULL) 1059 if (old == NULL || new == NULL)
1123 } 1123 }
1124 1124
1125 /* sys_open() merged into sysdep.c sys_open() */ 1125 /* sys_open() merged into sysdep.c sys_open() */
1126 1126
1127 int 1127 int
1128 mswindows_rename (const Intbyte *oldname, const Intbyte *newname) 1128 mswindows_rename (const Ibyte *oldname, const Ibyte *newname)
1129 { 1129 {
1130 int result; 1130 int result;
1131 Intbyte *temp; 1131 Ibyte *temp;
1132 1132
1133 /* MoveFile on Windows 95 doesn't correctly change the short file name 1133 /* MoveFile on Windows 95 doesn't correctly change the short file name
1134 alias in a number of circumstances (it is not easy to predict when 1134 alias in a number of circumstances (it is not easy to predict when
1135 just by looking at oldname and newname, unfortunately). In these 1135 just by looking at oldname and newname, unfortunately). In these
1136 cases, renaming through a temporary name avoids the problem. 1136 cases, renaming through a temporary name avoids the problem.
1144 the temp name has a long extension to ensure correct renaming. */ 1144 the temp name has a long extension to ensure correct renaming. */
1145 1145
1146 /* XEmacs: We sprintf() part of OLDNAME into part of OLDNAME + a number, 1146 /* XEmacs: We sprintf() part of OLDNAME into part of OLDNAME + a number,
1147 so the following calculation should certainly be enough. */ 1147 so the following calculation should certainly be enough. */
1148 1148
1149 temp = qxestrcpy (alloca_intbytes (2 * qxestrlen (oldname) + 100), oldname); 1149 temp = qxestrcpy (alloca_ibytes (2 * qxestrlen (oldname) + 100), oldname);
1150 1150
1151 if (mswindows_windows9x_p) 1151 if (mswindows_windows9x_p)
1152 { 1152 {
1153 Intbyte *o; 1153 Ibyte *o;
1154 Intbyte *p; 1154 Ibyte *p;
1155 int i = 0; 1155 int i = 0;
1156 1156
1157 if (o = qxestrrchr (oldname, '\\')) 1157 if (o = qxestrrchr (oldname, '\\'))
1158 o++; 1158 o++;
1159 else 1159 else
1160 o = (Intbyte *) oldname; 1160 o = (Ibyte *) oldname;
1161 1161
1162 if (p = qxestrrchr (temp, '\\')) 1162 if (p = qxestrrchr (temp, '\\'))
1163 p++; 1163 p++;
1164 else 1164 else
1165 p = temp; 1165 p = temp;
1207 1207
1208 return result; 1208 return result;
1209 } 1209 }
1210 1210
1211 int 1211 int
1212 mswindows_unlink (const Intbyte *path) 1212 mswindows_unlink (const Ibyte *path)
1213 { 1213 {
1214 Extbyte *pathout; 1214 Extbyte *pathout;
1215 1215
1216 C_STRING_TO_EXTERNAL (path, pathout, Qfile_name); 1216 C_STRING_TO_EXTERNAL (path, pathout, Qfile_name);
1217 /* On Unix, unlink works without write permission. */ 1217 /* On Unix, unlink works without write permission. */
1427 if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 1427 if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1428 permission |= _S_IEXEC; 1428 permission |= _S_IEXEC;
1429 else 1429 else
1430 { 1430 {
1431 #if 0 /* no way of knowing the filename */ 1431 #if 0 /* no way of knowing the filename */
1432 Intbyte *p = qxestrrchr (name, '.'); 1432 Ibyte *p = qxestrrchr (name, '.');
1433 if (p != NULL && 1433 if (p != NULL &&
1434 (qxestrcasecmp (p, ".exe") == 0 || 1434 (qxestrcasecmp (p, ".exe") == 0 ||
1435 qxestrcasecmp (p, ".com") == 0 || 1435 qxestrcasecmp (p, ".com") == 0 ||
1436 qxestrcasecmp (p, ".bat") == 0 || 1436 qxestrcasecmp (p, ".bat") == 0 ||
1437 qxestrcasecmp (p, ".cmd") == 0)) 1437 qxestrcasecmp (p, ".cmd") == 0))
1446 1446
1447 /* MSVC stat function can't cope with UNC names and has other bugs, so 1447 /* MSVC stat function can't cope with UNC names and has other bugs, so
1448 replace it with our own. This also allows us to calculate consistent 1448 replace it with our own. This also allows us to calculate consistent
1449 inode values without hacks in the main Emacs code. */ 1449 inode values without hacks in the main Emacs code. */
1450 int 1450 int
1451 mswindows_stat (const Intbyte *path, struct stat *buf) 1451 mswindows_stat (const Ibyte *path, struct stat *buf)
1452 { 1452 {
1453 Intbyte *name, *r; 1453 Ibyte *name, *r;
1454 WIN32_FIND_DATAW wfd; 1454 WIN32_FIND_DATAW wfd;
1455 HANDLE fh; 1455 HANDLE fh;
1456 DWORD fake_inode; 1456 DWORD fake_inode;
1457 int permission; 1457 int permission;
1458 Bytecount len; 1458 Bytecount len;
1464 { 1464 {
1465 errno = EFAULT; 1465 errno = EFAULT;
1466 return -1; 1466 return -1;
1467 } 1467 }
1468 1468
1469 name = qxestrcpy (alloca_intbytes (qxestrlen (path) + 10), path); 1469 name = qxestrcpy (alloca_ibytes (qxestrlen (path) + 10), path);
1470 errm = SetErrorMode (SEM_FAILCRITICALERRORS 1470 errm = SetErrorMode (SEM_FAILCRITICALERRORS
1471 | SEM_NOOPENFILEERRORBOX); 1471 | SEM_NOOPENFILEERRORBOX);
1472 1472
1473 get_volume_info (name, &path); 1473 get_volume_info (name, &path);
1474 /* must be valid filename, no wild cards or other invalid characters */ 1474 /* must be valid filename, no wild cards or other invalid characters */
1508 Not used later on. */ 1508 Not used later on. */
1509 } 1509 }
1510 else if (rootdir) 1510 else if (rootdir)
1511 { 1511 {
1512 if (!IS_DIRECTORY_SEP (name[len-1])) 1512 if (!IS_DIRECTORY_SEP (name[len-1]))
1513 qxestrcat (name, (Intbyte *) "\\"); 1513 qxestrcat (name, (Ibyte *) "\\");
1514 C_STRING_TO_TSTR (name, nameext); 1514 C_STRING_TO_TSTR (name, nameext);
1515 if (qxeGetDriveType (nameext) < 2) 1515 if (qxeGetDriveType (nameext) < 2)
1516 { 1516 {
1517 SetErrorMode (errm); 1517 SetErrorMode (errm);
1518 errno = ENOENT; 1518 errno = ENOENT;
1543 if (dir_find_handle != INVALID_HANDLE_VALUE 1543 if (dir_find_handle != INVALID_HANDLE_VALUE
1544 && dir_pathname 1544 && dir_pathname
1545 && qxestrncasecmp_i18n (dir_pathname, name, len) == 0 1545 && qxestrncasecmp_i18n (dir_pathname, name, len) == 0
1546 && IS_DIRECTORY_SEP (name[len]) 1546 && IS_DIRECTORY_SEP (name[len])
1547 && qxestrcasecmp_i18n (name + len + 1, 1547 && qxestrcasecmp_i18n (name + len + 1,
1548 (Intbyte *) dir_static.d_name) == 0) 1548 (Ibyte *) dir_static.d_name) == 0)
1549 { 1549 {
1550 /* This was the last entry returned by readdir. */ 1550 /* This was the last entry returned by readdir. */
1551 wfd = dir_find_data; 1551 wfd = dir_find_data;
1552 } 1552 }
1553 else 1553 else
1737 return _utime (filename, &newtimes); 1737 return _utime (filename, &newtimes);
1738 } 1738 }
1739 #endif 1739 #endif
1740 } 1740 }
1741 1741
1742 Intbyte * 1742 Ibyte *
1743 mswindows_getdcwd (int drivelet) 1743 mswindows_getdcwd (int drivelet)
1744 { 1744 {
1745 Extbyte *cwdext; 1745 Extbyte *cwdext;
1746 Intbyte *cwd; 1746 Ibyte *cwd;
1747 1747
1748 if (XEUNICODE_P) 1748 if (XEUNICODE_P)
1749 cwdext = (Extbyte *) _wgetdcwd (drivelet, NULL, 0); 1749 cwdext = (Extbyte *) _wgetdcwd (drivelet, NULL, 0);
1750 else 1750 else
1751 cwdext = _getdcwd (drivelet, NULL, 0); 1751 cwdext = _getdcwd (drivelet, NULL, 0);
1758 /*--------------------------------------------------------------------*/ 1758 /*--------------------------------------------------------------------*/
1759 /* Memory-mapped files */ 1759 /* Memory-mapped files */
1760 /*--------------------------------------------------------------------*/ 1760 /*--------------------------------------------------------------------*/
1761 1761
1762 int 1762 int
1763 open_input_file (file_data *p_file, const Intbyte *filename) 1763 open_input_file (file_data *p_file, const Ibyte *filename)
1764 { 1764 {
1765 /* Synched with FSF 20.6. We fixed some warnings. */ 1765 /* Synched with FSF 20.6. We fixed some warnings. */
1766 HANDLE file; 1766 HANDLE file;
1767 HANDLE file_mapping; 1767 HANDLE file_mapping;
1768 void *file_base; 1768 void *file_base;
1794 1794
1795 return TRUE; 1795 return TRUE;
1796 } 1796 }
1797 1797
1798 int 1798 int
1799 open_output_file (file_data *p_file, const Intbyte *filename, 1799 open_output_file (file_data *p_file, const Ibyte *filename,
1800 unsigned long size) 1800 unsigned long size)
1801 { 1801 {
1802 /* Synched with FSF 20.6. We fixed some warnings. */ 1802 /* Synched with FSF 20.6. We fixed some warnings. */
1803 HANDLE file; 1803 HANDLE file;
1804 HANDLE file_mapping; 1804 HANDLE file_mapping;
1860 return NULL; 1860 return NULL;
1861 } 1861 }
1862 #endif 1862 #endif
1863 1863
1864 void 1864 void
1865 mswindows_executable_type (const Intbyte *filename, int *is_dos_app, 1865 mswindows_executable_type (const Ibyte *filename, int *is_dos_app,
1866 int *is_cygnus_app) 1866 int *is_cygnus_app)
1867 { 1867 {
1868 /* Synched with FSF 20.6. We added MINGW stuff and casts. */ 1868 /* Synched with FSF 20.6. We added MINGW stuff and casts. */
1869 file_data executable; 1869 file_data executable;
1870 Intbyte *p; 1870 Ibyte *p;
1871 1871
1872 /* Default values in case we can't tell for sure. */ 1872 /* Default values in case we can't tell for sure. */
1873 *is_dos_app = FALSE; 1873 *is_dos_app = FALSE;
1874 *is_cygnus_app = FALSE; 1874 *is_cygnus_app = FALSE;
1875 1875
1956 1956
1957 for ( ; imports->Name; imports++) 1957 for ( ; imports->Name; imports++)
1958 { 1958 {
1959 Extbyte *dllname_ext = 1959 Extbyte *dllname_ext =
1960 (Extbyte *) RVA_TO_PTR (imports->Name, section, executable); 1960 (Extbyte *) RVA_TO_PTR (imports->Name, section, executable);
1961 Intbyte *dllname; 1961 Ibyte *dllname;
1962 1962
1963 EXTERNAL_TO_C_STRING (dllname_ext, dllname, Qbinary); 1963 EXTERNAL_TO_C_STRING (dllname_ext, dllname, Qbinary);
1964 1964
1965 /* The exact name of the cygwin dll has changed with 1965 /* The exact name of the cygwin dll has changed with
1966 various releases, but hopefully this will be reasonably 1966 various releases, but hopefully this will be reasonably
1967 future proof. */ 1967 future proof. */
1968 if (qxestrncasecmp (dllname, (Intbyte *) "cygwin", 6) == 0) 1968 if (qxestrncasecmp (dllname, (Ibyte *) "cygwin", 6) == 0)
1969 { 1969 {
1970 *is_cygnus_app = TRUE; 1970 *is_cygnus_app = TRUE;
1971 break; 1971 break;
1972 } 1972 }
1973 } 1973 }
1999 */ 1999 */
2000 (filename)) 2000 (filename))
2001 { 2001 {
2002 Extbyte shortname[MAX_PATH * MAX_XETCHAR_SIZE]; 2002 Extbyte shortname[MAX_PATH * MAX_XETCHAR_SIZE];
2003 Extbyte *fileext; 2003 Extbyte *fileext;
2004 Intbyte *shortint; 2004 Ibyte *shortint;
2005 2005
2006 CHECK_STRING (filename); 2006 CHECK_STRING (filename);
2007 2007
2008 /* first expand it. */ 2008 /* first expand it. */
2009 filename = Fexpand_file_name (filename, Qnil); 2009 filename = Fexpand_file_name (filename, Qnil);
2026 If FILENAME does not exist, return nil. 2026 If FILENAME does not exist, return nil.
2027 All path elements in FILENAME are converted to their long names. 2027 All path elements in FILENAME are converted to their long names.
2028 */ 2028 */
2029 (filename)) 2029 (filename))
2030 { 2030 {
2031 Intbyte *longname, *canon; 2031 Ibyte *longname, *canon;
2032 Lisp_Object ret; 2032 Lisp_Object ret;
2033 2033
2034 CHECK_STRING (filename); 2034 CHECK_STRING (filename);
2035 2035
2036 /* first expand it. */ 2036 /* first expand it. */
2113 } 2113 }
2114 2114
2115 /* determine which drives are fixed, for get_cached_volume_information */ 2115 /* determine which drives are fixed, for get_cached_volume_information */
2116 { 2116 {
2117 /* GetDriveType must have trailing backslash. */ 2117 /* GetDriveType must have trailing backslash. */
2118 Intbyte drive[] = "A:\\"; 2118 Ibyte drive[] = "A:\\";
2119 2119
2120 /* Loop over all possible drive letters */ 2120 /* Loop over all possible drive letters */
2121 while (*drive <= 'Z') 2121 while (*drive <= 'Z')
2122 { 2122 {
2123 Extbyte *driveext; 2123 Extbyte *driveext;