-/****/
-#ifdef HAVE_POSTGRESQLV7
-/* PGsetenvHandle is an opaque object and we need to be able to store them in
- Lisp code so we can make asynchronous environmental calls.
-
- Asynchronous setenv calls were introduced in libpq-7.0.
-*/
-#ifdef LIBPQ_7_0_IS_FIXED
-
-Lisp_Object Qpgsetenvp;
-
-static Lisp_Object
-make_pgsetenv (Lisp_PGsetenvHandle *pgsetenv)
-{
- Lisp_Object lisp_pgsetenv;
- XSETPGSETENV (lisp_pgsetenv, pgsetenv);
- return lisp_pgsetenv;
-}
-
-static Lisp_Object
-#ifdef RUNNING_XEMACS_21_1
-mark_pgsetenv (Lisp_Object obj, void (*markobj) (Lisp_Object))
-#else
-mark_pgsetenv (Lisp_Object obj)
-#endif
-{
- return Qnil;
-}
-
-static void
-print_pgsetenv (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
-{
- char *fmt = "#<PGsetenvHandle %s>";
- char buf[1024];
- PGsetenvHandle *h;
-
- h = (XPGSETENV (obj))->pgsetenv;
-
- sprintf (buf, fmt, h ? "live" : "DEAD");
-
- /* There are no accessor functions to retrieve any fields, so we must */
- /* treat this as being completely opaque. */
- if (print_readably)
- error ("printing unreadable object %s", buf);
- else
- write_c_string (buf, printcharfun);
-}
-
-static Lisp_PGsetenvHandle *
-allocate_pgresult (void)
-{
-#ifdef RUNNING_XEMACS_21_1
- Lisp_PGsetenvHandle *pgsetenv =
- alloc_lcrecord_type (Lisp_PGsetenvHandle, lrecord_pgsetenv);
-#else
- Lisp_PGsetenvHandle *pgsetenv =
- alloc_lcrecord_type (Lisp_PGsetenvHandle, &lrecord_pgsetenv);
-#endif
- pgsetenv->pgsetenv = (PGsetenvState *)NULL;
- return pgsetenv;
-}
-
-static void
-finalize_pgsetenv (void *header, int for_disksave)
-{
- Lisp_PGsetenvHandle *pgsetenv = (Lisp_PGsetenvHandle *)header;
-
- if (for_disksave)
- signal_simple_error ("Can't dump an emacs containing PGsetenvHandle objects",
- make_pgsetenv (pgsetenv));
-
- /* #### PGsetenvHandle's are allocated with malloc(), however in
- libpq-7.0 the treatment of them is little short of disastrous.
- We don't dare attempt to free it, because there are many code
- paths which lead to the handle being freed internally. The
- connection routines leak setenv handles and so will we until
- libpq gets cleaned up.
- Actually, in 7.0b1 asynchronous setenv cannot work outside libpq, so
- these functions are disabled in this API.
- */
- if (pgsetenv->pgsetenv)
- {
- free (pgsetenv->pgsetenv);
- pgsetenv->pgsetenv = (PGsetenvHandle *)NULL;
- }
-}
-
-#ifdef RUNNING_XEMACS_21_1
-DEFINE_LRECORD_IMPLEMENTATION ("pgresult", pgresult,
- mark_pgresult, print_pgresult, finalize_pgresult,
- NULL, NULL,
- Lisp_PGresult);
-#else
-DEFINE_LRECORD_IMPLEMENTATION ("pgresult", pgresult,
- mark_pgresult, print_pgresult, finalize_pgresult,
- NULL, NULL,
- 0,
- Lisp_PGresult);
-#endif /* RUNNING_XEMACS_21_1 */
-
-#endif /* LIBPQ_7_0_IS_FIXED */
-#endif /* HAVE_POSTGRESQLV7 */
-