Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zathura
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
111
Issues
111
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pwmt
zathura
Commits
5d2666da
Commit
5d2666da
authored
Jan 06, 2014
by
Sebastian Ramacher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move file based detection into separate function
parent
ecf090b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
31 deletions
+37
-31
document.c
document.c
+37
-31
No files found.
document.c
View file @
5d2666da
...
...
@@ -708,11 +708,47 @@ cleanup:
return
mime_type
;
}
static
const
char
*
guess_type_file
(
const
char
*
UNUSED
(
path
))
{
return
NULL
;
}
#else
static
const
char
*
guess_type_magic
(
const
char
*
UNUSED
(
path
))
{
return
NULL
;
}
static
const
char
*
guess_type_file
(
const
char
*
path
)
{
GString
*
command
=
g_string_new
(
"file -b --mime-type "
);
char
*
tmp
=
g_shell_quote
(
path
);
g_string_append
(
command
,
tmp
);
g_free
(
tmp
);
GError
*
error
=
NULL
;
char
*
out
=
NULL
;
int
ret
=
0
;
g_spawn_command_line_sync
(
command
->
str
,
&
out
,
NULL
,
&
ret
,
&
error
);
g_string_free
(
command
,
TRUE
);
if
(
error
!=
NULL
)
{
girara_warning
(
"failed to execute command: %s"
,
error
->
message
);
g_error_free
(
error
);
g_free
(
out
);
return
NULL
;
}
if
(
WEXITSTATUS
(
ret
)
!=
0
)
{
girara_warning
(
"file failed with error code: %d"
,
WEXITSTATUS
(
ret
));
g_free
(
out
);
return
NULL
;
}
g_strdelimit
(
out
,
"
\n\r
"
,
'\0'
);
return
out
;
}
#endif
static
const
char
*
...
...
@@ -777,38 +813,8 @@ guess_type(const char* path)
if
(
content_type
!=
NULL
)
{
return
content_type
;
}
#ifdef WITH_MAGIC
return
NULL
;
#else
/* and if libmagic is not available, try file as last resort */
girara_debug
(
"falling back to file"
);
GString
*
command
=
g_string_new
(
"file -b --mime-type "
);
char
*
tmp
=
g_shell_quote
(
path
);
g_string_append
(
command
,
tmp
);
g_free
(
tmp
);
GError
*
error
=
NULL
;
char
*
out
=
NULL
;
int
ret
=
0
;
g_spawn_command_line_sync
(
command
->
str
,
&
out
,
NULL
,
&
ret
,
&
error
);
g_string_free
(
command
,
TRUE
);
if
(
error
!=
NULL
)
{
girara_warning
(
"failed to execute command: %s"
,
error
->
message
);
g_error_free
(
error
);
g_free
(
out
);
return
NULL
;
}
if
(
WEXITSTATUS
(
ret
)
!=
0
)
{
girara_warning
(
"file failed with error code: %d"
,
WEXITSTATUS
(
ret
));
g_free
(
out
);
return
NULL
;
}
g_strdelimit
(
out
,
"
\n\r
"
,
'\0'
);
return
out
;
#endif
return
guess_type_file
(
path
);
}
zathura_plugin_t
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment