~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to src/backend/port/dynloader/hpux.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * dynloader.c
 
4
 *        dynamic loader for HP-UX using the shared library mechanism
 
5
 *
 
6
 * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
 
7
 * Portions Copyright (c) 1994, Regents of the University of California
 
8
 *
 
9
 *
 
10
 * IDENTIFICATION
 
11
 *        src/backend/port/dynloader/hpux.c
 
12
 *
 
13
 *      NOTES
 
14
 *              all functions are defined here -- it's impossible to trace the
 
15
 *              shl_* routines from the bundled HP-UX debugger.
 
16
 *
 
17
 *-------------------------------------------------------------------------
 
18
 */
 
19
#include "postgres.h"
 
20
 
 
21
/* System includes */
 
22
#include <a.out.h>
 
23
#include <dl.h>
 
24
 
 
25
#include "dynloader.h"
 
26
#include "utils/dynamic_loader.h"
 
27
 
 
28
void *
 
29
pg_dlopen(char *filename)
 
30
{
 
31
        /*
 
32
         * Use BIND_IMMEDIATE so that undefined symbols cause a failure return
 
33
         * from shl_load(), rather than an abort() later on when we attempt to
 
34
         * call the library!
 
35
         */
 
36
        shl_t           handle = shl_load(filename,
 
37
                                                                BIND_IMMEDIATE | BIND_VERBOSE | DYNAMIC_PATH,
 
38
                                                                  0L);
 
39
 
 
40
        return (void *) handle;
 
41
}
 
42
 
 
43
PGFunction
 
44
pg_dlsym(void *handle, char *funcname)
 
45
{
 
46
        PGFunction      f;
 
47
 
 
48
        if (shl_findsym((shl_t *) & handle, funcname, TYPE_PROCEDURE, &f) == -1)
 
49
                f = (PGFunction) NULL;
 
50
        return f;
 
51
}
 
52
 
 
53
void
 
54
pg_dlclose(void *handle)
 
55
{
 
56
        shl_unload((shl_t) handle);
 
57
}
 
58
 
 
59
char *
 
60
pg_dlerror(void)
 
61
{
 
62
        static char errmsg[] = "shl_load failed";
 
63
 
 
64
        if (errno)
 
65
                return strerror(errno);
 
66
 
 
67
        return errmsg;
 
68
}