Newer
Older
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
(let ((result
(alien-funcall
(extern-alien "getgrgid_r"
(function (* (struct group))
c-call:unsigned-int
(* (struct group))
(* c-call:char)
c-call:unsigned-int))
gid
(addr group-info)
(cast buf (* c-call:char))
2048)))
(unless (zerop (sap-int (alien-sap result)))
(make-group-info
:name (string (cast (slot result 'gr-name) c-call:c-string))
:password (string (cast (slot result 'gr-passwd) c-call:c-string))
:gid (slot result 'gr-gid)
:members (loop :with members = (slot result 'gr-mem)
:for i :from 0
:for member = (deref members i)
:until (zerop (sap-int (alien-sap member)))
:collect (string (cast member c-call:c-string))))))))
(defun unix-getgrgid (gid)
"Return a GROUP-INFO structure for the group identified by GID, or NIL if not found."
(declare (type unix-gid gid))
(let ((result
(alien-funcall
(extern-alien "getgrgid"
(function (* (struct group))
c-call:unsigned-int))
gid)))
(unless (zerop (sap-int (alien-sap result)))
(make-group-info
:name (string (cast (slot result 'gr-name) c-call:c-string))
:password (string (cast (slot result 'gr-passwd) c-call:c-string))
:gid (slot result 'gr-gid)
:members (loop :with members = (slot result 'gr-mem)
:for i :from 0
:for member = (deref members i)
:until (zerop (sap-int (alien-sap member)))
:collect (string (cast member c-call:c-string)))))))
#+solaris
(defun unix-setpwent ()
(void-syscall ("setpwent")))
#+solaris
(defun unix-endpwent ()
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
#+solaris
(defun unix-getpwent ()
(with-alien ((buf (array c-call:char 1024))
(user-info (struct passwd)))
(let ((result
(alien-funcall
(extern-alien "getpwent_r"
(function (* (struct passwd))
(* (struct passwd))
(* c-call:char)
c-call:unsigned-int))
(addr user-info)
(cast buf (* c-call:char))
1024)))
(when (not (zerop (sap-int (alien-sap result))))
(make-user-info
:name (string (cast (slot result 'pw-name) c-call:c-string))
:password (string (cast (slot result 'pw-passwd) c-call:c-string))
:uid (slot result 'pw-uid)
:gid (slot result 'pw-gid)
:age (string (cast (slot result 'pw-age) c-call:c-string))
:comment (string (cast (slot result 'pw-comment) c-call:c-string))
:gecos (string (cast (slot result 'pw-gecos) c-call:c-string))
:dir (string (cast (slot result 'pw-dir) c-call:c-string))
:shell (string (cast (slot result 'pw-shell) c-call:c-string)))))))