Skip to content

Latest commit

 

History

History
92 lines (73 loc) · 2.39 KB

platform_beos.cpp

File metadata and controls

92 lines (73 loc) · 2.39 KB
 
May 12, 2007
May 12, 2007
1
2
3
4
5
6
7
8
/**
* 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.
*/
Dec 13, 2006
Dec 13, 2006
9
10
11
12
13
// 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.
May 8, 2007
May 8, 2007
14
15
#if PLATFORM_BEOS
Dec 13, 2006
Dec 13, 2006
16
#include <stdio.h>
Jan 25, 2008
Jan 25, 2008
17
18
#include <string.h>
#include <be/app/Roster.h>
Dec 13, 2006
Dec 13, 2006
19
#include <be/kernel/image.h>
May 7, 2007
May 7, 2007
20
#include <be/kernel/OS.h>
Dec 13, 2006
Dec 13, 2006
21
Jan 25, 2008
Jan 25, 2008
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
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); }
Dec 13, 2006
Dec 13, 2006
56
57
58
59
60
61
62
63
64
65
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
Jan 25, 2008
Jan 25, 2008
66
extern "C" { void *beos_dlsym(void *lib, const char *sym); }
Dec 13, 2006
Dec 13, 2006
67
68
69
70
71
72
73
74
75
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
Jan 25, 2008
Jan 25, 2008
76
extern "C" { void beos_dlclose(void *lib); }
Dec 13, 2006
Dec 13, 2006
77
78
79
80
81
void beos_dlclose(void *lib)
{
unload_add_on((image_id) lib);
} // beos_dlclose
May 7, 2007
May 7, 2007
82
Jan 25, 2008
Jan 25, 2008
83
extern "C" { void beos_usleep(unsigned long microseconds); }
May 7, 2007
May 7, 2007
84
85
86
87
88
void beos_usleep(unsigned long microseconds)
{
snooze(microseconds);
} // beos_usleep
May 8, 2007
May 8, 2007
89
90
#endif // PLATFORM_BEOS
Dec 14, 2006
Dec 14, 2006
91
// end of beos.c ...