Commit Graph

18 Commits

Author SHA1 Message Date
Guy Harris a7256d50b5 wiretap: more work on file type/subtypes.
Provide a wiretap routine to get an array of all savable file
type/subtypes, sorted with pcap and pcapng at the top, followed by the
other types, sorted either by the name or the description.

Use that routine to list options for the -F flag for various commands

Rename wtap_get_savable_file_types_subtypes() to
wtap_get_savable_file_types_subtypes_for_file(), to indicate that it
provides an array of all file type/subtypes in which a given file can be
saved.  Have it sort all types, other than the default type/subtype and,
if there is one, the "other" type (both of which are put at the top), by
the name or the description.

Don't allow wtap_register_file_type_subtypes() to override any existing
registrations; have them always register a new type.  In that routine,
if there are any emply slots in the table, due to an entry being
unregistered, use it rather than allocating a new slot.

Don't allow unregistration of built-in types.

Rename the "dump open table" to the "file type/subtype table", as it has
entries for all types/subtypes, even if we can't write them.

Initialize that table in a routine that pre-allocates the GArray before
filling it with built-in types/subtypes, so it doesn't keep getting
reallocated.

Get rid of wtap_num_file_types_subtypes - it's just a copy of the size
of the GArray.

Don't have wtap_file_type_subtype_description() crash if handed an
file type/subtype that isn't a valid array index - just return NULL, as
we do with wtap_file_type_subtype_name().

In wtap_name_to_file_type_subtype(), don't use WTAP_FILE_TYPE_SUBTYPE_
names for the backwards-compatibility names - map those names to the
current names, and then look them up.  This reduces the number of
uses of hardwired WTAP_FILE_TYPE_SUBTYPE_ values.

Clean up the type of wtap_module_count - it has no need to be a gulong.

Have built-in wiretap file handlers register names to be used for their
file type/subtypes, rather than building the table in init.lua.

Add a new Lua C function get_wtap_filetypes() to construct the
wtap_filetypes table, based on the registered names, and use it in
init.lua.

Add a #define WSLUA_INTERNAL_FUNCTION to register functions intended
only for internal use in init.lua, so they can be made available from
Lua without being documented.

Get rid of WTAP_NUM_FILE_TYPES_SUBTYPES - most code has no need to use
it, as it can just request arrays of types, and the space of
type/subtype codes can be sparse due to registration in any case, so
code has to be careful using it.

