Lines Matching defs:in

11  * Redistribution and use in source and binary forms, with or without
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
85 extern IO in, out;
107 IO in, out; /* input/output state */
157 if (in.name == NULL) {
158 in.name = "stdin";
159 in.fd = STDIN_FILENO;
161 in.fd = open(in.name, O_RDONLY, 0);
162 if (in.fd < 0) {
164 in.name, strerror(errno));
169 /* Ensure in.fd is outside the stdio descriptor range */
170 in.fd = redup_clean_fd(in.fd);
173 getfdtype(&in);
175 if (files_cnt > 1 && !(in.flags & ISTAPE)) {
217 if ((in.db = malloc(out.dbsz + in.dbsz - 1)) == NULL) {
221 out.db = in.db;
222 } else if ((in.db =
223 malloc((u_int)(MAX(in.dbsz, cbsz) + cbsz))) == NULL ||
228 in.dbp = in.db;
232 if (in.offset)
262 io->flags |= ISPIPE; /* XXX fixed in 4.4BSD */
316 (void)memset(in.dbp, ' ', in.dbsz);
318 (void)memset(in.dbp, 0, in.dbsz);
321 n = read(in.fd, in.dbp, in.dbsz);
323 in.dbrcnt = 0;
335 in.name, strerror(errno));
346 * in sector size chunks.
348 if (!(in.flags & (ISPIPE|ISTAPE)) &&
349 lseek(in.fd, (off_t)in.dbsz, SEEK_CUR))
351 in.name, strerror(errno));
358 in.dbcnt += in.dbrcnt = in.dbsz;
362 } else if (n == in.dbsz) {
363 in.dbcnt += in.dbrcnt = n;
370 in.dbcnt += in.dbrcnt = in.dbsz;
372 in.dbcnt += in.dbrcnt = n;
382 out.dbcnt = in.dbcnt;
384 in.dbcnt = 0;
389 if ((n = in.dbrcnt) & 1) {
393 swab(in.dbp, in.dbp, n);
396 in.dbp += in.dbrcnt;
459 * output block in a single write; increment the full block stats.
466 * write the block in multiple chunks. The original versions of dd(1)
467 * never wrote a block in more than a single write, so the latter case
470 * One special case is if we're forced to do the write -- in that case
592 if (!(in.flags & (ISPIPE|ISTAPE))) {
593 if (lseek(in.fd,
594 (off_t)in.offset * (off_t)in.dbsz, SEEK_CUR) == -1) {
596 in.name, strerror(errno));
609 for (bcnt = in.dbsz, cnt = in.offset, warned = 0; cnt;) {
610 if ((nr = read(in.fd, in.db, bcnt)) > 0) {
611 if (in.flags & ISPIPE) {
613 bcnt = in.dbsz;
640 in.name);
646 fprintf(stderr, "%s: read error: %s", in.name, strerror(errno));
737 for (inp = in.dbp - (cnt = in.dbrcnt); cnt--; ++inp)
741 out.dbp = in.dbp;
742 out.dbcnt = in.dbcnt;
744 if (in.dbcnt >= out.dbsz) {
753 in.dbp = out.dbp;
754 in.dbcnt = out.dbcnt;
765 /* Just update the count, everything is already in the buffer. */
766 if (in.dbcnt)
767 out.dbcnt = in.dbcnt;
772 /* These can not be called, but just in case... */
784 * max in buffer: MAX(ibs, cbsz)
797 * Record truncation can cross block boundaries. If currently in a
803 for (inp = in.db, cnt = in.dbrcnt;
806 in.dbcnt = 0;
807 in.dbp = in.db;
812 in.dbcnt = cnt - 1;
813 in.dbp = inp + cnt - 1;
820 for (inp = in.dbp - in.dbcnt, outp = out.dbp; in.dbcnt;) {
821 maxlen = MIN(cbsz, in.dbcnt);
834 if (ch != '\n' && in.dbcnt < cbsz) {
835 (void)memmove(in.db, in.dbp - in.dbcnt, in.dbcnt);
840 in.dbcnt -= cnt;
842 --in.dbcnt;
852 if (!in.dbcnt || *inp != '\n')
856 for (; in.dbcnt && *inp++ != '\n'; --in.dbcnt);
857 if (!in.dbcnt)
860 --in.dbcnt;
869 in.dbp = in.db + in.dbcnt;
880 * translation. The bottom line is that anything left in the input
881 * buffer is a truncated record. Anything left in the output buffer
884 if (in.dbcnt) {
886 (void)memmove(out.dbp, in.dbp - in.dbcnt, in.dbcnt);
887 (void)memset(out.dbp + in.dbcnt,
888 ctab ? ctab[' '] : ' ', cbsz - in.dbcnt);
897 * max in buffer: MAX(ibs, cbsz) + cbsz
909 for (cnt = in.dbrcnt, inp = in.dbp - 1; cnt--; inp--)
916 for (inp = in.db; in.dbcnt >= cbsz; inp += cbsz, in.dbcnt -= cbsz) {
929 if (in.dbcnt)
930 (void)memmove(in.db, in.dbp - in.dbcnt, in.dbcnt);
931 in.dbp = in.db + in.dbcnt;
940 if (in.dbcnt) {
941 warnx("%s: short input record", in.name);
942 for (t = in.db + in.dbcnt - 1; t >= in.db && *t == ' '; --t);
943 if (t >= in.db) {
944 cnt = t - in.db + 1;
945 (void)memmove(out.dbp, in.db, cnt);
974 "%llu+%llu records in\n%llu+%llu records out\n",
997 "%llu bytes transferred in %lu.%03d secs (%llu bytes/sec)\n",
1060 in.dbsz = out.dbsz = 512;
1146 * if (in.offset > INT_MAX/in.dbsz || out.offset > INT_MAX/out.dbsz)
1172 in.dbsz = out.dbsz = strsuftoll("block size", arg, 1, UINT_MAX);
1205 in.dbsz = strsuftoll("input block size", arg, 1, UINT_MAX);
1212 in.name = arg;
1241 in.offset = strsuftoll("skip blocks", arg, 0, LLONG_MAX);
1279 * conversions to the C_BS check in the jcl routine above.