Lines Matching defs:out

85 extern IO		in, out;
109 IO in, out; /* input/output state */
184 if (out.name == NULL) {
186 out.fd = STDOUT_FILENO;
187 out.name = "stdout";
191 out.fd = open(out.name, O_RDWR | OFLAGS /*, DEFFILEMODE */);
197 if (out.fd < 0) {
198 out.fd = open(out.name, O_WRONLY | OFLAGS /*, DEFFILEMODE */);
199 out.flags |= NOREAD;
201 if (out.fd < 0) {
203 out.name, strerror(errno));
208 /* Ensure out.fd is outside the stdio descriptor range */
209 out.fd = redup_clean_fd(out.fd);
212 getfdtype(&out);
219 if ((in.db = malloc(out.dbsz + in.dbsz - 1)) == NULL) {
223 out.db = in.db;
226 (out.db = malloc((u_int)(out.dbsz + cbsz))) == NULL) {
231 out.dbp = out.db;
236 if (out.offset)
244 (void)ftruncate(out.fd, (off_t)out.offset * out.dbsz);
420 out.dbcnt = in.dbcnt;
453 if (ddflags & C_OSYNC && out.dbcnt < out.dbsz) {
454 (void)memset(out.dbp, 0, out.dbsz - out.dbcnt);
455 out.dbcnt = out.dbsz;
458 * to write out the final block un-sparse
460 if ((out.dbcnt == 0) && pending) {
461 memset(out.db, 0, out.dbsz);
462 out.dbcnt = out.dbsz;
463 out.dbp = out.db + out.dbcnt;
464 pending -= out.dbsz;
466 if (out.dbcnt)
476 if (out.fd == STDOUT_FILENO && fsync(out.fd) == -1 && errno != EINVAL) {
481 if (close(out.fd) == -1) {
496 * Write one or more blocks out. The common case is writing a full
511 outp = out.db;
512 for (n = force ? out.dbcnt : out.dbsz;; n = out.dbsz) {
531 if (lseek(out.fd, pending, SEEK_CUR) ==
536 out.name, strerror(errno));
540 nw = bwrite(out.fd, outp, cnt);
544 out.name);
550 out.name, strerror(errno));
558 st.sparse += pending/out.dbsz;
559 st.out_full += pending/out.dbsz;
565 if (n != out.dbsz)
574 if (out.flags & ISCHR && !warned) {
577 "device\n", out.name);
579 if (out.flags & ISTAPE) {
582 out.name);
587 if ((out.dbcnt -= n) < out.dbsz)
592 if (out.dbcnt)
593 (void)memmove(out.db, out.dbp - out.dbcnt, out.dbcnt);
594 out.dbp = out.db + out.dbcnt;
701 if (!(out.flags & ISTAPE)) {
702 if (lseek(out.fd,
703 (off_t)out.offset * (off_t)out.dbsz, SEEK_SET) == -1) {
705 out.name, strerror(errno));
713 if (out.flags & NOREAD) {
715 t_op.mt_count = out.offset;
717 if (ioctl(out.fd, MTIOCTOP, &t_op) < 0)*/
718 fprintf(stderr, "%s: cannot read", out.name);
725 for (cnt = 0; cnt < out.offset; ++cnt) {
726 if ((n = read(out.fd, out.db, out.dbsz)) > 0)
731 out.name, strerror(errno));
743 if (ioctl(out.fd, MTIOCTOP, &t_op) == -1) */ {
744 fprintf(stderr, "%s: cannot position\n", out.name);
749 while (cnt++ < out.offset)
750 if ((n = bwrite(out.fd, out.db, out.dbsz)) != out.dbsz) {
753 out.name, strerror(errno));
779 out.dbp = in.dbp;
780 out.dbcnt = in.dbcnt;
782 if (in.dbcnt >= out.dbsz) {
791 in.dbp = out.dbp;
792 in.dbcnt = out.dbcnt;
802 out.dbcnt = in.dbcnt;
820 * max out buffer: obs + cbsz
855 for (inp = in.dbp - in.dbcnt, outp = out.dbp; in.dbcnt;) {
899 out.dbp += cbsz;
900 if ((out.dbcnt += cbsz) >= out.dbsz)
902 outp = out.dbp;
921 (void)memmove(out.dbp, in.dbp - in.dbcnt, in.dbcnt);
922 (void)memset(out.dbp + in.dbcnt,
924 out.dbcnt += cbsz;
933 * max out buffer: obs + cbsz
955 (void)memmove(out.dbp, inp, cnt);
956 out.dbp += cnt;
957 out.dbcnt += cnt;
959 ++out.dbcnt;
960 *out.dbp++ = '\n';
961 if (out.dbcnt >= out.dbsz)
980 (void)memmove(out.dbp, in.db, cnt);
981 out.dbp += cnt;
982 out.dbcnt += cnt;
984 ++out.dbcnt;
985 *out.dbp++ = '\n';
1009 "%llu+%llu records in\n%llu+%llu records out\n",
1095 in.dbsz = out.dbsz = 512;
1181 * if (in.offset > INT_MAX/in.dbsz || out.offset > INT_MAX/out.dbsz)
1207 in.dbsz = out.dbsz = strsuftoll("block size", arg, 1, UINT_MAX);
1255 out.dbsz = strsuftoll("output block size", arg, 1, UINT_MAX);
1262 out.name = arg;
1269 out.offset = strsuftoll("seek blocks", arg, 0, LLONG_MAX);