wtap_get_num_file_types_subtypes() is no longer used, so remove it.  It
returns the number of elements in the file type/subtype array, which is
not necessarily the name of known file type/subtypes, as there may have
been some deregistered types, and those types do *not* get removed from
the array, they just get cleared so that they're available for future
allocation (we don't want the indices of any registered types to changes
if another type is deregistered, as those indicates are the type/subtype
values, so we can't shrink the array).

Clean up white space and remove some comments that shouldn't have been
added.
2021-02-17 21:54:28 +00:00
Dario Lombardo fe71e26af2 spdx: more licenses converted.
Change-Id: I3861061ec261e63b23621799e020e811ed78a343
Reviewed-on: https://code.wireshark.org/review/26333
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-03-07 15:56:44 +00:00
Peter Wu f52d1d52a6 wslua: do not pop from empty stack on newer LUA versions
Fixes this failure:

    tshark: lapi.c:175: lua_settop: Assertion `(-(idx+1) <= (L->top - (func + 1))) && "invalid new top"' failed.

Found using LUA 5.2 compiled with -DLUA_USE_APICHECK. Note that the
value returned by luaopen_bit does not affect the size of the stack
after using lua_call; if there are excess return values, then these will
be dropped after calling lua_call. See http://www.lua.org/pil/26.2.html

I also verified that the stack is still empty after calling all
wslua_reg_module functions.

Change-Id: Ia72635277ca4d8077e47a5c472391a78fe6d311e
Reviewed-on: https://code.wireshark.org/review/10664
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2015-09-30 12:31:56 +00:00
Jeff Morriss 042623617b Get us building with the subdir-objects automake option.
subdir-objects will be enabled unconditionally in automake-2.0 and
automake-1.14 gives us warnings about the upcoming change.

Rework I1b3c517f08d3c752ee03cb89482ee4951ceb5bf3 (and
I416f2d3611fb61659b9a7f7285e5f54a354fbe7d) to give wslua/make-reg.pl the directory of
the source files rather than the full path to each.

In echld don't use sources in the top-level directory in libechld: it breaks
distclean with subdir-objects turned on.

Bug: 10648
Change-Id: I404b074f1558376064c35d8fc96aea7e3d042a76
Reviewed-on: https://code.wireshark.org/review/6697
Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
2015-01-22 02:12:46 +00:00
Alexis La Goutte 757aa33220 Continue to remove $Id$ from top of file
(Using sed : sed -i '/^\# \$Id\$/,+1 d') (start with dash)

Change-Id: Ia4b5a6c2302f6a531f6a86c1ec3a2f8205c8c2dd
Reviewed-on: https://code.wireshark.org/review/881
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-31 18:48:06 +00:00
Hadriel Kaplan ea46cdc474 Add GLib's regex library into Lua
While Lua's built-in pattern support is ok for simple things, many people end
up wanting a real regex engine. Since Wireshark already includes the GLib
Regex library (a wrapper for PCRE), it makes sense to expose that library to
Lua scripts. This has been done using Lrexlib, one of the most popular regex
bindings for Lua. Lrexlib didn't support binding GLib's Regex in particular -
it does for PCRE but GLib is a different API - so I've done that. A fairly
thorough testsuite came along with that, which has been incorporated into the
wireshark wslua testuites as well in this commit.

Change-Id: I05811d1edf7af8d7c9f4f081de6850f31c0717c7
Reviewed-on: https://code.wireshark.org/review/332
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2014-03-10 07:11:12 +00:00
Hadriel Kaplan 2e7f771a18 Adds support for Lua Int64 and UInt64 operators, functions, and general
usefulness, working around bug #9162 until Lua 5.3 is released.

The existing Int64 and UInt64 classes provide virtually no
usefullness, other than for creating a string of their value.  While
one could then write Lua code to convert the string to Lua numbers and
such, ultimately Lua has no native 64-bit integer support, making such
a task difficult to handle in Lua.  This change adds a host of
functions and operators to the existing Int64 (gint64) and UInt64
(guint64) classes, to enable true 64-bit integer support on par with
native Lua numbers.

A test script is also provided, which tests the functions/operators.

Change-Id: I4c5f8f5219b9a88198902283bd32ddf24c346bbe
Reviewed-on: https://code.wireshark.org/review/83
Tested-by: Evan Huus <eapache@gmail.com>
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-02-04 00:37:46 +00:00
Hadriel Kaplan 3d59ff9e95 Fix for Bug-9711 Lua: the Lua stack is growing slightly during initialization.
Change-Id: I689319c0071fdb42583e8bd7633d8f0660c92f1b
Reviewed-on: https://code.wireshark.org/review/51
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Stig Bjørlykke <stig@bjorlykke.org>
2014-01-31 16:31:59 +00:00
Guy Harris 59722b868d In a source file that defines external functions, the header file that
declares the functions must be included, in order to make sure the
declarations match the function signature.  Make it so - which means
creating the header file in the first place.

That means luaopen_bit() doesn't need to, and shouldn't be, declared in
wslua.h.

Have make-reg.pl generate a #include of lua_bitop.h.  Also fix the "this
is autogenerated" warning.

svn path=/trunk/; revision=54725
2014-01-13 22:06:12 +00:00
Stig Bjørlykke c0d7a95f4e From Robert G. Jakabosky via bug 5575:
Fix module registration.  Must use lua_call() when calling luaopen_*()

svn path=/trunk/; revision=51965
2013-09-12 11:34:13 +00:00
Jeff Morriss 3729335973 We always HAVE_CONFIG_H so don't bother checking whether we have it or not.
svn path=/trunk/; revision=45016
2012-09-20 01:48:30 +00:00
Jakub Zawadzki bf81b42e1e Update Free Software Foundation address.
(COPYING will be updated in next commit)

svn path=/trunk/; revision=43536
2012-06-28 22:56:06 +00:00
Stig Bjørlykke 43851d797d Include config.h only from .c files.
This avoids a warning building epan.c which includes both config.h and wslua.h
(duplicate defines from config.h)

svn path=/trunk/; revision=36751
2011-04-21 13:13:39 +00:00
Stig Bjørlykke 155651b404 Move luaopen_bit() to wslua.h
svn path=/trunk/; revision=30193
2009-09-29 11:27:26 +00:00
Stig Bjørlykke 9b0aa6912f Added Lua BitOp, made by Mike Pall.
svn path=/trunk/; revision=28758
2009-06-16 05:26:46 +00:00
Balint Reczey 8566c6046e Adds 64 bit integer handling to Lua interface.
Fixes bug 2750.

svn path=/trunk/; revision=26216
2008-09-16 14:37:00 +00:00
Luis Ontanon e23201c62a - Make sure that the registration files are created whenever there's a change
- get rid of 5.0.2 stuff
- add the apply_filter() API


svn path=/trunk/; revision=19406
2006-10-03 14:27:45 +00:00
Luis Ontanon 6462d05044 Move the Lua interface into epan... (not a plugin anymore).
- Rename Tap into Listener
- add a mechanism to pass protocols' tap data to the Listener


svn path=/trunk/; revision=19319
2006-09-25 01:09:00 +00:00