16 #include <sys/types.h>
28 using namespace zypp::base;
89 static void XMLCALL
startElement(
void *userData,
const char *name,
const char **atts);
90 static void XMLCALL
endElement(
void *userData,
const char *name);
91 static void XMLCALL
characterData(
void *userData,
const XML_Char *s,
int len);
95 : parser( XML_ParserCreate(NULL) )
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;
124 XML_SetUserData(parser,
this);
131 XML_ParserFree(parser);
169 for (; *atts; atts += 2)
171 if (!strcmp(*atts, txt))
191 if (sw->
ename == name)
208 const char *priority =
find_attr(
"priority", atts);
209 const char *preference =
find_attr(
"preference", atts);
213 prio = atoi(priority);
215 prio = 101 - atoi(preference);
218 pd->
urls.back().priority = prio;
224 const char *type =
find_attr(
"type", atts);
225 const char *length =
find_attr(
"length", atts);
228 if (!type || !length)
234 blksize = strtoul(length, 0, 10);
244 if (!strcmp(type,
"sha1") || !strcmp(type,
"sha-1"))
246 else if (!strcmp(type,
"zsync"))
259 const char *type =
find_attr(
"type", atts);
262 if ((!strcmp(type,
"sha1") || !strcmp(type,
"sha-1")) && pd->
chksuml < 20)
264 else if (!strcmp(type,
"sha256") || !strcmp(type,
"sha-256"))
277 const char *piece =
find_attr(
"piece", atts);
294 for (i = 0; i < buflen; i++)
296 #define c2h(c) (((c)>='0' && (c)<='9') ? ((c)-'0') \
297 : ((c)>='a' && (c)<='f') ? ((c)-('a'-10)) \
298 : ((c)>='A' && (c)<='F') ? ((c)-('A'-10)) \
309 buf[i] = (buf[i] << 4) | v;
396 pd->
content =
reinterpret_cast<char *
>(realloc(pd->
content, l + 256));
407 MetaLinkParser::MetaLinkParser()
428 while (is.
stream().good())
430 is.
stream().read(buf,
sizeof(buf));
441 if (XML_Parse(
pd->
parser, buf, len, 0) == XML_STATUS_ERROR)
453 if (XML_Parse(
pd->
parser, 0, 0, 1) == XML_STATUS_ERROR)
462 std::vector<Url> urls;
464 for (i = 0; i <
pd->
nurls; ++i)
483 for (i = 0; i < nb; i++)
491 size_t blkno = bl.
addBlock(off, size);
497 unsigned char *p = &
pd->
zsync[4 * i];
498 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.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Base class for Exception.