Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

username completion and NIS+



Hi

The patch below adds code to access the passwd database directly with
NIS+ (not doing that was the main reason for the lack of speed under
Solaris 2.x).

The patch does not modify the configure stuff (I don't know how to do
that), I hope Richard will do that (?).

The new code needs the symbol HAVE_NIS_PLUS to be defined, so if you
want to try it, you currently have to add the #define with that symbol
by hand.

Bye
 Sven

P.S.: It's *much* faster, but for me it still takes ~12 seconds...

diff -c Src/zle_tricky.c ../../zsh/Src/zle_tricky.c
*** Src/zle_tricky.c	Thu May 11 10:03:28 1995
--- ../../zsh/Src/zle_tricky.c	Tue Jun  6 12:30:04 1995
***************
*** 47,52 ****
--- 47,55 ----
  dopestring;
  
  #endif
+ #ifdef HAVE_NIS_PLUS
+ #include <rpcsvc/nis.h>
+ #endif
  
  #define inststr(X) inststrlen((X),1,-1)
  
***************
*** 1604,1609 ****
--- 1607,1637 ----
  }
  #endif
  
+ #ifdef HAVE_NIS_PLUS
+ 
+ #define min(A, B)  ((A) < (B) ? (A) : (B))
+ 
+ static int
+ match_username(nis_name table, nis_object *object, void *userdata)
+ {
+     if (errflag)
+ 	return 1;
+     else {
+ 	static char buf[40];
+ 	register entry_col *ec =
+ 	    object->zo_data.objdata_u.en_data.en_cols.en_cols_val;
+ 	register int l = min(ec->ec_value.ec_value_len, 39);
+ 
+ 	memcpy(buf, ec->ec_value.ec_value_val, l);
+ 	buf[l] = '\0';
+ 
+ 	addmatch(dupstring(buf), NULL);
+     }
+     return 0;
+ }
+ #endif
+ 
+ 
  /**/
  void
  maketildelist(void)
***************
*** 1610,1622 ****
  {
      int i;
  
  #ifdef HAVE_NIS
      char domain[YPMAXDOMAIN];
      struct ypall_callback cb;
      dopestring data;
-     FILE *pwf;
-     char buf[BUFSIZ], *p;
-     int skipping;
  
      data.s = fpre;
      data.len = fpl;
--- 1638,1652 ----
  {
      int i;
  
+ #if defined(HAVE_NIS) || defined(HAVE_NIS_PLUS)
+     FILE *pwf;
+     char buf[BUFSIZ], *p;
+     int skipping;
+ 
  #ifdef HAVE_NIS
      char domain[YPMAXDOMAIN];
      struct ypall_callback cb;
      dopestring data;
  
      data.s = fpre;
      data.len = fpl;
***************
*** 1629,1634 ****
--- 1659,1670 ----
  	    if (getpwnam(getdata(n)) == NULL)
  		uremnode(matches, n);*/
      }
+ #else
+     /* Maybe we should turn this string into a #define'd constant...? */
+ 
+     nis_list("passwd.org_dir", EXPAND_NAME|ALL_RESULTS|FOLLOW_LINKS|FOLLOW_PATH,
+ 	     match_username, 0);
+ #endif
      /* Don't forget the non-NIS matches from the flat passwd file */
      if ((pwf = fopen(PASSWD_FILE, "r")) != NULL) {
  	skipping = 0;


--
Sven Wischnowsky                         oberon@xxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author