1 module allegro5.system;
2 
3 import allegro5.internal.da5;
4 import allegro5.config;
5 import allegro5.path;
6 import allegro5.base;
7 
8 version(Tango)
9 {
10 	import tango.core.Thread;
11 	import tango.stdc.stdlib : atexit;
12 }
13 else
14 {
15 	version(D_Version2)
16 	{
17 		import core.thread;
18 		import core.stdc.stdlib : atexit;
19 	}
20 	else
21 	{
22 		import std.c.stdlib : atexit;
23 		import std.thread;
24 	}
25 }
26 
27 int al_run_allegro(scope int delegate() user_main)
28 {
29 	extern(C) static int main_runner(int argc, char** argv)
30 	{
31 		version(OSX)
32 		{
33 			version(D_Version2)
34 				thread_attachThis();
35 			else
36 				Thread.thread_attach();
37 		}
38 		
39 		auto main_ret = (*cast(int delegate()*)argv[0])();
40 		
41 		version(OSX)
42 		{
43 			version(D_Version2)
44 				thread_detachThis();
45 			else
46 				Thread.thread_detach();
47 		}
48 		
49 		return main_ret;
50 	}
51 
52 	char* fake_arg = cast(char*)&user_main;
53 	return al_run_main(0, &fake_arg, &main_runner);
54 }
55 
56 extern (C)
57 {
58 	struct ALLEGRO_SYSTEM {};
59 
60 	bool al_install_system(int vers, int function(void function()) atexit_ptr);
61 	void al_uninstall_system();
62 	bool al_is_system_installed();
63 	ALLEGRO_SYSTEM* al_get_system_driver();
64 	ALLEGRO_CONFIG* al_get_system_config();
65 	
66 	bool al_init()
67 	{
68 		return al_install_system(ALLEGRO_VERSION_INT, &atexit);
69 	}
70 
71 	enum 
72 	{
73 		ALLEGRO_RESOURCES_PATH = 0,
74 		ALLEGRO_TEMP_PATH,
75 		ALLEGRO_USER_DATA_PATH,
76 		ALLEGRO_USER_HOME_PATH,
77 		ALLEGRO_USER_SETTINGS_PATH,
78 		ALLEGRO_USER_DOCUMENTS_PATH,
79 		ALLEGRO_EXENAME_PATH,
80 		ALLEGRO_LAST_PATH // must be last
81 	}
82 
83 	ALLEGRO_PATH* al_get_standard_path(int id);
84 	void al_set_exe_name(in char* path);
85 
86 	void al_set_org_name(in char* orgname);
87 	void al_set_app_name(in char* appname);
88 	const_char* al_get_org_name();
89 	const_char* al_get_app_name();
90 
91 	bool al_inhibit_screensaver(bool inhibit);
92 }