getpwent function

Passwd? getpwent()

Read an entry from the user database stream, opening it if necessary.

Repeated calls to getpwent will return the next use in the user database. When all users have been read null will be returned.

Once you have finished reading fromthe stream you MUST call endpwent() to close the stream otherwise a memory leak will occur.

Implementation

Passwd? getpwent() {
  _getpwent ??= Libc()
      .dylib
      .lookupFunction<ffi.Pointer<_passwd> Function(), _dart_getpwent>(
          'getpwent');

  final pwent = _getpwent!();
  if (pwent == ffi.nullptr) {
    return null;
  }
  return _buildPasswd(
      pwent,
      'Error occured attempting to read the next entry from the user '
      'database stream');
}