📄 display.c
字号:
/*************************************************************************** * * * db.* * * open source database kernel * * * * Copyright (c) 2000 Centura Software Corporation. All rights reserved. * * * * Use of this software, whether in source code format, or in executable, * * binary object code form, is governed by the CENTURA OPEN SOURCE LICENSE * * which is fully described in the LICENSE.TXT file, included within this * * distribution of source code files. * * * * Except as provided herein, the contents of this file are subject to the * * Centura Open Source Public License Version 1.0 (the "License"); you may * * not use this file except in compliance with the License. A copy of the * * License will be provided to you by Club ITTIA. * * * * Software distributed under the License is distributed on an "AS IS" * * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the * * License for the specific language governing rights and limitations * * under the License. * * * * The Original Code is db.linux version 1.0, released February 29, 2000. * * * * The Initial Developer of the Original Code is Centura Software * * Corporation. Portions created by Centura Software Corporation are * * Copyright (C) 1984-2000 Centura Software Corporation. All Rights * * Reserved. * * * * This file contains modifications to the Original Code made by ITTIA. * * This file may only be used in accordance with the ITTIA DB.* V.2 * * License Agreement which is available at WWW.ITTIA.COM. * * * **************************************************************************/#ifdef HAVE_CONFIG_H#include "psp_config.h"#endif#include "db.star.h"#include "dbtype.h"#ifndef WIN32#include <unistd.h>#endif#include <signal.h>#include "console.h"#include "ida.h"#define G_TOP 12#define UR_TOP 2#define FR_TOP 2#define US_TOP 9#define FS_TOP 3#define U_NAME_COL 2#define U_PEND_COL 21#define U_TIME_COL 26#define U_STAT_COL 31#define U_REC_COL 41#define U_LOG_COL 46#define F_NUM_COL 0#define F_NAME_COL 5#define F_NAME_LEN 24#define F_STAT_COL 30#define F_NUML_COL 36#define F_HOLD_COL 39#define F_PEND_COL 57#define G_QITMS_XY 6, 64#define G_MSGSR_XY 8, 64#define G_MSGSS_XY 9, 64#define G_GRANT_XY 6, 11#define G_REJCT_XY 7, 11#define G_TMOUT_XY 8, 11#define G_TOTAL_XY 9, 11#define G_FREED_XY 9, 27#define G_NUSER_XY 11, 06#define US_NAME_XY 0, 12#define US_TOUT_XY 0, 75#define US_PID_XY 1, 12#define US_TIME_XY 1, 75#define US_TAF_XY 2, 12#define US_STAT_XY 4, 12#define US_REC_XY 5, 12#define US_LOG_XY 6, 12#define US_LOCK_XY 8, 4#define US_PEND_XY 8, 14#define US_OPEN_XY 8, 24#define US_NET1_XY 4, 50#define US_NET2_XY 5, 50#define US_NET3_XY 6, 50#define FS_NAME_XY 0, 16#define FS_LOCK_XY 2, 4#define FS_REQ_XY 2, 13#define FS_OPEN_XY 2, 23#define MAXROWS 50#define CMD_LINE 23char *commands[] = { "USERS", "USER", "STATUS", "SHUTDOWN", "REFRESH", "QUIT", "FILES", "FILE", "KILL", "HELP", "EXIT", NULL};enum cmd { CMD_USERS, CMD_USER, CMD_STATUS, CMD_SHUTDOWN, CMD_REFRESH, CMD_QUIT, CMD_FILES, CMD_FILE, CMD_KILL, CMD_HELP, CMD_EXIT, CMD_DEFAULT};enum outline{ NO_OUTLINE, GENERAL_STATUS, USER_REPORT, FILE_REPORT, USER_STATUS, FILE_STATUS};typedef struct USERLINE_S{ int clr; int pend; int time; char rec[4]; char stat[9]; char name[17]; char log[17];} USERLINE;typedef struct FILELINE_S{ int clr; int num; int numl; char stat; char name[25]; char hold[17]; char pend[33];} FILELINE;typedef struct GENLINE_S{ int clr; char name[5][16];} GENLINE;typedef struct GENSCREEN_S{ long qitms; long msgsr; long msgss; long grant; long rejct; long tmout; long total; long freed; int clr; int nuser; GENLINE *lines;} GENSCREEN;typedef struct USERDATALINE_S{ int clr; char lock; char req; char name[45];} USERDATALINE;typedef struct USERDATASCREEN_S{ long pid; int clr; int timeout; int timer; int numlocks; int numreq; int numopen; char name[17]; char status[9]; char recover[4]; char logfile[FILENMLEN]; char taffile[FILENMLEN]; USERDATALINE *lines;} USERDATASCREEN;typedef struct FILEDATALINE_S{ int clr; char lock; char req; char name[17];} FILEDATALINE;typedef struct FILEDATASCREEN_S{ int clr; int numlock; int numreq; int numopen; char name[FILENMLEN]; FILEDATALINE *lines;} FILEDATASCREEN;/*** Local Functions ***/static void repaint(int);static void general_status(short);static void user_report(short);static void file_report(short);static void user_status(short);static void file_status(short);static void help_func(short);static void print_gs_outline(void);static void print_ur_outline(void);static void print_fr_outline(void);static void print_us_outline(void);static void print_fs_outline(void);static void print_gs_data(short);static void print_ur_data(short);static void print_fr_data(short);static void print_us_data(short, unsigned short);static void print_fs_data(short, unsigned short);static void print_user_line(short, unsigned short);static void print_file_line(short, unsigned short);static void clear_line(short, int *);static void show_help(void);static int get_command();static int do_command(char *);static int good_char(char);static void print_command_line(void);static void locate_to_cmnd_line(void);static int is_blank(char *);static void str_test(short, short, char *, char *, int, int);static void long_test(short, short, long *, long, int);static void int_test(short, short, int *, int, int);static void spc_test(short, short, int *, int, int);static void char_test(short, short, char *, char, int);static void vioPrint(int, int, char *);static void vioPutChar(short);static void vioLocate(int, int);static void vioClear(void);static void vioClearLine(int);/*** Local Data ***/#define MAXCOMMAND 22static enum outline curr_outline = NO_OUTLINE;static char command[MAXCOMMAND + 2];static void (*report_func)(short) = general_status;static void (*temp_func)(short);static int vio_ok = 0;static short top_line = 1;static char user_to_view[16];static unsigned short file_to_view;static USERLINE *user_line = NULL;static FILELINE *file_line = NULL;static GENSCREEN *general = NULL;static USERDATASCREEN *user_data = NULL;static FILEDATASCREEN *file_data = NULL;static short *files_open = NULL;static short *users_open = NULL;/**************************************************************************/void error_msg(char *msg){ if (vio_ok) { vioClearLine((short) (CMD_LINE + 1)); vioPrint((short) (CMD_LINE + 1), 0, msg); } else printf(msg);}/**************************************************************************/static int good_char(char key){ if (isalnum(key) || (key == ' ') || (key == '?') || (key == '_') || (key == '$')) { return 1; } else { return 0; }}/**************************************************************************/#define MAXRESULT 18static int is_blank(char *data){ while (*data) { if (*data++ != ' ') return 0; } return 1;}/**************************************************************************/static void str_test( short x, short y, char *prev_data, char *new_data, int clear, int len){ char temp[65]; int old_len = strlen(prev_data); int data_len = strlen(new_data); len = min(len, (int) sizeof(temp)-1); data_len = min(data_len, len); len = max(data_len, old_len); if (clear || strncmp(new_data, prev_data, len)) { memcpy(temp, new_data, data_len); memset(temp + data_len, ' ', len - data_len); temp[len] = '\0'; vioPrint(x, y, temp); temp[data_len] = '\0'; strcpy(prev_data, temp); }}/**************************************************************************/static void long_test( short x, short y, long *prev_data, long new_data, int clear){ char temp[16]; if (clear || (new_data != *prev_data)) { sprintf(temp, "%-7ld", new_data); vioPrint(x, y, temp); *prev_data = new_data; }}/**************************************************************************/static void int_test( short x, short y, int *prev_data, int new_data, int clear){ char temp[10]; if (clear || (new_data != *prev_data)) { sprintf(temp, "%-5d", new_data); vioPrint(x, y, temp); *prev_data = new_data; }}/**************************************************************************/static void spc_test( short x, short y, int *prev_data, int new_data, int clear){ char temp[10]; if (clear || (new_data != *prev_data)) { sprintf(temp, "(%d)_", new_data); vioPrint(x, y, temp); *prev_data = new_data; }}/**************************************************************************/static void char_test( short x, short y, char *prev_data, char new_data, int clear){ char temp[2] = " "; if (clear || (new_data != *prev_data)) { temp[0] = new_data; vioPrint(x, y, temp); *prev_data = new_data; }}#define keyBackSpace 0x08#define keyEsc 0x1B#define keyHome 0x47#define keyEnter 0x0A#define keyUp 0x48#define keyDown 0x45#define keyLeft 0x44#define keyRight 0x43#define keyEnd 0x4F#define keyPgUp 0x41#define keyPgDn 0x42#define keyFFFF 0xFFFF#define keyEscape 0x1b#define keyExtended 0xe0/**************************************************************************/static int get_command(){ unsigned short key = 0, row; int stat, extended = 0; static int next_char; static int first_time = 1; if (first_time) { memset(command, 0, sizeof(command)); next_char = 0; first_time = 0; repaint(0); } if (report_func == help_func) { getchar(); first_time = 1; for (row = 11; row <= (unsigned short)(CMD_LINE + 1); ++row) vioClearLine(row); curr_outline = NO_OUTLINE; report_func = temp_func; if (report_func) (*report_func)(0); print_command_line(); } else { key = (short) getchar();#ifdef HAVE_ALARM if (key != keyFFFF) alarm(0);#endif extended = 0; if ((key == keyEscape) || (key == keyExtended)) { extended = 1; getchar(); /* Ignore second char */ key = (short) getchar(); } } if (key) { if ((key == keyEnter) && (next_char > 0)) { stat = do_command(command); memset(command, 0, sizeof(command)); if (stat != CMD_HELP) { first_time = TRUE; print_command_line(); } next_char = 0; return stat; } if ( extended && ( (key == keyPgDn) || (key == keyPgUp) ||
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -