[BACK]Return to engine.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / systat

Annotation of src/usr.bin/systat/engine.h, Revision 1.13

1.13    ! martijn     1: /* $OpenBSD: engine.h,v 1.12 2020/01/12 20:51:08 martijn Exp $  */
1.1       canacar     2: /*
                      3:  * Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org>
                      4:  *
                      5:  * Permission to use, copy, modify, and distribute this software for any
                      6:  * purpose with or without fee is hereby granted, provided that the above
                      7:  * copyright notice and this permission notice appear in all copies.
                      8:  *
                      9:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     10:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     11:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     12:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     13:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     14:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     15:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     16:  */
                     17:
                     18: #ifndef _ENGINE_H_
                     19: #define _ENGINE_H_
                     20:
                     21: #include <curses.h>
                     22:
                     23: #define DEFAULT_WIDTH  80
                     24: #define DEFAULT_HEIGHT 25
                     25:
                     26: /* XXX do not hardcode! */
                     27: #define HEADER_LINES 4
                     28:
                     29:
                     30: #define CTRL_A  1
                     31: #define CTRL_B  2
                     32: #define CTRL_E  5
                     33: #define CTRL_F  6
                     34: #define CTRL_G  7
                     35: #define CTRL_H  8
                     36: #define CTRL_L  12
                     37: #define CTRL_N  14
                     38: #define CTRL_P  16
                     39: #define CTRL_V  22
                     40:
                     41: #define META_V  246
                     42:
                     43: #define MAX_LINE_BUF 1024
                     44:
                     45:
                     46: #define FLD_ALIGN_LEFT   0
                     47: #define FLD_ALIGN_RIGHT  1
                     48: #define FLD_ALIGN_CENTER 2
                     49: #define FLD_ALIGN_COLUMN 3
                     50: #define FLD_ALIGN_BAR    4
                     51:
                     52: #define FLD_FLAG_HIDDEN 1
                     53:
                     54:
                     55: typedef struct {
1.11      dlg        56:        const char *title;
1.1       canacar    57:        int norm_width;
                     58:        int max_width;
                     59:        int increment;
                     60:        int align;
                     61:        int start;
                     62:        int width;
                     63:        unsigned flags;
                     64:        int arg;
                     65: } field_def;
                     66:
                     67: typedef struct {
                     68:        char *name;
                     69:        char *match;
                     70:        int hotkey;
                     71:        int (*func) (const void *, const void *);
                     72: } order_type;
                     73:
                     74: struct view_manager {
                     75:        char *name;
                     76:        int  (*select_fn) (void);
                     77:        int  (*read_fn)   (void);
                     78:        void (*sort_fn)   (void);
                     79:        int  (*header_fn) (void);
                     80:        void (*print_fn)  (void);
                     81:        int  (*key_fn)    (int);
                     82:        order_type *order_list;
                     83:        order_type *order_curr;
                     84: };
                     85:
                     86: typedef struct {
                     87:        field_def **view;
                     88:        char *name;
                     89:        int hotkey;
                     90:        struct view_manager *mgr;
                     91: } field_view;
                     92:
                     93: struct command {
                     94:        char *prompt;
1.3       canacar    95:        void ( *exec)(const char *);
1.1       canacar    96: };
                     97:
1.13    ! martijn    98: enum message_mode {
        !            99:        MESSAGE_NONE,
        !           100:        MESSAGE_HELP,
        !           101:        MESSAGE_VIEW,
        !           102:        MESSAGE_ORDER
        !           103: };
1.1       canacar   104:
                    105: void tb_start(void);
                    106:
                    107: void tb_end(void);
                    108:
                    109: int tbprintf(char *format, ...) GCC_PRINTFLIKE(1,2);
1.7       mpf       110: int tbprintft(char *format, ...) GCC_PRINTFLIKE(1,2);
1.1       canacar   111:
                    112: void end_line(void);
                    113: void end_page(void);
                    114:
1.5       canacar   115: void print_fld_str(field_def *, const char *);
                    116: void print_fld_age(field_def *, unsigned int);
                    117: void print_fld_sdiv(field_def *, u_int64_t, int);
                    118: void print_fld_size(field_def *, u_int64_t);
                    119: void print_fld_ssdiv(field_def *, int64_t, int);
                    120: void print_fld_ssize(field_def *, int64_t);
                    121: void print_fld_bw(field_def *, double);
                    122: void print_fld_rate(field_def *, double);
                    123: void print_fld_uint(field_def *, unsigned int);
                    124: void print_fld_float(field_def *, double, int);
                    125: void print_fld_bar(field_def *, int);
                    126: void print_fld_tb(field_def *);
1.1       canacar   127:
                    128: void print_title(void);
                    129:
                    130: void hide_field(field_def *fld);
                    131: void show_field(field_def *fld);
                    132: void field_setup(void);
                    133:
                    134: void add_view(field_view *fv);
1.3       canacar   135: int set_view(const char *opt);
1.1       canacar   136: void next_view(void);
                    137: void prev_view(void);
                    138:
1.9       martijn   139: int foreach_order(void (*callback)(order_type *));
1.3       canacar   140: void set_order(const char *opt);
1.1       canacar   141: void next_order(void);
1.13    ! martijn   142: void show_help(void);
        !           143: void show_view(void);
        !           144: void show_order(void);
1.1       canacar   145:
                    146: void setup_term(int maxpr);
1.6       lum       147: int check_termcap(void);
1.1       canacar   148:
                    149: void engine_initialize(void);
                    150: void engine_loop(int countmax);
                    151:
                    152: struct command *command_set(struct command *cmd, const char *init);
1.13    ! martijn   153: void message_toggle(enum message_mode);
1.1       canacar   154: const char *message_set(const char *msg);
                    155:
                    156: void foreach_view(void (*callback)(field_view *));
                    157:
                    158: extern int sortdir;
                    159: extern useconds_t udelay;
                    160: extern int dispstart;
1.12      martijn   161: extern int humanreadable;
1.1       canacar   162: extern int interactive;
1.8       reyk      163: extern int averageonly;
1.1       canacar   164: extern int maxprint;
                    165: extern int paused;
                    166: extern int rawmode;
                    167: extern int rawwidth;
                    168: extern int columns, lines;
                    169:
                    170: extern int need_update;
                    171: extern int need_sort;
1.7       mpf       172: extern int separate_thousands;
1.1       canacar   173:
                    174: extern volatile sig_atomic_t gotsig_close;
                    175: extern volatile sig_atomic_t gotsig_resize;
                    176: extern volatile sig_atomic_t gotsig_alarm;
                    177:
                    178: extern field_view *curr_view;
                    179: extern struct view_manager *curr_mgr;
                    180:
                    181: extern char tmp_buf[MAX_LINE_BUF];
                    182:
                    183: extern int curr_line; /* XXX temp */
                    184: extern u_int32_t num_disp;
                    185: #endif