[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.1

1.1     ! canacar     1: /* $Id: engine.h,v 1.7 2007/10/02 04:17:37 canacar Exp $        */
        !             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 {
        !            56:        char *title;
        !            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;
        !            95:        void ( *exec)(void);
        !            96: };
        !            97:
        !            98:
        !            99: void tb_start(void);
        !           100:
        !           101: void tb_end(void);
        !           102:
        !           103: int tbprintf(char *format, ...) GCC_PRINTFLIKE(1,2);
        !           104:
        !           105: void end_line(void);
        !           106: void end_page(void);
        !           107:
        !           108: void print_fld_str(field_def *fld, const char *str);
        !           109: void print_fld_age(field_def *fld, unsigned int age);
        !           110: void print_fld_sdiv(field_def *fld, u_int64_t size, int div);
        !           111: void print_fld_size(field_def *fld, u_int64_t size);
        !           112: void print_fld_bw(field_def *fld, double bw);
        !           113: void print_fld_rate(field_def *fld, double rate);
        !           114: void print_fld_uint(field_def *fld, unsigned int size);
        !           115: void print_fld_bar(field_def *fld, int value);
        !           116: void print_fld_tb(field_def *fld);
        !           117:
        !           118: void print_title(void);
        !           119:
        !           120: void hide_field(field_def *fld);
        !           121: void show_field(field_def *fld);
        !           122: void field_setup(void);
        !           123:
        !           124: void add_view(field_view *fv);
        !           125: int set_view(char *opt);
        !           126: void next_view(void);
        !           127: void prev_view(void);
        !           128:
        !           129: void set_order(char *opt);
        !           130: void next_order(void);
        !           131:
        !           132: void setup_term(int maxpr);
        !           133:
        !           134: void engine_initialize(void);
        !           135: void engine_loop(int countmax);
        !           136:
        !           137: struct command *command_set(struct command *cmd, const char *init);
        !           138: const char *message_set(const char *msg);
        !           139:
        !           140: void foreach_view(void (*callback)(field_view *));
        !           141:
        !           142: extern int sortdir;
        !           143: extern useconds_t udelay;
        !           144: extern int dispstart;
        !           145: extern int interactive;
        !           146: extern int maxprint;
        !           147: extern int paused;
        !           148: extern int rawmode;
        !           149: extern int rawwidth;
        !           150: extern int columns, lines;
        !           151:
        !           152: extern int need_update;
        !           153: extern int need_sort;
        !           154:
        !           155: extern volatile sig_atomic_t gotsig_close;
        !           156: extern volatile sig_atomic_t gotsig_resize;
        !           157: extern volatile sig_atomic_t gotsig_alarm;
        !           158:
        !           159: extern field_view *curr_view;
        !           160: extern struct view_manager *curr_mgr;
        !           161:
        !           162: extern char tmp_buf[MAX_LINE_BUF];
        !           163: extern char cmdbuf[MAX_LINE_BUF];
        !           164:
        !           165: extern int curr_line; /* XXX temp */
        !           166: extern u_int32_t num_disp;
        !           167: #endif