33    static bool val = [](){
 
   34      const char * env = getenv(
"ZYPP_METALINK_DEBUG");
 
   55  for (i = 0; i < buflen; i++)
 
   57#define c2h(c) (((c)>='0' && (c)<='9') ? ((c)-'0')              \ 
   58                : ((c)>='a' && (c)<='f') ? ((c)-('a'-10))       \ 
   59                : ((c)>='A' && (c)<='F') ? ((c)-('A'-10))       \ 
   70      buf[i] = (buf[i] << 4) | v;
 
 
   81  std::ifstream is(filename.
c_str());
 
   84  is.exceptions(std::ifstream::eofbit | std::ifstream::failbit | std::ifstream::badbit);
 
   88      is.getline(buf, 
sizeof(buf));
 
   91      if (!strncmp(buf, 
"Length: ", 8))
 
   92        filesize = (off_t)strtoull(buf + 8, 0, 10);
 
   93      else if (!strncmp(buf, 
"Hash-Lengths: ", 14))
 
   94        (void)sscanf(buf + 14, 
"%d,%d,%d", &
sql, &
rsl, &
csl);
 
   95      else if (!strncmp(buf, 
"Blocksize: ", 11))
 
   97      else if (!strncmp(buf, 
"URL: http://", 12) || !strncmp(buf, 
"URL: https://", 13) || !strncmp(buf, 
"URL: ftp://", 11) || !strncmp(buf, 
"URL: tftp://", 12) )
 
   98        urls.push_back(buf + 5);
 
   99      else if (!strncmp(buf, 
"SHA-1: ", 7))
 
  101          unsigned char sha1[20];
 
  103            bl.setFileChecksum(
"SHA1", 20, sha1);
 
  117      bl.setRsumSequence( 
sql );
 
  123      for (i = 0; i < nblks; i++)
 
  131          size_t blkno = 
bl.addBlock(off, size);
 
  132          unsigned char rp[16];
 
  133          rp[0] = rp[1] = rp[2] = rp[3] = 0;
 
  135            is.read((
char *)rp + 4 - 
rsl, 
rsl);
 
  136          } 
catch ( 
const std::exception &e ) {
 
  149          bl.setRsum(blkno, 
rsl, rp[0] << 24 | rp[1] << 16 | rp[2] << 8 | rp[3], 
blksize);
 
  151            is.read((
char *)rp, 
csl);
 
  152          } 
catch ( 
const std::exception &e ) {
 
  179  MIL << 
"Parsed " << 
urls.size() << 
" mirrors from " << filename << std::endl;
 
  182      DBG << 
"- " <<  
url << std::endl;
 
 
  189  std::vector<Url> ret;
 
  191  for (i = 0; i < 
urls.size(); i++)
 
 
Base class for Exception.
const char * c_str() const
String representation.
String related utilities and Regular expression matching.
Namespace intended to collect all environment variables we use.
bool ZYPP_METALINK_DEBUG()
Hack to circumvent the currently poor –root support.
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
Easy-to use interface to the ZYPP dependency resolver.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.