OSDN Git Service

Enable 64 bit IO support on MinGW
[timidity41/timidity41.git] / timidity / dl_dld.c
1 /*
2     TiMidity++ -- MIDI to WAVE converter and player
3     Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
4     Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif /* HAVE_CONFIG_H */
24 /* dl_dld.c */
25
26 #include <stdio.h>
27 #include <dld.h>        /* GNU DLD header file */
28 #include <unistd.h>
29 #include "timidity.h"
30 #include "dlutils.h"
31
32 /*ARGSUSED*/
33 void dl_init(int argc, char **argv)
34 {
35     int dlderr;
36
37 #ifdef __linux__
38     dlderr = dld_init("/proc/self/exe");
39     if (dlderr)
40 #endif
41     {
42         dlderr = dld_init(dld_find_executable(argv[0]));
43         if (dlderr) {
44             char *msg = dld_strerror(dlderr);
45             fprintf(stderr, "dld_init(%s) failed: %s\n", argv[0], msg);
46         }
47     }
48 }
49
50 void *dl_load_file(char *filename)
51 {
52     int dlderr;
53
54     dlderr = dld_link(filename);
55     if(dlderr)
56     {
57         fprintf(stderr, "dld_link(%s): %s\n", filename, dld_strerror(dlderr));
58         return NULL;
59     }
60     return filename;
61 }
62
63 /*ARGSUSED*/
64 void *dl_find_symbol(void *libhandle, char *symbolname)
65 {
66     void *RETVAL;
67
68     RETVAL = (void *)dld_get_func(symbolname);
69     if (RETVAL == NULL)
70     {
71         fprintf(stderr, "dl_find_symbol: Unable to find '%s' symbol\n",
72                 symbolname);
73     }
74     return RETVAL;
75 }
76
77 void dl_free(void *libhandle)
78 {
79 }