16 #include <sys/types.h> 26 #include <libxml2/libxml/SAX2.h> 89 static void XMLCALL
startElement(
void *userData,
const xmlChar *name,
const xmlChar **atts);
90 static void XMLCALL
endElement(
void *userData,
const xmlChar *name);
91 static void XMLCALL
characterData(
void *userData,
const xmlChar *s,
int len);
99 , content( reinterpret_cast<char *>(malloc(256)) )
116 memset( swtab, 0,
sizeof(swtab) );
117 memset( sbtab, 0,
sizeof(sbtab) );
120 if (!swtab[sw->
from])
121 swtab[sw->
from] = sw;
126 memset(&sax, 0,
sizeof(sax));
132 parser = xmlCreatePushParserCtxt(&sax,
this, NULL, 0, NULL);
138 xmlFreeParserCtxt(parser);
158 std::vector<struct ml_url>
urls;
166 std::vector<unsigned char>
sha1;
182 for (; *atts; atts += 2)
184 if (!strcmp(reinterpret_cast<const char*>(*atts), txt))
185 return reinterpret_cast<const char*
>(atts[1]);
191 startElement(
void *userData,
const xmlChar *name,
const xmlChar **atts)
204 if (sw->
ename == reinterpret_cast<const char *>(name))
221 const char *priority =
find_attr(
"priority", atts);
222 const char *preference =
find_attr(
"preference", atts);
226 prio = atoi(priority);
228 prio = 101 - atoi(preference);
231 pd->
urls.back().priority = prio;
237 const char *type =
find_attr(
"type", atts);
238 const char *length =
find_attr(
"length", atts);
241 if (!type || !length)
247 blksize = strtoul(length, 0, 10);
257 if (!strcmp(type,
"sha1") || !strcmp(type,
"sha-1"))
259 else if (!strcmp(type,
"zsync"))
272 const char *type =
find_attr(
"type", atts);
275 if ((!strcmp(type,
"sha1") || !strcmp(type,
"sha-1")) && pd->
chksuml < 20)
277 else if (!strcmp(type,
"sha256") || !strcmp(type,
"sha-256"))
290 const char *piece =
find_attr(
"piece", atts);
307 for (i = 0; i < buflen; i++)
309 #define c2h(c) (((c)>='0' && (c)<='9') ? ((c)-'0') \ 310 : ((c)>='a' && (c)<='f') ? ((c)-('a'-10)) \ 311 : ((c)>='A' && (c)<='F') ? ((c)-('A'-10)) \ 322 buf[i] = (buf[i] << 4) | v;
409 pd->
content =
reinterpret_cast<char *
>(realloc(pd->
content, l + 256));
420 MetaLinkParser::MetaLinkParser()
441 while (is.
stream().good())
443 is.
stream().read(buf,
sizeof(buf));
455 if (xmlParseChunk(
pd->
parser, buf, len, 0)) {
468 if (xmlParseChunk(
pd->
parser, NULL, 0, 1)) {
478 std::vector<Url> urls;
480 for (i = 0; i <
pd->
nurls; ++i)
499 for (i = 0; i < nb; i++)
507 size_t blkno = bl.
addBlock(off, size);
513 unsigned char *p = &
pd->
zsync[4 * i];
514 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.