forked from icculus/mojosetup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
platform_beos.cpp
92 lines (73 loc) · 2.39 KB
/
platform_beos.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* MojoSetup; a portable, flexible installation application.
*
* Please see the file LICENSE.txt in the source's root directory.
*
* This file written by Ryan C. Gordon.
*/
// You also need to compile unix.c, but this lets us add some things that
// cause conflicts between the Be headers and MojoSetup, and use C++. These
// are largely POSIX things that are missing from BeOS 5...keeping them here
// even on Zeta lets us be binary compatible across everything, I think.
#if PLATFORM_BEOS
#include <stdio.h>
#include <string.h>
#include <be/app/Roster.h>
#include <be/kernel/image.h>
#include <be/kernel/OS.h>
extern "C" { int beos_launchBrowser(const char *url); }
int beos_launchBrowser(const char *url)
{
static struct { const char *prot, const char *mime } protmimemap[] =
{
{ "http://", "text/html" },
{ "https://", "text/html" },
{ "file://", "text/html" }, // let the web browser handle this.
{ "ftp://", "application/x-vnd.Be.URL.ftp" },
{ "mailto:", "text/x-email" },
{ NULL, NULL }
};
const char *mime = NULL;
for (int i = 0; protmimemap[i].prot != NULL; i++)
{
const char *prot = protmimemap[i].prot;
if (strncmp(url, prot, strlen(prot)) == 0)
{
mime = protmimemap[i].mime;
break;
} // if
} // for
if (mime == NULL)
return false; // no handler for this protocol.
// be_roster is a global object supplied by the system runtime.
return (be_roster->Launch(mime, 1, &url) == B_OK);
} // beos_launchBrowser
extern "C" { void *beos_dlopen(const char *fname, int unused); }
void *beos_dlopen(const char *fname, int unused)
{
const image_id lib = load_add_on(fname);
(void) unused;
if (lib < 0)
return NULL;
return (void *) lib;
} // beos_dlopen
extern "C" { void *beos_dlsym(void *lib, const char *sym); }
void *beos_dlsym(void *lib, const char *sym)
{
void *addr = NULL;
if (get_image_symbol((image_id) lib, sym, B_SYMBOL_TYPE_TEXT, &addr))
return NULL;
return addr;
} // beos_dlsym
extern "C" { void beos_dlclose(void *lib); }
void beos_dlclose(void *lib)
{
unload_add_on((image_id) lib);
} // beos_dlclose
extern "C" { void beos_usleep(unsigned long microseconds); }
void beos_usleep(unsigned long microseconds)
{
snooze(microseconds);
} // beos_usleep
#endif // PLATFORM_BEOS
// end of beos.c ...