summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixFCmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tclUnixFCmd.c')
-rw-r--r--unix/tclUnixFCmd.c60
1 files changed, 53 insertions, 7 deletions
diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c
index 27b880e..a517da7 100644
--- a/unix/tclUnixFCmd.c
+++ b/unix/tclUnixFCmd.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixFCmd.c,v 1.54 2006/07/20 06:18:38 das Exp $
+ * RCS: @(#) $Id: tclUnixFCmd.c,v 1.55 2006/09/06 13:23:37 vasiljevic Exp $
*
* Portions of this code were derived from NetBSD source code which has the
* following copyright notice:
@@ -1290,7 +1290,13 @@ GetGroupAttribute(
Tcl_Obj **attributePtrPtr) /* A pointer to return the object with. */
{
Tcl_StatBuf statBuf;
+#ifdef TCL_THREADS
+ int buflen = 512;
+ char buf[512]; /* Should be really using sysconf() to get this size */
+ struct group gr, *groupPtr = NULL;
+#else
struct group *groupPtr;
+#endif
int result;
result = TclpObjStat(fileName, &statBuf);
@@ -1304,7 +1310,13 @@ GetGroupAttribute(
return TCL_ERROR;
}
- groupPtr = getgrgid(statBuf.st_gid); /* INTL: Native. */
+#ifdef TCL_THREADS
+ result = TclpGetGrGid(statBuf.st_gid, &gr, buf, buflen, &groupPtr);
+#else
+ groupPtr = getgrgid(statBuf.st_gid);
+ result = 0;
+#endif
+
if (groupPtr == NULL) {
*attributePtrPtr = Tcl_NewIntObj((int) statBuf.st_gid);
} else {
@@ -1344,7 +1356,13 @@ GetOwnerAttribute(
Tcl_Obj **attributePtrPtr) /* A pointer to return the object with. */
{
Tcl_StatBuf statBuf;
+#ifdef TCL_THREADS
+ int buflen = 512;
+ char buf[512]; /* Should be really using sysconf() to get this size */
+ struct passwd pw, *pwPtr = NULL;
+#else
struct passwd *pwPtr;
+#endif
int result;
result = TclpObjStat(fileName, &statBuf);
@@ -1358,7 +1376,13 @@ GetOwnerAttribute(
return TCL_ERROR;
}
- pwPtr = getpwuid(statBuf.st_uid); /* INTL: Native. */
+#ifdef TCL_THREADS
+ result = TclpGetPwUid(statBuf.st_uid, &pw, buf, buflen, &pwPtr);
+#else
+ pwPtr = getpwuid(statBuf.st_uid);
+ result = 0;
+#endif
+
if (pwPtr == NULL) {
*attributePtrPtr = Tcl_NewIntObj((int) statBuf.st_uid);
} else {
@@ -1447,14 +1471,25 @@ SetGroupAttribute(
if (Tcl_GetLongFromObj(NULL, attributePtr, &gid) != TCL_OK) {
Tcl_DString ds;
- struct group *groupPtr;
+#ifdef TCL_THREADS
+ int buflen = 512; /* Should be really using sysconf() to get this size */
+ char buf[512];
+ struct group gr, *groupPtr = NULL;
+#else
+ struct group *groupPtr = NULL;
+#endif
CONST char *string;
int length;
string = Tcl_GetStringFromObj(attributePtr, &length);
native = Tcl_UtfToExternalDString(NULL, string, length, &ds);
- groupPtr = getgrnam(native); /* INTL: Native. */
+#ifdef TCL_THREADS
+ result = TclpGetGrNam(native, &gr, buf, buflen, &groupPtr); /* INTL: Native. */
+#else
+ groupPtr = getgrnam(native); /* INTL: Native. */
+ result = 0;
+#endif
Tcl_DStringFree(&ds);
if (groupPtr == NULL) {
@@ -1513,14 +1548,25 @@ SetOwnerAttribute(
if (Tcl_GetLongFromObj(NULL, attributePtr, &uid) != TCL_OK) {
Tcl_DString ds;
- struct passwd *pwPtr;
+#ifdef TCL_THREADS
+ int buflen = 512;
+ char buf[512]; /* Should be really using sysconf() to get this size */
+ struct passwd pw, *pwPtr = NULL;
+#else
+ struct passwd *pwPtr = NULL;
+#endif
CONST char *string;
int length;
string = Tcl_GetStringFromObj(attributePtr, &length);
native = Tcl_UtfToExternalDString(NULL, string, length, &ds);
- pwPtr = getpwnam(native); /* INTL: Native. */
+#ifdef TCL_THREADS
+ result = TclpGetPwNam(native, &pw, buf, buflen, &pwPtr); /* INTL: Native. */
+#else
+ pwPtr = getpwnam(native); /* INTL: Native. */
+ result = 0;
+#endif
Tcl_DStringFree(&ds);
if (pwPtr == NULL) {