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

📄 ckuusx.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
    	case F000:		/* 0, print both strings, and n as a char */	    if ((int)strlen(s1) + (int)strlen(s2) + 5 > DBUFL) {		sprintf(sp,"DEBUG string too long\n");	    } else {		if (n > 31 && n < 127)		  sprintf(sp,"%s%s:%c\n",s1,s2,n);		else if (n < 32 || n == 127)		  sprintf(sp,"%s%s:^%c\n",s1,s2,(n+64) & 0x7F);		else if (n > 127 && n < 160)		  sprintf(sp,"%s%s:~^%c\n",s1,s2,(n-64) & 0x7F);		else if (n > 159 && n < 256)		  sprintf(sp,"%s%s:~%c\n",s1,s2,n & 0x7F);		else sprintf(sp,"%s%s:%ld\n",s1,s2,n);	    }	    if (zsout(ZDFILE,dbptr) < 0) deblog = 0;	    break;    	case F001:			/* 1, "=n" */	    sprintf(sp,"=%ld\n",n);	    if (zsout(ZDFILE,dbptr) < 0) deblog = 0;	    break;    	case F010:			/* 2, "[s2]" */	    if ((int)strlen(s2) + 4 > DBUFL)	      sprintf(sp,"DEBUG string too long\n");	    else sprintf(sp,"[%s]\n",s2);	    if (zsout(ZDFILE,"") < 0) deblog = 0;	    break;    	case F011:			/* 3, "[s2]=n" */	    if ((int)strlen(s2) + 15 > DBUFL)	      sprintf(sp,"DEBUG string too long\n");	    else sprintf(sp,"[%s]=%ld\n",s2,n);	    if (zsout(ZDFILE,dbptr) < 0) deblog = 0;	    break;    	case F100:			/* 4, "s1" */	    if (zsoutl(ZDFILE,s1) < 0) deblog = 0;	    break;    	case F101:			/* 5, "s1=n" */	    if ((int)strlen(s1) + 15 > DBUFL)	      sprintf(sp,"DEBUG string too long\n");	    else sprintf(sp,"%s=%ld\n",s1,n);	    if (zsout(ZDFILE,dbptr) < 0) deblog = 0;	    break;    	case F110:			/* 6, "s1[s2]" */	    if ((int)strlen(s1) + (int)strlen(s2) + 4 > DBUFL)	      sprintf(sp,"DEBUG string too long\n");	    else sprintf(sp,"%s[%s]\n",s1,s2);	    if (zsout(ZDFILE,dbptr) < 0) deblog = 0;	    break;    	case F111:			/* 7, "s1[s2]=n" */	    if ((int)strlen(s1) + (int)strlen(s2) + 15 > DBUFL)	      sprintf(sp,"DEBUG string too long\n");	    else sprintf(sp,"%s[%s]=%ld\n",s1,s2,n);	    if (zsout(ZDFILE,dbptr) < 0) deblog = 0;	    break;	default:	    sprintf(sp,"\n?Invalid format for debug() - %d\n",f);	    if (zsout(ZDFILE,dbptr) < 0) deblog = 0;    }    return(0);}#endif /* DEBUG */#ifdef TLOG#define TBUFL 300/*  T L O G  --  Log a record in the transaction file  *//* Call with a format and 3 arguments: two strings and a number:   f  - Format, a bit string in range 0-7, bit x is on, arg #x is printed.   s1,s2 - String arguments 1 and 2.   n  - Int, argument 3.*/VOIDtlog(f,s1,s2,n) int f; long n; char *s1, *s2; {    static char s[TBUFL];    char *sp = s; int x;    if (!tralog) return;		/* If no transaction log, don't */    switch (f) {    	case F000:			/* 0 (special) "s1 n s2"  */	    if ((int)strlen(s1) + (int)strlen(s2) + 15 > TBUFL)	      sprintf(sp,"?T-Log string too long\n");	    else sprintf(sp,"%s %ld %s\n",s1,n,s2);	    if (zsout(ZTFILE,s) < 0) tralog = 0;	    break;    	case F001:			/* 1, " n" */	    sprintf(sp," %ld\n",n);	    if (zsout(ZTFILE,s) < 0) tralog = 0;	    break;    	case F010:			/* 2, "[s2]" */	    x = (int)strlen(s2);	    if (s2[x] == '\n') s2[x] = '\0';	    if (x + 6 > TBUFL)	      sprintf(sp,"?T-Log string too long\n");	    else sprintf(sp,"[%s]\n",s2);	    if (zsout(ZTFILE,"") < 0) tralog = 0;	    break;    	case F011:			/* 3, "[s2] n" */	    x = (int)strlen(s2);	    if (s2[x] == '\n') s2[x] = '\0';	    if (x + 6 > TBUFL)	      sprintf(sp,"?T-Log string too long\n");	    else sprintf(sp,"[%s] %ld\n",s2,n);	    if (zsout(ZTFILE,s) < 0) tralog = 0;	    break;    	case F100:			/* 4, "s1" */	    if (zsoutl(ZTFILE,s1) < 0) tralog = 0;	    break;    	case F101:			/* 5, "s1: n" */	    if ((int)strlen(s1) + 15 > TBUFL)	      sprintf(sp,"?T-Log string too long\n");	    else sprintf(sp,"%s: %ld\n",s1,n);	    if (zsout(ZTFILE,s) < 0) tralog = 0;	    break;    	case F110:			/* 6, "s1 s2" */	    x = (int)strlen(s2);	    if (s2[x] == '\n') s2[x] = '\0';	    if ((int)strlen(s1) + x + 4 > TBUFL)	      sprintf(sp,"?T-Log string too long\n");	    else sprintf(sp,"%s %s\n",s1,s2);	    if (zsout(ZTFILE,s) < 0) tralog = 0;	    break;    	case F111:			/* 7, "s1 s2: n" */	    x = (int)strlen(s2);	    if (s2[x] == '\n') s2[x] = '\0';	    if ((int)strlen(s1) + x + 15 > TBUFL)	      sprintf(sp,"?T-Log string too long\n");	    else sprintf(sp,"%s %s: %ld\n",s1,s2,n);	    if (zsout(ZTFILE,s) < 0) tralog = 0;	    break;	default:	    sprintf(sp,"\n?Invalid format for tlog() - %ld\n",n);	    if (zsout(ZTFILE,s) < 0) tralog = 0;    }}#endif /* TLOG */#ifdef CK_CURSES/*  There are three different ways to do fullscreen on VMS.  1. Use the real curses library, VAXCCURSE.  2. Use do-it-yourself code.  3. Use the Screen Manager, SMG$.  Method 1 doesn't work quite right; you can't call endwin(), so once you've  started curses mode, you can never leave.  Method 2 doesn't optimize the screen, and so much more time is spent in  screen writes.  This actually causes file transfers to fail because the  tty device input buffer can be overrun while the screen is being updated,  especially on a slow MicroVAX that has small typeahead buffers.  In the following #ifdef block, #define one of them and #undef the other 2.  So now let's try method 3...*/#ifdef VMS#define CK_SMG				/* Screen Manager */#undef MYCURSES				/* Do-it-yourself */#undef VMSCURSE				/* VAXCCURSE library */#endif /* VMS *//*  S C R E E N C  --  Screen display function, uses curses  *//* Idea for curses display contributed by Chris Pratt of APV Baker, UK *//* Avoid conficts with curses.h */#ifndef MYCURSES#undef VOID				/* This was defined in ckcdeb.h */#endif /* MYCURSES */#undef BS				/* These were defined in ckcasc.h */#undef CR#undef NL#undef SO#undef US#ifdef VMS				/* VMS fullscreen display */#ifdef MYCURSES				/* Do-it-yourself method */extern int isvt52;			/* From CKVTIO.C */#define printw printf#else#ifdef VMSCURSE				/* VMS curses library VAXCCURSE */#include <curses.h> /* Note: Screen manager doesn't need a header file */#endif /* VMSCURSE */#endif /* MYCURSES */#else					/* Not VMS */#ifdef MYCURSES				/* Do-it-yourself method */#define isvt52 0			/* Used by OS/2, VT-100/ANSI always */#define printw printf#else#include <curses.h>			/* So use real curses */#endif /* MYCURSES */#endif /* VMS */#ifdef CK_SMG/*  Long section for Screen Manager starts here...  By William Bader.*/#include "ckvvms.h"/* #include <smgdef.h> *//* #include <smgmsg.h> */extern unsigned int vms_status;	    /* Used for system service return status */static long smg_pasteboard_id = -1;	/* pasteboard identifier */static long smg_display_id = -1;	/* display identifier */static int smg_open = 0;		/* flag if smg current open */#define	clrtoeol()	SMG$ERASE_LINE(&smg_display_id, 0, 0)#define clear()		SMG$ERASE_DISPLAY(&smg_display_id, 0, 0, 0, 0)#define	touchwin(scr)	SMG$REPAINT_SCREEN(&smg_pasteboard_id)static voidmove(row, col) int row, col; {    /* Change from 0-based for curses to 1-based for SMG */    ++row; ++col;    CHECK_ERR("move: smg$set_cursor_abs",	      SMG$SET_CURSOR_ABS(&smg_display_id, &row, &col));}static voidrefresh() {    CHECK_ERR("refresh: smg$end_pasteboard_update",	      SMG$END_PASTEBOARD_UPDATE(&smg_pasteboard_id));    CHECK_ERR("refresh: smg$begin_pasteboard_update",	      SMG$BEGIN_PASTEBOARD_UPDATE(&smg_pasteboard_id));}#ifdef VMS_V40#define	OLD_VMS#endif /* VMS_V40 */#ifdef VMS_V42#define	OLD_VMS#endif /* VMS_V42 */#ifdef VMS_V44#define	OLD_VMS#endif /* VMS_V44 */static intinitscr() {    int rows = 24, cols = 80;    int row = 1, col = 1;    if (smg_pasteboard_id == -1) { 	/* Open the screen */#ifdef OLD_VMS	CHECK_ERR("initscr: smg$create_pasteboard",		  SMG$CREATE_PASTEBOARD(&smg_pasteboard_id, 0, 0, 0, 0));#else	/* For VMS V5, not tested */	CHECK_ERR("initscr: smg$create_pasteboard",		  SMG$CREATE_PASTEBOARD(&smg_pasteboard_id, 0, 0, 0, 0, 0));#endif /* OLD_VMS */    }    if (smg_display_id == -1) {		/* Create a display window */	CHECK_ERR("initscr: smg$create_virtual_display",		  SMG$CREATE_VIRTUAL_DISPLAY(&rows, &cols, &smg_display_id,					     0, 0, 0));	/* Connect the display window to the screen */	CHECK_ERR("initscr: smg$paste_virtual_display",		  SMG$PASTE_VIRTUAL_DISPLAY(&smg_display_id,&smg_pasteboard_id,					    &row,&col));    }    if (!smg_open) {			/* Start a batch update */	smg_open = 1;	CHECK_ERR("initscr: smg$begin_pasteboard_update",		  SMG$BEGIN_PASTEBOARD_UPDATE(&smg_pasteboard_id));    }    return(1);}static voidendwin() {    if (!smg_open)      return;    smg_open = 0;    CHECK_ERR("endwin: smg$end_pasteboard_update",	      SMG$END_PASTEBOARD_UPDATE(&smg_pasteboard_id));    move(22, 0);#ifdef COMMENT/*  These calls clear the screen.*/    CHECK_ERR("endwin: smg$delete_virtual_display",	      SMG$DELETE_VIRTUAL_DISPLAY(&smg_display_id));    smg_display_id = -1;    CHECK_ERR("endwin: smg$delete_pasteboard",	      SMG$DELETE_PASTEBOARD(&smg_pasteboard_id, 0));    smg_pasteboard_id = -1;#endif /* COMMENT */}static void printw(str, a1, a2, a3, a4, a5, a6, a7, a8)char *str;long a1, a2, a3, a4, a5, a6, a7, a8;/* printw */ {    char buf[255];    $DESCRIPTOR(text_dsc, buf);    text_dsc.dsc$w_length = sprintf(buf, str, a1, a2, a3, a4, a5, a6, a7, a8);    CHECK_ERR("printw: smg$put_chars",	      SMG$PUT_CHARS(&smg_display_id, &text_dsc, 0, 0, 0, 0, 0));}#endif /* CK_SMG */#ifdef MYCURSES/*  Do-it-yourself curses implementation for VMS, OS/2 and other ANSI/VT-100's.  Supports only the VT52 and VT1xx (and later VT2xx/3xx/4xx) terminals.  By Terry Kennedy, St Peters College.   First, some stuff we can just ignore:*/inttouchwin(x) int x; {}intinitscr() {}intrefresh() {}intendwin() {}/* * Now, some stuff we need to do: */_PROTOTYP( int move, (int, int) );intmove(row, col) int row, col; {    if (isvt52)      printf("\033Y%c%c", row + 037, col + 037);    else      printf("\033[%d;%dH", row + 1, col + 1);}intclear() {    move(1,1);    if (isvt52)      printf("\033J");    else      printf("\033[J");}intclrtoeol() {    if (isvt52)      printf("\033K");    else      printf("\033[K");}#endif /* MYCURSES *//* Screen line numbers */#define CW_BAN  0			/* Curses Window Banner */#define CW_DIR  2			/* Current directory */#define CW_LIN  3			/* Communication device */#define CW_SPD  4			/* Communication speed */#define CW_PAR  5			/* Parity */#define CW_NAM  7			/* Filename */#define CW_TYP  8			/* File type */#define CW_SIZ  9			/* File size */#define CW_PCD 10			/* Percent done */#define CW_TR  11			/* Time remaining */#define CW_WS  12			/* Window slots */#define CW_PT  13			/* Packet type */#define CW_PC  14			/* Packet count */#define CW_PL  15			/* Packet length */#define CW_PR  16			/* Packet retry */#define CW_PB  17			/* Packet block check */#define CW_ERR 19			/* Error message */#define CW_MSG 20			/* Info message */#define CW_INT 22			/* Instructions */static int cinit = 0;			/* Flag for curses init'd */static int cendw = 0;			/* endwin() was called */static#ifdef CK_ANSIC				/* Because VOID used by curses.h */void#else#ifdef MYCURSESVOID#elseint#endif /* MYCURSES */#endif /* CK_ANSIC */scrft() {				/* Display file type */    move(CW_TYP,22);    if (binary) {#ifdef VMS	if (binary == XYFT_I)	  printw("image");	else if (binary == XYFT_L)	  printw("labeled");	else printw("binary");#else /* Not VMS */	printw("binary");#endif /* VMS */    } else {	printw("text");    }    clrtoeol();    return;}char *					/* Convert seconds to hh:mm:ss */#ifdef CK_ANSIChhmmss(long x)#elsehhmmss(x) long x;#endif /* CK_ANSIC *//* hhmmss(x) */ {    static char buf[10];    long s, h, m;    h = x / 3600L;			/* Hours */    x = x % 3600L;    m = x / 60L;			/* Minutes */    s = x % 60L;			/* Seconds */    if (x > -1L)      sprintf(buf,"%02ld:%02ld:%02ld",h,m,s);    else buf[0] = NUL;    return((char *)buf);}

⌨️ 快捷键说明

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