📄 msgwrt.c
字号:
case (shtoct): /*** short octal ***/ if (*((short *) ctx->item_ptr) == -1) break; printf("%*s", BT$F2_LEN-5, BT$SPACE); printf("o%04o", *((short *) ctx->item_ptr)); break; case (lngoct): /*** long octal ***/ if (*((long *) ctx->item_ptr) == -1) break; printf("%*s", BT$F2_LEN-9, BT$SPACE); printf("o%08o", *((long *) ctx->item_ptr)); break; case (srgdec): /*** short reg decimal ***/ printf("%*d.",BT$F2_LEN-1, *((short *) ctx->item_ptr)); reg = *((long *) ctx->item_ptr); if ((reg != -1) && (in_st.out_form != UE$OUT_TERSE)) bld_reg_string(ctx,reg); break; case (srghex): /*** short reg hex ***/ printf("%*s", BT$F2_LEN-5, BT$SPACE); sht = *((short *) ctx->item_ptr); printf("x%04.4X", sht); reg = *((long *) ctx->item_ptr); if ((reg != -1) && (in_st.out_form != UE$OUT_TERSE)) bld_reg_string(ctx,reg); break; case (srgnov): /*** short reg (no label or value)***/ printf("%*s", BT$F2_LEN, BT$SPACE); reg = *((long *) ctx->item_ptr); if ((reg != -1) && (in_st.out_form != UE$OUT_TERSE)) bld_reg_string(ctx,reg); break; case (ctsvec): /*** count short vector ***/ len = *((short *)ctx->item_ptr); if (len > ctx->item_DSD_ptr->COUNT) len = ctx->item_DSD_ptr->COUNT; if (len > 0) hex_dump((ctx->item_ptr + 2), (len * 2),2,0); break; case (invmov): /*** invalid move ***/ label_dsd_ptr = find_label_dsd(ctx->item_DSD_ptr->LABEL_IX); printf("Invalid move TYPE = %d, DISPLAY TYPE = %d", ctx->item_DSD_ptr->TYPE,label_dsd_ptr->TYPE); break; } break; case (DD$N_V): bld_invalid_string(ctx); break; }return(UE$SUCC); }/*... ENDROUTINE OUTPUT_FLD *//** .SBTTL BLD_REG_STRING - Builds register formated output**++* FUNCTIONAL DESCRIPTION: ** This routine is called to build formatted* register output of the given input.* * CALLING SEQUENCE: CALL BLD_REG_STRING (..See Below..)** FORMAL PARAMETERS: ** reg a long with the register contents** IMPLICIT INPUTS: NONE** IMPLICIT OUTPUTS: Final formatted output string* * ROUTINE VALUE: UE$SUCC if successful* UE$FAIL if failure* * SIDE EFFECTS: Creates the final output**--*//*... ROUTINE BLD_REG_STRING (ctx,reg) */long bld_reg_string (ctx,reg)DD$STD_DSD_CTX *ctx;unsigned long reg;{DD$DSP_LABELS_PTR find_label_dsd();DD$DSP_LABELS_PTR label_dsd_ptr;long get_next_field_dsd();char *string_ptr;unsigned long bits;short first;short len;first = TRUE;do { /* The next three instructions need */ /* to be kept separate because VMS */ /* will propagate the high order bit */ /* on the last shift right if they */ /* are combined into one instruction */ bits = reg >> ctx->field_position; bits = bits << (32 - ctx->field_DSD_ptr->SIZE); bits = bits >> (32 - ctx->field_DSD_ptr->SIZE); /*************************************/ switch (ctx->field_DSD_ptr->TYPE) { case (DC_INTEGER): if (!first) { printf("\n%*s",BT$F1_LEN,BT$SPACE); printf("%*s", BT$F2_LEN,BT$SPACE); } printf("%*s", BT$F3_LEN,BT$SPACE); printf("%s ", dsd_get_label(ctx->field_DSD_ptr->LABEL_IX)); label_dsd_ptr = find_label_dsd(ctx->field_DSD_ptr->LABEL_IX); if (label_dsd_ptr->TYPE == DF_DECIMAL) printf("%-d.", bits); else if (label_dsd_ptr->TYPE == DF_OCTAL) printf("o%-o", bits); else printf("x%-X", bits); break; case (DC_CODED): if ((int)(string_ptr = (char *) decode_register_field(ctx,bits)) != DD$UNKNOWN_CODE) { if (!first) { printf("\n%*s",BT$F1_LEN,BT$SPACE); printf("%*s", BT$F2_LEN,BT$SPACE); } printf("%*s", BT$F3_LEN,BT$SPACE); len = strlen(dsd_get_label(ctx->field_DSD_ptr->LABEL_IX)); if (len > 1) printf("%s ", dsd_get_label(ctx->field_DSD_ptr->LABEL_IX)); print_string (string_ptr, BT$F1_LEN + BT$F2_LEN + BT$F3_LEN, BT$F4_LEN, BT$F4_LEN - len); } break; default: break; } first = FALSE; }while ((get_next_field_dsd(ctx)) == DD$SUCCESS);return(UE$SUCC);}/*... ENDROUTINE BLD_REG_STRING *//** .SBTTL BLD_INVALID_STRING - Builds invalid output**++* FUNCTIONAL DESCRIPTION: ** This routine is called to build a string* from invalid input.* * CALLING SEQUENCE: CALL BLD_INVALID_STRING (..See Below..)** FORMAL PARAMETERS: ctx** IMPLICIT INPUTS: NONE** IMPLICIT OUTPUTS: Final formatted output string* * ROUTINE VALUE: UE$SUCC if successful* UE$FAIL if failure* * SIDE EFFECTS: Creates the final output**--*//*... ROUTINE BLD_INVALID_STRING (ctx) */long bld_invalid_string (ctx)DD$STD_DSD_CTX *ctx;{unsigned short sht;unsigned long lng;printf("%*s",BT$F2_LEN, BT$INV_ITEM);printf("%*s",BT$F3_LEN,BT$SPACE); /* skip filler */switch (ctx->item_DSD_ptr->TYPE) { case (DT_LONG): case (DT_INDEXED): case (DT_REGISTER): lng = *((long *) ctx->item_ptr); printf("x%-08.8X", lng); break; case (DT_SHORT): case (DT_SHORT_INDEX): case (DT_SHORT_REGISTER): sht = *((short *) ctx->item_ptr); printf("x%-04.4X", sht); break; }}/*... ENDROUTINE BLD_INVALID_STRING *//** .SBTTL BLD_DMY_STRING - Builds date and time formated output**++* FUNCTIONAL DESCRIPTION: ** This routine is called to build formatted* date and time output of the given input.* * CALLING SEQUENCE: CALL BLD_DMY_STRING (..See Below..)** FORMAL PARAMETERS: ** std_item pointer to the input field* dsd_item pointer to the field descriptor** IMPLICIT INPUTS: NONE** IMPLICIT OUTPUTS: Final formatted output string* * ROUTINE VALUE: UE$SUCC if successful* UE$FAIL if failure* * SIDE EFFECTS: Creates the final output**--*//*... ROUTINE BLD_DMY_STRING (bindate) */long bld_dmy_string (bindate)long *bindate;{struct timeval tv, *tvp;struct timezone tz, *tzp;struct tm lt, *ltp;printf("%*s",BT$F2_LEN,BT$SPACE); /* skip numeric field */printf("%*s",BT$F3_LEN,BT$SPACE); /* skip filler */if (*bindate == UE$NULL) printf("NULL Date & Time");else { tvp = &tv; tzp = &tz; ltp = < gettimeofday(tvp,tzp); ltp = localtime(bindate); printf("%-24.24s %s", ctime(bindate), /* print string */ timezone(tzp->tz_minuteswest,ltp->tm_isdst)); }}/*... ENDROUTINE BLD_DMY_STRING *//** .SBTTL PRINT_STRING - Prints out a string on the right side of* the screen.**++* FUNCTIONAL DESCRIPTION: ** This routine is called to print out a char string within* th boundries of the field on the right hand side of the screen.* * CALLING SEQUENCE: CALL PRINT_STRING (..See Below..)** FORMAL PARAMETERS: ** str_ptr pointer to the input field* wrap_col starting column for wrap* buflen size of buffer for lines* this_buf size of buffer for line 1** IMPLICIT INPUTS: NONE** IMPLICIT OUTPUTS: Final formatted output string* * ROUTINE VALUE: UE$SUCC if successful* UE$FAIL if failure* * SIDE EFFECTS: Creates the final output**--*//*... ROUTINE PRINT_STRING (str_ptr,wrap_col,buflen,this_buf) */long print_string (str_ptr,wrap_col,buflen,this_buf)DD$BYTE *str_ptr;short wrap_col;short buflen;short this_buf;{short i;short len;short offset;short num_put;char line[LINESIZE];len = strlen(str_ptr);num_put = 0;tran_tbl['\0'] = '\0';tran_tbl['\t'] = '\t';tran_tbl['\n'] = '\n';for (i = 0; i < len ; i++) { str_ptr[i] = tran_tbl[str_ptr[i]]; }while (len > 0) { offset = strcspn(str_ptr," \t\n\0"); if ((offset + num_put) > this_buf) { printf("\n%*s _", wrap_col, BT$SPACE); num_put = 2; this_buf = buflen; } printf("%.*s ",(offset), str_ptr); len -= (offset + 1); num_put += (offset + 1); if ((len != 0) && (str_ptr[offset] == '\n')) { printf("\n%*s", wrap_col, BT$SPACE); num_put = 0; } str_ptr += (offset + 1); }return(UE$SUCC);}/*... ENDROUTINE PRINT_STRING *//** .SBTTL HEX_DUMP - function used to print a hex dump*++* FUNCTIONAL DESCRIPTION: ** - this function receives the pointer to an area in memory* and a length and it prints a HEX dump of it.** FORMAL PARAMETERS: Pointer to area in memory.* Length of area to dump.*** IMPLICIT INPUTS: NONE** IMPLICIT OUTPUTS: NONE** COMPLETION STATUS: NONE** SIDE EFFECTS: NONE**--*//*... FUNCTION HEX_DUMP */long hex_dump(ptr,len,size,addr)DD$BYTE *ptr;short len;short size;long addr;{short offset = 0;short i;short j;char line[LINESIZE];static char hex_tbl[17] = "0123456789ABCDEF";tran_tbl['\0'] = '.';tran_tbl['\t'] = '.';tran_tbl['\n'] = '.';if (size != 2) size = 4;for (;;) { for (i = 0; i < LINESIZE; i++) line[i] = ' '; line[44] = '*'; line[61] = '*'; printf("\n%04.4X: ", (addr+offset)); for (j = 0; j < (16/size); j++) { for (i = size; i > 0; i--, offset++) { line[(j*(size*2+2))+(i*2)] = hex_tbl[(ptr[offset]>>4)&(0x0f)]; line[(j*(size*2+2))+(i*2)+1] = hex_tbl[(ptr[offset] )&(0x0f)]; } for (i = 0; i < size; i++) { line[45 + i + (j * size)] = tran_tbl[ptr[offset - size + i]]; } if (len <= offset) { for (i = 0; i < (len - offset); i++) { line[45 + i] = tran_tbl[ptr[offset - 16 + i]]; } printf("%*.*s", LINESIZE, LINESIZE, line); return; } } printf("%*.*s", LINESIZE, LINESIZE, line); }}/*... ENDFUNCTION HEX_DUMP */char *ctime();unsigned longvms_to_unix_time(date_low, date_high)unsigned long date_low, date_high;{ unsigned long divisor, dividend_low, dividend_high, quotient, remainder; unsigned long subtrahend_low, subtrahend_high, dif_low, dif_high; int i; dif_low = date_low; dif_high = date_high; subtrahend_low = 0x4beb4000; /* difference between 00:00 jan 1 1970 and */ subtrahend_high = 0x7c9567; /* 00:00 nov 17 1858 in 100nanoseconds */ /* returns 1 if result is negative, else returns 0 */ i=subq(subtrahend_low, subtrahend_high, &dif_low, &dif_high); if(i){ return((long)0); } dividend_low = dif_low; dividend_high = dif_high; divisor = 0x989680; quotient = 0; remainder = 0; divq(divisor, dividend_low, dividend_high, "ient, &remainder); return(quotient);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -