Loading...
Searching...
No Matches
XrdCks.cc File Reference
`#include <cstdio>`
`#include <cstdlib>`
`#include <cstring>`
`#include <iostream>`
`#include <sys/types.h>`
`#include <sys/stat.h>`
`#include <unistd.h>`
`#include <fcntl.h>`
`#include <cerrno>`
`#include "XrdCks/XrdCksXAttr.hh"`
`#include "XrdOuc/XrdOucXAttr.hh"`
Include dependency graph for XrdCks.cc:

Go to the source code of this file.

## Functions

void | Display ()
int | main (int argc, char *argv[])
void | Unable (int rc)
void | Usage (int rc)

## Variables

const char * | csCmd
struct stat | Stat
XrdOucXAttr< XrdCksXAttr > | xCS

## Function Documentation

## Display()

void Display | ( |  | ) |

Definition at line 56 of file XrdCks.cc.

{
const char *stale;
char csBuff[512];
// Check if the checksum is stale
//
if (xCS.Attr.Cks.fmTime != Stat.st_mtime) stale = " stale";
else stale = "";
// Get displayable checksum
//
xCS.Attr.Cks.Get(csBuff, sizeof(csBuff));
// Display the information
//
std::cout <<xCS.Attr.Cks.Name<<' '<<csBuff<<stale<<std::endl;
}
Stat
struct stat Stat
Definition XrdCks.cc:49
xCS
XrdOucXAttr< XrdCksXAttr > xCS
Definition XrdCks.cc:48

References Stat, and xCS.

Referenced by main(), main(), and XrdCmsUtils::ParseMan().

Here is the caller graph for this function:

## main()

int main | ( | int | argc,
|  | char * | argv[] )

Definition at line 108 of file XrdCks.cc.

{
char *csName, *csPath, *csVal;
int rc;
// Make sure the right number of arguments are here
//
if (argc <= 2)
{if (argc > 1 && !strcmp(argv[1], "-h")) Usage(0);
Usage(1);
}
// Verify the name
//
csName = argv[2];
if (!xCS.Attr.Cks.Set(csName))
{std::cerr <<"xrdsetcks: checksum name '"<<csName<<"' is invalid"<<std::endl;
exit(3);
}
// Determine what we should be doing
//
if (argc < 3) csCmd = "query";
else {csVal = argv[3];
if (!strcmp("delete", csVal)) csCmd = "delete";
else {csCmd = "set";
if (strncmp("0x", csVal, 2)) csVal += 2;
if (!xCS.Attr.Cks.Set(csVal, strlen(csVal)))
{std::cerr <<"xrdcks: checksum value is invalid"
<<std::endl;
exit(3);
}
}
}
// Verify the path
//
csPath = argv[1];
if (stat(csPath, &Stat)) Unable(errno);
// Handle query request
//
if (*csCmd == 'q')
{if ((rc = xCS.Get(csPath))) Unable(rc);
if (strcmp(xCS.Attr.Cks.Name, csName)) Unable(EILSEQ);
Display();
exit(0);
}
// Handle delete
//
if (*csCmd == 'd')
{if ((rc = xCS.Del(csPath))) Unable(rc);
exit(0);
}
// Handle the set
//
xCS.Attr.Cks.fmTime = static_cast<long long>(Stat.st_mtime);
xCS.Attr.Cks.csTime = 0;
if ((rc = xCS.Set(csPath))) Unable(rc);
exit(0);
}
Unable
void Unable(int rc)
Definition XrdCks.cc:79
csCmd
const char * csCmd
Definition XrdCks.cc:50
Display
void Display()
Definition XrdCks.cc:56
Usage
void Usage(int rc)
Definition XrdCks.cc:93
stat
#define stat(a, b)
Definition XrdPosix.hh:101

References csCmd, Display(), Stat, stat, Unable(), Usage(), and xCS.

Here is the call graph for this function:

## Unable()

void Unable | ( | int | rc | ) |

Definition at line 79 of file XrdCks.cc.

{
char eBuff[256];
if (rc < 0) rc = -rc;
snprintf(eBuff, sizeof(eBuff), "%s", strerror(rc));
*eBuff = tolower(*eBuff);
std::cerr<<"xrdcks: Unable to "<<csCmd<<" checksum; "<<eBuff<<std::endl;
exit(5);
}

References csCmd.

Referenced by main().

Here is the caller graph for this function:

## Usage()

void Usage | ( | int | rc | ) |

Definition at line 93 of file XrdCks.cc.

{
std::cerr <<"Usage: xrdcks <path> <cksname> [<cksval>|delete]\n"
" xrdcks -h\n\n"
"Where: <path> - path to the target file\n"
" <cksname> - checksum name (e.g. adler32)\n"
" <cksval> - ASCII hex of value (even number of digits)"
<<std::endl;
exit(rc);
}

Referenced by main().

Here is the caller graph for this function:

## Variable Documentation

## csCmd

const char* csCmd

Definition at line 50 of file XrdCks.cc.

Referenced by main(), and Unable().

## Stat

struct stat Stat

Definition at line 49 of file XrdCks.cc.

Referenced by XrdCpFile::XrdCpFile(), XrdTlsContext::XrdTlsContext(), XrdXmlRdrTiny::XrdXmlRdrTiny(), XrdFrmTSort::Add(), XrdOfsPoscq::Add(), XrdDigAuth::Authorize(), XrdCksManager::Calc(), XrdCksManOss::Calc(), XrdOfs::chmod(), XrdDigConfig::Configure(), XrdOfsChkPnt::Create(), XrdOfsCPFile::Create(), XrdCl::FileSystem::DirList(), XrdCl::FileSystem::DirList(), Display(), XrdCmsBlackList::DoIt(), XrdCl::LocalFileHandler::ExecRequest(), XrdCl::ActionExecutor::Execute(), XrdPfc::Cache::ExecuteCommandUrl(), XrdW41Dirs::Expand(), XrdOssPath::Extract(), XrdPosixFile::Finalize(), XrdOucUtils::findPgm(), XrdOfsHanOssErr::Fstat(), XrdPssFile::Fstat(), XrdOucUtils::getFile(), XrdCmsBlackList::Init(), XrdOfsPoscq::Init(), XrdOucN2NLoader::Load(), main(), XrdCksManager::ModTime(), XrdCksManOss::ModTime(), XrdDigDirectory::nextEntry(), XrdDigFile::open(), XrdNetRefresh::Register(), XrdCpFile::Resolve(), XrdOfsCPFile::RestoreInfo(), XrdOfsTPCProg::Run(), XrdCl::File::Stat(), XrdCl::FileSystem::Stat(), XrdCl::ZipArchive::Stat(), XrdOssWrapDF::StatRet(), XrdFrcUtils::updtCpy(), XrdEc::Reader::VectorRead(), and XrdVERSIONINFO().

## xCS

XrdOucXAttr<XrdCksXAttr> xCS

Definition at line 48 of file XrdCks.cc.

Referenced by XrdCksManager::Calc(), XrdCksManager::Del(), Display(), fGetXattrAdler32(), fSetXattrAdler32(), XrdCksManager::Get(), main(), XrdCksManager::Set(), and XrdCksManager::Ver().