For now, call the finish routine in Lua file writers "close".
authorGuy Harris <guy@alum.mit.edu>
Mon, 16 Nov 2015 19:17:45 +0000 (11:17 -0800)
committerGuy Harris <guy@alum.mit.edu>
Mon, 16 Nov 2015 19:18:15 +0000 (19:18 +0000)
If we ever change the way file writers work, in a fashion incompatible
with the existing way they work, we'll also rename this member - and get
rid of checks for earlier versions of the Lua interface.

Change-Id: I64065944fa31371f5249cafd930c18f180ad7299
Reviewed-on: https://code.wireshark.org/review/11879
Reviewed-by: Guy Harris <guy@alum.mit.edu>
epan/wslua/wslua.h
epan/wslua/wslua_file_handler.c
test/lua/pcap_file.lua

index 80226b1fb7cc28d4c85d58d0f434ca3b46a008e0..4d0ca22b60939b9513debbdc7be957ba850c5111 100644 (file)
@@ -290,7 +290,7 @@ struct _wslua_filehandler {
     int can_write_encap_ref;
     int write_open_ref;
     int write_ref;
-    int write_finish_ref;
+    int write_close_ref;
     int file_type;
     gboolean registered;
 };
index ea4fa8d1865d16c2e17e944b395369d9403b838a..1fced5dca56579d6ca5ba2265c1853ce172b226f 100644 (file)
@@ -515,7 +515,7 @@ wslua_filehandler_dump_open(wtap_dumper *wdh, int *err)
         }
 
         /* it's ok to not have a finish routine */
-        if (fh->write_finish_ref != LUA_NOREF)
+        if (fh->write_close_ref != LUA_NOREF)
             wdh->subtype_finish = wslua_filehandler_dump_finish;
         else
             wdh->subtype_finish = NULL;
@@ -582,7 +582,7 @@ wslua_filehandler_dump_finish(wtap_dumper *wdh, int *err)
     File *fp = NULL;
     CaptureInfoConst *fc = NULL;
 
-    INIT_FILEHANDLER_ROUTINE(write_finish,FALSE);
+    INIT_FILEHANDLER_ROUTINE(write_close,FALSE);
 
     /* Reset errno */
     if (err) {
@@ -597,7 +597,7 @@ wslua_filehandler_dump_finish(wtap_dumper *wdh, int *err)
         case 0:
             retval = wslua_optboolint(L,-1,0);
             break;
-        CASE_ERROR("write_finish")
+        CASE_ERROR("write_close")
     }
 
     END_FILEHANDLER_ROUTINE();
@@ -656,7 +656,7 @@ WSLUA_CONSTRUCTOR FileHandler_new(lua_State* L) {
     fh->seq_read_close_ref = LUA_NOREF;
     fh->write_open_ref = LUA_NOREF;
     fh->write_ref = LUA_NOREF;
-    fh->write_finish_ref = LUA_NOREF;
+    fh->write_close_ref = LUA_NOREF;
     fh->can_write_encap_ref = LUA_NOREF;
 
     fh->registered = FALSE;
@@ -795,7 +795,7 @@ WSLUA_FUNCTION wslua_deregister_filehandler(lua_State* L) {
     int can_write_encap_ref;
     int write_open_ref;
     int write_ref;
-    int write_finish_ref;
+    int write_close_ref;
 */
 
 /* WSLUA_ATTRIBUTE FileHandler_read_open WO The Lua function to be called when Wireshark opens a file for reading.
@@ -908,7 +908,7 @@ WSLUA_ATTRIBUTE_FUNC_SETTER(FileHandler,write);
 
     It is not necessary to set this field to a Lua function - `FileHandler` can be registered without doing so - it is available
     in case there is memory/state to clear in your script when the file is closed. */
-WSLUA_ATTRIBUTE_FUNC_SETTER(FileHandler,write_finish);
+WSLUA_ATTRIBUTE_FUNC_SETTER(FileHandler,write_close);
 
 /* generate other member accessors setters/getters */
 
@@ -957,7 +957,7 @@ WSLUA_ATTRIBUTES FileHandler_attributes[] = {
     WSLUA_ATTRIBUTE_WOREG(FileHandler,can_write_encap),
     WSLUA_ATTRIBUTE_WOREG(FileHandler,write_open),
     WSLUA_ATTRIBUTE_WOREG(FileHandler,write),
-    WSLUA_ATTRIBUTE_WOREG(FileHandler,write_finish),
+    WSLUA_ATTRIBUTE_WOREG(FileHandler,write_close),
     WSLUA_ATTRIBUTE_ROREG(FileHandler,type),
     WSLUA_ATTRIBUTE_RWREG(FileHandler,extensions),
     WSLUA_ATTRIBUTE_RWREG(FileHandler,writing_must_seek),
index e013b8a16b6adf25eed3afcabd8fdd3db1289947..b949a38717dba4c114bae5878b107411bf4fa735 100644 (file)
@@ -730,8 +730,8 @@ local function write(file, capture, frame)
     return true
 end
 
-local function write_finish(file, capture)
-    dprint2("write_finish() called")
+local function write_close(file, capture)
+    dprint2("write_close() called")
     dprint2("Good night, and good luck")
     return true
 end
@@ -743,7 +743,7 @@ local fh2 = FileHandler.new("Lua-based PCAP writer", "lua_pcap2", "A Lua-based f
 fh2.can_write_encap = can_write_encap
 fh2.write_open = write_open
 fh2.write = write
-fh2.write_finish = write_finish
+fh2.write_close = write_close
 fh2.extensions = "pcap;cap" -- this is just a hint
 
 -- and finally, register the FileHandler!