2021-06-06 01:26:18 +00:00
|
|
|
/**
|
|
|
|
* Looking Glass
|
2021-08-04 09:48:32 +00:00
|
|
|
* Copyright © 2017-2021 The Looking Glass Authors
|
2021-06-06 01:26:18 +00:00
|
|
|
* https://looking-glass.io
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
|
|
|
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
2019-02-28 08:31:04 +00:00
|
|
|
|
2019-05-09 09:07:23 +00:00
|
|
|
#include "interface/platform.h"
|
|
|
|
#include "common/debug.h"
|
2019-05-09 12:06:58 +00:00
|
|
|
#include "common/option.h"
|
2021-01-14 10:07:28 +00:00
|
|
|
#include "common/stringutils.h"
|
2020-01-02 12:34:35 +00:00
|
|
|
#include "common/thread.h"
|
2019-05-09 09:07:23 +00:00
|
|
|
|
2019-03-01 01:54:15 +00:00
|
|
|
#include <stdlib.h>
|
2019-03-01 10:01:25 +00:00
|
|
|
#include <string.h>
|
2019-03-02 09:31:33 +00:00
|
|
|
#include <signal.h>
|
2019-03-04 06:08:49 +00:00
|
|
|
#include <errno.h>
|
2021-01-14 10:07:28 +00:00
|
|
|
#include <pwd.h>
|
|
|
|
#include <unistd.h>
|
2019-03-01 01:54:15 +00:00
|
|
|
|
2019-03-01 10:01:25 +00:00
|
|
|
struct app
|
|
|
|
{
|
2020-01-03 03:56:13 +00:00
|
|
|
const char * executable;
|
2020-05-30 02:31:26 +00:00
|
|
|
char * dataPath;
|
2019-03-01 10:01:25 +00:00
|
|
|
};
|
|
|
|
|
2020-01-03 03:56:13 +00:00
|
|
|
struct app app = { 0 };
|
2019-05-11 01:21:18 +00:00
|
|
|
|
2019-02-28 08:31:04 +00:00
|
|
|
int main(int argc, char * argv[])
|
|
|
|
{
|
2021-07-07 13:05:46 +00:00
|
|
|
// initialize for DEBUG_* macros
|
|
|
|
debug_init();
|
|
|
|
|
2019-04-11 07:15:17 +00:00
|
|
|
app.executable = argv[0];
|
2020-05-30 02:31:26 +00:00
|
|
|
|
|
|
|
struct passwd * pw = getpwuid(getuid());
|
|
|
|
alloc_sprintf(&app.dataPath, "%s/", pw->pw_dir);
|
|
|
|
|
2019-05-09 12:06:58 +00:00
|
|
|
int result = app_main(argc, argv);
|
2020-05-30 02:31:26 +00:00
|
|
|
|
|
|
|
free(app.dataPath);
|
2019-05-09 12:06:58 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-01-03 03:53:56 +00:00
|
|
|
void sigHandler(int signo)
|
2019-05-09 12:06:58 +00:00
|
|
|
{
|
2020-01-03 03:53:56 +00:00
|
|
|
DEBUG_INFO("SIGINT");
|
|
|
|
app_quit();
|
|
|
|
}
|
2019-03-01 10:01:25 +00:00
|
|
|
|
2021-01-14 06:05:26 +00:00
|
|
|
bool app_init(void)
|
2020-01-03 03:53:56 +00:00
|
|
|
{
|
2019-03-02 09:31:33 +00:00
|
|
|
signal(SIGINT, sigHandler);
|
2019-05-09 12:06:58 +00:00
|
|
|
return true;
|
2019-02-28 08:31:04 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 06:05:26 +00:00
|
|
|
const char * os_getExecutable(void)
|
2019-04-11 07:15:17 +00:00
|
|
|
{
|
|
|
|
return app.executable;
|
2020-05-30 02:31:26 +00:00
|
|
|
}
|
|
|
|
|
2021-01-14 06:05:26 +00:00
|
|
|
const char * os_getDataPath(void)
|
2020-05-30 02:31:26 +00:00
|
|
|
{
|
|
|
|
return app.dataPath;
|
|
|
|
}
|
2021-02-03 22:42:54 +00:00
|
|
|
|
|
|
|
bool os_blockScreensaver()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2021-06-04 02:39:11 +00:00
|
|
|
|
|
|
|
void os_showMessage(const char * caption, const char * msg)
|
|
|
|
{
|
|
|
|
DEBUG_INFO("%s: %s", caption, msg);
|
|
|
|
}
|