aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/passwd.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-01-26 05:38:38 +0000
committerChristopher Faylor <me@cgf.cx>2003-01-26 05:38:38 +0000
commit6503705696e9e778fb51b1be354bc879f18ba61c (patch)
treebac2a0b68cb962abf7424d905276e27353624508 /winsup/cygwin/passwd.cc
parentc9b99d0d2a61c0307c25ce16e41f80b2e67d8806 (diff)
downloadnewlib-6503705696e9e778fb51b1be354bc879f18ba61c.zip
newlib-6503705696e9e778fb51b1be354bc879f18ba61c.tar.gz
newlib-6503705696e9e778fb51b1be354bc879f18ba61c.tar.bz2
* include/sys/strace.h (paranoid_printf): Define as not being part of "all"
output. * pwdgrp.h (pwdgrp::next_num): Rename from next_int. Returns true/false if parse operation succeeded. (pwdgrp::reparse): Remove. (pwdgrp::raw_ptr): New function. Returns pointer in line. (pwdgrp::next_num): New functions for parsing other than unsigned long. * grp.cc (pwdgrp::parse_group): Reinstate previous parsing behavior. Don't fill in fields with NULL and assign empty gr_mem to known pointer rather than doing a pointless calloc. Streamline gr_mem parsing. Don't increment curr_lines here. * passwd.cc (pwdgrp::parse_passwd): Use new behavior of next_num. Don't increment curr_lines here. * uinfo.cc (pwdgrp::next_str): Keep returning EOL if out of data. (pwdgrp::reparse): Remove. (pwdgrp::next_num): Rename from next_int. Return bool indicating success of parse, argument returns value parsed. (pwdgrp::add_line): Increment curr_lines here on successful parse. (pwdgrp::load): (from Pierre Humblet) Don't return status. Just report it here.
Diffstat (limited to 'winsup/cygwin/passwd.cc')
-rw-r--r--winsup/cygwin/passwd.cc25
1 files changed, 9 insertions, 16 deletions
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc
index 0b85f95..fe21299 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -37,28 +37,22 @@ static pwdgrp pr (passwd_buf);
bool
pwdgrp::parse_passwd ()
{
- int n;
# define res (*passwd_buf)[curr_lines]
- /* Allocate enough room for the passwd struct and all the strings
- in it in one go */
+
memset (&res, 0, sizeof (res));
+
res.pw_name = next_str ();
res.pw_passwd = next_str ();
- n = next_int ();
- if (n < 0)
+ if (res.pw_name == res.pw_passwd)
return false;
- res.pw_uid = n;
- n = next_int ();
- if (n < 0)
- return false;
- res.pw_gid = n;
- res.pw_comment = 0;
+ (void) next_num (res.pw_uid);
+ (void) next_num (res.pw_gid);
+ res.pw_comment = NULL;
res.pw_gecos = next_str ();
res.pw_dir = next_str ();
res.pw_shell = next_str ();
- curr_lines++;
return true;
# undef res
}
@@ -69,8 +63,7 @@ pwdgrp::parse_passwd ()
void
pwdgrp::read_passwd ()
{
- if (!load ("/etc/passwd"))
- debug_printf ("load failed");
+ load ("/etc/passwd");
char strbuf[128] = "";
bool searchentry = true;
@@ -79,7 +72,7 @@ pwdgrp::read_passwd ()
if (wincap.has_security ())
{
static char NO_COPY pretty_ls[] = "????????:*:-1:-1:";
- pr.add_line (pretty_ls);
+ add_line (pretty_ls);
cygsid tu = cygheap->user.sid ();
tu.string (strbuf);
if (myself->uid == ILLEGAL_UID)
@@ -101,7 +94,7 @@ pwdgrp::read_passwd ()
myself->gid,
strbuf, getenv ("HOME") ?: "");
debug_printf ("Completing /etc/passwd: %s", linebuf);
- pr.add_line (linebuf);
+ add_line (linebuf);
}
return;
}