2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
11 * Copyright (c) 1980 Regents of the University of California.
12 * All rights reserved. The Berkeley software License Agreement
13 * specifies the terms and conditions for redistribution.
16 #pragma ident "%Z%%M% %I% %E% SMI"
19 * Sum bytes in file mod 2^16
25 main(int argc
, char **argv
)
36 if ((f
= fopen(argv
[i
], "r")) == NULL
) {
37 (void) fprintf(stderr
,
38 "sum: Can't open %s\n", argv
[i
]);
46 while ((c
= getc(f
)) != EOF
) {
49 sum
= (sum
>>1) + 0x8000;
57 (void) fprintf(stderr
,
58 "sum: read error on %s\n",
59 argc
> 1 ? argv
[i
] : "-");
62 (void) printf("%05u %5lld", sum
,
63 (nbytes
+ BUFSIZ
- 1) / BUFSIZ
);
65 (void) printf(" %s", argv
[i
]);