Last change
on this file since 1158 was 1046, checked in by alloc, 8 years ago |
Daodan: Added Windows MinGW and build batch file
|
File size:
1.1 KB
|
Line | |
---|
1 | # passwd.awk --- access password file information
|
---|
2 | #
|
---|
3 | # Arnold Robbins, arnold@skeeve.com, Public Domain
|
---|
4 | # May 1993
|
---|
5 | # Revised October 2000
|
---|
6 |
|
---|
7 | BEGIN {
|
---|
8 | # tailor this to suit your system
|
---|
9 | _pw_awklib = "/usr/sbin/awk/"
|
---|
10 | }
|
---|
11 |
|
---|
12 | function _pw_init( oldfs, oldrs, olddol0, pwcat, using_fw)
|
---|
13 | {
|
---|
14 | if (_pw_inited)
|
---|
15 | return
|
---|
16 |
|
---|
17 | oldfs = FS
|
---|
18 | oldrs = RS
|
---|
19 | olddol0 = $0
|
---|
20 | using_fw = (PROCINFO["FS"] == "FIELDWIDTHS")
|
---|
21 | FS = ":"
|
---|
22 | RS = "\n"
|
---|
23 |
|
---|
24 | pwcat = _pw_awklib "pwcat"
|
---|
25 | while ((pwcat | getline) > 0) {
|
---|
26 | _pw_byname[$1] = $0
|
---|
27 | _pw_byuid[$3] = $0
|
---|
28 | _pw_bycount[++_pw_total] = $0
|
---|
29 | }
|
---|
30 | close(pwcat)
|
---|
31 | _pw_count = 0
|
---|
32 | _pw_inited = 1
|
---|
33 | FS = oldfs
|
---|
34 | if (using_fw)
|
---|
35 | FIELDWIDTHS = FIELDWIDTHS
|
---|
36 | RS = oldrs
|
---|
37 | $0 = olddol0
|
---|
38 | }
|
---|
39 | function getpwnam(name)
|
---|
40 | {
|
---|
41 | _pw_init()
|
---|
42 | if (name in _pw_byname)
|
---|
43 | return _pw_byname[name]
|
---|
44 | return ""
|
---|
45 | }
|
---|
46 | function getpwuid(uid)
|
---|
47 | {
|
---|
48 | _pw_init()
|
---|
49 | if (uid in _pw_byuid)
|
---|
50 | return _pw_byuid[uid]
|
---|
51 | return ""
|
---|
52 | }
|
---|
53 | function getpwent()
|
---|
54 | {
|
---|
55 | _pw_init()
|
---|
56 | if (_pw_count < _pw_total)
|
---|
57 | return _pw_bycount[++_pw_count]
|
---|
58 | return ""
|
---|
59 | }
|
---|
60 | function endpwent()
|
---|
61 | {
|
---|
62 | _pw_count = 0
|
---|
63 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.