diff --git a/src/Makefile.am b/src/Makefile.am index 0a5efb99..135f5843 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -101,7 +101,6 @@ libdiag_a_SOURCES = \ ansi_scrubber.cc \ bookmarks.cc \ collation-functions.cc \ - datetime-extension-functions.cc \ extension-functions.c \ fs-extension-functions.cc \ grep_proc.cc \ @@ -126,6 +125,7 @@ libdiag_a_SOURCES = \ pcrepp.cc \ piper_proc.cc \ sql_util.cc \ + state-extension-functions.cc \ strnatcmp.c \ textview_curses.cc \ view_curses.cc \ diff --git a/src/Makefile.in b/src/Makefile.in index 280e7983..48307342 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -107,20 +107,19 @@ am__v_AR_1 = libdiag_a_AR = $(AR) $(ARFLAGS) libdiag_a_LIBADD = am_libdiag_a_OBJECTS = ansi_scrubber.$(OBJEXT) bookmarks.$(OBJEXT) \ - collation-functions.$(OBJEXT) \ - datetime-extension-functions.$(OBJEXT) \ - extension-functions.$(OBJEXT) fs-extension-functions.$(OBJEXT) \ - grep_proc.$(OBJEXT) hist_source.$(OBJEXT) \ - line_buffer.$(OBJEXT) listview_curses.$(OBJEXT) \ - lnav_commands.$(OBJEXT) lnav_config.$(OBJEXT) \ - lnav_util.$(OBJEXT) log_format.$(OBJEXT) logfile.$(OBJEXT) \ - logfile_sub_source.$(OBJEXT) \ + collation-functions.$(OBJEXT) extension-functions.$(OBJEXT) \ + fs-extension-functions.$(OBJEXT) grep_proc.$(OBJEXT) \ + hist_source.$(OBJEXT) line_buffer.$(OBJEXT) \ + listview_curses.$(OBJEXT) lnav_commands.$(OBJEXT) \ + lnav_config.$(OBJEXT) lnav_util.$(OBJEXT) log_format.$(OBJEXT) \ + logfile.$(OBJEXT) logfile_sub_source.$(OBJEXT) \ network-extension-functions.$(OBJEXT) data_scanner.$(OBJEXT) \ data_parser.$(OBJEXT) readline_curses.$(OBJEXT) \ session_data.$(OBJEXT) sequence_matcher.$(OBJEXT) \ sqlite-extension-func.$(OBJEXT) statusview_curses.$(OBJEXT) \ string-extension-functions.$(OBJEXT) pcrepp.$(OBJEXT) \ - piper_proc.$(OBJEXT) sql_util.$(OBJEXT) strnatcmp.$(OBJEXT) \ + piper_proc.$(OBJEXT) sql_util.$(OBJEXT) \ + state-extension-functions.$(OBJEXT) strnatcmp.$(OBJEXT) \ textview_curses.$(OBJEXT) view_curses.$(OBJEXT) \ vt52_curses.$(OBJEXT) log_vtab_impl.$(OBJEXT) \ xterm_mouse.$(OBJEXT) yajlpp.$(OBJEXT) yajl.$(OBJEXT) \ @@ -432,7 +431,6 @@ libdiag_a_SOURCES = \ ansi_scrubber.cc \ bookmarks.cc \ collation-functions.cc \ - datetime-extension-functions.cc \ extension-functions.c \ fs-extension-functions.cc \ grep_proc.cc \ @@ -457,6 +455,7 @@ libdiag_a_SOURCES = \ pcrepp.cc \ piper_proc.cc \ sql_util.cc \ + state-extension-functions.cc \ strnatcmp.c \ textview_curses.cc \ view_curses.cc \ @@ -617,7 +616,6 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/collation-functions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data_parser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data_scanner.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/datetime-extension-functions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extension-functions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs-extension-functions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grep_proc.Po@am__quote@ @@ -640,6 +638,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/session_data.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sql_util.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sqlite-extension-func.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/state-extension-functions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/statusview_curses.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string-extension-functions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strnatcmp.Po@am__quote@ diff --git a/src/sqlite-extension-func.c b/src/sqlite-extension-func.c index 70d22dee..ba5c239d 100644 --- a/src/sqlite-extension-func.c +++ b/src/sqlite-extension-func.c @@ -38,7 +38,7 @@ sqlite_registration_func_t sqlite_registration_funcs[] = { common_extension_functions, - datetime_extension_functions, + state_extension_functions, string_extension_functions, network_extension_functions, fs_extension_functions, diff --git a/src/sqlite-extension-func.h b/src/sqlite-extension-func.h index e7b9f52d..54f2a68d 100644 --- a/src/sqlite-extension-func.h +++ b/src/sqlite-extension-func.h @@ -63,8 +63,8 @@ typedef int (*sqlite_registration_func_t)(const struct FuncDef **basic_funcs, int common_extension_functions(const struct FuncDef **basic_funcs, const struct FuncDefAgg **agg_funcs); -int datetime_extension_functions(const struct FuncDef **basic_funcs, - const struct FuncDefAgg **agg_funcs); +int state_extension_functions(const struct FuncDef **basic_funcs, + const struct FuncDefAgg **agg_funcs); int string_extension_functions(const struct FuncDef **basic_funcs, const struct FuncDefAgg **agg_funcs); diff --git a/src/datetime-extension-functions.cc b/src/state-extension-functions.cc similarity index 78% rename from src/datetime-extension-functions.cc rename to src/state-extension-functions.cc index e6c6c211..4f12f082 100644 --- a/src/datetime-extension-functions.cc +++ b/src/state-extension-functions.cc @@ -26,7 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * @file datetime-extension-functions.cc + * @file state-extension-functions.cc */ #include @@ -42,7 +42,14 @@ #include "sql_util.hh" #include "sqlite-extension-func.h" -static void sql_logline_datetime(sqlite3_context *context, +static void sql_log_top_line(sqlite3_context *context, + int argc, sqlite3_value **argv) +{ + sqlite3_result_int64(context, + (int64_t)lnav_data.ld_views[LNV_LOG].get_top()); +} + +static void sql_log_top_datetime(sqlite3_context *context, int argc, sqlite3_value **argv) { char buffer[64]; @@ -55,11 +62,12 @@ static void sql_logline_datetime(sqlite3_context *context, sqlite3_result_text(context, buffer, strlen(buffer), SQLITE_TRANSIENT); } -int datetime_extension_functions(const struct FuncDef **basic_funcs, - const struct FuncDefAgg **agg_funcs) +int state_extension_functions(const struct FuncDef **basic_funcs, + const struct FuncDefAgg **agg_funcs) { static const struct FuncDef datetime_funcs[] = { - { "logline_datetime", 0, 0, SQLITE_UTF8, 0, sql_logline_datetime }, + { "log_top_line", 0, 0, SQLITE_UTF8, 0, sql_log_top_line }, + { "log_top_datetime", 0, 0, SQLITE_UTF8, 0, sql_log_top_datetime }, { NULL } };