13 #include <sys/types.h>
33 #ifndef CSIDL_COMMON_APPDATA
34 #define CSIDL_COMMON_APPDATA 35
66 if (!login) login =
getenv(
"USER");
76 #if defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT)
78 safe_setup_str(
const char *str)
80 if (str == 0) str =
"";
87 setup_passwd(
struct passwd *pwd)
91 safe_setup_str(pwd->pw_name),
92 #ifdef HAVE_ST_PW_PASSWD
93 safe_setup_str(pwd->pw_passwd),
97 #ifdef HAVE_ST_PW_GECOS
98 safe_setup_str(pwd->pw_gecos),
100 safe_setup_str(pwd->pw_dir),
101 safe_setup_str(pwd->pw_shell),
102 #ifdef HAVE_ST_PW_CHANGE
105 #ifdef HAVE_ST_PW_QUOTA
108 #ifdef HAVE_ST_PW_AGE
109 PW_AGE2VAL(pwd->pw_age),
111 #ifdef HAVE_ST_PW_CLASS
112 safe_setup_str(pwd->pw_class),
114 #ifdef HAVE_ST_PW_COMMENT
115 safe_setup_str(pwd->pw_comment),
117 #ifdef HAVE_ST_PW_EXPIRE
145 #if defined(HAVE_GETPWENT)
159 return setup_passwd(pwd);
189 return setup_passwd(pwd);
196 static int passwd_blocking = 0;
201 passwd_blocking = (int)
Qfalse;
211 while (pw = getpwent()) {
220 if (passwd_blocking) {
223 passwd_blocking = (int)
Qtrue;
224 rb_ensure(passwd_iterate, 0, passwd_ensure, 0);
258 else if (pw = getpwent()) {
259 return setup_passwd(pw);
340 if (pw = getpwent()) {
341 return setup_passwd(pw);
349 setup_group(
struct group *grp)
361 safe_setup_str(grp->gr_name),
362 #ifdef HAVE_ST_GR_PASSWD
363 safe_setup_str(grp->gr_passwd),
403 return setup_group(grp);
435 return setup_group(grp);
442 static int group_blocking = 0;
447 group_blocking = (int)
Qfalse;
458 while (pw = getgrent()) {
467 if (group_blocking) {
470 group_blocking = (int)
Qtrue;
471 rb_ensure(group_iterate, 0, group_ensure, 0);
501 else if (grp = getgrent()) {
502 return setup_group(grp);
532 etc_each_group(
VALUE obj)
580 if (gr = getgrent()) {
581 return setup_group(gr);
587 #define numberof(array) (sizeof(array) / sizeof(*(array)))
620 WCHAR path[_MAX_PATH];
622 if (!len)
return Qnil;
682 "name",
"passwd",
"uid",
"gid",
683 #ifdef HAVE_ST_PW_GECOS
687 #ifdef HAVE_ST_PW_CHANGE
690 #ifdef HAVE_ST_PW_QUOTA
693 #ifdef HAVE_ST_PW_AGE
696 #ifdef HAVE_ST_PW_CLASS
699 #ifdef HAVE_ST_PW_COMMENT
702 #ifdef HAVE_ST_PW_EXPIRE
751 #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)
#define rb_tainted_str_new2
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
VALUE rb_struct_define(const char *,...)
static VALUE etc_setpwent(VALUE obj)
static VALUE etc_getpwent(VALUE obj)
static VALUE etc_setgrent(VALUE obj)
VALUE rb_ary_push(VALUE ary, VALUE item)
static VALUE etc_getgrnam(VALUE obj, VALUE nam)
VALUE rb_struct_new(VALUE,...)
void rb_raise(VALUE exc, const char *fmt,...)
static VALUE etc_systmpdir(void)
#define RETURN_ENUMERATOR(obj, argc, argv)
#define CSIDL_COMMON_APPDATA
#define SafeStringValue(v)
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)
void rb_define_const(VALUE, const char *, VALUE)
static VALUE etc_getgrgid(int argc, VALUE *argv, VALUE obj)
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)
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)
VALUE rb_define_module(const char *name)
VALUE rb_filesystem_str_new_cstr(const char *)
static VALUE etc_sysconfdir(VALUE obj)
static VALUE etc_getgrent(VALUE obj)