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

📄 clone.c

📁 Dos6.0
💻 C
字号:

#include <bios.h>
#include <dos.h>
#include <string.h>
#include <direct.h>
#include <stdio.h>
#include <io.h>
#include <stdlib.h>
#include <fcntl.h>
#include <memory.h>
#include <string.h>
#include <conio.h>
#include <stdarg.h>
#include <errno.h>
#include "fastlynx.h"
#include "server.h"
#include "dc.h"

#define CTRL_C	    0x003
#define ESC	        0x01B

int _fastcall percent(long current, long total);
void _fastcall getargs(char near *cmdline);
void _fastcall getprog(char near *progname);
void near pascal set_critical_error(void);
void _fastcall long_to_ascii(long value, char near *buff);
unsigned int _fastcall pstrlen(char near *str);
int _fastcall isdigit(byte value);
unsigned pascal paragon_bios_keybrd(unsigned service);
void add_all_bios_serial(void);
void add_all_bios_parallel(void);

#include "str.h"

#pragma intrinsic(memset, _enable, _disable, memcmp)

extern byte check_abort_flag;

static char dl_name[]  = "interlnk.exe";

static int top_row;
static int left_col;
static int box_height;
static int box_width;
static int remote_port;
static int screen_height;
static int screen_width;
static int status_col;
static int percent_col;
static int scan_port_col;
static int left_margin;

char *server_name = "intersvr.exe";

extern struct FxBiosInfo Bios;
extern char *final_msg;

char double_percent_s[] = "%s%s";

static byte exit_called = FALSE;
static byte remote_found = FALSE;       // Set TRUE when remote computer found

void draw_screen(char *string, int extra_lines, int color)
{
    char *ptr = string;
    int width;
    char *lines[20];
    int  widths[20];
    int  i;

    fill_attr(coord(1, 0), boxsize(scr_rows - 2, 80), ' ', TITLE_COLOR);
    screen_height = 0;
    screen_width = 0;
    while (*ptr) {
        lines[screen_height] = ptr;
        width = 0;
        while (*ptr && *ptr != '\n') {
            width++;
            ptr++;
        }
        if (width > screen_width)
            screen_width = width;
        widths[screen_height] = width;
        screen_height++;
        if (*ptr == '\n') ptr++;
    }
    box_height = (screen_height + 4 + extra_lines);
    box_width  = screen_width + 6;
    top_row = (scr_rows - 2 - box_height) / 2 + 1;
    left_col = (80 - (screen_width + 6)) / 2;
    draw_box(coord(top_row, left_col),  boxsize(box_height, box_width),
            SINGLE, color);
    for (i = 0; i < screen_height; i++) {
        if (widths[i])
            dispmem_attr(coord(top_row + 2 + i, left_col + 3),
                lines[i], widths[i], color);
    }
}

static void call_clone_exit(void)
{
    static byte clone_exit_cmd = CLONE_EXIT_CMD;

    if (remote_found && !exit_called) {
        exit_called = TRUE;
        if (fx_baud == BAUD_38400)
            FxSendSerialBlock(&clone_exit_cmd, sizeof(clone_exit_cmd));
        FxCloneExit();
    }
}

static void cdecl error_printf(char *fmt, ...)
{
    va_list arg_ptr;
    char msg_buff[512];

    va_start(arg_ptr, fmt);
    vsprintf(msg_buff, fmt, arg_ptr);
    strcat(msg_buff, press_enter_to_return);
    call_clone_exit();
    draw_screen(msg_buff, 0, ERROR_COLOR);
    for (;;) {
        if ( read_key() == '\r' )
            break;
    }
}

void near _fastcall update_progress(int percentage)
{
    char buff[5];

    sprintf(buff, "%3d%%", percentage);
    dispstr_attr(coord(scr_rows - 1, percent_col), buff, STATUS_COLOR);
}

static int near pascal get_upload_options()
{
    int key;
    word start_ticks = bios_ticks();
    int option_row;
    int last_remote_port;
    char screen2[1024];

    justify_str(coord(scr_rows - 1, 0), 80, STATUS_COLOR, install_status_line1, -1);
    draw_screen(install_signon, 5, LIST_NORMAL);
    option_row = top_row + 4 + screen_height;
    draw_box(coord(option_row - 1, 35), boxsize(4, 10), SINGLE, LIST_NORMAL);
    last_remote_port = -1;
    remote_port = 0;
    do
    {
        if (remote_port != last_remote_port) {
            last_remote_port = remote_port;
            justify_str(coord(option_row, 36), 8,
                        remote_port == 0 ? LIST_REVERSE : LIST_NORMAL,
                        "COM1", 0);
            justify_str(coord(option_row + 1, 36), 8,
                        remote_port == 0 ? LIST_NORMAL : LIST_REVERSE,
                        "COM2", 0);
        }
        if ( check_key() ) {
            key = read_key();
            switch (key) {
            case CTRL_C:
            case ALT_F4:
                key = F3;
                break;
            case '1':
                remote_port = 0;
                break;
            case '2':
                remote_port = 1;
                break;
            case UP:
                if (remote_port)
                    remote_port = 0;
                break;
            case DOWN:
                if (remote_port == 0)
                    remote_port++;
                break;
            }
        }
    } while (key != '1' && key != '2' && key != F3 && key != '\r');
    if (key == F3) return FALSE;

    strtcpy(screen2, upload_remote_prompt, sizeof(screen2));
    strrepc(screen2, '#', remote_port + '1');
    draw_screen(screen2, 0, LIST_NORMAL);
    justify_str(coord(scr_rows - 1, 0), 80, STATUS_COLOR, install_status_line2, -1);
    status_col = strchr(install_status_line2, '

⌨️ 快捷键说明

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