aboutsummaryrefslogtreecommitdiffstats
path: root/tshark.c
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2021-06-06 14:10:22 +0200
committerStig Bjørlykke <stig@bjorlykke.org>2021-06-07 06:24:28 +0000
commit5dbaa8d3b28cf32a103408868fa4cf5b63dd6a56 (patch)
treeaf6a8eb8f355d29acf99e7583839336c5121ccb2 /tshark.c
parent6895f71574c68a8231925d61443c6fbcb33ee7af (diff)
wsutil: Add filesystem write_file_binary_mode()
Add a generic function to write content to file. Use this on write TLS session keys from UI and tshark, and for export objects. Remove the now unused export_object_ui.[ch].
Diffstat (limited to 'tshark.c')
-rw-r--r--tshark.c18
1 files changed, 1 insertions, 17 deletions
diff --git a/tshark.c b/tshark.c
index 83d93d008f..b8a5492c01 100644
--- a/tshark.c
+++ b/tshark.c
@@ -531,22 +531,6 @@ glossary_option_help(void)
}
static void
-tshark_write_to_file(const gchar *filename, const gchar *data)
-{
- int fd = ws_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
- if (fd == -1) {
- open_failure_message(filename, errno, TRUE);
- return;
- }
-
- if (ws_write(fd, data, (unsigned int)strlen(data)) < 0) {
- write_failure_message(filename, errno);
- }
-
- ws_close(fd);
-}
-
-static void
tshark_log_handler (const gchar *log_domain, GLogLevelFlags log_level,
const gchar *message, gpointer user_data)
{
@@ -2347,7 +2331,7 @@ main(int argc, char *argv[])
if (tls_session_keys_file) {
gchar *keylist = ssl_export_sessions();
- tshark_write_to_file(tls_session_keys_file, keylist);
+ write_file_binary_mode(tls_session_keys_file, keylist, strlen(keylist));
g_free(keylist);
}