2016-09-04 20:41:48 +00:00
|
|
|
/*
|
2019-12-19 22:22:41 +00:00
|
|
|
* chr - Andrew Chronister
|
2016-09-04 20:41:48 +00:00
|
|
|
*
|
2019-12-19 22:22:41 +00:00
|
|
|
* 12.19.2019
|
2016-09-04 20:41:48 +00:00
|
|
|
*
|
2019-12-19 22:22:41 +00:00
|
|
|
* Updated linux layer for 4coder
|
2016-09-04 20:41:48 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
2019-12-19 22:22:41 +00:00
|
|
|
#define FPS 60
|
|
|
|
#define frame_useconds (1000000 / FPS)
|
2017-06-30 21:28:09 +00:00
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
#include "4coder_base_types.h"
|
2019-12-19 22:22:41 +00:00
|
|
|
#include "4coder_version.h"
|
|
|
|
#include "4coder_events.h"
|
2016-09-04 20:41:48 +00:00
|
|
|
|
2019-12-19 22:22:41 +00:00
|
|
|
#include "4coder_table.h"
|
|
|
|
#include "4coder_types.h"
|
|
|
|
#include "4coder_default_colors.h"
|
2017-02-18 01:04:41 +00:00
|
|
|
|
2019-12-19 22:22:41 +00:00
|
|
|
#include "4coder_system_types.h"
|
|
|
|
#define STATIC_LINK_API
|
|
|
|
#include "generated/system_api.h"
|
2016-09-04 20:41:48 +00:00
|
|
|
|
2019-12-19 22:22:41 +00:00
|
|
|
#include "4ed_font_interface.h"
|
|
|
|
#define STATIC_LINK_API
|
|
|
|
#include "generated/graphics_api.h"
|
|
|
|
#define STATIC_LINK_API
|
|
|
|
#include "generated/font_api.h"
|
2016-09-04 20:41:48 +00:00
|
|
|
|
2019-12-19 22:22:41 +00:00
|
|
|
#include "4ed_font_set.h"
|
2017-11-10 18:27:39 +00:00
|
|
|
#include "4ed_render_target.h"
|
2019-12-19 22:22:41 +00:00
|
|
|
#include "4ed_search_list.h"
|
2016-09-04 20:41:48 +00:00
|
|
|
#include "4ed.h"
|
2017-07-18 22:09:16 +00:00
|
|
|
|
2019-12-19 22:22:41 +00:00
|
|
|
#include "generated/system_api.cpp"
|
|
|
|
#include "generated/graphics_api.cpp"
|
|
|
|
#include "generated/font_api.cpp"
|
2017-07-18 22:09:16 +00:00
|
|
|
|
2019-12-19 22:22:41 +00:00
|
|
|
#include "4coder_base_types.cpp"
|
|
|
|
#include "4coder_stringf.cpp"
|
|
|
|
#include "4coder_events.cpp"
|
|
|
|
#include "4coder_hash_functions.cpp"
|
|
|
|
#include "4coder_table.cpp"
|
|
|
|
#include "4coder_log.cpp"
|
2017-07-18 22:09:16 +00:00
|
|
|
|
2019-12-19 22:22:41 +00:00
|
|
|
#include "4ed_search_list.cpp"
|
2016-09-04 20:41:48 +00:00
|
|
|
|
2019-12-19 22:22:41 +00:00
|
|
|
#include <unistd.h>
|
2016-09-04 20:41:48 +00:00
|
|
|
|
|
|
|
internal
|
2019-12-19 22:22:41 +00:00
|
|
|
system_get_path_sig(){
|
|
|
|
// Arena* arena, System_Path_Code path_code
|
|
|
|
String_Const_u8 result = {};
|
|
|
|
switch (path_code){
|
|
|
|
case SystemPath_CurrentDirectory:
|
2018-12-15 09:10:42 +00:00
|
|
|
{
|
2019-12-19 22:22:41 +00:00
|
|
|
// glibc extension: getcwd allocates its own memory if passed NULL
|
|
|
|
char *working_dir = getcwd(NULL, 0);
|
|
|
|
u64 working_dir_len = cstring_length(working_dir);
|
|
|
|
u8 *out = push_array(arena, u8, working_dir_len);
|
|
|
|
block_copy(out, working_dir, working_dir_len);
|
|
|
|
free(working_dir);
|
|
|
|
result = SCu8(out, working_dir_len);
|
2018-12-15 09:10:42 +00:00
|
|
|
}break;
|
2016-09-04 20:41:48 +00:00
|
|
|
|
2019-12-19 22:22:41 +00:00
|
|
|
case SystemPath_Binary:
|
2016-09-04 20:41:48 +00:00
|
|
|
{
|
2019-12-19 22:22:41 +00:00
|
|
|
// linux-specific: binary path symlinked at /proc/self/exe
|
|
|
|
ssize_t binary_path_len = readlink("/proc/self/exe", NULL, 0);
|
|
|
|
u8* out = push_array(arena, u8, binary_path_len);
|
|
|
|
readlink("/proc/self/exe", (char*)out, binary_path_len);
|
|
|
|
String_u8 out_str = Su8(out, binary_path_len);
|
|
|
|
out_str.string = string_remove_last_folder(out_str.string);
|
|
|
|
string_null_terminate(&out_str);
|
|
|
|
result = out_str.string;
|
|
|
|
}break;
|
2017-03-30 06:40:16 +00:00
|
|
|
}
|
2016-09-04 20:41:48 +00:00
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2019-12-19 22:22:41 +00:00
|
|
|
int main(int argc, char **argv){
|
2016-09-04 20:41:48 +00:00
|
|
|
}
|