Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/cmp/cmp.c
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include <libutil.h> | #include <libutil.h> | ||||
#include "extern.h" | #include "extern.h" | ||||
bool lflag, sflag, xflag, zflag; | bool bflag, lflag, sflag, xflag, zflag; | ||||
static const struct option long_opts[] = | static const struct option long_opts[] = | ||||
{ | { | ||||
{"print-bytes", no_argument, NULL, 'b'}, | |||||
{"ignore-initial", required_argument, NULL, 'i'}, | {"ignore-initial", required_argument, NULL, 'i'}, | ||||
{"verbose", no_argument, NULL, 'l'}, | {"verbose", no_argument, NULL, 'l'}, | ||||
{"bytes", required_argument, NULL, 'n'}, | {"bytes", required_argument, NULL, 'n'}, | ||||
{"silent", no_argument, NULL, 's'}, | {"silent", no_argument, NULL, 's'}, | ||||
{"quiet", no_argument, NULL, 's'}, | {"quiet", no_argument, NULL, 's'}, | ||||
{NULL, no_argument, NULL, 0} | {NULL, no_argument, NULL, 0} | ||||
}; | }; | ||||
Show All 24 Lines | main(int argc, char *argv[]) | ||||
struct stat sb1, sb2; | struct stat sb1, sb2; | ||||
off_t skip1, skip2, limit; | off_t skip1, skip2, limit; | ||||
int ch, fd1, fd2, oflag; | int ch, fd1, fd2, oflag; | ||||
bool special; | bool special; | ||||
const char *file1, *file2; | const char *file1, *file2; | ||||
skip1 = skip2 = 0; | skip1 = skip2 = 0; | ||||
oflag = O_RDONLY; | oflag = O_RDONLY; | ||||
while ((ch = getopt_long(argc, argv, "+hi:ln:sxz", long_opts, NULL)) != -1) | while ((ch = getopt_long(argc, argv, "+bhi:ln:sxz", long_opts, NULL)) != -1) | ||||
switch (ch) { | switch (ch) { | ||||
case 'b': /* Print bytes */ | |||||
bflag = true; | |||||
break; | |||||
case 'h': /* Don't follow symlinks */ | case 'h': /* Don't follow symlinks */ | ||||
oflag |= O_NOFOLLOW; | oflag |= O_NOFOLLOW; | ||||
break; | break; | ||||
case 'i': | case 'i': | ||||
if (!parse_iskipspec(optarg, &skip1, &skip2)) { | if (!parse_iskipspec(optarg, &skip1, &skip2)) { | ||||
fprintf(stderr, | fprintf(stderr, | ||||
"Invalid --ignore-initial: %s\n", | "Invalid --ignore-initial: %s\n", | ||||
optarg); | optarg); | ||||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |