Diff
Not logged in

Differences From Artifact [b3f0ebb189]:

To Artifact [d0be17b503]:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * tclUnixCompat.c
 *
 * Written by: Zoran Vasiljevic (vasiljevic@users.sourceforge.net). 
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclUnixCompat.c,v 1.1.2.6 2006/09/08 11:15:14 vasiljevic Exp $
 *
 */

#include "tclInt.h"
#include "tclPort.h"
#include <pwd.h>
#include <grp.h>








|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * tclUnixCompat.c
 *
 * Written by: Zoran Vasiljevic (vasiljevic@users.sourceforge.net). 
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclUnixCompat.c,v 1.1.2.7 2006/09/08 19:25:13 andreas_kupries Exp $
 *
 */

#include "tclInt.h"
#include "tclPort.h"
#include <pwd.h>
#include <grp.h>
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 * Mutex to lock access to MT-unsafe calls. This is just to protect 
 * our own usage. It does not protect us from others calling the
 * same functions without (or using some different) lock. 
 */

Tcl_Mutex compatLock;

#if (!defined(HAVE_GETHOSTBYNAME_R) && !defined(HAVE_GETHOSTBYADDR_R)) || \
    (!defined(HAVE_GETPWUID_R)      && !defined(HAVE_GETGRGID_R))


/*
 *---------------------------------------------------------------------------
 *
 * CopyArray --
 *







|
|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 * Mutex to lock access to MT-unsafe calls. This is just to protect 
 * our own usage. It does not protect us from others calling the
 * same functions without (or using some different) lock. 
 */

Tcl_Mutex compatLock;

#if (!defined(HAVE_GETHOSTBYNAME_R) || !defined(HAVE_GETHOSTBYADDR_R)) || \
    (!defined(HAVE_GETPWUID_R)      || !defined(HAVE_GETGRGID_R))


/*
 *---------------------------------------------------------------------------
 *
 * CopyArray --
 *
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166

    return len;
}
#endif /* !defined(HAVE_GETHOSTBYNAME_R) && !defined(HAVE_GETHOSTBYADDR_R) && \
    !defined(HAVE_GETPWUID_R) && !defined(HAVE_GETGRGID_R) */


#if !defined(HAVE_GETHOSTBYNAME_R) && !defined(HAVE_GETHOSTBYADDR_R)

/*
 *---------------------------------------------------------------------------
 *
 * CopyHostnent --
 *
 *      Copies string fields of the hostnent structure to the 







|







152
153
154
155
156
157
158
159
160
161
162
163
164
165
166

    return len;
}
#endif /* !defined(HAVE_GETHOSTBYNAME_R) && !defined(HAVE_GETHOSTBYADDR_R) && \
    !defined(HAVE_GETPWUID_R) && !defined(HAVE_GETGRGID_R) */


#if !defined(HAVE_GETHOSTBYNAME_R) || !defined(HAVE_GETHOSTBYADDR_R)

/*
 *---------------------------------------------------------------------------
 *
 * CopyHostnent --
 *
 *      Copies string fields of the hostnent structure to the 
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
    int h_errno;
    return (gethostbyname_r(name, &tsdPtr->hent, tsdPtr->hbuf,
                            sizeof(tsdPtr->hbuf), &hePtr, &h_errno) == 0) ? 
        &tsdPtr->hent : NULL;

#elif defined(HAVE_GETHOSTBYNAME_R_3)
    struct hostent_data data;
    return (gethostbyname_r(host, &tsdPtr->hent, &data) == 0) ?
        &tsdPtr->buf.hent : NULL;
#else
    struct hostent *hePtr;
    Tcl_MutexLock(&compatLock);
    hePtr = gethostbyname(name);
    if (hePtr != NULL) {
        tsdPtr->hent = *hePtr;
        hePtr = &tsdPtr->hent;







|
|







576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
    int h_errno;
    return (gethostbyname_r(name, &tsdPtr->hent, tsdPtr->hbuf,
                            sizeof(tsdPtr->hbuf), &hePtr, &h_errno) == 0) ? 
        &tsdPtr->hent : NULL;

#elif defined(HAVE_GETHOSTBYNAME_R_3)
    struct hostent_data data;
    return (gethostbyname_r(name, &tsdPtr->hent, &data) == 0) ?
        &tsdPtr->hent : NULL;
#else
    struct hostent *hePtr;
    Tcl_MutexLock(&compatLock);
    hePtr = gethostbyname(name);
    if (hePtr != NULL) {
        tsdPtr->hent = *hePtr;
        hePtr = &tsdPtr->hent;