2012-07-13 16:26:47 +00:00
|
|
|
/**
|
2013-05-03 06:02:03 +00:00
|
|
|
* Copyright (c) 2007-2012, Timothy Stack
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
2013-05-28 04:35:00 +00:00
|
|
|
*
|
2013-05-03 06:02:03 +00:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
2013-05-28 04:35:00 +00:00
|
|
|
*
|
2013-05-03 06:02:03 +00:00
|
|
|
* * Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
* * Neither the name of Timothy Stack nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
2013-05-28 04:35:00 +00:00
|
|
|
*
|
2013-05-03 06:02:03 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
|
|
|
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
|
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2012-07-13 16:26:47 +00:00
|
|
|
* @file lnav.hh
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __lnav_hh
|
|
|
|
#define __lnav_hh
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-09-06 14:37:18 +00:00
|
|
|
#include <signal.h>
|
|
|
|
|
2012-07-13 16:26:47 +00:00
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <list>
|
|
|
|
#include <stack>
|
|
|
|
#include <memory>
|
|
|
|
|
2013-05-31 15:01:31 +00:00
|
|
|
#include "byte_array.hh"
|
2012-07-13 16:26:47 +00:00
|
|
|
#include "grapher.hh"
|
|
|
|
#include "logfile.hh"
|
|
|
|
#include "hist_source.hh"
|
|
|
|
#include "statusview_curses.hh"
|
|
|
|
#include "listview_curses.hh"
|
|
|
|
#include "top_status_source.hh"
|
|
|
|
#include "bottom_status_source.hh"
|
|
|
|
#include "grep_highlighter.hh"
|
|
|
|
#include "db_sub_source.hh"
|
|
|
|
#include "textfile_sub_source.hh"
|
|
|
|
#include "log_vtab_impl.hh"
|
2013-05-31 15:01:31 +00:00
|
|
|
#include "readline_curses.hh"
|
2013-10-11 13:22:29 +00:00
|
|
|
#include "xterm_mouse.hh"
|
|
|
|
#include "piper_proc.hh"
|
2014-02-10 15:25:28 +00:00
|
|
|
#include "term_extra.hh"
|
2012-07-13 16:26:47 +00:00
|
|
|
|
|
|
|
/** The command modes that are available while viewing a file. */
|
|
|
|
typedef enum {
|
|
|
|
LNM_PAGING,
|
|
|
|
LNM_COMMAND,
|
|
|
|
LNM_SEARCH,
|
|
|
|
LNM_CAPTURE,
|
|
|
|
LNM_SQL,
|
|
|
|
} ln_mode_t;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
LNB_SYSLOG,
|
|
|
|
LNB__MAX,
|
|
|
|
|
2014-02-10 15:53:56 +00:00
|
|
|
LNB_TIMESTAMP,
|
|
|
|
LNB_HELP,
|
|
|
|
LNB_ROTATED,
|
2012-07-13 16:26:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Flags set on the lnav command-line. */
|
|
|
|
typedef enum {
|
2013-05-28 04:35:00 +00:00
|
|
|
LNF_SYSLOG = (1L << LNB_SYSLOG),
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
LNF_ROTATED = (1L << LNB_ROTATED),
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
LNF_TIMESTAMP = (1L << LNB_TIMESTAMP),
|
2014-02-10 15:53:56 +00:00
|
|
|
LNF_HELP = (1L << LNB_HELP),
|
2013-05-01 04:48:16 +00:00
|
|
|
|
2014-02-10 15:53:56 +00:00
|
|
|
LNF__ALL = (LNF_SYSLOG|LNF_HELP)
|
2012-07-13 16:26:47 +00:00
|
|
|
} lnav_flags_t;
|
|
|
|
|
|
|
|
/** The different views available. */
|
|
|
|
typedef enum {
|
|
|
|
LNV_LOG,
|
|
|
|
LNV_TEXT,
|
|
|
|
LNV_HELP,
|
|
|
|
LNV_HISTOGRAM,
|
|
|
|
LNV_GRAPH,
|
|
|
|
LNV_DB,
|
|
|
|
LNV_EXAMPLE,
|
|
|
|
|
|
|
|
LNV__MAX
|
|
|
|
} lnav_view_t;
|
|
|
|
|
2013-05-31 15:01:31 +00:00
|
|
|
extern const char *lnav_view_strings[LNV__MAX];
|
|
|
|
|
2012-07-13 16:26:47 +00:00
|
|
|
/** The status bars. */
|
|
|
|
typedef enum {
|
|
|
|
LNS_TOP,
|
|
|
|
LNS_BOTTOM,
|
|
|
|
|
|
|
|
LNS__MAX
|
|
|
|
} lnav_status_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
LG_GRAPH,
|
|
|
|
LG_CAPTURE,
|
2012-09-06 14:37:18 +00:00
|
|
|
|
2012-07-13 16:26:47 +00:00
|
|
|
LG__MAX
|
|
|
|
} lnav_grep_t;
|
|
|
|
|
|
|
|
void sqlite_close_wrapper(void *mem);
|
|
|
|
|
2013-06-16 01:07:50 +00:00
|
|
|
typedef std::pair<int, int> ppid_time_pair_t;
|
2013-06-02 21:20:15 +00:00
|
|
|
typedef std::pair<ppid_time_pair_t, std::string> session_pair_t;
|
|
|
|
|
2012-07-13 16:26:47 +00:00
|
|
|
struct _lnav_data {
|
2013-06-16 01:07:50 +00:00
|
|
|
std::string ld_session_id;
|
|
|
|
time_t ld_session_time;
|
2013-06-19 13:47:36 +00:00
|
|
|
time_t ld_session_load_time;
|
2013-06-16 01:07:50 +00:00
|
|
|
time_t ld_session_save_time;
|
|
|
|
std::list<session_pair_t> ld_session_file_names;
|
|
|
|
int ld_session_file_index;
|
2013-05-28 04:35:00 +00:00
|
|
|
const char * ld_program_name;
|
|
|
|
const char * ld_debug_log_name;
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
std::set<std::pair<std::string, int> > ld_file_names;
|
|
|
|
std::list<logfile *> ld_files;
|
|
|
|
std::list<std::string> ld_other_files;
|
2013-09-14 19:30:57 +00:00
|
|
|
std::list<std::pair<std::string, int> > ld_files_to_front;
|
2013-05-28 04:35:00 +00:00
|
|
|
sig_atomic_t ld_looping;
|
|
|
|
sig_atomic_t ld_winched;
|
2013-10-11 13:22:29 +00:00
|
|
|
sig_atomic_t ld_child_terminated;
|
2013-05-28 04:35:00 +00:00
|
|
|
unsigned long ld_flags;
|
|
|
|
WINDOW * ld_window;
|
|
|
|
ln_mode_t ld_mode;
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
statusview_curses ld_status[LNS__MAX];
|
|
|
|
top_status_source ld_top_source;
|
|
|
|
bottom_status_source ld_bottom_source;
|
|
|
|
listview_curses::action::broadcaster ld_scroll_broadcaster;
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
time_t ld_top_time;
|
2013-06-22 14:55:49 +00:00
|
|
|
int ld_top_time_millis;
|
2013-05-28 04:35:00 +00:00
|
|
|
time_t ld_bottom_time;
|
2013-06-22 14:55:49 +00:00
|
|
|
int ld_bottom_time_millis;
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
std::stack<textview_curses *> ld_view_stack;
|
|
|
|
textview_curses ld_views[LNV__MAX];
|
|
|
|
std::auto_ptr<grep_highlighter> ld_search_child[LNV__MAX];
|
|
|
|
vis_line_t ld_search_start_line;
|
|
|
|
readline_curses * ld_rl_view;
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
logfile_sub_source ld_log_source;
|
|
|
|
hist_source ld_hist_source;
|
|
|
|
int ld_hist_zoom;
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
textfile_sub_source ld_text_source;
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
std::map<textview_curses *, int> ld_last_user_mark;
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
grapher ld_graph_source;
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
hist_source ld_db_source;
|
|
|
|
db_label_source ld_db_rows;
|
|
|
|
db_overlay_source ld_db_overlay;
|
|
|
|
std::vector<std::string> ld_db_key_names;
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
int ld_max_fd;
|
|
|
|
fd_set ld_read_fds;
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
std::auto_ptr<grep_highlighter> ld_grep_child[LG__MAX];
|
2013-07-24 14:42:16 +00:00
|
|
|
std::string ld_previous_search;
|
2013-06-16 01:07:50 +00:00
|
|
|
std::string ld_last_search[LNV__MAX];
|
2012-07-13 16:26:47 +00:00
|
|
|
|
2013-05-28 04:35:00 +00:00
|
|
|
log_vtab_manager * ld_vtab_manager;
|
|
|
|
auto_mem<sqlite3, sqlite_close_wrapper> ld_db;
|
2013-10-11 13:22:29 +00:00
|
|
|
|
|
|
|
std::list<pid_t> ld_children;
|
|
|
|
std::list<piper_proc *> ld_pipers;
|
|
|
|
xterm_mouse ld_mouse;
|
2014-02-10 15:25:28 +00:00
|
|
|
term_extra ld_term_extra;
|
2012-07-13 16:26:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct _lnav_data lnav_data;
|
|
|
|
|
|
|
|
void rebuild_indexes(bool force);
|
|
|
|
|
2013-05-24 14:55:56 +00:00
|
|
|
void ensure_view(textview_curses *expected_tc);
|
2013-01-20 06:28:21 +00:00
|
|
|
bool toggle_view(textview_curses *toggle_tc);
|
2013-06-02 21:20:15 +00:00
|
|
|
|
|
|
|
std::string execute_command(std::string cmdline);
|
|
|
|
|
2013-06-06 02:34:48 +00:00
|
|
|
bool setup_logline_table();
|
|
|
|
int sql_callback(sqlite3_stmt *stmt);
|
|
|
|
|
2013-06-15 23:42:21 +00:00
|
|
|
void execute_search(lnav_view_t view, const std::string ®ex);
|
2013-09-14 19:30:57 +00:00
|
|
|
|
|
|
|
void redo_search(lnav_view_t view_index);
|
|
|
|
|
2012-07-13 16:26:47 +00:00
|
|
|
#endif
|