MCPcopy Create free account
hub / github.com/NetHack/NetHack / check_user_string

Function check_user_string

sys/vms/vmsunix.c:385–419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383
384#ifdef SYSCF
385boolean
386check_user_string(const char *userlist)
387{
388 char usrnambuf[BUFSZ];
389 const char *sptr, *p, *q;
390 int ln;
391
392 if (!strcmp(userlist, "*"))
393 return TRUE;
394
395 /* FIXME: ought to use $getjpi or $getuai to retrieve user name here... */
396 Strcpy(usrnambuf, nh_getenv("USER"));
397 ln = (int) strlen(usrnambuf);
398 if (!ln)
399 return FALSE;
400
401 while ((sptr = strstri(userlist, usrnambuf)) != 0) {
402 /* check for full word: start of list or following a space or comma */
403 if ((sptr == userlist || sptr[-1] == ' ' || sptr[-1] == ',')
404 /* and also preceding a space or comma or at end of list */
405 && (sptr[ln] == ' ' || sptr[ln] == ',' || sptr[ln] == '\0'))
406 return TRUE;
407 /* doesn't match full word, but maybe we got a false hit when
408 looking for "jane" in the list "janedoe jane" so keep going */
409 p = strchr(sptr + 1, ' ');
410 q = strchr(sptr + 1, ',');
411 if (!p || (q && q < p))
412 p = q;
413 if (!p)
414 break;
415 userlist = p + 1;
416 }
417
418 return FALSE;
419}
420#endif /* SYSCF */
421
422#if defined(SHELL) || defined(SUSPEND)

Callers 2

doshFunction · 0.70
dosuspendFunction · 0.50

Calls 2

strstriFunction · 0.85
nh_getenvFunction · 0.50

Tested by

no test coverage detected