diff options
author | Guido van Rossum <guido@python.org> | 1995-01-10 15:36:38 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-01-10 15:36:38 (GMT) |
commit | a6a1e536acb3769a087dc705e6035f913a28a9ab (patch) | |
tree | fc5e5adfd5ccf222aefea41500e56e7d5b9a5fe5 /Modules/posixmodule.c | |
parent | 5524a59b0930638413ab44b150a3e66818a34cf9 (diff) | |
download | cpython-a6a1e536acb3769a087dc705e6035f913a28a9ab.zip cpython-a6a1e536acb3769a087dc705e6035f913a28a9ab.tar.gz cpython-a6a1e536acb3769a087dc705e6035f913a28a9ab.tar.bz2 |
added bufsize parameter to fdopen and popen
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 0b8a6a8..8631e64 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -868,16 +868,22 @@ posix_popen(self, args) object *self; object *args; { - char *name, *mode; + char *name; + char *mode = "r"; + int bufsize = -1; FILE *fp; - if (!getargs(args, "(ss)", &name, &mode)) + object *f; + if (!newgetargs(args, "s|si", &name, &mode, &bufsize)) return NULL; BGN_SAVE fp = popen(name, mode); END_SAVE if (fp == NULL) return posix_error(); - return newopenfileobject(fp, name, mode, pclose); + f = newopenfileobject(fp, name, mode, pclose); + if (f != NULL) + setfilebufsize(f, bufsize); + return f; } #ifdef HAVE_SETUID @@ -1272,18 +1278,21 @@ posix_fdopen(self, args) { extern int fclose PROTO((FILE *)); int fd; - char *mode; + char *mode = "r"; + int bufsize = -1; FILE *fp; - if (!getargs(args, "(is)", &fd, &mode)) + object *f; + if (!newgetargs(args, "i|si", &fd, &mode, &bufsize)) return NULL; BGN_SAVE fp = fdopen(fd, mode); END_SAVE if (fp == NULL) return posix_error(); - /* From now on, ignore SIGPIPE and let the error checking - do the work. */ - return newopenfileobject(fp, "(fdopen)", mode, fclose); + f = newopenfileobject(fp, "(fdopen)", mode, fclose); + if (f != NULL) + setfilebufsize(f, bufsize); + return f; } static object * @@ -1369,7 +1378,7 @@ static struct methodlist posix_methods[] = { {"getuid", posix_getuid}, {"kill", posix_kill}, #endif /* !NT */ - {"popen", posix_popen}, + {"popen", posix_popen, 1}, #ifdef HAVE_SETUID {"setuid", posix_setuid}, #endif /* HAVE_SETUID */ @@ -1405,7 +1414,7 @@ static struct methodlist posix_methods[] = { {"read", posix_read}, {"write", posix_write}, {"fstat", posix_fstat}, - {"fdopen", posix_fdopen}, + {"fdopen", posix_fdopen, 1}, {"pipe", posix_pipe}, {NULL, NULL} /* Sentinel */ }; |