?? vms.c
字號:
Info(slide, 1, ((char *)slide, "[Warning: CRC error, discarding PKWARE extra field]\n")); len = 0; type = VAT_NONE; } while (len > PK_FLDHDR_SIZE) { register struct PK_field *fld; int skip=0; fld = (struct PK_field *)scn; switch(fld->tag) { case ATR$C_UCHAR: pka_uchar = L(&fld->value); break; case ATR$C_RECATTR: pka_rattr = *(struct fatdef *)(&fld->value); break; case ATR$C_UIC: case ATR$C_ADDACLENT: skip = !uO.X_flag; break; } if ( !skip ) { pka_atr[pka_idx].atr$w_size = fld->size; pka_atr[pka_idx].atr$w_type = fld->tag; pka_atr[pka_idx].atr$l_addr = &fld->value; ++pka_idx; } len -= fld->size + PK_FLDHDR_SIZE; scn += fld->size + PK_FLDHDR_SIZE; } pka_atr[pka_idx].atr$w_size = 0; /* End of list */ pka_atr[pka_idx].atr$w_type = 0; pka_atr[pka_idx].atr$l_addr = 0; /* NULL when DECC VAX gets fixed */ } len -= hdr->size + EB_HEADSIZE; scan += hdr->size + EB_HEADSIZE; } if ( type == VAT_IZ ) { if (outfab != NULL) { /* Do not link XABPRO,XABRDT now. Leave them for sys$close() */ outfab->fab$l_xab = NULL; if (xabfhc != NULL) { xabfhc->xab$l_nxt = outfab->fab$l_xab; outfab->fab$l_xab = (void *) xabfhc; } if (xabdat != NULL) { xabdat->xab$l_nxt = outfab->fab$l_xab; outfab->fab$l_xab = (void *) xabdat; } if (first_xab != NULL) /* Link xaball,xabkey subchain */ { last_xab->xab$l_nxt = outfab->fab$l_xab; outfab->fab$l_xab = (void *) first_xab; } } else type = VAT_NONE; } return type;}static void free_up(){ /* * Free up all allocated xabs */ if (xabdat != NULL) free(xabdat); if (xabpro != NULL) free(xabpro); if (xabrdt != NULL) free(xabrdt); if (xabfhc != NULL) free(xabfhc); while (first_xab != NULL) { struct XAB *x; x = (struct XAB *) first_xab->xab$l_nxt; free(first_xab); first_xab = x; } if (outfab != NULL && outfab != &fileblk) free(outfab);}#ifdef CHECK_VERSIONSstatic int get_vms_version(verbuf, len) char *verbuf; int len;{ int i = SYI$_VERSION; int verlen = 0; struct dsc$descriptor version; char *m; version.dsc$a_pointer = verbuf; version.dsc$w_length = len - 1; version.dsc$b_dtype = DSC$K_DTYPE_B; version.dsc$b_class = DSC$K_CLASS_S; if (ERR(lib$getsyi(&i, 0, &version, &verlen, 0, 0)) || verlen == 0) return 0; /* Cut out trailing spaces "V5.4-3 " -> "V5.4-3" */ for (m = verbuf + verlen, i = verlen - 1; i > 0 && verbuf[i] == ' '; --i) --m; *m = '\0'; /* Cut out release number "V5.4-3" -> "V5.4" */ if ((m = strrchr(verbuf, '-')) != NULL) *m = '\0'; return strlen(verbuf) + 1; /* Transmit ending '\0' too */}#endif /* CHECK_VERSIONS *//* flush contents of output buffer */int flush(__G__ rawbuf, size, unshrink) /* return PK-type error code */ __GDEF uch *rawbuf; ulg size; int unshrink;{ G.crc32val = crc32(G.crc32val, rawbuf, (extent)size); if (uO.tflag) return PK_COOL; /* Do not output. Update CRC only */ else return (*_flush_routine)(__G__ rawbuf, size, 0);}static int _flush_blocks(__G__ rawbuf, size, final_flag) /* Asynchronous version */ __GDEF uch *rawbuf; unsigned size; int final_flag; /* 1 if this is the final flushout */{ int status; unsigned off = 0; while (size > 0) { if (curbuf->bufcnt < BUFS512) { unsigned ncpy; ncpy = size > (BUFS512 - curbuf->bufcnt) ? (BUFS512 - curbuf->bufcnt) : size; memcpy(curbuf->buf + curbuf->bufcnt, rawbuf + off, ncpy); size -= ncpy; curbuf->bufcnt += ncpy; off += ncpy; } if (curbuf->bufcnt == BUFS512) { status = WriteBuffer(__G__ curbuf->buf, curbuf->bufcnt); if (status) return status; curbuf = curbuf->next; curbuf->bufcnt = 0; } } return (final_flag && (curbuf->bufcnt > 0)) ? WriteBuffer(__G__ curbuf->buf, curbuf->bufcnt) : PK_COOL;}#ifdef ASYNCH_QIOstatic int WriteQIO(__G__ buf, len) __GDEF uch *buf; unsigned len;{ int status; if (pka_io_pending) { status = sys$synch(0, &pka_io_sb); if (!ERR(status)) status = pka_io_sb.status; if (ERR(status)) { vms_msg(__G__ "[ WriteQIO: sys$synch found I/O failure ]\n", status); return PK_DISK; } pka_io_pending = FALSE; } /* * Put content of buffer as a single VB */ status = sys$qio(0, pka_devchn, IO$_WRITEVBLK, &pka_io_sb, 0, 0, buf, len, pka_vbn, 0, 0, 0); if (ERR(status)) { vms_msg(__G__ "[ WriteQIO: sys$qio failed ]\n", status); return PK_DISK; } pka_io_pending = TRUE; pka_vbn += (len>>9); return PK_COOL;}static int _flush_qio(__G__ rawbuf, size, final_flag) /* Asynchronous version */ __GDEF uch *rawbuf; unsigned size; int final_flag; /* 1 if this is the final flushout */{ int status; unsigned off = 0; while (size > 0) { if (curbuf->bufcnt < BUFS512) { unsigned ncpy; ncpy = size > (BUFS512 - curbuf->bufcnt) ? (BUFS512 - curbuf->bufcnt) : size; memcpy(curbuf->buf + curbuf->bufcnt, rawbuf + off, ncpy); size -= ncpy; curbuf->bufcnt += ncpy; off += ncpy; } if (curbuf->bufcnt == BUFS512) { status = WriteQIO(__G__ curbuf->buf, curbuf->bufcnt); if (status) return status; curbuf = curbuf->next; curbuf->bufcnt = 0; } } return (final_flag & (curbuf->bufcnt > 0)) ? WriteQIO(curbuf->buf, (curbuf->bufcnt+1)&(~1)) : /* even byte count! */ PK_COOL;}#else /* !ASYNCH_QIO */static int _flush_qio(__G__ rawbuf, size, final_flag) __GDEF uch *rawbuf; unsigned size; int final_flag; /* 1 if this is the final flushout */{ int status; uch *out_ptr=rawbuf; if ( final_flag ) { if ( loccnt > 0 ) { status = sys$qiow(0, pka_devchn, IO$_WRITEVBLK, &pka_io_sb, 0, 0, locbuf, (loccnt+1)&(~1), /* Round up to even byte count */ pka_vbn, 0, 0, 0); if (!ERR(status)) status = pka_io_sb.status; if (ERR(status)) { vms_msg(__G__ "[ Write QIO failed ]\n", status); return PK_DISK; } } return PK_COOL; } if ( loccnt > 0 ) { /* * Fill local buffer upto 512 bytes then put it out */ unsigned ncpy; ncpy = 512-loccnt; if ( ncpy > size ) ncpy = size; memcpy(locptr, out_ptr, ncpy); locptr += ncpy; loccnt += ncpy; size -= ncpy; out_ptr += ncpy; if ( loccnt == 512 ) { status = sys$qiow(0, pka_devchn, IO$_WRITEVBLK, &pka_io_sb, 0, 0, locbuf, loccnt, pka_vbn, 0, 0, 0); if (!ERR(status)) status = pka_io_sb.status; if (ERR(status)) { vms_msg(__G__ "[ Write QIO failed ]\n", status); return PK_DISK; } pka_vbn++; loccnt = 0; locptr = locbuf; } } if ( size >= 512 ) { unsigned nblk, put_cnt; /* * Put rest of buffer as a single VB */ put_cnt = (nblk = size>>9)<<9; status = sys$qiow(0, pka_devchn, IO$_WRITEVBLK, &pka_io_sb, 0, 0, out_ptr, put_cnt, pka_vbn, 0, 0, 0); if (!ERR(status)) status = pka_io_sb.status; if (ERR(status)) { vms_msg(__G__ "[ Write QIO failed ]\n", status); return PK_DISK; } pka_vbn += nblk; out_ptr += put_cnt; size -= put_cnt; } if ( size > 0 ) { memcpy(locptr, out_ptr, size); loccnt += size; locptr += size; } return PK_COOL;}#endif /* ?ASYNCH_QIO *//* * The routine _flush_varlen() requires: "(size & 1) == 0" * (The variable-length record algorithm assumes an even byte-count!) */static int _flush_varlen(__G__ rawbuf, size, final_flag) __GDEF uch *rawbuf; unsigned size; int final_flag;{ unsigned nneed; unsigned reclen; uch *inptr=rawbuf; /* * Flush local buffer */ if ( loccnt > 0 ) /* incomplete record left from previous call */ { reclen = *(ush*)locbuf; nneed = reclen + 2 - loccnt; if ( nneed > size ) { if ( size+loccnt > BUFSMAXREC ) { char buf[80]; Info(buf, 1, (buf, "[ Record too long (%u bytes) ]\n", reclen)); return PK_DISK; } memcpy(locbuf+loccnt, inptr, size); loccnt += size; size = 0; } else { memcpy(locbuf+loccnt, inptr, nneed); loccnt += nneed; size -= nneed; inptr += nneed; if ( reclen & 1 ) { size--; inptr++; } if ( WriteRecord(__G__ locbuf+2, reclen) ) return PK_DISK; loccnt = 0; } } /* * Flush incoming records */ while (size > 0) { reclen = *(ush*)inptr; if ( reclen+2 <= size ) { if (WriteRecord(__G__ inptr+2, reclen)) return PK_DISK; size -= 2+reclen; inptr += 2+reclen; if ( reclen & 1) { --size; ++inptr; } } else { memcpy(locbuf, inptr, size); loccnt = size; size = 0; } } /* * Final flush rest of local buffer */ if ( final_flag && loccnt > 0 ) { char buf[80]; Info(buf, 1, (buf, "[ Warning, incomplete record of length %u ]\n", (unsigned)*(ush*)locbuf)); if ( WriteRecord(__G__ locbuf+2, loccnt-2) ) return PK_DISK; }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -