* username completion and NIS+
@ 1995-06-06 10:34 Sven Wischnowsky
0 siblings, 0 replies; only message in thread
From: Sven Wischnowsky @ 1995-06-06 10:34 UTC (permalink / raw)
To: zsh-workers
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@cs.tu-berlin.de
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1995-06-06 10:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-06-06 10:34 username completion and NIS+ Sven Wischnowsky
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).