comparison src/dired.c @ 528:ef4d2466a29c

[xemacs-hg @ 2001-05-10 09:59:45 by ben] implement user-name-all-completions under Windows. xemacs.mak: need another lib (netapi32.lib) for user-name-all-completions. emacs.c: create new function force-debugging-signal (only when DEBUG_XEMACS) to breakpoint or abort to the debugger. mule\mule-coding.el, file-coding.c, file-coding.h, lisp.h: move coding-system-charset to lisp to avoid doc warning. autoload.el, packages.el, startup.el, update-elc-2.el, update-elc.el: Rewrite much of the bootstrapping process to be more robust, and in particular to rebuild the auto-autoloads and custom-loads files no matter what state (including missing) they're currently in. xemacs.mak: remove autoload-building target. Makefile.in.in: remove autoload targets.
author ben
date Thu, 10 May 2001 09:59:57 +0000
parents 223736d75acb
children 0493e9f3c27f
comparison
equal deleted inserted replaced
527:7b35ad872326 528:ef4d2466a29c
32 #include "commands.h" 32 #include "commands.h"
33 #include "elhash.h" 33 #include "elhash.h"
34 #include "regex.h" 34 #include "regex.h"
35 #include "opaque.h" 35 #include "opaque.h"
36 #include "syntax.h" 36 #include "syntax.h"
37
38 #ifdef WIN32_NATIVE
39 #include "syswindows.h"
40 #include <lmaccess.h>
41 #include <lmapibuf.h>
42 #include <lmerr.h>
43 #endif
37 44
38 Lisp_Object Vcompletion_ignored_extensions; 45 Lisp_Object Vcompletion_ignored_extensions;
39 Lisp_Object Qdirectory_files; 46 Lisp_Object Qdirectory_files;
40 Lisp_Object Qfile_name_completion; 47 Lisp_Object Qfile_name_completion;
41 Lisp_Object Qfile_name_all_completions; 48 Lisp_Object Qfile_name_all_completions;
508 return Qt; 515 return Qt;
509 return Fsubstring (bestmatch, Qzero, make_int (bestmatchsize)); 516 return Fsubstring (bestmatch, Qzero, make_int (bestmatchsize));
510 } 517 }
511 518
512 519
513
514 /* The *pwent() functions do not exist on NT. #### The NT equivalent
515 is NetUserEnum(), and rewriting to use it is not hard.*/
516 #ifndef WIN32_NATIVE
517
518 static Lisp_Object user_name_completion (Lisp_Object user, 520 static Lisp_Object user_name_completion (Lisp_Object user,
519 int all_flag, 521 int all_flag,
520 int *uniq); 522 int *uniq);
521 523
522 DEFUN ("user-name-completion", Fuser_name_completion, 1, 1, 0, /* 524 DEFUN ("user-name-completion", Fuser_name_completion, 1, 1, 0, /*
587 } 589 }
588 590
589 static Lisp_Object 591 static Lisp_Object
590 user_name_completion_unwind (Lisp_Object cache_incomplete_p) 592 user_name_completion_unwind (Lisp_Object cache_incomplete_p)
591 { 593 {
594 #ifndef WIN32_NATIVE
592 endpwent (); 595 endpwent ();
593 speed_up_interrupts (); 596 speed_up_interrupts ();
597 #endif
594 598
595 if (! NILP (XCAR (cache_incomplete_p))) 599 if (! NILP (XCAR (cache_incomplete_p)))
596 free_user_cache (&user_cache); 600 free_user_cache (&user_cache);
597 601
598 free_cons (XCONS (cache_incomplete_p)); 602 free_cons (XCONS (cache_incomplete_p));
628 > USER_CACHE_TTL)) 632 > USER_CACHE_TTL))
629 free_user_cache (&user_cache); 633 free_user_cache (&user_cache);
630 634
631 if (!user_cache.user_names) 635 if (!user_cache.user_names)
632 { 636 {
637 #ifndef WIN32_NATIVE
633 struct passwd *pwd; 638 struct passwd *pwd;
639 #else
640 DWORD entriesread;
641 DWORD totalentries;
642 DWORD resume_handle = 0;
643 #endif
644
634 Lisp_Object cache_incomplete_p = noseeum_cons (Qt, Qnil); 645 Lisp_Object cache_incomplete_p = noseeum_cons (Qt, Qnil);
635 int speccount = specpdl_depth (); 646 int speccount = specpdl_depth ();
636 647
648 record_unwind_protect (user_name_completion_unwind, cache_incomplete_p);
649 #ifndef WIN32_NATIVE
637 slow_down_interrupts (); 650 slow_down_interrupts ();
638 setpwent (); 651 setpwent ();
639 record_unwind_protect (user_name_completion_unwind, cache_incomplete_p);
640 while ((pwd = getpwent ())) 652 while ((pwd = getpwent ()))
641 { 653 {
642 QUIT; 654 QUIT;
643 DO_REALLOC (user_cache.user_names, user_cache.size, 655 DO_REALLOC (user_cache.user_names, user_cache.size,
644 user_cache.length + 1, struct user_name); 656 user_cache.length + 1, struct user_name);
647 (user_cache.user_names[user_cache.length].ptr, 659 (user_cache.user_names[user_cache.length].ptr,
648 user_cache.user_names[user_cache.length].len), 660 user_cache.user_names[user_cache.length].len),
649 Qnative); 661 Qnative);
650 user_cache.length++; 662 user_cache.length++;
651 } 663 }
664 #else
665 do
666 {
667 USER_INFO_0 *bufptr;
668 NET_API_STATUS status_status_statui_statum_statu;
669 int i;
670
671 QUIT;
672 status_status_statui_statum_statu =
673 NetUserEnum (NULL, 0, 0, (LPBYTE *) &bufptr, 1024, &entriesread,
674 &totalentries, &resume_handle);
675 if (status_status_statui_statum_statu != NERR_Success &&
676 status_status_statui_statum_statu != ERROR_MORE_DATA)
677 invalid_operation ("Error enumerating users",
678 make_int (GetLastError ()));
679 for (i = 0; i < entriesread; i++)
680 {
681 int nout =
682 WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK,
683 bufptr[i].usri0_name,
684 -1, 0, 0, "~", 0);
685 void *outp = alloca (nout);
686 WideCharToMultiByte (CP_ACP, WC_COMPOSITECHECK,
687 bufptr[i].usri0_name, -1,
688 (LPSTR) outp, nout, "~", 0);
689 DO_REALLOC (user_cache.user_names, user_cache.size,
690 user_cache.length + 1, struct user_name);
691 TO_INTERNAL_FORMAT (C_STRING, outp,
692 MALLOC,
693 (user_cache.
694 user_names[user_cache.length].ptr,
695 user_cache.
696 user_names[user_cache.length].len),
697 Qmswindows_tstr);
698 user_cache.length++;
699 }
700 NetApiBufferFree (bufptr);
701 }
702 while (entriesread != totalentries);
703 #endif
704
652 XCAR (cache_incomplete_p) = Qnil; 705 XCAR (cache_incomplete_p) = Qnil;
653 unbind_to (speccount, Qnil); 706 unbind_to (speccount, Qnil);
654 707
655 EMACS_GET_TIME (user_cache.last_rebuild_time); 708 EMACS_GET_TIME (user_cache.last_rebuild_time);
656 } 709 }
711 return bestmatch; 764 return bestmatch;
712 if (matchcount == 1 && bestmatchsize == user_name_length) 765 if (matchcount == 1 && bestmatchsize == user_name_length)
713 return Qt; 766 return Qt;
714 return Fsubstring (bestmatch, Qzero, make_int (bestmatchsize)); 767 return Fsubstring (bestmatch, Qzero, make_int (bestmatchsize));
715 } 768 }
716 #endif /* ! defined WIN32_NATIVE */
717 769
718 770
719 Lisp_Object 771 Lisp_Object
720 make_directory_hash_table (const char *path) 772 make_directory_hash_table (const char *path)
721 { 773 {
877 defsymbol (&Qfile_attributes, "file-attributes"); 929 defsymbol (&Qfile_attributes, "file-attributes");
878 930
879 DEFSUBR (Fdirectory_files); 931 DEFSUBR (Fdirectory_files);
880 DEFSUBR (Ffile_name_completion); 932 DEFSUBR (Ffile_name_completion);
881 DEFSUBR (Ffile_name_all_completions); 933 DEFSUBR (Ffile_name_all_completions);
882 #ifndef WIN32_NATIVE
883 DEFSUBR (Fuser_name_completion); 934 DEFSUBR (Fuser_name_completion);
884 DEFSUBR (Fuser_name_completion_1); 935 DEFSUBR (Fuser_name_completion_1);
885 DEFSUBR (Fuser_name_all_completions); 936 DEFSUBR (Fuser_name_all_completions);
886 #endif
887 DEFSUBR (Ffile_attributes); 937 DEFSUBR (Ffile_attributes);
888 } 938 }
889 939
890 void 940 void
891 vars_of_dired (void) 941 vars_of_dired (void)