~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to src/port/win32env.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-01 17:41:41 UTC
  • mfrom: (1.1.4 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20090701174141-jfmn9tt8e69m950x
Tags: 8.4.0-1
* Final 8.4.0 release. Major enhancements:
  - Windowing Functions
  - Common Table Expressions and Recursive Queries
  - Default and variadic parameters for functions
  - Parallel Restore
  - Column Permissions
  - Per-database locale settings
  - Improved hash indexes
  - Improved join performance for EXISTS and NOT EXISTS queries
  - Easier-to-use Warm Standby
  - Automatic sizing of the Free Space Map
  - Visibility Map (greatly reduces vacuum overhead for slowly-changing
    tables)
  - Version-aware psql (backslash commands work against older servers)
  - Support SSL certificates for user authentication
  - Per-function runtime statistics
  - Easy editing of functions in psql
  - New contrib modules: pg_stat_statements, auto_explain, citext,
    btree_gin 
  Upload to unstable, 8.4 is the new default. 
* debian/control: Build the versionless metapackages and have them point to
  8.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*-------------------------------------------------------------------------
2
2
 *
3
3
 * win32env.c
4
 
 *    putenv() and unsetenv() for win32, that updates both process
5
 
 *    environment and the cached versions in (potentially multiple)
6
 
 *    MSVCRT.
 
4
 *        putenv() and unsetenv() for win32, that updates both process
 
5
 *        environment and the cached versions in (potentially multiple)
 
6
 *        MSVCRT.
7
7
 *
8
8
 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
9
9
 * Portions Copyright (c) 1994, Regents of the University of California
10
10
 *
11
11
 *
12
12
 * IDENTIFICATION
13
 
 *        $PostgreSQL: pgsql/src/port/win32env.c,v 1.2 2009/02/12 12:53:34 mha Exp $
 
13
 *        $PostgreSQL: pgsql/src/port/win32env.c,v 1.3 2009/06/11 14:49:15 momjian Exp $
14
14
 *
15
15
 *-------------------------------------------------------------------------
16
16
 */
20
20
int
21
21
pgwin32_putenv(const char *envval)
22
22
{
23
 
        char   *envcpy;
24
 
        char   *cp;
 
23
        char       *envcpy;
 
24
        char       *cp;
25
25
 
26
26
        /*
27
27
         * Each version of MSVCRT has its own _putenv() call in the runtime
28
28
         * library.
29
29
         *
30
 
         * If we're in VC 7.0 or later (means != mingw), update in
31
 
         * the 6.0 MSVCRT.DLL environment as well, to work with third party
32
 
         * libraries linked against it (such as gnuwin32 libraries).
 
30
         * If we're in VC 7.0 or later (means != mingw), update in the 6.0
 
31
         * MSVCRT.DLL environment as well, to work with third party libraries
 
32
         * linked against it (such as gnuwin32 libraries).
33
33
         */
34
34
#if defined(_MSC_VER) && (_MSC_VER >= 1300)
35
 
        typedef int             (_cdecl *PUTENVPROC)(const char *);
36
 
        HMODULE                         hmodule;
37
 
        static PUTENVPROC       putenvFunc = NULL;
38
 
        int                                     ret;
 
35
        typedef int (_cdecl * PUTENVPROC) (const char *);
 
36
        HMODULE         hmodule;
 
37
        static PUTENVPROC putenvFunc = NULL;
 
38
        int                     ret;
39
39
 
40
40
        if (putenvFunc == NULL)
41
41
        {
42
42
                hmodule = GetModuleHandle("msvcrt");
43
43
                if (hmodule == NULL)
44
44
                        return 1;
45
 
                putenvFunc = (PUTENVPROC)GetProcAddress(hmodule, "_putenv");
 
45
                putenvFunc = (PUTENVPROC) GetProcAddress(hmodule, "_putenv");
46
46
                if (putenvFunc == NULL)
47
47
                        return 1;
48
48
        }
49
49
        ret = putenvFunc(envval);
50
50
        if (ret != 0)
51
51
                return ret;
52
 
#endif /* _MSC_VER >= 1300 */
 
52
#endif   /* _MSC_VER >= 1300 */
53
53
 
54
54
 
55
55
        /*
56
 
         * Update the process environment - to make modifications visible
57
 
         * to child processes.
 
56
         * Update the process environment - to make modifications visible to child
 
57
         * processes.
58
58
         *
59
59
         * Need a copy of the string so we can modify it.
60
60
         */
68
68
        {
69
69
                /*
70
70
                 * Only call SetEnvironmentVariable() when we are adding a variable,
71
 
                 * not when removing it. Calling it on both crashes on at least certain
72
 
                 * versions of MingW.
 
71
                 * not when removing it. Calling it on both crashes on at least
 
72
                 * certain versions of MingW.
73
73
                 */
74
74
                if (!SetEnvironmentVariable(envcpy, cp))
75
75
                {
86
86
void
87
87
pgwin32_unsetenv(const char *name)
88
88
{
89
 
        char   *envbuf;
 
89
        char       *envbuf;
90
90
 
91
 
        envbuf = (char *) malloc(strlen(name)+2);
 
91
        envbuf = (char *) malloc(strlen(name) + 2);
92
92
        if (!envbuf)
93
93
                return;
94
94
 
96
96
        pgwin32_putenv(envbuf);
97
97
        free(envbuf);
98
98
}
99