Adding group entry API.

This commit is contained in:
Alex Shinn 2014-03-09 20:29:58 +09:00
parent 9d1f046385
commit 313e82e553
2 changed files with 28 additions and 2 deletions

View file

@ -2,6 +2,7 @@
(define-library (chibi system) (define-library (chibi system)
(export user-information user? user-name user-password (export user-information user? user-name user-password
user-id user-group-id user-gecos user-home user-shell user-id user-group-id user-gecos user-home user-shell
group-information group-name group-password group-id
current-user-id current-group-id current-user-id current-group-id
current-effective-user-id current-effective-group-id current-effective-user-id current-effective-group-id
set-current-user-id! set-current-effective-user-id! set-current-user-id! set-current-effective-user-id!
@ -14,4 +15,8 @@
(define (user-information user) (define (user-information user)
(car (if (string? user) (car (if (string? user)
(getpwnam_r user (make-string 1024)) (getpwnam_r user (make-string 1024))
(getpwuid_r user (make-string 1024))))))) (getpwuid_r user (make-string 1024)))))
(define (group-information group)
(car (if (string? group)
(getgrnam_r group (make-string 1024))
(getgrgid_r group (make-string 1024)))))))

View file

@ -1,9 +1,10 @@
(c-system-include "unistd.h") (c-system-include "unistd.h")
(c-system-include "pwd.h") (c-system-include "pwd.h")
(c-system-include "grp.h")
(c-system-include "sys/types.h") (c-system-include "sys/types.h")
;;> \subsubsubsection{\scheme{(user-information name-or-id)}} ;;> \section{\scheme{(user-information name-or-id)}}
;;> Returns the password entry for the given user. \var{name-or-id} ;;> Returns the password entry for the given user. \var{name-or-id}
;;> should be a string indicating the user name, or an integer ;;> should be a string indicating the user name, or an integer
@ -62,3 +63,23 @@
(link string) (link string)
(value (string-size arg2) int) (value (string-size arg2) int)
(result pointer passwd))) (result pointer passwd)))
(define-c-struct group
predicate: group?
(string gr_name group-name)
(string gr_passwd group-password)
(gid_t gr_gid group-id)
;;((array string) gr_mem group-members)
)
(define-c errno getgrgid_r
(gid_t (result group)
(link string)
(value (string-size arg2) int)
(result pointer group)))
(define-c errno getgrnam_r
(string (result group)
(link string)
(value (string-size arg2) int)
(result pointer group)))