*
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.46 2004/07/01 00:51:29 tgl Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.47 2004/08/08 06:44:32 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
        return nstr;
 }
+
+
+#ifdef WIN32
+/*
+ *     Memory support routines for libpgport on Win32
+ *
+ *     Win32 can't load a library that DLLIMPORTs a variable
+ *     if the link object files also DLLIMPORT the same variable.
+ *     For this reason, libpgport can't reference CurrentMemoryContext
+ *     in the palloc macro calls.
+ *
+ *     To fix this, we create several functions here that allow us to
+ *     manage memory without doing the inline in libpgport.
+ */
+void *
+pgport_palloc(Size sz)
+{
+       return palloc(sz);
+}
+
+char *
+pgport_pstrdup(const char *str)
+{
+       return pstrdup(str);
+}
+
+
+/* Doesn't reference a DLLIMPORT variable, but here for completeness. */
+void
+pgport_pfree(void *pointer)
+{
+       pfree(pointer);
+       return;
+}
+#endif
 
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  *
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.46 2004/08/04 21:34:12 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.47 2004/08/08 06:44:33 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
        const char *p;
        int                     ret;
 
+       /*
+        *      Win32 has to use double-quotes for args, rather than single quotes.
+        *      Strangely enough, this is the only place we pass a database name
+        *      on the command line, except template1 that doesn't need quoting.
+        */     
+#ifndef WIN32
        appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin,
+#else
+       appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp \"", SYSTEMQUOTE, pg_dump_bin,
+#endif
                                          pgdumpopts->data);
 
        /* Shell quoting is not quite like SQL quoting, so can't use fmtId */
        for (p = dbname; *p; p++)
        {
+#ifndef WIN32
                if (*p == '\'')
                        appendPQExpBuffer(cmd, "'\"'\"'");
                else
+#endif
+               /* not needed on Win32 */
                        appendPQExpBufferChar(cmd, *p);
        }
 
+#ifndef WIN32
        appendPQExpBufferChar(cmd, '\'');
-       appendStringLiteral(cmd, SYSTEMQUOTE, false);
+#else
+       appendPQExpBufferChar(cmd, '"');
+#endif
 
+       if (strlen(SYSTEMQUOTE) > 0)
+               appendPQExpBuffer(cmd, SYSTEMQUOTE);
+       
        if (verbose)
                fprintf(stderr, _("%s: running \"%s\"\n"), progname, cmd->data);
 
 
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/port.h,v 1.49 2004/08/08 01:43:33 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.50 2004/08/08 06:44:33 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #define rename(from, to)               pgrename(from, to)
 #define unlink(path)                   pgunlink(path)
 #define symlink(oldpath, newpath)      pgsymlink(oldpath, newpath)
+
 #endif
 
 extern bool rmtree(char *path, bool rmtopdir);
 
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.27 2003/11/29 22:41:15 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.28 2004/08/08 06:44:35 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #define pstrdup(str)  MemoryContextStrdup(CurrentMemoryContext, (str))
 
+/* Used for Win32 */
+void *pgport_palloc(Size sz);
+char *pgport_pstrdup(const char *str);
+void pgport_pfree(void *pointer);
+
 #endif   /* PALLOC_H */
 
  *     Win32 (NT, Win2k, XP).  replace() doesn't work on Win95/98/Me.
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/port/dirmod.c,v 1.17 2004/08/08 05:04:41 momjian Exp $
+ *       $PostgreSQL: pgsql/src/port/dirmod.c,v 1.18 2004/08/08 06:44:36 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 #undef rename
 #undef unlink
 
+#ifndef FRONTEND
+#define palloc(sz)             pgport_palloc(sz)
+#define pstrdup(str)   pgport_pstrdup(str)
+#define pfree(pointer) pgport_pfree(pointer)
+#endif
+
+
 /*
  *     pgrename
  */