1N/A/*********************************************************************** 1N/A* This software is part of the ast package * 1N/A* Copyright (c) 1992-2011 AT&T Intellectual Property * 1N/A* and is licensed under the * 1N/A* Common Public License, Version 1.0 * 1N/A* by AT&T Intellectual Property * 1N/A* A copy of the License is available at * 1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 1N/A* Information and Software Systems Research * 1N/A* Glenn Fowler <gsf@research.att.com> * 1N/A* David Korn <dgk@research.att.com> * 1N/A***********************************************************************/ 1N/A * sum -- list file checksum and size 1N/A"[-?\n@(#)$Id: sum (AT&T Research) 2010-07-28 $\n]" 1N/A"[+NAME?cksum,md5sum,sum - print file checksum and block count]" 1N/A"[+DESCRIPTION?\bsum\b lists the checksum, and for most methods the block" 1N/A" count, for each file argument. The standard input is read if there are" 1N/A" no \afile\a arguments. \bgetconf UNIVERSE\b determines the default" 1N/A" \bsum\b method: \batt\b for the \batt\b universe, \bbsd\b otherwise." 1N/A" The default for the other commands is the command name itself. The" 1N/A" \batt\b method is a true sum, all others are order dependent.]" 1N/A"[+?Method names consist of a leading identifier and 0 or more options" 1N/A"[+?\bgetconf PATH_RESOLVE\b determines how symbolic links are handled. This" 1N/A" can be explicitly overridden by the \b--logical\b, \b--metaphysical\b," 1N/A" and \b--physical\b options below. \bPATH_RESOLVE\b can be one of:]{" 1N/A" [+logical?Follow all symbolic links.]" 1N/A" [+metaphysical?Follow command argument symbolic links," 1N/A" otherwise don't follow.]" 1N/A" [+physical?Don't follow symbolic links.]" 1N/A"[a:all?List the checksum for all files. Use with \b--total\b to list both" 1N/A" individual and total checksums and block counts.]" 1N/A"[b:binary?Read files in binary mode. This is the default.]" 1N/A"[B:scale?Block count scale (bytes per block) override for methods that" 1N/A" include size in the output. The default is method specific.]#[scale]" 1N/A"[c:check?Each \afile\a is interpreted as the output from a previous \bsum\b." 1N/A" If \b--header\b or \b--permissions\b was specified in the previous" 1N/A" \bsum\b then the checksum method is automatically determined," 1N/A" otherwise \b--method\b must be specified. The listed checksum is" 1N/A" compared with the current value and a warning is issued for each file" 1N/A" that does not match. If \afile\a was generated by \b--permissions\b" 1N/A" then the file mode, user and group are also checked. Empty lines," 1N/A" lines starting with \b#<space>\b, or the line \b#\b are ignored. Lines" 1N/A" containing no blanks are interpreted as [no]]\aname\a[=\avalue\a]]" 1N/A" [+method=name?Checksum method to apply to subsequent lines.]" 1N/A" [+permissions?Subsequent lines were generated with" 1N/A" \b--permissions\b.]" 1N/A"[h:header?Print the checksum method as the first output line. Used with" 1N/A" \b--check\b and \b--permissions\b.]" 1N/A"[l:list?Each \afile\a is interpreted as a list of files, one per line," 1N/A" that is checksummed.]" 1N/A"[p:permissions?If \b--check\b is not specified then list the file" 1N/A" mode, user and group between the checksum and path. User and group" 1N/A" matching the caller are output as \b-\b. If \b--check\b is" 1N/A" specified then the mode, user and group for each path in \afile\a" 1N/A" are updated if necessary to match those in \afile\a. A warning is" 1N/A" printed on the standard error for each changed file.]" 1N/A"[R:recursive?Recursively checksum the contents of directories.]" 1N/A"[S:silent|status?No output for \b--check\b; 0 exit status means all sums" 1N/A" matched, non-0 means at least one sum failed to match. Ignored for" 1N/A" \b--permissions\b.]" 1N/A"[t:total?List only the total checksum and block count of all files." 1N/A" \b--all\b \b--total\b lists each checksum and the total. The" 1N/A" total checksum and block count may be different from the checksum" 1N/A" and block count of the catenation of all files due to partial" 1N/A" blocks that may occur when the files are treated separately.]" 1N/A"[T:text?Read files in text mode (i.e., treat \b\\r\\n\b as \b\\n\b).]" 1N/A"[w!:warn?Warn about invalid \b--check\b lines.]" 1N/A"[x:method|algorithm?Specifies the checksum \amethod\a to" 1N/A" apply. Parenthesized method options are readonly implementation" 1N/A" details.]:[method]{\fmethods\f}" 1N/A"[L:logical|follow?Follow symbolic links when traversing directories. The" 1N/A" default is determined by \bgetconf PATH_RESOLVE\b.]" 1N/A"[H:metaphysical?Follow command argument symbolic links, otherwise don't" 1N/A" follow symbolic links when traversing directories. The default is" 1N/A" determined by \bgetconf PATH_RESOLVE\b.]" 1N/A"[P:physical?Don't follow symbolic links when traversing directories. The" 1N/A" default is determined by \bgetconf PATH_RESOLVE\b.]" 1N/A"[r:bsd?Equivalent to \b--method=bsd --scale=512\b for compatibility with" 1N/A" other \bsum\b(1) implementations.]" 1N/A"[s:sysv?Equivalent to \b--method=sys5\b for compatibility with other" 1N/A" \bsum\b(1) implementations.]" 1N/A"[+SEE ALSO?\bgetconf\b(1), \btw\b(1), \buuencode\b(1)]" 1N/A unsigned long size;
/* combined size of all files */ 1N/A int warn;
/* invalid check line warnings */ 1N/A * open path for read mode 1N/A * close an openfile() stream 1N/A * compute and print sum on an open file 1N/A * verify previous sum output 1N/A if (!*s || *s ==
'#' && (!*(s +
1) || *(s +
1) ==
' ' || *(s +
1) ==
'\t'))
1N/A if (*e ==
'-' && (t - e) ==
1)
1N/A if (*t ==
'-' && (e - t) ==
1)
1N/A * sum the list of files in lp 1N/A * order child entries 1N/A * optget() info discipline function