~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

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

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*-------------------------------------------------------------------------
 
2
 *
 
3
 * dynloader.c
 
4
 *        Dynamic Loader for Postgres for BeOS
 
5
 *
 
6
 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
 
7
 * Portions Copyright (c) 1994, Regents of the University of California
 
8
 *
 
9
 *
 
10
 * IDENTIFICATION
 
11
 *        $PostgreSQL: pgsql/src/backend/port/dynloader/beos.c,v 1.15 2004-12-31 22:00:32 pgsql Exp $
 
12
 *
 
13
 *-------------------------------------------------------------------------
 
14
 */
 
15
 
 
16
#include "postgres.h"
 
17
 
 
18
#include "utils/dynamic_loader.h"
 
19
 
 
20
 
 
21
void *
 
22
pg_dlopen(char *filename)
 
23
{
 
24
        image_id   *im;
 
25
 
 
26
        /* Handle memory allocation to store the Id of the shared object */
 
27
        im = (image_id *) (malloc(sizeof(image_id)));
 
28
 
 
29
        /* Add-on loading */
 
30
        *im = beos_dl_open(filename);
 
31
 
 
32
        return im;
 
33
}
 
34
 
 
35
 
 
36
char *
 
37
pg_dlerror()
 
38
{
 
39
        static char errmsg[] = "Load Add-On failed";
 
40
 
 
41
        return errmsg;
 
42
}
 
43
 
 
44
PGFunction
 
45
pg_dlsym(void *handle, char *funcname)
 
46
{
 
47
        PGFunction      fpt;
 
48
 
 
49
        /* Checking that "Handle" is valid */
 
50
        if ((handle) && ((*(int *) (handle)) >= 0))
 
51
        {
 
52
                beos_dl_sym(*((int *) (handle)), funcname, (void **) &fpt);
 
53
                return fpt;
 
54
        }
 
55
        elog(WARNING, "add-on not loaded correctly");
 
56
        return NULL;
 
57
}
 
58
 
 
59
void
 
60
pg_dlclose(void *handle)
 
61
{
 
62
        /* Checking that "Handle" is valid */
 
63
        if ((handle) && ((*(int *) (handle)) >= 0))
 
64
        {
 
65
                if (beos_dl_close(*(image_id *) handle) != B_OK)
 
66
                        elog(WARNING, "error while unloading add-on");
 
67
                free(handle);
 
68
        }
 
69
}