summaryrefslogtreecommitdiff
path: root/xdelta1/libedsio/library.c
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta1/libedsio/library.c')
-rw-r--r--xdelta1/libedsio/library.c121
1 files changed, 0 insertions, 121 deletions
diff --git a/xdelta1/libedsio/library.c b/xdelta1/libedsio/library.c
deleted file mode 100644
index f13193c..0000000
--- a/xdelta1/libedsio/library.c
+++ /dev/null
@@ -1,121 +0,0 @@
1/* -*-Mode: C;-*-
2 * $Id: library.c 1.1 Sun, 28 Jan 2007 10:02:26 -0800 jmacd $
3 *
4 * Copyright (C) 1998, 1999, Josh MacDonald.
5 * All Rights Reserved.
6 *
7 * Author: Josh MacDonald <jmacd@CS.Berkeley.EDU>
8 */
9
10#include "edsio.h"
11#include <gmodule.h>
12
13typedef struct _Library Library;
14
15struct _Library {
16 const char* name;
17 const char* libname;
18 gint index;
19 gboolean loaded;
20};
21
22static Library known_libraries[] = {
23 { "xd", "xdelta", 3 },
24 { "edsio", "edsio", 6 },
25};
26
27static GHashTable* loaded_libraries;
28
29static void
30edsio_library_init ()
31{
32 if (! loaded_libraries)
33 {
34 gint i;
35 gint n = sizeof (known_libraries) / sizeof (Library);;
36
37 loaded_libraries = g_hash_table_new (g_int_hash, g_int_equal);
38
39 for (i = 0; i < n; i += 1)
40 {
41 Library* lib = known_libraries + i;
42
43 g_hash_table_insert (loaded_libraries, & lib->index, lib);
44 }
45 }
46}
47
48void
49edsio_library_register (guint32 number, const char* name)
50{
51 Library* lib;
52
53 edsio_library_init ();
54
55 lib = g_hash_table_lookup (loaded_libraries, & number);
56
57 if (lib)
58 {
59 lib->loaded = TRUE;
60 return;
61 }
62
63 lib = g_new0 (Library, 1);
64
65 lib->index = number;
66 lib->name = name;
67 lib->loaded = TRUE;
68
69 g_hash_table_insert (loaded_libraries, & lib->index, lib);
70}
71
72gboolean
73edsio_library_check (guint32 number)
74{
75 Library* lib;
76
77 edsio_library_init ();
78
79 lib = g_hash_table_lookup (loaded_libraries, & number);
80
81 if (lib)
82 {
83 lib->loaded = TRUE;
84 return TRUE;
85 }
86
87#if 0
88 if (lib->libname && g_module_supported ())
89 {
90 GModule *module;
91 GString *module_name = g_string_new (NULL);
92 GString *symbol_name = g_string_new (NULL);
93 gboolean (* init) (void);
94
95 if (! (module = g_module_open (module_name->str, 0)))
96 {
97 edsio_generate_stringstring_event (EC_EdsioGModuleError, module_name->str, g_module_error ());
98 return FALSE;
99 }
100
101 if (! g_module_symbol (module,
102 symbol_name->str,
103 (void**) & init))
104 {
105 edsio_generate_stringstring_event (EC_EdsioGModuleError, g_module_name (module), g_module_error ());
106 return FALSE;
107 }
108
109 g_module_make_resident (module);
110
111 g_module_close (module);
112
113 lib->loaded = TRUE;
114
115 return (* init) ();
116 }
117#endif
118
119 edsio_generate_int_event (EC_EdsioUnregisteredLibrary, number);
120 return FALSE;
121}