13 #include <sys/types.h>
33 #ifndef CSIDL_COMMON_APPDATA
34 #define CSIDL_COMMON_APPDATA 35
58 if (!login) login =
getenv(
"USER");
68 #if defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT)
70 safe_setup_str(
const char *
str)
72 if (str == 0) str =
"";
79 setup_passwd(
struct passwd *pwd)
83 safe_setup_str(pwd->pw_name),
84 #ifdef HAVE_ST_PW_PASSWD
85 safe_setup_str(pwd->pw_passwd),
89 #ifdef HAVE_ST_PW_GECOS
90 safe_setup_str(pwd->pw_gecos),
92 safe_setup_str(pwd->pw_dir),
93 safe_setup_str(pwd->pw_shell),
94 #ifdef HAVE_ST_PW_CHANGE
97 #ifdef HAVE_ST_PW_QUOTA
100 #ifdef HAVE_ST_PW_AGE
101 PW_AGE2VAL(pwd->pw_age),
103 #ifdef HAVE_ST_PW_CLASS
104 safe_setup_str(pwd->pw_class),
106 #ifdef HAVE_ST_PW_COMMENT
107 safe_setup_str(pwd->pw_comment),
109 #ifdef HAVE_ST_PW_EXPIRE
129 #if defined(HAVE_GETPWENT)
143 return setup_passwd(pwd);
166 return setup_passwd(pwd);
173 static int passwd_blocking = 0;
187 while (pw = getpwent()) {
197 if (passwd_blocking) {
201 rb_ensure(passwd_iterate, 0, passwd_ensure, 0);
230 else if (pw = getpwent()) {
231 return setup_passwd(pw);
321 if (pw = getpwent()) {
322 return setup_passwd(pw);
330 setup_group(
struct group *grp)
342 safe_setup_str(grp->gr_name),
343 #ifdef HAVE_ST_GR_PASSWD
344 safe_setup_str(grp->gr_passwd),
378 return setup_group(grp);
404 return setup_group(grp);
411 static int group_blocking = 0;
425 while (pw = getgrent()) {
435 if (group_blocking) {
439 rb_ensure(group_iterate, 0, group_ensure, 0);
468 else if (grp = getgrent()) {
469 return setup_group(grp);
553 if (gr = getgrent()) {
554 return setup_group(gr);
560 #define numberof(array) (sizeof(array) / sizeof(*(array)))
589 WCHAR
path[_MAX_PATH];
591 if (!len)
return Qnil;
630 "name",
"passwd",
"uid",
"gid",
631 #ifdef HAVE_ST_PW_GECOS
635 #ifdef HAVE_ST_PW_CHANGE
638 #ifdef HAVE_ST_PW_QUOTA
641 #ifdef HAVE_ST_PW_AGE
644 #ifdef HAVE_ST_PW_CLASS
647 #ifdef HAVE_ST_PW_COMMENT
650 #ifdef HAVE_ST_PW_EXPIRE
660 #ifdef HAVE_ST_GR_PASSWD
static VALUE etc_getpwnam(VALUE obj, VALUE nam)
static VALUE etc_endgrent(VALUE obj)
static VALUE etc_group(VALUE obj)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
static VALUE etc_setpwent(VALUE obj)
static VALUE etc_getpwent(VALUE obj)
static VALUE etc_setgrent(VALUE obj)
VALUE rb_struct_new(VALUE,...)
VALUE rb_ary_push(VALUE ary, VALUE item)
static VALUE INT2NUM(int v)
#define RSTRING_PTR(string)
static VALUE etc_getgrnam(VALUE obj, VALUE nam)
void rb_raise(VALUE exc, const char *fmt,...)
static VALUE etc_systmpdir(void)
#define CSIDL_COMMON_APPDATA
VALUE rb_tainted_str_new2(const char *)
static VALUE etc_getpwuid(int argc, VALUE *argv, VALUE obj)
static VALUE etc_passwd(VALUE obj)
VALUE rb_w32_conv_from_wchar(const WCHAR *wstr, rb_encoding *enc)
int rb_block_given_p(void)
static VALUE etc_getgrgid(int argc, VALUE *argv, VALUE obj)
void rb_define_const(VALUE, const char *, VALUE)
UINT rb_w32_system_tmpdir(WCHAR *path, UINT len)
void rb_define_module_function(VALUE module, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a module function for module.
static VALUE etc_getlogin(VALUE obj)
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
void rb_extend_object(VALUE obj, VALUE module)
register unsigned int len
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
void rb_sys_fail(const char *mesg)
static VALUE etc_each_passwd(VALUE obj)
VALUE rb_w32_special_folder(int type)
static VALUE etc_endpwent(VALUE obj)
rb_encoding * rb_filesystem_encoding(void)
#define RETURN_ENUMERATOR(obj, argc, argv)
#define SafeStringValue(v)
VALUE rb_filesystem_str_new_cstr(const char *)
VALUE rb_struct_define(const char *,...)
VALUE rb_define_module(const char *name)
static VALUE etc_sysconfdir(VALUE obj)
static VALUE etc_getgrent(VALUE obj)