Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b2b44e5b
Commit
b2b44e5b
authored
Dec 18, 1996
by
Roger E. Masse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed.
parent
96bd636a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
28 deletions
+27
-28
Modules/grpmodule.c
Modules/grpmodule.c
+27
-28
No files found.
Modules/grpmodule.c
View file @
b2b44e5b
...
...
@@ -31,29 +31,28 @@ PERFORMANCE OF THIS SOFTWARE.
/* UNIX group file access module */
#include "allobjects.h"
#include "modsupport.h"
#include "Python.h"
#include <sys/types.h>
#include <grp.h>
static
o
bject
*
mkgrent
(
p
)
static
PyO
bject
*
mkgrent
(
p
)
struct
group
*
p
;
{
o
bject
*
v
,
*
w
;
PyO
bject
*
v
,
*
w
;
char
**
member
;
if
((
w
=
newlistobject
(
0
))
==
NULL
)
{
if
((
w
=
PyList_New
(
0
))
==
NULL
)
{
return
NULL
;
}
for
(
member
=
p
->
gr_mem
;
*
member
!=
NULL
;
member
++
)
{
object
*
x
=
newstringobject
(
*
member
);
if
(
x
==
NULL
||
addlistitem
(
w
,
x
)
!=
0
)
{
XDECREF
(
x
);
DECREF
(
w
);
PyObject
*
x
=
PyString_FromString
(
*
member
);
if
(
x
==
NULL
||
PyList_Append
(
w
,
x
)
!=
0
)
{
Py_
XDECREF
(
x
);
Py_
DECREF
(
w
);
return
NULL
;
}
}
v
=
mkv
alue
(
"(sslO)"
,
v
=
Py_BuildV
alue
(
"(sslO)"
,
p
->
gr_name
,
p
->
gr_passwd
,
#if defined(NeXT) && defined(_POSIX_SOURCE) && defined(__LITTLE_ENDIAN__)
...
...
@@ -64,60 +63,60 @@ static object *mkgrent(p)
(
long
)
p
->
gr_gid
,
#endif
w
);
DECREF
(
w
);
Py_
DECREF
(
w
);
return
v
;
}
static
o
bject
*
grp_getgrgid
(
self
,
args
)
o
bject
*
self
,
*
args
;
static
PyO
bject
*
grp_getgrgid
(
self
,
args
)
PyO
bject
*
self
,
*
args
;
{
int
gid
;
struct
group
*
p
;
if
(
!
getintarg
(
args
,
&
gid
))
return
NULL
;
if
((
p
=
getgrgid
(
gid
))
==
NULL
)
{
err_setstr
(
KeyError
,
"getgrgid(): gid not found"
);
PyErr_SetString
(
PyExc_
KeyError
,
"getgrgid(): gid not found"
);
return
NULL
;
}
return
mkgrent
(
p
);
}
static
o
bject
*
grp_getgrnam
(
self
,
args
)
o
bject
*
self
,
*
args
;
static
PyO
bject
*
grp_getgrnam
(
self
,
args
)
PyO
bject
*
self
,
*
args
;
{
char
*
name
;
struct
group
*
p
;
if
(
!
getstrarg
(
args
,
&
name
))
return
NULL
;
if
((
p
=
getgrnam
(
name
))
==
NULL
)
{
err_setstr
(
KeyError
,
"getgrnam(): name not found"
);
PyErr_SetString
(
PyExc_
KeyError
,
"getgrnam(): name not found"
);
return
NULL
;
}
return
mkgrent
(
p
);
}
static
o
bject
*
grp_getgrall
(
self
,
args
)
o
bject
*
self
,
*
args
;
static
PyO
bject
*
grp_getgrall
(
self
,
args
)
PyO
bject
*
self
,
*
args
;
{
o
bject
*
d
;
PyO
bject
*
d
;
struct
group
*
p
;
if
(
!
getnoarg
(
args
))
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
if
((
d
=
newlistobject
(
0
))
==
NULL
)
if
((
d
=
PyList_New
(
0
))
==
NULL
)
return
NULL
;
setgrent
();
while
((
p
=
getgrent
())
!=
NULL
)
{
o
bject
*
v
=
mkgrent
(
p
);
if
(
v
==
NULL
||
addlistitem
(
d
,
v
)
!=
0
)
{
XDECREF
(
v
);
DECREF
(
d
);
PyO
bject
*
v
=
mkgrent
(
p
);
if
(
v
==
NULL
||
PyList_Append
(
d
,
v
)
!=
0
)
{
Py_
XDECREF
(
v
);
Py_
DECREF
(
d
);
return
NULL
;
}
}
return
d
;
}
static
struct
methodlist
grp_methods
[]
=
{
static
PyMethodDef
grp_methods
[]
=
{
{
"getgrgid"
,
grp_getgrgid
},
{
"getgrnam"
,
grp_getgrnam
},
{
"getgrall"
,
grp_getgrall
},
...
...
@@ -127,5 +126,5 @@ static struct methodlist grp_methods[] = {
void
initgrp
()
{
initm
odule
(
"grp"
,
grp_methods
);
Py_InitM
odule
(
"grp"
,
grp_methods
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment