3 * Routines for reading a binary file containing a ruby marshal object
5 * Copyright 2018, Dario Lombardo <lomato@gmail.com>
7 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include "file_wrappers.h"
17 #include "ruby_marshal.h"
19 static gboolean is_ruby_marshal(const guint8* filebuf)
21 if (filebuf[0] != RUBY_MARSHAL_MAJOR)
23 if (filebuf[1] != RUBY_MARSHAL_MINOR)
52 wtap_open_return_val ruby_marshal_open(wtap *wth, int *err, gchar **err_info)
54 /* The size of this buffer should match the expectations of is_ruby_marshal */
58 bytes_read = file_read(filebuf, sizeof(filebuf), wth->fh);
61 *err = file_error(wth->fh, err_info);
62 return WTAP_OPEN_ERROR;
65 if (bytes_read != sizeof(filebuf) || !is_ruby_marshal(filebuf)) {
66 return WTAP_OPEN_NOT_MINE;
69 if (file_seek(wth->fh, 0, SEEK_SET, err) == -1) {
70 return WTAP_OPEN_ERROR;
73 wth->file_type_subtype = WTAP_FILE_TYPE_SUBTYPE_RUBY_MARSHAL;
74 wth->file_encap = WTAP_ENCAP_RUBY_MARSHAL;
75 wth->file_tsprec = WTAP_TSPREC_SEC;
76 wth->subtype_read = wtap_full_file_read;
77 wth->subtype_seek_read = wtap_full_file_seek_read;
78 wth->snapshot_length = 0;
80 return WTAP_OPEN_MINE;
84 * Editor modelines - https://www.wireshark.org/tools/modelines.html
89 * indent-tabs-mode: nil
92 * vi: set shiftwidth=4 tabstop=8 expandtab:
93 * :indentSize=4:tabSize=8:noTabs=true: