⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 display.c

📁 db.* (pronounced dee-be star) is an advanced, high performance, small footprint embedded database fo
💻 C
📖 第 1 页 / 共 3 页
字号:
               (key == keyHome) || (key == keyEnd) ||               (key == keyLeft) || (key == keyRight) ) )        {            if (report_func)                (*report_func)(key);            return CMD_DEFAULT;        }        if (key == keyEsc)        {            memset(command, 0, sizeof(command));            next_char = 0;            print_command_line();            return CMD_DEFAULT;        }        if (key == keyBackSpace)        {            if (next_char > 0)            {                command[--next_char] = '\0';                vioPutChar(key);                vioPutChar(' ');                vioPutChar(key);            }        }        else        {            if ((next_char < MAXCOMMAND) && (!extended) && good_char((char) key))            {                command[next_char++] = (char) key;                command[next_char]   = '\0';                vioPutChar(key);            }        }    }    return CMD_DEFAULT;}/**************************************************************************/static int do_command(char *command){    register enum cmd i;    int n;    char *p;    /* skip leading spaces */    while (*command == ' ')        ++command;    for (i = 0; commands[i]; i++)        if (strnicmp(commands[i], command, strlen(commands[i])) == 0)            break;    command[0] = '\0';    switch (i)    {        case CMD_FILE:            if (! is_blank(command + 4))            {                p = command + 4;                                while (*p == ' ')                    p++;                file_to_view = atoi(p);                file_status(-1);            }            break;        case CMD_FILES:            file_report(-1);            break;        case CMD_HELP:            show_help();            break;        case CMD_KILL:            if (!is_blank(command + 4))            {                p = command + 4;                while (*p == ' ')                    p++;                kill_user(p);            }            break;        case CMD_QUIT:        case CMD_EXIT:            report_func = NULL;            return CMD_QUIT;        case CMD_REFRESH:            if (strlen(command) > 7 && !is_blank(command + 7))            {                n = atoi(command + 7);                if (n >= 2 && n <= 59)                    refresh_secs = n;            }            break;        case CMD_SHUTDOWN:            kill_lockmgr();            report_func = NULL;            return CMD_QUIT;        case CMD_STATUS:            general_status(0);            break;        case CMD_USERS:            user_report(-1);            break;        case CMD_USER:            if (!is_blank(command + 4))            {                p = command + 4;                while (*p == ' ')                    p++;                strcpy(user_to_view, p);                while (user_to_view[strlen(user_to_view) - 1] == ' ')                    user_to_view[strlen(user_to_view) - 1] = '\0';                user_status(-1);            }            break;        default:            return CMD_DEFAULT;    }    return i;}/**************************************************************************/static void clear_line(short row, int *clear){    if (!*clear)    {        *clear = TRUE;        vioClearLine(row);    }}/**************************************************************************/static void print_gs_outline(){    if (curr_outline != GENERAL_STATUS)    {        vioClear();        vioPrint(0, (short) (40 - (strlen(title1) / 2)), title1);        vioPrint(1, (short) (40 - (strlen(title2) / 2)), title2);        vioPrint(2,  0, "Name:");        vioPrint(2,  8, lockmgrn);        vioPrint(6, 43, "Receive Queue items:");        vioPrint(8, 54, "Requests:");        vioPrint(9, 55, "Replies:");        vioPrint(4,  0, "Locks");        vioPrint(5,  0, "_______________________________");        vioPrint(6,  2, "Granted:");        vioPrint(7,  1, "Rejected:");        vioPrint(8,  0, "Timed Out:");        vioPrint(9,  4, "Total:");        vioPrint(9, 20, "Freed:");        vioPrint(11, 0, "Users    _______________________________________________________________");        curr_outline = GENERAL_STATUS;        general->clr = TRUE;    }}/**************************************************************************/static void print_gs_data(short scroll){    unsigned short col, row = G_TOP, user = 0;    unsigned short num_users = GetNumUsers();    int   user_no = 0;    char  temp_s[16];    int   clear = general->clr, done = FALSE;    long_test(G_QITMS_XY, &general->qitms, GetNumQItems(), clear);    long_test(G_MSGSR_XY, &general->msgsr, GetMsgsReceived(), clear);    long_test(G_MSGSS_XY, &general->msgss, GetMsgsSent(), clear);    long_test(G_GRANT_XY, &general->grant, GetLocksGranted(), clear);    long_test(G_REJCT_XY, &general->rejct, GetLocksRejected(), clear);    long_test(G_TMOUT_XY, &general->tmout, GetLocksTimedOut(), clear);    long_test(G_TOTAL_XY, &general->total, GetTotalLocks(), clear);    long_test(G_FREED_XY, &general->freed, GetLocksFreed(), clear);    do    {        clear = general->lines[row - G_TOP].clr | general->clr;        for (col = 0; (col < 5); col++, user++)        {            strcpy(temp_s, "               ");            if (!done)            {                while ((user < num_users) && !IsUserActive(user))                    user++;                if (user < num_users)                {                    sprintf(temp_s, "%-15.15s", GetUserId(user));                    user_no++;                }                else                    done = TRUE;            }            if (clear || strcmp(temp_s, general->lines[row - G_TOP].name[col]))            {                vioPrint(row, (short) (col * 16), temp_s);                strcpy(general->lines[row - G_TOP].name[col], temp_s);            }            general->lines[row - G_TOP].clr = FALSE;        }        row++;        if (done && general->lines[row - G_TOP].name[col][0] == '\0')            break;    } while ((user < num_users) && (row < CMD_LINE));    if (row >= CMD_LINE)    {        while (user < num_users)        {            if (IsUserActive(user++))                user_no++;        }    }    spc_test(G_NUSER_XY, &general->nuser, user_no, general->clr);    while (row < CMD_LINE)    {        clear_line(row, &general->lines[row - G_TOP].clr);        row++;    }    general->clr = FALSE;    locate_to_cmnd_line();}/**************************************************************************/static void general_status(short scroll){    report_func = general_status;    top_line = G_TOP;    get_tables();    print_gs_outline();    print_gs_data(scroll);}/**************************************************************************/static void print_ur_outline(){    unsigned short i;    if (curr_outline != USER_REPORT)    {        vioClear();        vioPrint(0, 2,            "User Name          Q    TO   Status    Rec  Log File");        vioPrint(1, 2,            "_________________  ___  ___  ________  ___  __________");        curr_outline = USER_REPORT;        for (i = 0; i < (unsigned short)(CMD_LINE - UR_TOP); i++)            user_line[i].clr = TRUE;    }}/**************************************************************************/static void print_user_line(short row, unsigned short user){    int tmp = row - UR_TOP;    int clear = user_line[tmp].clr;    str_test(row, U_NAME_COL, user_line[tmp].name,  GetUserId(user),        clear, 16);    int_test(row, U_PEND_COL, &user_line[tmp].pend, GetUserPending(user),   clear);    int_test(row, U_TIME_COL, &user_line[tmp].time, GetUserTimer(user),     clear);    str_test(row, U_STAT_COL, user_line[tmp].stat,  GetUserStatus(user),    clear, 8);    str_test(row, U_REC_COL,  user_line[tmp].rec,   GetUserRecover(user),   clear, 3);    str_test(row, U_LOG_COL,  user_line[tmp].log,   GetUserLogFile(user),   clear, 16);    user_line[tmp].clr = FALSE;}/**************************************************************************/static void print_ur_data(short scroll){    unsigned short    user;    static short      top = 0;    short             prev_top = top;    unsigned short    row,                      num_users = GetNumUsers();    if (scroll == -1)    {        top = 0;    }    else    {        if (scroll == keyPgDn)        {            top = CMD_LINE - 2;            if (top > (short) (num_users - CMD_LINE + 2))                top = num_users - CMD_LINE + 2;        }        else        {            if (scroll == keyPgUp)                top -= CMD_LINE - 2;        }        if (scroll == keyEnd)            top = num_users - CMD_LINE + 2;        if ((scroll == keyHome) || (top < 0))            top = 0;        if (scroll && (top == prev_top))            return;    }    for ( user = top, row = UR_TOP;            (user < num_users) && (row < CMD_LINE);            user++)    {        print_user_line(row++, user);    }    while (row < (unsigned short)(CMD_LINE - 1))    {        clear_line(row, &user_line[row - UR_TOP].clr);        row++;    }    locate_to_cmnd_line();}/**************************************************************************/static void user_report(short scroll){    report_func = user_report;    top_line = UR_TOP;    get_tables();    print_ur_outline();    print_ur_data(scroll);}/**************************************************************************/static void print_fr_outline(){    unsigned short i;    if (curr_outline != FILE_REPORT)    {        vioClear();        vioPrint(0, 0,            "Num  Device@Host:Inode        Lock  #  Holding lock      Waiting");        vioPrint(1, 0,            "___  ________________________ ____  _  ________________  ____________________");        curr_outline = FILE_REPORT;        for (i = 0; i < (unsigned short)(CMD_LINE - FR_TOP); i++)            file_line[i].clr = TRUE;    }}static void print_file_line(short row, unsigned short file){    unsigned tmp = row - FR_TOP;    int clear = file_line[tmp].clr;    int_test(row, F_NUM_COL,   &file_line[tmp].num,  file, clear);    str_test(row, F_NAME_COL,  file_line[tmp].name,  GetFileName(file, FALSE),            clear, F_NAME_LEN);    char_test(row, F_STAT_COL, &file_line[tmp].stat, GetLockStat(file), clear);    int_test(row, F_NUML_COL,  &file_line[tmp].numl, GetNumLocks(file), clear);    str_test(row, F_HOLD_COL,  file_line[tmp].hold,  GetUserWLock(file), clear,            16);    str_test(row, F_PEND_COL,  file_line[tmp].pend,  GetPendLocks(file), clear,            30);    file_line[tmp].clr = FALSE;}/**************************************************************************/static void print_fr_data(short scroll){    static unsigned short row;    static short top  = 0;    short prev_top = top;    unsigned short num_files = GetNumFiles();    register unsigned short file;    if (scroll == -1)    {        top = 0;    }    else    {        if (scroll == keyPgDn)        {            top += CMD_LINE - 2;            if (top > (short) (num_files - CMD_LINE + 2))                top = num_files - CMD_LINE + 2;        }        else        {            if (scroll == keyPgUp)                top -= CMD_LINE - 2;        }        if (scroll == keyEnd)            top = num_files - CMD_LINE + 2;        if (scroll == keyHome || top < 0)            top = 0;        if ((scroll > 0) && (top == prev_top))            return;    }    for (file = top, row = 2; (file < num_files) && row < CMD_LINE; file++)    {        if (IsFileActive(file))            print_file_line(row++, file);    }    while (row < (unsigned short)(CMD_LINE - 1))    {        clear_line(row, &file_line[row - FR_TOP].clr);        row++;    }    locate_to_cmnd_line();}/**************************************************************************/static void file_report(short scroll){    report_func = file_report;    top_line = FR_TOP;    get_tables();    print_fr_outline();    print_fr_data(scroll);}/**************************************************************************/static void print_us_outline(){    if (curr_outline != USER_STATUS)    {        vioClear();        vioPrint(0, 1,  "User Name:");        vioPrint(0, 66, "Timeout:");        vioPrint(1, 68, "Timer:");        vioPrint(2, 2,  "Taf File:");        vioPrint(3, 5, "___________________________________________________________________");        vioPrint(4, 4,  "Status:");        vioPrint(5, 0,  "Recovering:");        vioPrint(6, 2,  "Log File:");        vioPrint(8, 0,  "Lock(0)___Pend(0)___Open(0)_______________________________________________");        curr_outline = USER_STATUS;        user_data->clr = TRUE;    }}/**************************************************************************/static void print_us_data(short scroll, unsigned short user){    static short   top = 0,                   taf_left = 0,                   log_left = 0;    short          prev_top = top,                   prev_taf = taf_left,                   prev_log = log_left;    char           taffile[FILENMLEN];    char           logfile[FILENMLEN];    char           temp_s[40];    char           temp_c;    unsigned short file,                   numfiles,                   num_files_open,                   row,                   i;    int            clear = user_data->clr;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -