#include <iostream>
#include <fcntl.h>
#include <cstdio>
#include <unistd.h>
#include <sys/stat.h>
#include <cstring>
#include <sys/types.h>
#include <sys/uio.h>
#include "XrdOuc/XrdOucCRC.hh"
#include "XrdSys/XrdSysE2T.hh"
Go to the source code of this file.
|
void | Fatal (const char *op, const char *target) |
|
int | main (int argc, char *argv[]) |
|
void | Usage (int rc) |
|
◆ O_DIRECT
◆ Fatal()
void Fatal |
( |
const char * |
op, |
|
|
const char * |
target |
|
) |
| |
Definition at line 58 of file XrdCrc32c.cc.
63 std::cerr <<
"xrdcrc32c: Unable to "<<op<<
' '<<target<<
"; "<<
XrdSysE2T(errno)<<std::endl;
const char * XrdSysE2T(int errcode)
References XrdSysE2T().
Referenced by XrdSecProtocolztn::XrdSecProtocolztn(), XrdOfsTPCAuth::Add(), XrdSecProtocolkrb5::Authenticate(), XrdSecProtocolztn::Authenticate(), XrdOfsTPC::Authorize(), XrdOfsTPC::Death(), XrdOfsTPCAuth::Get(), XrdSecProtocolkrb5::getCredentials(), XrdSecProtocolztn::getCredentials(), XrdSecProtocolkrb5::Init(), main(), XrdOfsTPC::Screen(), XrdTlsContext::SetContextCiphers(), XrdSecProtocolztnInit(), and XrdSecProtocolztnObject().
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 91 of file XrdCrc32c.cc.
95 static const int buffSZ = 1024*1024;
96 const char *fPath, *fmt =
"%08x";
97 int bytes, fd,
opts = O_RDONLY;
99 bool addPath =
true, addNL =
true;
105 if (argc > 1 &&
'-' == *argv[1])
106 while ((c = getopt(argc,argv,
"dhnsx")) && ((
unsigned char)c != 0xff))
113 case 'n': addNL =
false;
115 case 's': addPath =
false;
117 case 'x': fmt =
"%x";
119 default: std::cerr <<pgm <<
'-' <<char(
optopt) <<
" option is invalid" <<std::endl;
138 int rc = posix_memalign(&buffP, sysconf(_SC_PAGESIZE), buffSZ);
139 if (rc) {errno = rc;
Fatal(
"allocate buffer to read", fPath);}
143 while((bytes =
read(fd, buffP, buffSZ)) > 0)
148 if (bytes < 0)
Fatal(
"read", fPath);
152 sprintf(csBuff, fmt, csVal);
153 std::cout <<(
char *)csBuff;
154 if (addPath) std::cout <<
' ' <<fPath;
155 if (addNL) std::cout << std::endl;
void Fatal(const char *op, const char *target)
int open(const char *path, int oflag,...)
ssize_t read(int fildes, void *buf, size_t nbyte)
static uint32_t Calc32C(const void *data, size_t count, uint32_t prevcs=0)
References XrdOucCRC::Calc32C(), Fatal(), O_DIRECT, open(), optind, optopt, opts, read(), and Usage().
◆ Usage()
Definition at line 71 of file XrdCrc32c.cc.
73 std::cerr <<
"\nUsage: xrdcrc32c [opts] [<path> | -]\n"
74 "\n<path> the path to the file whose checksum if to be computed."
75 "\n- compute checksum from data presented at standard in;"
76 "\n example: xrdcp <url> - | xrdcrc32c -\n"
77 "\nopts: -d -h -n -s -x\n"
78 "\n-d read data directly into the buffer, do not use the file cache."
79 "\n-h display usage information (arguments ignored)."
80 "\n-n do not end output with a newline character."
81 "\n-s do not include file path in output result."
82 "\n-x do not print leading zeroes in the checksum, if any."
Referenced by main().