aruu

[MIRROR] Actual replacement for Busybox | suckless
git clone https://git.daat.foo/aruu.git
Log | Files | Refs | README | LICENSE

accounts.c (490B)


      1 /* see LICENSE file for copyright and license details */
      2 #include "../accounts.h"
      3 
      4 #include <ctype.h>
      5 #include <string.h>
      6 
      7 #define NAME_MAX_ACCT 32
      8 
      9 int
     10 acct_valid_name(const char *name)
     11 {
     12   size_t n = strlen(name);
     13 
     14   if (n == 0 || n > NAME_MAX_ACCT || !(islower((unsigned char)name[0]) || name[0] == '_'))
     15     return 0;
     16   for (; *name; name++)
     17     if (!islower((unsigned char)*name) && !isdigit((unsigned char)*name) && *name != '_'
     18         && *name != '-')
     19       return 0;
     20   return 1;
     21 }