16 #include <sys/types.h> 26 #include <libxml2/libxml/SAX2.h> 90 static void XMLCALL
startElement(
void *userData,
const xmlChar *name,
const xmlChar **atts);
91 static void XMLCALL
endElement(
void *userData,
const xmlChar *name);
92 static void XMLCALL
characterData(
void *userData,
const xmlChar *s,
int len);
100 , content( reinterpret_cast<char *>(malloc(256)) )
117 memset( swtab, 0,
sizeof(swtab) );
118 memset( sbtab, 0,
sizeof(sbtab) );
121 if (!swtab[sw->
from])
122 swtab[sw->
from] = sw;
127 memset(&sax, 0,
sizeof(sax));
133 parser = xmlCreatePushParserCtxt(&sax,
this, NULL, 0, NULL);
139 xmlFreeParserCtxt(parser);
183 for (; *atts; atts += 2)
185 if (!strcmp(reinterpret_cast<const char*>(*atts), txt))
186 return reinterpret_cast<const char*
>(atts[1]);
192 startElement(
void *userData,
const xmlChar *name,
const xmlChar **atts)
205 if (sw->
ename == reinterpret_cast<const char *>(name))
222 const char *priority =
find_attr(
"priority", atts);
223 const char *preference =
find_attr(
"preference", atts);
227 prio = atoi(priority);
229 prio = 101 - atoi(preference);
232 pd->
urls.back().priority = prio;
238 const char *type =
find_attr(
"type", atts);
239 const char *length =
find_attr(
"length", atts);
242 if (!type || !length)
248 blksize = strtoul(length, 0, 10);
258 if (!strcmp(type,
"sha1") || !strcmp(type,
"sha-1"))
260 else if (!strcmp(type,
"zsync"))
273 const char *type =
find_attr(
"type", atts);
276 if ((!strcmp(type,
"sha1") || !strcmp(type,
"sha-1")) && pd->
chksuml < 20)
278 else if (!strcmp(type,
"sha256") || !strcmp(type,
"sha-256"))
291 const char *piece =
find_attr(
"piece", atts);
308 for (i = 0; i < buflen; i++)
310 #define c2h(c) (((c)>='0' && (c)<='9') ? ((c)-'0') \ 311 : ((c)>='a' && (c)<='f') ? ((c)-('a'-10)) \ 312 : ((c)>='A' && (c)<='F') ? ((c)-('A'-10)) \ 323 buf[i] = (buf[i] << 4) | v;
410 pd->
content =
reinterpret_cast<char *
>(realloc(pd->
content, l + 256));
421 MetaLinkParser::MetaLinkParser()
442 while (is.
stream().good())
444 is.
stream().read(buf,
sizeof(buf));
456 if (xmlParseChunk(
pd->
parser, buf, len, 0)) {
469 if (xmlParseChunk(
pd->
parser, NULL, 0, 1)) {
479 std::vector<Url> urls;
481 for (i = 0; i <
pd->
nurls; ++i)
500 for (i = 0; i < nb; i++)
508 size_t blkno = bl.
addBlock(off, size);
514 unsigned char *p = &
pd->
zsync[4 * i];
515 bl.
setRsum(blkno, 4, p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24,
pd->
blksize);
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Base class for Exception.
Easy-to use interface to the ZYPP dependency resolver.