mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-02-27 17:04:38 +01:00
Update style
This commit is contained in:
parent
66b6fa65a1
commit
627a0749bc
1 changed files with 10 additions and 16 deletions
26
zathura.c
26
zathura.c
|
@ -68,8 +68,8 @@ zathura_init(int argc, char* argv[])
|
||||||
|
|
||||||
gchar* config_dir = NULL, *data_dir = NULL, *plugin_path = NULL, *loglevel = NULL, *password = NULL;
|
gchar* config_dir = NULL, *data_dir = NULL, *plugin_path = NULL, *loglevel = NULL, *password = NULL;
|
||||||
bool forkback = false, print_version = false;
|
bool forkback = false, print_version = false;
|
||||||
GOptionEntry entries[] =
|
|
||||||
{
|
GOptionEntry entries[] = {
|
||||||
{ "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, _("Reparents to window specified by xid"), "xid" },
|
{ "reparent", 'e', 0, G_OPTION_ARG_INT, &embed, _("Reparents to window specified by xid"), "xid" },
|
||||||
{ "config-dir", 'c', 0, G_OPTION_ARG_FILENAME, &config_dir, _("Path to the config directory"), "path" },
|
{ "config-dir", 'c', 0, G_OPTION_ARG_FILENAME, &config_dir, _("Path to the config directory"), "path" },
|
||||||
{ "data-dir", 'd', 0, G_OPTION_ARG_FILENAME, &data_dir, _("Path to the data directory"), "path" },
|
{ "data-dir", 'd', 0, G_OPTION_ARG_FILENAME, &data_dir, _("Path to the data directory"), "path" },
|
||||||
|
@ -85,8 +85,7 @@ zathura_init(int argc, char* argv[])
|
||||||
g_option_context_add_main_entries(context, entries, NULL);
|
g_option_context_add_main_entries(context, entries, NULL);
|
||||||
|
|
||||||
GError* error = NULL;
|
GError* error = NULL;
|
||||||
if (g_option_context_parse(context, &argc, &argv, &error) == false)
|
if (g_option_context_parse(context, &argc, &argv, &error) == false) {
|
||||||
{
|
|
||||||
printf("Error parsing command line arguments: %s\n", error->message);
|
printf("Error parsing command line arguments: %s\n", error->message);
|
||||||
g_option_context_free(context);
|
g_option_context_free(context);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
|
@ -95,8 +94,7 @@ zathura_init(int argc, char* argv[])
|
||||||
g_option_context_free(context);
|
g_option_context_free(context);
|
||||||
|
|
||||||
/* Fork into the background if the user really wants to ... */
|
/* Fork into the background if the user really wants to ... */
|
||||||
if (forkback == true)
|
if (forkback == true) {
|
||||||
{
|
|
||||||
int pid = fork();
|
int pid = fork();
|
||||||
if (pid > 0) { /* parent */
|
if (pid > 0) { /* parent */
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -395,8 +393,7 @@ prepare_document_open_from_stdin(zathura_t* zathura)
|
||||||
GError* error = NULL;
|
GError* error = NULL;
|
||||||
gchar* file = NULL;
|
gchar* file = NULL;
|
||||||
gint handle = g_file_open_tmp("zathura.stdin.XXXXXX", &file, &error);
|
gint handle = g_file_open_tmp("zathura.stdin.XXXXXX", &file, &error);
|
||||||
if (handle == -1)
|
if (handle == -1) {
|
||||||
{
|
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
girara_error("Can not create temporary file: %s", error->message);
|
girara_error("Can not create temporary file: %s", error->message);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
|
@ -406,8 +403,7 @@ prepare_document_open_from_stdin(zathura_t* zathura)
|
||||||
|
|
||||||
// read from stdin and dump to temporary file
|
// read from stdin and dump to temporary file
|
||||||
int stdinfno = fileno(stdin);
|
int stdinfno = fileno(stdin);
|
||||||
if (stdinfno == -1)
|
if (stdinfno == -1) {
|
||||||
{
|
|
||||||
girara_error("Can not read from stdin.");
|
girara_error("Can not read from stdin.");
|
||||||
close(handle);
|
close(handle);
|
||||||
g_unlink(file);
|
g_unlink(file);
|
||||||
|
@ -417,10 +413,8 @@ prepare_document_open_from_stdin(zathura_t* zathura)
|
||||||
|
|
||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
ssize_t count = 0;
|
ssize_t count = 0;
|
||||||
while ((count = read(stdinfno, buffer, BUFSIZ)) > 0)
|
while ((count = read(stdinfno, buffer, BUFSIZ)) > 0) {
|
||||||
{
|
if (write(handle, buffer, count) != count) {
|
||||||
if (write(handle, buffer, count) != count)
|
|
||||||
{
|
|
||||||
girara_error("Can not write to temporary file: %s", file);
|
girara_error("Can not write to temporary file: %s", file);
|
||||||
close(handle);
|
close(handle);
|
||||||
g_unlink(file);
|
g_unlink(file);
|
||||||
|
@ -428,10 +422,10 @@ prepare_document_open_from_stdin(zathura_t* zathura)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(handle);
|
close(handle);
|
||||||
|
|
||||||
if (count != 0)
|
if (count != 0) {
|
||||||
{
|
|
||||||
girara_error("Can not read from stdin.");
|
girara_error("Can not read from stdin.");
|
||||||
g_unlink(file);
|
g_unlink(file);
|
||||||
g_free(file);
|
g_free(file);
|
||||||
|
|
Loading…
Add table
Reference in a new issue