From 326d93714a71d6c2b1350c18ae585a458e8229cb Mon Sep 17 00:00:00 2001 From: ge Date: Wed, 18 Mar 2026 15:32:52 +0300 Subject: [PATCH] Revert "all: rename module to pwdb" This reverts commit 2d9ec0bf59f0ce8b4cd1f173d3a77b9865f528f9. The name `pwd` is still better, since it matches the name of the corresponding C header file. --- README.md | 2 +- pwdb.c.v => pwd.c.v | 24 ++++++++++++------------ pwdb_test.v => pwd_test.v | 8 ++++---- v.mod | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) rename pwdb.c.v => pwd.c.v (89%) rename pwdb_test.v => pwd_test.v (63%) diff --git a/README.md b/README.md index fb8ed44..ef0579d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Access to the UNIX Password Database -`pwdb` module provides thread-safe access to the UNIX user account and password +`pwd` module provides thread-safe access to the UNIX user account and password database. See [passwd(5)](https://man7.org/linux/man-pages/man5/passwd.5.html), diff --git a/pwdb.c.v b/pwd.c.v similarity index 89% rename from pwdb.c.v rename to pwd.c.v index 3b97e56..8545ac4 100644 --- a/pwdb.c.v +++ b/pwd.c.v @@ -1,24 +1,24 @@ @[has_globals] -module pwdb +module pwd import sync $if windows { - $compile_error('pwdb: MS Windows is not supported') + $compile_error('pwd: MS Windows is not supported') } #include #include -__global pwdb_mutex &sync.Mutex +__global pwd_mutex &sync.Mutex fn init() { - pwdb_mutex = sync.new_mutex() + pwd_mutex = sync.new_mutex() } fn cleanup() { - pwdb_mutex.destroy() - unsafe { free(pwdb_mutex) } + pwd_mutex.destroy() + unsafe { free(pwd_mutex) } } struct C.passwd { @@ -77,9 +77,9 @@ fn make_error(name string, uid int) IError { // get_by_uid returns the passwd database entry by user ID. // If the entry is not found, the EntryNotFoundError error will be returned. pub fn get_by_uid(uid int) !Passwd { - pwdb_mutex.lock() + pwd_mutex.lock() defer { - pwdb_mutex.unlock() + pwd_mutex.unlock() } pw := C.getpwuid(uid) if isnil(pw) { @@ -91,9 +91,9 @@ pub fn get_by_uid(uid int) !Passwd { // get_by_uid returns the passwd database entry by user name. // If the entry is not found, the EntryNotFoundError error will be returned. pub fn get_by_name(name string) !Passwd { - pwdb_mutex.lock() + pwd_mutex.lock() defer { - pwdb_mutex.unlock() + pwd_mutex.unlock() } pw := C.getpwnam(&char(name.str)) if isnil(pw) { @@ -105,11 +105,11 @@ pub fn get_by_name(name string) !Passwd { // get_all returns all entries from passwd database in arbitrary order. pub fn get_all() []Passwd { mut pwds := []Passwd{} - pwdb_mutex.lock() + pwd_mutex.lock() C.setpwent() defer { C.endpwent() - pwdb_mutex.unlock() + pwd_mutex.unlock() } for { pw := C.getpwent() diff --git a/pwdb_test.v b/pwd_test.v similarity index 63% rename from pwdb_test.v rename to pwd_test.v index c3cdab3..376e0ef 100644 --- a/pwdb_test.v +++ b/pwd_test.v @@ -1,17 +1,17 @@ // vtest build: !windows -import pwdb +import pwd fn test_get_by_uid() { - pw := pwdb.get_by_uid(0)! + pw := pwd.get_by_uid(0)! assert pw.name == 'root' } fn test_get_by_name() { - pw := pwdb.get_by_name('root')! + pw := pwd.get_by_name('root')! assert pw.uid == 0 } fn test_get_all() { - pws := pwdb.get_all() + pws := pwd.get_all() assert pws.len > 0 } diff --git a/v.mod b/v.mod index acf8511..f90418f 100644 --- a/v.mod +++ b/v.mod @@ -1,5 +1,5 @@ Module { - name: 'pwdb' + name: 'pwd' description: 'Access to the UNIX password database' version: '0.1.0' license: 'Unlicense'