13 #include <sys/types.h> 33 #ifndef CSIDL_COMMON_APPDATA 34 #define CSIDL_COMMON_APPDATA 35 66 if (!login) login =
getenv(
"USER");
83 #if defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT) 85 safe_setup_str(
const char *str)
87 if (str == 0) str =
"";
94 setup_passwd(
struct passwd *pwd)
98 safe_setup_str(pwd->pw_name),
99 #ifdef HAVE_ST_PW_PASSWD
100 safe_setup_str(pwd->pw_passwd),
104 #ifdef HAVE_ST_PW_GECOS
105 safe_setup_str(pwd->pw_gecos),
107 safe_setup_str(pwd->pw_dir),
108 safe_setup_str(pwd->pw_shell),
109 #ifdef HAVE_ST_PW_CHANGE
112 #ifdef HAVE_ST_PW_QUOTA
115 #ifdef HAVE_ST_PW_AGE
116 PW_AGE2VAL(pwd->pw_age),
118 #ifdef HAVE_ST_PW_CLASS
119 safe_setup_str(pwd->pw_class),
121 #ifdef HAVE_ST_PW_COMMENT
122 safe_setup_str(pwd->pw_comment),
124 #ifdef HAVE_ST_PW_EXPIRE
152 #if defined(HAVE_GETPWENT) 166 return setup_passwd(pwd);
196 return setup_passwd(pwd);
203 static int passwd_blocking = 0;
208 passwd_blocking = (int)
Qfalse;
218 while (pw = getpwent()) {
227 if (passwd_blocking) {
230 passwd_blocking = (int)
Qtrue;
231 rb_ensure(passwd_iterate, 0, passwd_ensure, 0);
265 else if (pw = getpwent()) {
266 return setup_passwd(pw);
347 if (pw = getpwent()) {
348 return setup_passwd(pw);
356 setup_group(
struct group *grp)
368 safe_setup_str(grp->gr_name),
369 #ifdef HAVE_ST_GR_PASSWD
370 safe_setup_str(grp->gr_passwd),
410 return setup_group(grp);
442 return setup_group(grp);
449 static int group_blocking = 0;
454 group_blocking = (int)
Qfalse;
465 while (pw = getgrent()) {
474 if (group_blocking) {
477 group_blocking = (int)
Qtrue;
478 rb_ensure(group_iterate, 0, group_ensure, 0);
508 else if (grp = getgrent()) {
509 return setup_group(grp);
539 etc_each_group(
VALUE obj)
587 if (gr = getgrent()) {
588 return setup_group(gr);
594 #define numberof(array) (sizeof(array) / sizeof(*(array))) 627 WCHAR path[_MAX_PATH];
629 if (!len)
return Qnil;
689 "name",
"passwd",
"uid",
"gid",
690 #ifdef HAVE_ST_PW_GECOS
694 #ifdef HAVE_ST_PW_CHANGE
697 #ifdef HAVE_ST_PW_QUOTA
700 #ifdef HAVE_ST_PW_AGE
703 #ifdef HAVE_ST_PW_CLASS
706 #ifdef HAVE_ST_PW_COMMENT
709 #ifdef HAVE_ST_PW_EXPIRE
758 #ifdef HAVE_ST_GR_PASSWD
static VALUE etc_getpwnam(VALUE obj, VALUE nam)
static VALUE etc_endgrent(VALUE obj)
size_t strlen(const char *)
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_external_str_new_with_enc(const char *ptr, long len, rb_encoding *)
VALUE rb_struct_new(VALUE,...)
VALUE rb_ary_push(VALUE ary, VALUE item)
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)
rb_encoding * rb_utf8_encoding(void)
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,...)
rb_encoding * rb_locale_encoding(void)
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)
#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)