#
-# Makefile.am for zypp/solver/testsuite/src
+# Makefile.am for zypp/testsuite/solver/src
#
-SUBDIRS =
-
INCLUDES = -I/usr/include/libxml2 \
-Ihelix \
-DZYPP_BASE_LOGGER_LOGGROUP=\"testsuite\"
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* Buffer.cc
- *
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#include <sys/mman.h>
-
-#include <cstdio>
-#include <fcntl.h>
-#include <cstdlib>
-#include <unistd.h>
-#include <iostream>
-#include <ctype.h>
-#include <string>
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include "Buffer.h"
-
-#include "zlib.h"
-#ifdef HAVE_BZ2
-/* Older bzlib didn't icnlude stdio.h */
-# include <bzlib.h>
-#endif
-
-#include "zypp/base/Logger.h"
-
-
-using namespace std;
-
-
-//---------------------------------------------------------------------------
-// compress/uncompress stuff
-
-/*
- * Magic gunzipping goodness
- */
-
-/*
- * Count number of bytes to skip at start of buf
- */
-static int gz_magic[2] = {0x1f, 0x8b};
-/* gzip flag byte */
-#define GZ_ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
-#define GZ_HEAD_CRC 0x02 /* bit 1 set: header CRC present */
-#define GZ_EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define GZ_ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define GZ_COMMENT 0x10 /* bit 4 set: file comment present */
-#define GZ_RESERVED 0xE0 /* bits 5..7: reserved */
-
-static int
-count_gzip_header (const unsigned char *buf, unsigned int input_length)
-{
- int method, flags;
- const unsigned char *s = buf;
- unsigned int left_len = input_length;
-
- if (left_len < 4) return -1;
- if (*s++ != gz_magic[0] || *s++ != gz_magic[1]) {
- return -2;
- }
-
- method = *s++;
- flags = *s++;
- left_len -= 4;
-
- if (method != Z_DEFLATED || (flags & GZ_RESERVED) != 0) {
- /* If it's not deflated, or the reserved isn't 0 */
- return -3;
- }
-
- /* Skip time, xflags, OS code */
- if (left_len < 6) return -4;
- s += 6;
- left_len -= 6;
-
- if (flags & GZ_EXTRA_FIELD) {
- unsigned int len;
- if (left_len < 2) return -5;
- len = (unsigned int)(*s++);
- len += ((unsigned int)(*s++)) << 8;
- if (left_len < len) return -6;
- s += len;
- left_len -= len;
- }
-
- /* Skip filename */
- if (flags & GZ_ORIG_NAME) {
- while (--left_len != 0 && *s++ != '\0') ;
- if (left_len == 0) return -7;
- }
- /* Skip comment */
- if (flags & GZ_COMMENT) {
- while (--left_len != 0 && *s++ != '\0') ;
- if (left_len == 0) return -7;
- }
- /* Skip CRC */
- if (flags & GZ_HEAD_CRC) {
- if (left_len < 2) return -7;
- s += 2;
- left_len -= 2;
- }
-
- return input_length - left_len;
-}
-
-
-int
-gunzip_memory (const unsigned char *input_buffer, unsigned int input_length, ByteArray **out_ba)
-{
- z_stream zs;
- char *outbuf = NULL;
- ByteArray *ba = NULL;
- int zret;
-
- int gzip_hdr;
-
- if (input_buffer == NULL) return -1;
- if (input_length == 0) return -2;
- if (out_ba == NULL) return -3;
-
- ba = (ByteArray *)malloc (sizeof (ByteArray));
- ba->data = NULL;
- ba->len = 0;
-
- gzip_hdr = count_gzip_header (input_buffer, input_length);
- if (gzip_hdr < 0)
- return -1;
-
- zs.next_in = (unsigned char *) input_buffer + gzip_hdr;
- zs.avail_in = input_length - gzip_hdr;
- zs.zalloc = NULL;
- zs.zfree = NULL;
- zs.opaque = NULL;
-
-#define OUTBUFSIZE 10000
- outbuf = (char *)malloc (OUTBUFSIZE);
- zs.next_out = (Bytef *)outbuf;
- zs.avail_out = OUTBUFSIZE;
-
- /* Negative inflateinit is magic to tell zlib that there is no
- * zlib header */
- inflateInit2 (&zs, -MAX_WBITS);
-
- while (1) {
- zret = inflate (&zs, Z_SYNC_FLUSH);
- if (zret != Z_OK && zret != Z_STREAM_END)
- break;
-
- ba->data = (byte *)realloc (ba->data, ba->len + (OUTBUFSIZE - zs.avail_out));
- memcpy (ba->data + ba->len, outbuf, OUTBUFSIZE - zs.avail_out);
- ba->len += (OUTBUFSIZE - zs.avail_out);
-
- zs.next_out = (Bytef *)outbuf;
- zs.avail_out = OUTBUFSIZE;
-
- if (zret == Z_STREAM_END)
- break;
- }
-
- inflateEnd (&zs);
- free ((void *)outbuf);
-
- if (zret != Z_STREAM_END) {
- ERR << "libz inflate failed! (" << zret << ")" << endl;
- free (ba->data);
- free (ba);
- ba = NULL;
- } else {
- zret = 0;
- }
-
- *out_ba = ba;
- return zret;
-}
-
-
-int
-gzip_memory (const char *input_buffer, unsigned int input_length, ByteArray **out_ba)
-{
- z_stream zs;
- char *outbuf = NULL;
- ByteArray *ba = NULL;
- int zret;
-
- if (input_buffer == NULL) return -1;
- if (input_length == 0) return -2;
- if (out_ba == NULL) return -3;
-
- ba = (ByteArray *)malloc (sizeof (ByteArray));
- ba->data = NULL;
- ba->len = 0;
-
- zs.next_in = (unsigned char *) input_buffer;
- zs.avail_in = input_length;
- zs.zalloc = NULL;
- zs.zfree = NULL;
- zs.opaque = NULL;
-
- outbuf = (char *)malloc (OUTBUFSIZE);
- zs.next_out = (Bytef *)outbuf;
- zs.avail_out = OUTBUFSIZE;
-
- deflateInit (&zs, Z_DEFAULT_COMPRESSION);
-
- while (1) {
- if (zs.avail_in)
- zret = deflate (&zs, Z_SYNC_FLUSH);
- else
- zret = deflate (&zs, Z_FINISH);
-
- if (zret != Z_OK && zret != Z_STREAM_END)
- break;
-
- ba->data = (byte *)realloc (ba->data, ba->len + (OUTBUFSIZE - zs.avail_out));
- memcpy (ba->data + ba->len, outbuf, OUTBUFSIZE - zs.avail_out);
- ba->len += (OUTBUFSIZE - zs.avail_out);
-
- zs.next_out = (Bytef *)outbuf;
- zs.avail_out = OUTBUFSIZE;
-
- if (zret == Z_STREAM_END)
- break;
- }
-
- deflateEnd (&zs);
- free ((void *)outbuf);
-
- if (zret != Z_STREAM_END) {
- ERR << "libz deflate failed! (" << zret << ")" << endl;
- free (ba->data);
- free (ba);
- ba = NULL;
- } else {
- zret = 0;
- }
-
- *out_ba = ba;
- return zret;
-} /* gzip_memory */
-
-
-bool
-memory_looks_gzipped (const unsigned char *buffer)
-{
- if (buffer == NULL)
- return false;
-
- /* This is from RFC 1952 */
-
- return buffer[0] == gz_magic[0] /* ID1 */
- && buffer[1] == gz_magic[1]; /* ID2 */
-}
-
-/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
-
-static char bz2_magic[3] = { 'B', 'Z', 'h' };
-
-int
-bunzip2_memory (const unsigned char *input_buffer, unsigned int input_length, ByteArray **out_ba)
-{
-#ifndef HAVE_BZ2
-
- ERR << "bz2 support not compiled in" << endl;
- *out_ba = NULL;
-
- return -1;
-
-#else
-
- bz_stream bzs;
- ByteArray *ba;
- char *outbuf;
- int bzret;
-
- if (input_buffer == NULL) return -1;
- if (input_length == 0) return -2;
- if (out_ba == NULL) return -3;
-
- ba = (ByteArray *)malloc (sizeof (ByteArray));
- ba->data = NULL;
- ba->len = 0;
-
- bzs.next_in = (unsigned char *) input_buffer;
- bzs.avail_in = input_length;
- bzs.bzalloc = NULL;
- bzs.bzfree = NULL;
- bzs.opaque = NULL;
-
- outbuf = (char *)malloc (OUTBUFSIZE);
- bzs.next_out = (Bytef *)outbuf;
- bzs.avail_out = OUTBUFSIZE;
-
- BZ2_bzDecompressInit (&bzs, 1, 0);
-
- while (1) {
- bzret = BZ2_bzDecompress (&bzs);
- if (bzret != BZ_OK && bzret != BZ_STREAM_END)
- break;
-
- ba->data = (byte *)realloc (ba->data, ba->len + (OUTBUFSIZE - zs.avail_out));
- memcpy (ba->data + ba->len, outbuf, OUTBUFSIZE - zs.avail_out);
- ba->len += (OUTBUFSIZE - zs.avail_out);
-
- bzs.next_out = (Bytef *)outbuf;
- bzs.avail_out = OUTBUFSIZE;
-
- if (bzret == BZ_STREAM_END)
- break;
-
- if (bzs.avail_in == 0) {
- /* The data is incomplete */
- bzret = -1;
- break;
- }
- }
-
- BZ2_bzDecompressEnd (&bzs);
- free ((void *)outbuf);
-
- if (bzret != BZ_STREAM_END) {
- ERR << "libbzip2 decompress failed (" << bzret << ")" << endl;
- free (ba->data);
- free (ba);
- ba = NULL;
- } else {
- bzret = 0;
- }
-
- *out_ba = ba;
- return bzret;
-#endif
-}
-
-
-int
-bzip2_memory (const char *input_buffer, unsigned int input_length, ByteArray **out_ba)
-{
-#ifndef HAVE_BZ2
-
- ERR << "bz2 support not compiled in" << endl;
- *out_ba = NULL;
-
- return -1;
-
-#else
-
- bz_stream bzs;
- ByteArray *ba;
- char *outbuf;
- int bzret;
-
- if (input_buffer == NULL) return -1;
- if (input_length == 0) return -2;
- if (out_ba == NULL) return -3;
-
- ba = (ByteArray *)malloc (sizeof (ByteArray));
- ba->data = NULL;
- ba->len = 0;
-
- bzs.next_in = (unsigned char *) input_buffer;
- bzs.avail_in = input_length;
- bzs.bzalloc = NULL;
- bzs.bzfree = NULL;
- bzs.opaque = NULL;
-
- outbuf = (char *)malloc (OUTBUFSIZE);
- bzs.next_out = (Bytef *)outbuf;
- bzs.avail_out = OUTBUFSIZE;
-
- BZ2_bzCompressInit (&bzs, 5, 1, 0);
-
- while (1) {
- if (bzs.avail_in)
- bzret = BZ2_bzCompress (&bzs, BZ_RUN);
- else
- bzret = BZ2_bzCompress (&bzs, BZ_FINISH);
-
- if (bzret != BZ_OK && bzret != BZ_STREAM_END)
- break;
-
- ba->data = (byte *)realloc (ba->data, ba->len + (OUTBUFSIZE - zs.avail_out));
- memcpy (ba->data + ba->len, outbuf, OUTBUFSIZE - zs.avail_out);
- ba->len += (OUTBUFSIZE - zs.avail_out);
-
- bzs.next_out = (Bytef *)outbuf;
- bzs.avail_out = OUTBUFSIZE;
-
- if (bzret == BZ_STREAM_END)
- break;
- }
-
- BZ2_bzCompressEnd (&bzs);
- free ((void *)outbuf);
-
- if (bzret != BZ_STREAM_END) {
- ERR << "bz2 compress failed! (" << bzret << ")" << endl;
- free (ba->data);
- free (ba);
- ba = NULL;
- } else {
- bzret = 0;
- }
-
- *out_ba = ba;
- return bzret;
-#endif
-}
-
-
-bool
-memory_looks_bzip2ed (const unsigned char *buffer)
-{
- if (buffer == NULL)
- return false;
-
- return buffer[0] == bz2_magic[0]
- && buffer[1] == bz2_magic[1]
- && buffer[2] == bz2_magic[2];
-}
-
-/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */
-
-int
-uncompress_memory (const unsigned char *input_buffer, unsigned int input_length, ByteArray **out_ba)
-{
- if (input_length > 2 && memory_looks_bzip2ed (input_buffer))
- return bunzip2_memory (input_buffer, input_length, out_ba);
- else if (input_length > 3 && memory_looks_gzipped (input_buffer))
- return gunzip_memory (input_buffer, input_length, out_ba);
- else
- return -1;
-}
-
-bool
-memory_looks_compressed (const unsigned char *buffer, size_t size)
-{
-#ifdef HAVE_BZ2
- if (size > 2 && memory_looks_bzip2ed (buffer))
- return true;
-#endif
-
- if (size > 4 && memory_looks_gzipped (buffer))
- return true;
-
- return false;
-}
-
-//---------------------------------------------------------------------------
-// I/O stuff
-
-/*
- * This just allows reading from the buffer for now. It could be extended to
- * do writing if necessary.
- */
-
-Buffer *
-bufferMapFile (const string & filename)
-{
- struct stat s;
- int fd;
- unsigned char *data;
- Buffer *buf = NULL;
-
- if (filename.empty())
- return NULL;
-
- if (stat(filename.c_str(), &s) < 0)
- return NULL;
-
- fd = open(filename.c_str(), O_RDONLY);
-
- if (fd < 0)
- return NULL;
-
- data = (unsigned char *)mmap(NULL, s.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
-
- close (fd);
-
- if (data == MAP_FAILED)
- return NULL;
-
- /* Transparently uncompress */
- if (memory_looks_compressed (data, s.st_size)) {
- ByteArray *byte_array = NULL;
-
- if (uncompress_memory (data, s.st_size, &byte_array)) {
- WAR << "Uncompression of '" << filename << "' failed" << endl;
- } else {
- buf = (Buffer *)malloc(sizeof (Buffer));
- buf->data = byte_array->data;
- buf->size = byte_array->len;
- buf->is_mmapped = false;
- }
-
- munmap (data, s.st_size);
-
- if (byte_array) {
- free (byte_array);
- }
-
- } else {
- buf = (Buffer *)malloc(sizeof (Buffer));
- buf->data = (byte *)data;
- buf->size = s.st_size;
- buf->is_mmapped = true;
- }
-
- return buf;
-} /* bufferMapFile */
-
-
-void
-bufferUnmapFile (Buffer *buf)
-{
- if (buf == NULL) return;
-
- if (buf->is_mmapped)
- munmap (buf->data, buf->size);
- else
- free (buf->data);
-
- free (buf);
-}
-
-//---------------------------------------------------------------------------
-// XML stuff
-
-xmlDoc *
-parseXmlFromBuffer (const char *input_buffer, size_t input_length)
-{
- xmlDoc *doc = NULL;
-
- if (input_buffer == NULL) return NULL;
-
- if (input_length > 3 && memory_looks_gzipped ((const unsigned char *)input_buffer)) {
- ByteArray *buf;
-
- if (uncompress_memory ((const unsigned char *)input_buffer, input_length, &buf)) {
- return NULL;
- }
- doc = xmlParseMemory ((const char *)(buf->data), buf->len);
- free (buf->data);
- free (buf);
- } else {
- doc = xmlParseMemory (input_buffer, input_length);
- }
-
- return doc;
-}
-
-
-xmlDoc *
-parseXmlFromFile (const string & filename)
-{
- Buffer *buf;
- xmlDoc *doc = NULL;
-
- if (filename.empty()) return NULL;
-
- buf = bufferMapFile (filename);
- if (buf) {
- doc = xmlParseMemory ((const char *)(buf->data), buf->size);
- bufferUnmapFile (buf);
- }
-
- return doc;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * Buffer.h
- *
- * Copyright (C) 2003 Ximian, Inc.
- * Copyright (c) 2005 SUSE Linux Products GmbH
- *
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-
-#ifndef BUFFER_H
-#define BUFFER_H
-
-#include <sys/types.h>
-#include <string>
-
-typedef unsigned char byte;
-
-typedef struct {
- byte *data;
- size_t len;
-} ByteArray;
-
-// An easy way to map files. If we map a compressed file,
-// it will be magically uncompressed for us.
-
-typedef struct {
- byte *data;
- size_t size;
- bool is_mmapped;
-} Buffer;
-
-Buffer *bufferMapFile (const std::string & filename);
-void bufferUnmapFile (Buffer *buffer);
-
-
-xmlDoc *parseXmlFromBuffer (const char *input_buffer, size_t input_length);
-xmlDoc *parseXmlFromFile (const std::string & filename);
-
-
-#endif // BUFFER_H
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixAtomImpl.cc
- *
-*/
-
-#include "HelixAtomImpl.h"
-#include "zypp/source/SourceImpl.h"
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-
-using namespace std;
-using namespace zypp::detail;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixAtomImpl
-//
-///////////////////////////////////////////////////////////////////
-
-/** Default ctor
-*/
-HelixAtomImpl::HelixAtomImpl (Source_Ref source_r, const zypp::HelixParser & parsed)
- : _source (source_r)
-{
-}
-
-Source_Ref
-HelixAtomImpl::source() const
-{ return _source; }
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixAtomImpl.h
- *
-*/
-#ifndef ZYPP_SOLVER_TEMPORARY_HELIXATOMIMPL_H
-#define ZYPP_SOLVER_TEMPORARY_HELIXATOMIMPL_H
-
-#include "zypp/detail/AtomImpl.h"
-#include "HelixParser.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixAtomImpl
-//
-/** Class representing a package
-*/
-class HelixAtomImpl : public detail::AtomImplIf
-{
-public:
-
- class HelixParser;
- /** Default ctor
- */
- HelixAtomImpl( Source_Ref source_r, const zypp::HelixParser & data );
-
- /** */
- virtual Source_Ref source() const;
-
-protected:
- Source_Ref _source;
-
-
- };
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOLVER_TEMPORARY_HELIXATOMIMPL_H
+++ /dev/null
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/*
- * extract.cc
- *
- * Copyright (C) 2000-2003 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-
-#include "HelixExtract.h"
-#include "HelixParser.h"
-#include "Buffer.h"
-
-#include "zypp/base/Logger.h"
-
-using namespace std;
-using namespace zypp;
-
-namespace zypp {
-
-int
-extractHelixBuffer (const char *buf, size_t len, HelixSourceImpl *impl)
-{
- MIL << "extractHelixBuffer()" << endl;
-
- if (buf == NULL || len == 0)
- return 1;
-
- HelixParser parser;
- parser.parseChunk (buf, len, impl);
- parser.done ();
-
- return 0;
-}
-
-
-int
-extractHelixFile (const std::string & filename, HelixSourceImpl *impl)
-{
- MIL << "extractHelixFile(" << filename << ")" << endl;
-
- Buffer *buf;
-
- if (filename.empty())
- return -1;
-
- buf = bufferMapFile (filename);
- if (buf == NULL)
- return -1;
-
- extractHelixBuffer ((const char *)(buf->data), buf->size, impl);
-
- bufferUnmapFile (buf);
-
- return 0;
-}
-
-} // namespace zypp
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-
-/*
- * HelixExtract.h
- *
- * Copyright (C) 2003 Ximian, Inc.
- * Copyright (c) 2005 SUSE Linux Products GmbH
- *
- */
-
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- * USA.
- */
-
-#ifndef HELIXEXTRACT_H
-#define HELIXEXTRACT_H
-
-#include "zypp/Resolvable.h"
-#include "zypp/Source.h"
-#include "zypp/ResStore.h"
-
-#include "HelixParser.h"
-
-namespace zypp {
-
-class HelixSourceImpl;
-
-int extractHelixBuffer (const char *data, size_t len, HelixSourceImpl *impl);
-int extractHelixFile (const std::string & filename, HelixSourceImpl *impl);
-
-}
-
-#endif /* HELIXEXTRACT_H */
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/testsuite/solver/HelixLanguageImpl.cc
- *
-*/
-
-#include "HelixLanguageImpl.h"
-#include "zypp/source/SourceImpl.h"
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-
-using namespace std;
-using namespace zypp::detail;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixLanguageImpl
-//
-///////////////////////////////////////////////////////////////////
-
-/** Default ctor
-*/
-HelixLanguageImpl::HelixLanguageImpl (Source_Ref source_r, const zypp::HelixParser & parsed)
- : LanguageImplIf()
-{
-}
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/testsuite/solver/HelixLanguageImpl.h
- *
-*/
-#ifndef ZYPP_HELIXLANGUAGEIMPL_H
-#define ZYPP_HELIXLANGUAGEIMPL_H
-
-#include "zypp/Language.h"
-#include "HelixParser.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixLanguageImpl
-//
-/** Class representing a package
-*/
-class HelixLanguageImpl : public detail::LanguageImplIf
-{
-public:
-
- class HelixParser;
- /** Default ctor
- */
- HelixLanguageImpl( Source_Ref source_r, const zypp::HelixParser & data );
-
-protected:
-
- };
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_HELIXLANGUAGEIMPL_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixMessageImpl.cc
- *
-*/
-
-#include "HelixMessageImpl.h"
-#include "zypp/source/SourceImpl.h"
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-
-using namespace std;
-using namespace zypp::detail;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixMessageImpl
-//
-///////////////////////////////////////////////////////////////////
-
-/** Default ctor
-*/
-HelixMessageImpl::HelixMessageImpl (Source_Ref source_r, const zypp::HelixParser & parsed)
- : _source (source_r)
-{
-}
-
-Source_Ref
-HelixMessageImpl::source() const
-{ return _source; }
-
-TranslatedText
-HelixMessageImpl::text () const
-{ return _text; }
-
-std::string
-HelixMessageImpl::type () const
-{ return _type; }
-
-ByteCount
-HelixMessageImpl::size() const
-{ return _size_installed; }
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixMessageImpl.h
- *
-*/
-#ifndef ZYPP_SOLVER_TEMPORARY_HELIXMESSAGEIMPL_H
-#define ZYPP_SOLVER_TEMPORARY_HELIXMESSAGEIMPL_H
-
-#include "zypp/detail/MessageImpl.h"
-#include "HelixParser.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixMessageImpl
-//
-/** Class representing a package
-*/
-class HelixMessageImpl : public detail::MessageImplIf
-{
-public:
-
- class HelixParser;
- /** Default ctor
- */
- HelixMessageImpl( Source_Ref source_r, const zypp::HelixParser & data );
-
- TranslatedText text () const;
- std::string type () const;
- virtual ByteCount size() const;
- /** */
- virtual Source_Ref source() const;
-
-protected:
- Source_Ref _source;
- TranslatedText _text;
- std::string _type;
- ByteCount _size_installed;
-
-
- };
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOLVER_TEMPORARY_HELIXMESSAGEIMPL_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixPackageImpl.cc
- *
-*/
-
-#include "HelixPackageImpl.h"
-#include "zypp/source/SourceImpl.h"
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-
-using namespace std;
-using namespace zypp::detail;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixPackageImpl
-//
-///////////////////////////////////////////////////////////////////
-
-/** Default ctor
-*/
-HelixPackageImpl::HelixPackageImpl (Source_Ref source_r, const zypp::HelixParser & parsed)
- : _source (source_r)
- , _summary(parsed.summary)
- , _description(parsed.description)
- , _group(parsed.section)
- , _install_only(parsed.installOnly)
- , _size_installed(parsed.installedSize)
- , _size_archive(parsed.fileSize)
- , _mediaid(parsed.location)
-{
-}
-
-Source_Ref
-HelixPackageImpl::source() const
-{ return _source; }
-
-/** Package summary */
-TranslatedText HelixPackageImpl::summary() const
-{ return _summary; }
-
-/** Package description */
-TranslatedText HelixPackageImpl::description() const
-{ return _description; }
-
-PackageGroup HelixPackageImpl::group() const
-{ return _group; }
-
-ByteCount HelixPackageImpl::size() const
-{ return _size_installed; }
-
-/** */
-ByteCount HelixPackageImpl::archivesize() const
-{ return _size_archive; }
-
-bool HelixPackageImpl::installOnly() const
-{ return _install_only; }
-
-unsigned int HelixPackageImpl::sourceMediaNr() const
-{ return _mediaid; }
-
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixPackageImpl.h
- *
-*/
-#ifndef ZYPP_SOLVER_TEMPORARY_HELIXPACKAGEIMPL_H
-#define ZYPP_SOLVER_TEMPORARY_HELIXPACKAGEIMPL_H
-
-#include "zypp/detail/PackageImpl.h"
-#include "HelixParser.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixPackageImpl
-//
-/** Class representing a package
-*/
-class HelixPackageImpl : public detail::PackageImplIf
-{
-public:
-
- class HelixParser;
- /** Default ctor
- */
- HelixPackageImpl( Source_Ref source_r, const zypp::HelixParser & data );
-
- /** Package summary */
- virtual TranslatedText summary() const;
- /** Package description */
- virtual TranslatedText description() const;
- virtual ByteCount size() const;
- /** */
- virtual PackageGroup group() const;
- /** */
- virtual ByteCount archivesize() const;
- /** */
- virtual bool installOnly() const;
- /** */
- virtual unsigned sourceMediaNr() const;
- /** */
- virtual Source_Ref source() const;
-
- /** */
- virtual Vendor vendor() const
- { return "SuSE";}
-
-
-protected:
- Source_Ref _source;
- TranslatedText _summary;
- TranslatedText _description;
- PackageGroup _group;
- bool _install_only;
-
- ByteCount _size_installed;
- ByteCount _size_archive;
-
- unsigned int _mediaid;
-
- };
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOLVER_TEMPORARY_HELIXPACKAGEIMPL_H
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* HelixParser.cc wrapper for XML I/O
- *
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <ctype.h>
-#include <assert.h>
-#include "HelixParser.h"
-#include "HelixPackageImpl.h"
-#include "HelixSourceImpl.h"
-
-#include "zypp/ResObject.h"
-#include "zypp/CapFactory.h"
-#include "zypp/CapSet.h"
-#include "zypp/Dependencies.h"
-#include "zypp/Edition.h"
-
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-
-using namespace std;
-using namespace zypp;
-
-//---------------------------------------------------------------------------
-
-static Resolvable::Kind
-string2kind (const std::string & str)
-{
- Resolvable::Kind kind = ResTraits<Package>::kind;
- if (!str.empty()) {
- if (str == "package") {
- // empty
- }
- else if (str == "patch") {
- kind = ResTraits<Patch>::kind;
- }
- else if (str == "pattern") {
- kind = ResTraits<Pattern>::kind;
- }
- else if (str == "selection") {
- kind = ResTraits<Selection>::kind;
- }
- else if (str == "script") {
- kind = ResTraits<Script>::kind;
- }
- else if (str == "message") {
- kind = ResTraits<Message>::kind;
- }
- else if (str == "product") {
- kind = ResTraits<Product>::kind;
- }
- else if (str == "language") {
- kind = ResTraits<Language>::kind;
- }
- else if (str == "atom") {
- kind = ResTraits<Atom>::kind;
- }
- else {
- ERR << "get_resItem unknown kind '" << str << "'" << endl;
- }
- }
- return kind;
-}
-
-
-//---------------------------------------------------------------------------
-
-static Capability
-parse_dep_attrs(bool *is_obsolete, bool *is_pre, const xmlChar **attrs)
-{
- CapFactory factory;
- int i;
- bool op_present = false;
- /* Temporary variables dependent upon the presense of an 'op' attribute */
-
- Resolvable::Kind dkind = ResTraits<Package>::kind; // default to package
- string dname;
- int depoch = Edition::noepoch;
- string dversion;
- string drelease;
- string darch = "noarch";
- Rel relation = Rel::ANY;
-
- *is_obsolete = false;
- *is_pre = false;
-
- for (i = 0; attrs[i]; i++) {
- const string attr ((const char *)attrs[i++]);
- const string value ((const char *)attrs[i]);
-
- if (attr == "name") dname = value;
- else if ((attr == "kind")
- || (attr == "refers")) dkind = string2kind (value);
- else if (attr == "op") { op_present = true; relation = Rel(value); }
- else if (attr == "epoch") depoch = str::strtonum<int>( value );
- else if (attr == "version") dversion = value;
- else if (attr == "release") drelease = value;
- else if (attr == "arch") darch = value;
- else if (attr == "obsoletes") *is_obsolete = true;
- else if (attr == "pre") if (value == "1") *is_pre = true;
- else {
- _DBG("HelixParser") << "! Unknown attribute: " << attr << " = " << value << endl;
- }
-
- }
-
- return factory.parse ( dkind, dname, relation, Edition (dversion, drelease, depoch));
-}
-
-
-//---------------------------------------------------------------------------
-// SAX callbacks
-
-static void
-sax_start_document(void *ptr)
-{
- HelixParser *ctx = (HelixParser *)ptr;
- if (ctx->processing()) return;
-
-// _XXX("HelixParser") << "* Start document" << endl;
-
- ctx->setProcessing (true);
-}
-
-
-static void
-sax_end_document(void *ptr)
-{
- HelixParser *ctx = (HelixParser *)ptr;
- if (!ctx->processing()) return;
-
-// _XXX("HelixParser") << "* End document" << endl;
-
- ctx->setProcessing (false);
-}
-
-
-static void
-sax_start_element(void *ptr, const xmlChar *xmlchar, const xmlChar **attrs)
-{
- HelixParser *ctx = (HelixParser *)ptr;
-
- ctx->releaseBuffer();
-
-#if 0
- _XXX("HelixParser") << "* Start element (" << (const char *)name << ")";
-
- if (attrs) {
- for (int i = 0; attrs[i]; i += 2) {
- _DBG("HelixParser") << " - Attribute (" << (const char *)attrs[i] << "=" << (const char *)attrs[i+1] << ")" << endl;
- }
- }
-#endif
-
- string token ((const char *)xmlchar);
-
- if (token == "channel"
- || token == "subchannel") {
- /* Unneeded container tags. Ignore */
- return;
- }
-
- return ctx->startElement (token, attrs);
-
-}
-
-
-static void
-sax_end_element(void *ptr, const xmlChar *xmlchar)
-{
- HelixParser *ctx = (HelixParser *)ptr;
-
-// _XXX("HelixParser") << "* End element (" << (const char *)name << ")" << endl;
- string token ((const char *)xmlchar);
-
- if (token == "channel"
- || token == "subchannel") {
- /* Unneeded container tags. Ignore */
- token.clear();
- }
-
- return ctx->endElement (token);
-}
-
-
-static void
-sax_characters(void *ptr, const xmlChar *ch, int len)
-{
- HelixParser *ctx = (HelixParser *)ptr;
-
- ctx->toBuffer (str::trim (string ((const char *)ch, len)));
- return;
-}
-
-
-static void
-sax_warning(void *ptr, const char *msg, ...)
-{
- va_list args;
- char tmp[2048];
-
- va_start(args, msg);
-
- if (vsnprintf(tmp, 2048, msg, args) >= 2048) ERR << "vsnprintf overflow" << endl;
- WAR << "* SAX Warning: " << tmp << endl;
-
- va_end(args);
-}
-
-
-static void
-sax_error(void *ptr, const char *msg, ...)
-{
- va_list args;
- char tmp[2048];
-
- va_start(args, msg);
-
- if (vsnprintf(tmp, 2048, msg, args) >= 2048) ERR << "vsnprintf overflow" << endl;;
- ERR << "* SAX Error: " << tmp <<endl;
-
- va_end(args);
-}
-
-
-static xmlSAXHandler sax_handler = {
- NULL, /* internalSubset */
- NULL, /* isStandalone */
- NULL, /* hasInternalSubset */
- NULL, /* hasExternalSubset */
- NULL, /* resolveEntity */
- NULL, /* getEntity */
- NULL, /* entityDecl */
- NULL, /* notationDecl */
- NULL, /* attributeDecl */
- NULL, /* elementDecl */
- NULL, /* unparsedEntityDecl */
- NULL, /* setDocumentLocator */
- sax_start_document, /* startDocument */
- sax_end_document, /* endDocument */
- sax_start_element, /* startElement */
- sax_end_element, /* endElement */
- NULL, /* reference */
- sax_characters, /* characters */
- NULL, /* ignorableWhitespace */
- NULL, /* processingInstruction */
- NULL, /* comment */
- sax_warning, /* warning */
- sax_error, /* error */
- sax_error /* fatalError */
-};
-
-//---------------------------------------------------------------------------
-
-HelixParser::HelixParser ()
- : _processing (false)
- , _xml_context (NULL)
- , _state (PARSER_TOPLEVEL)
- , _stored(true)
- , _dep_set (NULL)
- , _toplevel_dep_set (NULL)
- , _impl (NULL)
-{
-// _XXX("HelixParser") << "* Context created (" << this << ")" << endl;
-}
-
-
-HelixParser::~HelixParser()
-{
- releaseBuffer ();
-}
-
-//---------------------------------------------------------------------------
-
-string
-HelixParser::asString ( void ) const
-{
- return toString (*this);
-}
-
-
-string
-HelixParser::toString ( const HelixParser & context )
-{
- return "<HelixParser/>";
-}
-
-
-ostream &
-HelixParser::dumpOn( ostream & str ) const
-{
- str << asString();
- return str;
-}
-
-
-ostream&
-operator<<( ostream& os, const HelixParser& context)
-{
- return os << context.asString();
-}
-
-//---------------------------------------------------------------------------
-
-void
-HelixParser::toBuffer (string data)
-{
- _text_buffer = data;
-
-// _XXX("HelixParser") << "HelixParser[" << this << "]::toBuffer(" << data << "...," << (long)size << ")" << endl;
-}
-
-
-void
-HelixParser::releaseBuffer ()
-{
- _text_buffer.clear();
-
-// _XXX("HelixParser") << "HelixParser[" << this << "]::releaseBuffer()" << endl;
-}
-
-
-// called for extracting
-
-void
-HelixParser::parseChunk(const char *xmlbuf, size_t size, HelixSourceImpl *impl)
-{
-// _DBG("HelixParser") << "HelixParser::parseChunk(" << xmlbuf << "...," << (long)size << ")" << endl;
-
- xmlSubstituteEntitiesDefault(true);
-
- if (!_xml_context) {
- _xml_context = xmlCreatePushParserCtxt(&sax_handler, this, NULL, 0, NULL);
- }
-
- _impl = impl;
-
- xmlParseChunk(_xml_context, xmlbuf, size, 0);
-}
-
-
-void
-HelixParser::done()
-{
-// _XXX("HelixParser") << "HelixParser::done()" << endl;
-
- if (_processing)
- xmlParseChunk(_xml_context, NULL, 0, 1);
-
- if (_xml_context)
- xmlFreeParserCtxt(_xml_context);
-
- if (!_stored) {
- ERR << "Incomplete package lost" << endl;
- }
-
- return;
-}
-
-
-//---------------------------------------------------------------------------
-// Parser state callbacks
-
-void
-HelixParser::startElement(const string & token, const xmlChar **attrs)
-{
-// _XXX("HelixParser") << "HelixParser::startElement(" << token << ")" << endl;
-
- switch (_state) {
- case PARSER_TOPLEVEL:
- toplevelStart (token, attrs);
- break;
- case PARSER_RESOLVABLE:
- resolvableStart (token, attrs);
- break;
- case PARSER_HISTORY:
- historyStart (token, attrs);
- break;
- case PARSER_DEP:
- dependencyStart (token, attrs);
- break;
- default:
- break;
- }
-
- return;
-}
-
-
-void
-HelixParser::endElement(const string & token)
-{
-// _XXX("HelixParser") << "HelixParser::endElement(" << token << ")" << endl;
-
- if (!token.empty()) { // sax_end_element might set token to NULL
- switch (_state) {
- case PARSER_RESOLVABLE:
- resolvableEnd (token);
- break;
- case PARSER_HISTORY:
- historyEnd (token);
- break;
- case PARSER_UPDATE:
- updateEnd (token);
- break;
- case PARSER_DEP:
- dependencyEnd (token);
- break;
- default:
- break;
- }
- }
-
- releaseBuffer();
-
- return;
-}
-
-
-void
-HelixParser::toplevelStart(const std::string & token, const xmlChar **attrs)
-{
-// _XXX("HelixParser") << "HelixParser::toplevelStart(" << token << ")" << endl;
-
- if ((token == "package")
- || (token == "pattern")
- || (token == "selection")
- || (token == "script")
- || (token == "message")
- || (token == "language")
- || (token == "patch")
- || (token == "atom")
- || (token == "product")) {
-
- _state = PARSER_RESOLVABLE;
-
- _stored = false;
- _history.clear();
-
- name.clear();
- epoch = 0;
- version.clear();
- release.clear();
- arch = "noarch";
- summary.clear();
- description.clear();
- section.clear();
- kind = string2kind (token); // needed for <update>..</update>, see updateStart
-
- fileSize = 0;
- installedSize = 0;
- installOnly = false;
- installed = false;
-
- provides.clear();
- prerequires.clear();
- requires.clear();
- conflicts.clear();
- obsoletes.clear();
- recommends.clear();
- suggests.clear();
- freshens.clear();
- enhances.clear();
- supplements.clear();
-
- }
- else {
- _DBG("HelixParser") << "! Not handling " << token << " at toplevel" << endl;
- }
-}
-
-
-void
-HelixParser::resolvableStart(const std::string & token, const xmlChar **attrs)
-{
-// _XXX("HelixParser") << "HelixParser::resolvableStart(" << token << ")" << endl;
-
- /* Only care about the containers here */
- if (token == "history") {
- _state = PARSER_HISTORY;
- }
- else if (token == "deps") {
- /*
- * We can get a <deps> tag surrounding the actual package
- * dependency sections (requires, provides, conflicts, etc).
- * In this case, we'll just ignore this tag quietly.
- */
- }
- else if (token == "requires") {
- _state = PARSER_DEP;
- _dep_set = _toplevel_dep_set = &requires;
- }
- else if (token == "recommends") {
- _state = PARSER_DEP;
- _dep_set = _toplevel_dep_set = &recommends;
- }
- else if (token == "suggests") {
- _state = PARSER_DEP;
- _dep_set = _toplevel_dep_set = &suggests;
- }
- else if (token == "conflicts") {
- bool is_obsolete = false;
- int i;
-
- _state = PARSER_DEP;
-
- for (i = 0; attrs && attrs[i] && !is_obsolete; i += 2) {
- string attr ((const char *)(attrs[i]));
- if (attr == "obsoletes")
- is_obsolete = true;
- }
-
- if (is_obsolete)
- _dep_set = _toplevel_dep_set = &obsoletes;
- else {
- _dep_set = _toplevel_dep_set = &conflicts;
- }
- }
- else if (token == "obsoletes") {
- _state = PARSER_DEP;
- _dep_set = _toplevel_dep_set = &obsoletes;
- }
- else if (token == "provides") {
- _state = PARSER_DEP;
- _dep_set = _toplevel_dep_set = &provides;
- }
-#if 0 // disabled
- else if (token == "children") {
- _state = PARSER_DEP;
- _dep_set = _toplevel_dep_set = &children;
- }
-#endif
- else if (token == "freshens") {
- _state = PARSER_DEP;
- _dep_set = _toplevel_dep_set = &freshens;
- }
- else if (token == "enhances") {
- _state = PARSER_DEP;
- _dep_set = _toplevel_dep_set = &enhances;
- }
- else if (token == "supplements") {
- _state = PARSER_DEP;
- _dep_set = _toplevel_dep_set = &supplements;
- }
- else {
-// _XXX("HelixParser") << "! Not handling " << token << " in package start" << endl;
- }
-}
-
-
-void
-HelixParser::historyStart(const std::string & token, const xmlChar **attrs)
-{
-// _XXX("HelixParser") << "HelixParser::historyStart(" << token << ")" << endl;
-
- if (token == "update") {
-
- _state = PARSER_UPDATE;
- }
- else {
- _XXX("HelixParser") << "! Not handling " << token << " in history" << endl;
- }
-}
-
-
-void
-HelixParser::dependencyStart(const std::string & token, const xmlChar **attrs)
-{
-// _XXX("HelixParser") << "HelixParser::dependencyStart(" << token << ")" << endl;
-
- if (token == "dep") {
- Capability dep;
- bool is_obsolete;
- bool is_pre;
-
- dep = parse_dep_attrs(&is_obsolete, &is_pre, attrs);
-
- if (is_obsolete)
- obsoletes.insert (dep);
- else if (is_pre)
- prerequires.insert (dep);
- else {
- _dep_set->insert (dep);
- }
- }
- else if (token == "or")
- _dep_set->clear();
- else {
- _DBG("HelixParser") << "! Not handling " << token << " in dependency" << endl;
- }
-}
-
-
-//---------------------------------------------------------------------------
-
-
-void
-HelixParser::resolvableEnd (const std::string & token)
-{
-// _XXX("HelixParser") << "HelixParser::resolvableEnd(" << token << ")" << endl;
-
- if ((token == "package")
- || (token == "pattern")
- || (token == "selection")
- || (token == "script")
- || (token == "message")
- || (token == "language")
- || (token == "patch")
- || (token == "atom")
- || (token == "product")) {
-
- kind = string2kind (token);
-
- /* If possible, grab the version info from the most recent update.
- * Otherwise, try to find where the package provides itself and use
- * that version info.
- */
- // searching the highest version. It is not sure anymore that the last
- // has highest version
-
- History *history = NULL;
-
- if (!_history.empty())
- {
- for (HistoryList::iterator iter = _history.begin(); iter != _history.end(); iter++)
- {
- if (!history)
- history = &(*iter);
- else
- {
- Edition ed (history->version, history->release, history->epoch);
- Edition itered (iter->version, iter->release, iter->epoch);
- if (ed < itered)
- history = &(*iter);
- }
- }
- }
-
- if (history != NULL) {
- name = history->name;
- epoch = history->epoch;
- version = history->version;
- release = history->release;
- fileSize = history->fileSize;
- installedSize = history->installedSize;
- }
-
- // check if we provide ourselfs properly
-
- CapFactory factory;
- Edition edition (version, release, epoch);
- Capability selfdep = factory.parse ( kind, name, Rel::EQ, edition);
- CapSet::const_iterator piter;
- for (piter = provides.begin(); piter != provides.end(); piter++) {
- if ((*piter) == selfdep)
- break;
- }
-
- if (piter == provides.end()) { // no self provide found, construct one
-// _XXX("HelixParser") << "Adding self-provide [" << selfdep.asString() << "]" << endl;
- provides.insert (selfdep);
- }
-
- if (_impl) {
- _impl->parserCallback (*this);
- }
-
-// _DBG("HelixParser") << package->asString(true) << endl;
-// _DBG("HelixParser") << "HelixParser::resolvableEnd(" << token << ") done: '" << package->asString(true) << "'" << endl;
-// _XXX("HelixParser") << "HelixParser::resolvableEnd now " << _all_packages.size() << " packages" << endl;
- _stored = true;
- _state = PARSER_TOPLEVEL;
- }
- else if (token == "name") { name = _text_buffer;
- } else if (token == "version") { version = _text_buffer; // either here or in history
- } else if (token == "release") { release = _text_buffer;
- } else if (token == "pretty_name") { // ignore
- } else if (token == "summary") { summary = _text_buffer;
- } else if (token == "description") { description = _text_buffer;
- } else if (token == "section") { section = _text_buffer;
- } else if (token == "arch") { arch = _text_buffer;
- } else if (token == "filesize") { fileSize = str::strtonum<long>(_text_buffer);
- } else if (token == "installedsize") { installedSize = str::strtonum<long>(_text_buffer);
- } else if (token == "install_only") { installOnly = true;
- } else if (token == "md5sum") { // ignore
- } else if (token == "location") { location = str::strtonum<unsigned int>(_text_buffer);
- } else if (token == "deps") { // ignore, see resolvableStart
- } else {
- _DBG("HelixParser") << "HelixParser::resolvableEnd(" << token << ") unknown" << endl;
- }
-
-// _XXX("HelixParser") << "HelixParser::resolvableEnd(" << token << ") done" << endl;
-
- releaseBuffer();
-}
-
-
-void
-HelixParser::historyEnd (const std::string & token)
-{
-// _XXX("HelixParser") << "HelixParser::historyEnd(" << token << ")" << endl;
-
- if (token == "history") {
-
- _state = PARSER_RESOLVABLE;
- }
-}
-
-
-void
-HelixParser::updateEnd (const std::string & token)
-{
-// _XXX("HelixParser") << "HelixParser::updateEnd(" << token << ")" << endl;
-
- if (token == "update") {
- History history = { name, epoch, version, release, arch, fileSize, installedSize };
- _history.push_back(history);
- _state = PARSER_HISTORY;
- } else if (token == "epoch") { epoch = str::strtonum<int>(_text_buffer);
- } else if (token == "version") { version = _text_buffer;
- } else if (token == "release") { release = _text_buffer;
- } else if (token == "arch") { arch = _text_buffer;
- } else if (token == "filename") { // ignore
- } else if (token == "filesize") { fileSize = str::strtonum<long>(_text_buffer);
- } else if (token == "installedsize") { installedSize = str::strtonum<long>(_text_buffer);
- } else if (token == "signaturename") { // ignore
- } else if (token == "signaturesize") { // ignore
- } else if (token == "md5sum") { // ignore
- } else if (token == "importance") { // ignore
- } else if (token == "description") { // ignore
- } else if (token == "hid") { // ignore
- } else if (token == "license") { // ignore
- } else {
- ERR << "HelixParser::updateEnd(" << token << ") unknown" << endl;
- }
-
- releaseBuffer();
-}
-
-
-void
-HelixParser::dependencyEnd (const std::string & token)
-{
-// _XXX("HelixParser") << "HelixParser::dependencyEnd(" << token << ")" << endl;
-
- if (token == "or") {
-#if 0
- OrDependency_Ptr or_dep = OrDependency::fromDependencyList (*_dep_set);
- Dependency_Ptr dep = new Dependency (or_dep);
-
- (*_dep_set).clear();
-
- (*_toplevel_dep_set).push_back (dep);
- _dep_set = _toplevel_dep_set;
-#endif
- }
- else if (token == "dep") {
- /* We handled everything we needed for dep in start */
- }
- else {
- /* All of the dep lists (requires, provides, etc.) */
- _toplevel_dep_set = NULL;
- _dep_set = NULL;
- _state = PARSER_RESOLVABLE;
- }
-}
-
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* HelixParser.h: XML routines
- *
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef ZYPP_SOLVER_TEMPORARY_HELIXPARSER_H
-#define ZYPP_SOLVER_TEMPORARY_HELIXPARSER_H
-
-#include <iosfwd>
-#include <string>
-#include <list>
-
-#include "zypp/CapSet.h"
-#include "zypp/ResStore.h"
-#include "zypp/Dependencies.h"
-#include "zypp/Source.h"
-
-#include "XmlNode.h"
-
-namespace zypp {
-
-class HelixParser;
-class HelixSourceImpl;
-typedef bool (*ParserCallback) (const HelixParser & parsed, HelixSourceImpl *impl);
-typedef struct {
- std::string name;
- int epoch;
- std::string version;
- std::string release;
- std::string arch;
- long fileSize;
- long installedSize;
-} History;
-typedef std::list<History> HistoryList;
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixParser
-
-class HelixParser
-{
- public:
- enum _HelixParserState {
- PARSER_TOPLEVEL = 0,
- PARSER_RESOLVABLE,
- PARSER_HISTORY,
- PARSER_UPDATE,
- PARSER_DEP,
- };
- typedef enum _HelixParserState HelixParserState;
-
- private:
- bool _processing;
- xmlParserCtxtPtr _xml_context;
- HelixParserState _state;
-
- /* Temporary state */
- bool _stored;
-
-
- public:
- Resolvable::Kind kind;
- std::string name;
- int epoch;
- std::string version;
- std::string release;
- std::string arch;
- std::string summary;
- std::string description;
- std::string section;
- int fileSize;
- int installedSize;
- bool installOnly;
- bool installed;
- unsigned int location;
-
- CapSet provides;
- CapSet prerequires;
- CapSet requires;
- CapSet conflicts;
- CapSet obsoletes;
- CapSet recommends;
- CapSet suggests;
- CapSet freshens;
- CapSet enhances;
- CapSet supplements;
-
- private:
- // these point to one of the Dependency sets during dependency parsing
- CapSet *_dep_set;
- CapSet *_toplevel_dep_set; // just needed during 'or' parsing
-
- HistoryList _history;
-
- std::string _text_buffer;
-
- void setState (HelixParserState state) { _state = state; }
-
- public:
-
- HelixParser ();
- virtual ~HelixParser();
-
- // ---------------------------------- I/O
-
- static std::string toString ( const HelixParser & parser);
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- friend std::ostream& operator<<( std::ostream & str, const HelixParser & parser);
- std::string asString ( void ) const;
-
- // ---------------------------------- accessors
-
- bool processing (void) const { return _processing; }
- void setProcessing (bool processing) { _processing = processing; }
-
- public:
- // ---------------------------------- accessors
-
- HelixParserState state (void) const { return _state; }
-
- // ---------------------------------- methods
- // callbacks from xml_ parser functions
-
- void toBuffer (std::string data);
- void releaseBuffer (void); // free _text_buffer
-
- void startElement(const std::string & token, const xmlChar **attrs);
- void endElement(const std::string & token);
-
- void parseChunk (const char *xmlbuf, size_t size, HelixSourceImpl *impl);
- void done (void);
-
- private:
- HelixSourceImpl *_impl;
-
- // internal HelixParser functions, c++-style
- void toplevelStart(const std::string & token, const xmlChar **attrs);
- void resolvableStart(const std::string & token, const xmlChar **attrs);
- void historyStart(const std::string & token, const xmlChar **attrs);
- void dependencyStart(const std::string & token, const xmlChar **attrs);
-
- void updateEnd(const std::string & token);
- void resolvableEnd(const std::string & token);
- void historyEnd(const std::string & token);
- void dependencyEnd(const std::string & token);
-
-};
-
-} // namespace zypp
-
-#endif // ZYPP_SOLVER_TEMPORARY_HELIXPARSER_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixPatchImpl.cc
- *
-*/
-
-#include "HelixPatchImpl.h"
-#include "zypp/source/SourceImpl.h"
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-
-using namespace std;
-using namespace zypp::detail;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixPatchImpl
-//
-///////////////////////////////////////////////////////////////////
-
-/** Default ctor
-*/
-HelixPatchImpl::HelixPatchImpl (Source_Ref source_r, const zypp::HelixParser & parsed)
- : _source (source_r)
- , _size_installed(parsed.installedSize)
-{
-}
-
-Source_Ref
-HelixPatchImpl::source() const
-{ return _source; }
-
-ByteCount HelixPatchImpl::size() const
-{ return _size_installed; }
-
- /** Patch ID */
-std::string HelixPatchImpl::id() const
-{ return ""; }
-
- /** Patch time stamp */
-Date HelixPatchImpl::timestamp() const
-{ return 0; }
-
- /** Patch category (recommended, security,...) */
-std::string HelixPatchImpl::category() const
-{ return ""; }
-
- /** Does the system need to reboot to finish the update process? */
-bool HelixPatchImpl::reboot_needed() const
-{ return false; }
-
- /** Does the patch affect the package manager itself? */
-bool HelixPatchImpl::affects_pkg_manager() const
-{ return false; }
-
- /** Is the patch installation interactive? (does it need user input?) */
-bool HelixPatchImpl::interactive() const
-{ return false; }
-
- /** The list of all atoms building the patch */
-PatchImplIf::AtomList HelixPatchImpl::all_atoms() const
-{ return AtomList(); }
-
- /** The list of those atoms which have not been installed */
-PatchImplIf::AtomList HelixPatchImpl::not_installed_atoms() const
-{ return AtomList(); }
-
-
-// TODO check necessarity of functions below
-void HelixPatchImpl::mark_atoms_to_freshen(bool freshen)
-{ return; }
-
-bool HelixPatchImpl::any_atom_selected() const
-{ return false; }
-
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixPatchImpl.h
- *
-*/
-#ifndef ZYPP_SOLVER_TEMPORARY_HELIXPATCHIMPL_H
-#define ZYPP_SOLVER_TEMPORARY_HELIXPATCHIMPL_H
-
-#include "zypp/detail/PatchImpl.h"
-#include "HelixParser.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixPatchImpl
-//
-/** Class representing a package
-*/
-class HelixPatchImpl : public detail::PatchImplIf
-{
-public:
-
- class HelixParser;
- /** Default ctor
- */
- HelixPatchImpl( Source_Ref source_r, const zypp::HelixParser & data );
-
-
- /** Patch ID */
- virtual std::string id() const ;
- /** Patch time stamp */
- virtual Date timestamp() const ;
- /** Patch category (recommended, security,...) */
- virtual std::string category() const ;
- /** Does the system need to reboot to finish the update process? */
- virtual bool reboot_needed() const ;
- /** Does the patch affect the package manager itself? */
- virtual bool affects_pkg_manager() const ;
- /** */
- virtual ByteCount size() const;
-
- /** Is the patch installation interactive? (does it need user input?) */
- virtual bool interactive() const;
- /** The list of all atoms building the patch */
- virtual AtomList all_atoms() const;
- /** The list of those atoms which have not been installed */
- virtual AtomList not_installed_atoms() const;
-
-// TODO check necessarity of functions below
- virtual void mark_atoms_to_freshen(bool freshen) ;
- virtual bool any_atom_selected() const;
-
- /** */
- virtual Source_Ref source() const;
-
-protected:
- Source_Ref _source;
- ByteCount _size_installed;
- };
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOLVER_TEMPORARY_HELIXPACKAGEIMPL_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixPatternImpl.cc
- *
-*/
-
-#include "HelixPatternImpl.h"
-#include "zypp/source/SourceImpl.h"
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-
-using namespace std;
-using namespace zypp::detail;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixPatternImpl
-//
-///////////////////////////////////////////////////////////////////
-
-/** Default ctor
-*/
-HelixPatternImpl::HelixPatternImpl (Source_Ref source_r, const zypp::HelixParser & parsed)
- : _source (source_r)
- , _summary(parsed.summary)
- , _description(parsed.description)
- , _group(parsed.section)
- , _install_only(parsed.installOnly)
- , _size_installed(parsed.installedSize)
- , _size_archive(parsed.fileSize)
-{
-}
-
-Source_Ref
-HelixPatternImpl::source() const
-{ return _source; }
-
-/** Pattern summary */
-TranslatedText HelixPatternImpl::summary() const
-{ return _summary; }
-
-/** Pattern description */
-TranslatedText HelixPatternImpl::description() const
-{ return _description; }
-
-PackageGroup HelixPatternImpl::group() const
-{ return _group; }
-
-ByteCount HelixPatternImpl::size() const
-{ return _size_installed; }
-
-/** */
-ByteCount HelixPatternImpl::archivesize() const
-{ return _size_archive; }
-
-bool HelixPatternImpl::installOnly() const
-{ return _install_only; }
-
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixPatternImpl.h
- *
-*/
-#ifndef ZYPP_SOLVER_TEMPORARY_HELIXPATTERNIMPL_H
-#define ZYPP_SOLVER_TEMPORARY_HELIXPATTERNIMPL_H
-
-#include "zypp/detail/PatternImpl.h"
-#include "HelixParser.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixPatternImpl
-//
-/** Class representing a package
-*/
-class HelixPatternImpl : public detail::PatternImplIf
-{
-public:
-
- class HelixParser;
- /** Default ctor
- */
- HelixPatternImpl( Source_Ref source_r, const zypp::HelixParser & data );
-
- /** Pattern summary */
- virtual TranslatedText summary() const;
- /** Pattern description */
- virtual TranslatedText description() const;
- virtual ByteCount size() const;
- /** */
- virtual PackageGroup group() const;
- /** */
- virtual ByteCount archivesize() const;
- /** */
- virtual bool installOnly() const;
- /** */
-
- /** */
- virtual Source_Ref source() const;
-protected:
- Source_Ref _source;
- TranslatedText _summary;
- TranslatedText _description;
- PackageGroup _group;
- bool _install_only;
-
- ByteCount _size_installed;
- ByteCount _size_archive;
-
-
- };
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOLVER_TEMPORARY_HELIXPACKAGEIMPL_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixProductImpl.cc
- *
-*/
-
-#include "HelixProductImpl.h"
-#include "zypp/source/SourceImpl.h"
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-
-using namespace std;
-using namespace zypp::detail;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixProductImpl
-//
-///////////////////////////////////////////////////////////////////
-
-/** Default ctor
-*/
-HelixProductImpl::HelixProductImpl (Source_Ref source_r, const zypp::HelixParser & parsed)
- : _source (source_r)
- , _summary(parsed.summary)
- , _description(parsed.description)
- , _group(parsed.section)
- , _install_only(parsed.installOnly)
- , _size_installed(parsed.installedSize)
- , _size_archive(parsed.fileSize)
-{
-}
-
-Source_Ref
-HelixProductImpl::source() const
-{ return _source; }
-
-/** Package summary */
-TranslatedText HelixProductImpl::summary() const
-{ return _summary; }
-
-/** Package description */
-TranslatedText HelixProductImpl::description() const
-{ return _description; }
-
-PackageGroup HelixProductImpl::group() const
-{ return _group; }
-
-ByteCount HelixProductImpl::size() const
-{ return _size_installed; }
-
-/** */
-ByteCount HelixProductImpl::archivesize() const
-{ return _size_archive; }
-
-bool HelixProductImpl::installOnly() const
-{ return _install_only; }
-
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixProductImpl.h
- *
-*/
-#ifndef ZYPP_SOLVER_TEMPORARY_HELIXPRODUCTIMPL_H
-#define ZYPP_SOLVER_TEMPORARY_HELIXPRODUCTIMPL_H
-
-#include "zypp/detail/ProductImpl.h"
-#include "HelixParser.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixProductImpl
-//
-/** Class representing a package
-*/
-class HelixProductImpl : public detail::ProductImplIf
-{
-public:
-
- class HelixParser;
- /** Default ctor
- */
- HelixProductImpl( Source_Ref source_r, const zypp::HelixParser & data );
-
- /** Product summary */
- virtual TranslatedText summary() const;
- /** Product description */
- virtual TranslatedText description() const;
- virtual ByteCount size() const;
- /** */
- virtual PackageGroup group() const;
- /** */
- virtual ByteCount archivesize() const;
- /** */
- virtual bool installOnly() const;
- /** */
-
- /** */
- virtual Source_Ref source() const;
-
-protected:
- Source_Ref _source;
- TranslatedText _summary;
- TranslatedText _description;
- PackageGroup _group;
- bool _install_only;
-
- ByteCount _size_installed;
- ByteCount _size_archive;
-
-
- };
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOLVER_TEMPORARY_HELIXPACKAGEIMPL_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixScriptImpl.cc
- *
-*/
-
-#include "HelixScriptImpl.h"
-#include "zypp/source/SourceImpl.h"
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-
-using namespace std;
-using namespace zypp::detail;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixScriptImpl
-//
-///////////////////////////////////////////////////////////////////
-
-/** Default ctor
-*/
-HelixScriptImpl::HelixScriptImpl (Source_Ref source_r, const zypp::HelixParser & parsed)
- : _source (source_r)
- , _size_installed(parsed.installedSize)
-{
-}
-
-Source_Ref
-HelixScriptImpl::source() const
-{ return _source; }
-
-/** Get the script to perform the change */
-Pathname HelixScriptImpl::do_script() const
-{ return "do_script"; }
-
-/** Get the script to undo the change */
-Pathname HelixScriptImpl::undo_script() const
-{ return "undo_script"; }
-
-/** Check whether script to undo the change is available */
-bool HelixScriptImpl::undo_available() const
-{ return false; }
-
-ByteCount HelixScriptImpl::size() const
-{ return _size_installed; }
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixPackageImpl.h
- *
-*/
-#ifndef ZYPP_SOLVER_TEMPORARY_HELIXSCRIPTIMPL_H
-#define ZYPP_SOLVER_TEMPORARY_HELIXSCRIPTIMPL_H
-
-#include "zypp/detail/ScriptImpl.h"
-#include "HelixParser.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixScriptImpl
-//
-/** Class representing a script
-*/
-class HelixScriptImpl : public detail::ScriptImplIf
-{
-public:
-
- class HelixParser;
- /** Default ctor
- */
- HelixScriptImpl( Source_Ref source_r, const zypp::HelixParser & data );
-
- /** Get the script to perform the change */
- virtual Pathname do_script() const;
- /** Get the script to undo the change */
- virtual Pathname undo_script() const;
- /** Check whether script to undo the change is available */
- virtual bool undo_available() const;
- /** */
- virtual ByteCount size() const;
-
- /** */
- virtual Source_Ref source() const;
-
-protected:
- Source_Ref _source;
- ByteCount _size_installed;
-
-
- };
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOLVER_TEMPORARY_HELIXPACKAGEIMPL_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixSelectionImpl.cc
- *
-*/
-
-#include "HelixSelectionImpl.h"
-#include "zypp/source/SourceImpl.h"
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-
-using namespace std;
-using namespace zypp::detail;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixSelectionImpl
-//
-///////////////////////////////////////////////////////////////////
-
-/** Default ctor
-*/
-HelixSelectionImpl::HelixSelectionImpl (Source_Ref source_r, const zypp::HelixParser & parsed)
- : _source (source_r)
- , _summary(parsed.summary)
- , _description(parsed.description)
-{
-}
-
-Source_Ref
-HelixSelectionImpl::source() const
-{ return _source; }
-
-/** Selection summary */
-TranslatedText HelixSelectionImpl::summary() const
-{ return _summary; }
-
-/** Selection description */
-TranslatedText HelixSelectionImpl::description() const
-{ return _description; }
-
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/solver/temporary/HelixSelectionImpl.h
- *
-*/
-#ifndef ZYPP_SOLVER_TEMPORARY_HELIXSELECTIONIMPL_H
-#define ZYPP_SOLVER_TEMPORARY_HELIXSELECTIONIMPL_H
-
-#include "zypp/detail/SelectionImpl.h"
-#include "HelixParser.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixSelectionImpl
-//
-/** Class representing a package
-*/
-class HelixSelectionImpl : public detail::SelectionImplIf
-{
-public:
-
- class HelixParser;
- /** Default ctor
- */
- HelixSelectionImpl( Source_Ref source_r, const zypp::HelixParser & data );
-
- /** Selection summary */
- virtual TranslatedText summary() const;
- /** Selection description */
- virtual TranslatedText description() const;
-
- /** */
- virtual Source_Ref source() const;
-protected:
- Source_Ref _source;
- TranslatedText _summary;
- TranslatedText _description;
-
- };
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOLVER_TEMPORARY_HELIXSELECTIONIMPL_H
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* HelixSourceImpl.cc
- *
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#include "HelixExtract.h"
-#include "HelixSourceImpl.h"
-#include "HelixPackageImpl.h"
-#include "HelixScriptImpl.h"
-#include "HelixLanguageImpl.h"
-#include "HelixMessageImpl.h"
-#include "HelixAtomImpl.h"
-#include "HelixPatchImpl.h"
-#include "HelixSelectionImpl.h"
-#include "HelixPatternImpl.h"
-#include "HelixProductImpl.h"
-
-#include "zypp/source/SourceImpl.h"
-#include "zypp/base/Logger.h"
-#include "zypp/base/Exception.h"
-
-
-using namespace std;
-using namespace zypp;
-
-//---------------------------------------------------------------------------
-
-HelixSourceImpl::HelixSourceImpl()
-{
- MIL << "HelixSourceImpl::HelixSourceImpl()" << endl;
-}
-
-
-void
-HelixSourceImpl::factoryInit()
-{
- MIL << "HelixSourceImpl::factoryInit()" << endl;
- try {
- media::MediaManager media_mgr;
- MIL << "Adding no media verifier" << endl;
- media::MediaAccessId _media = _media_set->getMediaAccessId(1);
- media_mgr.delVerifier(_media);
- media_mgr.addVerifier(_media, media::MediaVerifierRef(new media::NoVerifier()));
- }
- catch (const Exception & excpt_r)
- {
-#warning FIXME: If media data is not set, verifier is not set. Should the media be refused instead?
- ZYPP_CAUGHT(excpt_r);
- WAR << "Verifier not found" << endl;
- }
- return;
-}
-
-
-void
-HelixSourceImpl::factoryCtor( const media::MediaId & media_r, const Pathname & path_r, const std::string & alias_r, const Pathname cache_dir_r)
-{
- MIL << "HelixSourceImpl::factoryCtor(<media>, " << path_r << ", " << alias_r << ", " << cache_dir_r << ")" << endl;
-// _media = media_r;
- _pathname = path_r;
- _alias = alias_r;
- _cache_dir = cache_dir_r;
-}
-
-
-void
-HelixSourceImpl::createResolvables(Source_Ref source)
-{
- _source = source;
-
- MIL << "HelixSourceImpl::createResolvables(" << _pathname << ", for source " << source.alias() << ")" << endl;
- extractHelixFile (_pathname.asString(), this);
-}
-
-
-
-//-----------------------------------------------------------------------------
-
-Dependencies
-HelixSourceImpl::createDependencies (const HelixParser & parsed)
-{
- Dependencies deps;
-
- deps[Dep::PROVIDES] = parsed.provides;
- deps[Dep::PREREQUIRES] = parsed.prerequires;
- deps[Dep::REQUIRES] = parsed.requires;
- deps[Dep::CONFLICTS] = parsed.conflicts;
- deps[Dep::OBSOLETES] = parsed.obsoletes;
- deps[Dep::RECOMMENDS] = parsed.recommends;
- deps[Dep::SUGGESTS] = parsed.suggests;
- deps[Dep::FRESHENS] = parsed.freshens;
- deps[Dep::ENHANCES] = parsed.enhances;
- deps[Dep::SUPPLEMENTS] = parsed.supplements;
-
- return deps;
-}
-
-
-Package::Ptr
-HelixSourceImpl::createPackage (const HelixParser & parsed)
-{
- try
- {
- detail::ResImplTraits<HelixPackageImpl>::Ptr impl(new HelixPackageImpl(_source, parsed));
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name,
- Edition( parsed.version, parsed.release, parsed.epoch ),
- Arch( parsed.arch ),
- createDependencies (parsed));
- Package::Ptr package = detail::makeResolvableFromImpl(dataCollect, impl);
- return package;
- }
- catch (const Exception & excpt_r)
- {
- ERR << excpt_r << endl;
- throw "Cannot create package object";
- }
- return NULL;
-}
-
-
-Language::Ptr
-HelixSourceImpl::createLanguage (const HelixParser & parsed)
-{
- try
- {
- detail::ResImplTraits<HelixLanguageImpl>::Ptr impl(new HelixLanguageImpl(_source, parsed));
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name,
- Edition( parsed.version, parsed.release, parsed.epoch ),
- Arch( parsed.arch ),
- createDependencies (parsed));
- Language::Ptr message = detail::makeResolvableFromImpl(dataCollect, impl);
- return message;
- }
- catch (const Exception & excpt_r)
- {
- ERR << excpt_r << endl;
- throw "Cannot create language object";
- }
- return NULL;
-}
-
-
-Message::Ptr
-HelixSourceImpl::createMessage (const HelixParser & parsed)
-{
- try
- {
- detail::ResImplTraits<HelixMessageImpl>::Ptr impl(new HelixMessageImpl(_source, parsed));
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name,
- Edition( parsed.version, parsed.release, parsed.epoch ),
- Arch( parsed.arch ),
- createDependencies (parsed));
- Message::Ptr message = detail::makeResolvableFromImpl(dataCollect, impl);
- return message;
- }
- catch (const Exception & excpt_r)
- {
- ERR << excpt_r << endl;
- throw "Cannot create message object";
- }
- return NULL;
-}
-
-
-Script::Ptr
-HelixSourceImpl::createScript (const HelixParser & parsed)
-{
- try
- {
- detail::ResImplTraits<HelixScriptImpl>::Ptr impl(new HelixScriptImpl(_source, parsed));
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name,
- Edition( parsed.version, parsed.release, parsed.epoch ),
- Arch( parsed.arch ),
- createDependencies (parsed));
- Script::Ptr script = detail::makeResolvableFromImpl(dataCollect, impl);
- return script;
- }
- catch (const Exception & excpt_r)
- {
- ERR << excpt_r << endl;
- throw "Cannot create script object";
- }
- return NULL;
-}
-
-
-Atom::Ptr
-HelixSourceImpl::createAtom (const HelixParser & parsed)
-{
- try
- {
- detail::ResImplTraits<HelixAtomImpl>::Ptr impl(new HelixAtomImpl(_source, parsed));
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name,
- Edition( parsed.version, parsed.release, parsed.epoch ),
- Arch( parsed.arch ),
- createDependencies (parsed));
- Atom::Ptr atom = detail::makeResolvableFromImpl(dataCollect, impl);
- return atom;
- }
- catch (const Exception & excpt_r)
- {
- ERR << excpt_r << endl;
- throw "Cannot create atom object";
- }
- return NULL;
-}
-
-
-Patch::Ptr
-HelixSourceImpl::createPatch (const HelixParser & parsed)
-{
- try
- {
- detail::ResImplTraits<HelixPatchImpl>::Ptr impl(new HelixPatchImpl(_source, parsed));
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name,
- Edition( parsed.version, parsed.release, parsed.epoch ),
- Arch( parsed.arch ),
- createDependencies (parsed));
- Patch::Ptr patch = detail::makeResolvableFromImpl(dataCollect, impl);
- return patch;
- }
- catch (const Exception & excpt_r)
- {
- ERR << excpt_r << endl;
- throw "Cannot create patch object";
- }
- return NULL;
-}
-
-
-Selection::Ptr
-HelixSourceImpl::createSelection (const HelixParser & parsed)
-{
- try
- {
- detail::ResImplTraits<HelixSelectionImpl>::Ptr impl(new HelixSelectionImpl(_source, parsed));
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name,
- Edition( parsed.version, parsed.release, parsed.epoch ),
- Arch( parsed.arch ),
- createDependencies (parsed));
- Selection::Ptr pattern = detail::makeResolvableFromImpl(dataCollect, impl);
- return pattern;
- }
- catch (const Exception & excpt_r)
- {
- ERR << excpt_r << endl;
- throw "Cannot create selection object";
- }
- return NULL;
-}
-
-
-Pattern::Ptr
-HelixSourceImpl::createPattern (const HelixParser & parsed)
-{
- try
- {
- detail::ResImplTraits<HelixPatternImpl>::Ptr impl(new HelixPatternImpl(_source, parsed));
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name,
- Edition( parsed.version, parsed.release, parsed.epoch ),
- Arch( parsed.arch ),
- createDependencies (parsed));
- Pattern::Ptr pattern = detail::makeResolvableFromImpl(dataCollect, impl);
- return pattern;
- }
- catch (const Exception & excpt_r)
- {
- ERR << excpt_r << endl;
- throw "Cannot create pattern object";
- }
- return NULL;
-}
-
-
-Product::Ptr
-HelixSourceImpl::createProduct (const HelixParser & parsed)
-{
- try
- {
- detail::ResImplTraits<HelixProductImpl>::Ptr impl(new HelixProductImpl(_source, parsed));
-
- // Collect basic Resolvable data
- NVRAD dataCollect( parsed.name,
- Edition( parsed.version, parsed.release, parsed.epoch ),
- Arch( parsed.arch ),
- createDependencies (parsed));
- Product::Ptr product = detail::makeResolvableFromImpl(dataCollect, impl);
- return product;
- }
- catch (const Exception & excpt_r)
- {
- ERR << excpt_r << endl;
- throw "Cannot create product object";
- }
- return NULL;
-}
-
-//-----------------------------------------------------------------------------
-
-void
-HelixSourceImpl::parserCallback (const HelixParser & parsed)
-{
- try {
- if (parsed.kind == ResTraits<Package>::kind) {
- Package::Ptr p = createPackage (parsed);
- _store.insert (p);
- }
- else if (parsed.kind == ResTraits<Message>::kind) {
- Message::Ptr m = createMessage (parsed);
- _store.insert (m);
- }
- else if (parsed.kind == ResTraits<Language>::kind) {
- Language::Ptr l = createLanguage( parsed );
- _store.insert (l);
- }
- else if (parsed.kind == ResTraits<Script>::kind) {
- Script::Ptr s = createScript (parsed);
- _store.insert (s);
- }
- else if (parsed.kind == ResTraits<Patch>::kind) {
- Patch::Ptr p = createPatch (parsed);
- _store.insert (p);
- }
- else if (parsed.kind == ResTraits<Selection>::kind) {
- Selection::Ptr s = createSelection(parsed);
- _store.insert (s);
- }
- else if (parsed.kind == ResTraits<Pattern>::kind) {
- Pattern::Ptr p = createPattern (parsed);
- _store.insert (p);
- }
- else if (parsed.kind == ResTraits<Product>::kind) {
- Product::Ptr p = createProduct (parsed);
- _store.insert (p);
- }
- else if (parsed.kind == ResTraits<Atom>::kind) {
- Atom::Ptr a = createAtom (parsed);
- _store.insert (a);
- }
- else {
- ERR << "Unsupported kind " << parsed.kind << endl;
- }
- }
- catch (const Exception & excpt_r)
- {
- ZYPP_CAUGHT (excpt_r);
- }
-}
-
-//-----------------------------------------------------------------------------
-
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* HelixSourceImpl.h
- *
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef ZYPP_SOLVER_HELIXSOURCEIMPL_H
-#define ZYPP_SOLVER_HELIXSOURCEIMPL_H
-
-#include <iosfwd>
-#include <string>
-
-#include "zypp/source/SourceImpl.h"
-
-#include "HelixParser.h"
-
-#include "zypp/Package.h"
-#include "zypp/Language.h"
-#include "zypp/Message.h"
-#include "zypp/Script.h"
-#include "zypp/Atom.h"
-#include "zypp/Patch.h"
-#include "zypp/Product.h"
-#include "zypp/Selection.h"
-#include "zypp/Pattern.h"
-
-namespace zypp {
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : HelixSourceImpl
-
-class HelixSourceImpl : public zypp::source::SourceImpl {
-
- public:
-
- /** Default ctor */
- HelixSourceImpl();
-
- private:
- /** Ctor substitute.
- * Actually get the metadata.
- * \throw EXCEPTION on fail
- */
- virtual void factoryInit();
-
-
- public:
- void factoryCtor( const media::MediaId & media_r,
- const Pathname & path_r = "/",
- const std::string & alias_r = "",
- const Pathname cache_dir_r = "");
-
- virtual const bool valid() const
- { return true; }
-
- Package::Ptr createPackage (const HelixParser & data);
- Message::Ptr createMessage (const HelixParser & data);
- Language::Ptr createLanguage (const HelixParser & data);
- Script::Ptr createScript (const HelixParser & data);
- Atom::Ptr createAtom (const HelixParser & data);
- Patch::Ptr createPatch (const HelixParser & data);
- Pattern::Ptr createPattern (const HelixParser & data);
- Selection::Ptr createSelection (const HelixParser & data);
- Product::Ptr createProduct (const HelixParser & data);
-
- Dependencies createDependencies (const HelixParser & data);
-
- void parserCallback (const HelixParser & data);
-
- private:
- Source_Ref _source;
- Pathname _pathname;
- void createResolvables(Source_Ref source_r);
-
-};
-
-
-} // namespace zypp
-
-#endif // ZYPP_SOLVER_HELIXSOURCEIMPL_H
+++ /dev/null
-#
-# Makefile.am for testsuite/solver/src/helix
-#
-
-INCLUDES = \
- -I$(top_srcdir) -Wall \
- -I/usr/include/libxml2 \
- -DG_LOG_DOMAIN=\"helix\" \
- -DZYPP_BASE_LOGGER_LOGGROUP=\"helix\"
-
-LDADD = $(noinst_LTLIBRARIES) $(top_srcdir)/zypp/lib@PACKAGE@.la
-
-noinst_HEADERS = \
- Buffer.h \
- XmlNode.h \
- HelixExtract.h \
- HelixParser.h \
- HelixSourceImpl.h \
- HelixPackageImpl.h \
- HelixLanguageImpl.h \
- HelixScriptImpl.h \
- HelixMessageImpl.h \
- HelixAtomImpl.h \
- HelixPatchImpl.h \
- HelixSelectionImpl.h \
- HelixPatternImpl.h \
- HelixProductImpl.h
-
-noinst_LTLIBRARIES = lib@PACKAGE@_helix.la
-
-lib@PACKAGE@_helix_la_SOURCES = \
- Buffer.cc \
- XmlNode.cc \
- HelixExtract.cc \
- HelixParser.cc \
- HelixSourceImpl.cc \
- HelixLanguageImpl.cc \
- HelixPackageImpl.cc \
- HelixScriptImpl.cc \
- HelixMessageImpl.cc \
- HelixAtomImpl.cc \
- HelixPatchImpl.cc \
- HelixSelectionImpl.cc \
- HelixPatternImpl.cc \
- HelixProductImpl.cc
-
+++ /dev/null
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* XmlNode.cc wrapper for xmlNodePtr from libxml2
- *
- * Copyright (C) 2000-2002 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * Definition of 'edition'
- * contains epoch-version-release-arch
- * and comparision functions
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#include "XmlNode.h"
-#include "zypp/base/Logger.h"
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
-using namespace std;
-
-IMPL_PTR_TYPE(XmlNode);
-
-//---------------------------------------------------------------------------
-
-XmlNode::XmlNode (const xmlNodePtr node)
- : _node(node)
-{
-}
-
-XmlNode::XmlNode (const string & name)
- : _node(xmlNewNode (NULL, (const xmlChar *)name.c_str()))
-{
-}
-
-XmlNode::~XmlNode ()
-{
-}
-
-//---------------------------------------------------------------------------
-
-string
-XmlNode::asString ( void ) const
-{
- return toString (*this);
-}
-
-
-string
-XmlNode::toString ( const XmlNode & node )
-{
- return "<xmlnode/>";
-}
-
-
-ostream &
-XmlNode::dumpOn( ostream & str ) const
-{
- str << asString();
- return str;
-}
-
-
-ostream&
-operator<<( ostream& os, const XmlNode& node)
-{
- return os << node.asString();
-}
-
-//---------------------------------------------------------------------------
-
-string
-XmlNode::getValue (const string & name, const string & deflt) const
-{
- string ret;
- xmlChar *xml_s;
- xmlNode *child;
-
- xml_s = xmlGetProp(_node, (const xmlChar *)name.c_str());
-// // XXX << "XmlNode::getValue(" << name << ") xmlGetProp '" << (char *)xml_s << "'" << endl;
-
- if (xml_s) {
- ret = string ((const char *)xml_s);
- xmlFree (xml_s);
- return ret;
- }
-
- child = _node->xmlChildrenNode;
-
- while (child) {
-// // XXX << "XmlNode::getValue(" << name << ") child '" << (child->name) << "'" << endl;
- if (strcasecmp((const char *)(child->name), name.c_str()) == 0) {
- xml_s = xmlNodeGetContent(child);
-// // XXX << "XmlNode::getValue(" << name << ") xmlNodeGetContent '" << (char *)xml_s << "'" << endl;
- if (xml_s) {
- ret = string ((const char *)xml_s);
- xmlFree (xml_s);
- return ret;
- }
- }
- child = child->next;
- }
-
- // XXX << "XmlNode::getValue(" << name << ") deflt" << endl;
- return deflt;
-}
-
-
-bool
-XmlNode::hasProp (const std::string & name) const
-{
- xmlChar *ret;
-
- ret = xmlGetProp (_node, (const xmlChar *)name.c_str());
- if (ret) {
- return true;
- }
- return false;
-}
-
-
-string
-XmlNode::getProp (const std::string & name, const std::string & deflt) const
-{
- xmlChar *ret;
- string gs;
-
- ret = xmlGetProp (_node, (const xmlChar *)name.c_str());
-
- if (ret) {
- // XXX << "XmlNode::getProp(" << name << ") xmlGetProp '" << (char *)ret << "'" << endl;
-
- gs = string ((const char *)ret);
- xmlFree (ret);
- return gs;
- }
- return deflt;
-}
-
-
-bool
-XmlNode::getIntValue (const std::string & name, int *value) const
-{
- string strval;
- char *ret;
- long z;
-
- strval = this->getValue (name);
- if (strval.empty()) {
- return false;
- }
-
- z = strtol (strval.c_str(), &ret, 10);
- if (*ret != '\0') {
- return false;
- }
-
- *value = z;
- return true;
-}
-
-
-int
-XmlNode::getIntValueDefault (const std::string & name, int def) const
-{
- int z;
- if (this->getIntValue (name, &z))
- return z;
- else
- return def;
-}
-
-
-unsigned int
-XmlNode::getUnsignedIntValueDefault (const std::string & name, unsigned int def) const
-{
- unsigned int z;
- if (this->getUnsignedIntValue (name, &z))
- return z;
- else
- return def;
-}
-
-
-bool
-XmlNode::getUnsignedIntValue (const std::string & name, unsigned int *value) const
-{
- string strval;
- char *ret;
- int z;
-
- strval = this->getValue (name);
- if (strval.empty()) {
- return false;
- }
-
- z = strtoul (strval.c_str(), &ret, 10);
- if (*ret != '\0') {
- return false;
- }
-
- *value = z;
- return true;
-}
-
-
-unsigned int
-XmlNode::getUnsignedIntPropDefault (const std::string & name, unsigned int def) const
-{
- xmlChar *buf;
- unsigned int ret;
-
- buf = xmlGetProp (_node, (const xmlChar *)name.c_str());
-
- if (buf) {
- ret = strtol ((const char *)buf, NULL, 10);
- xmlFree (buf);
- return (ret);
- }
- return (def);
-}
-
-
-string
-XmlNode::getContent (void) const
-{
- xmlChar *buf;
- string ret;
-
- buf = xmlNodeGetContent (_node);
-
- ret = string ((const char *)buf);
-
- xmlFree (buf);
-
- return (ret);
-}
-
-
-unsigned int
-XmlNode::getUnsignedIntContentDefault (unsigned int def) const
-{
- xmlChar *buf;
- unsigned int ret;
-
- buf = xmlNodeGetContent (_node);
-
- if (buf) {
- ret = strtol ((const char *)buf, NULL, 10);
- xmlFree (buf);
- return (ret);
- }
- return (def);
-}
-
-
-const XmlNode_Ptr
-XmlNode::getNode (const std::string & name) const
-{
- xmlNodePtr iter;
-
- for (iter = _node->xmlChildrenNode; iter; iter = iter->next) {
- if (strcasecmp ((const char *)(iter->name), name.c_str()) == 0) {
- return new XmlNode (iter);
- }
- }
-
- return NULL;
-}
-
-
-//---------------------------------------------------------------------------
-
-
-void
-XmlNode::addTextChild (const std::string & name, const std::string & content)
-{
- xmlNewTextChild (_node, NULL, (const xmlChar *)name.c_str(), (const xmlChar *)content.c_str());
-}
-
-///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* XmlNode.h wrapper for xmlNode* from libxml2
- *
- * Copyright (C) 2000-2003 Ximian, Inc.
- * Copyright (C) 2005 SUSE Linux Products GmbH
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License,
- * version 2, as published by the Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef ZYPP_SOLVER_TEMPORARY_XMLNODE_H
-#define ZYPP_SOLVER_TEMPORARY_XMLNODE_H
-
-#include <list>
-#include <iostream>
-#include <iosfwd>
-#include <string>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
-#include "zypp/base/PtrTypes.h"
-
-/////////////////////////////////////////////////////////////////////////
-namespace zypp
-{ ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- namespace solver
- { /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- namespace detail
- { ///////////////////////////////////////////////////////////////////
-
-DEFINE_PTR_TYPE(XmlNode);
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : XmlNode
-
-class XmlNode : public base::ReferenceCounted, private base::NonCopyable
-{
-
- private:
- const xmlNodePtr _node;
-
- public:
- XmlNode (const xmlNodePtr node);
- XmlNode (const std::string & name);
- virtual ~XmlNode ();
-
- // ---------------------------------- I/O
-
- static std::string toString ( const XmlNode & node );
-
- virtual std::ostream & dumpOn( std::ostream & str ) const;
-
- friend std::ostream& operator<<( std::ostream&, const XmlNode & );
-
- std::string asString ( void ) const;
-
- // ---------------------------------- accessors
-
- const std::string name() const { return (std::string((const char *)_node->name)); }
- xmlNodePtr node() const { return (_node); }
- XmlNode_Ptr next() const { return (_node->next == NULL ? NULL : new XmlNode (_node->next)); }
- XmlNode_Ptr children() const { return (_node->xmlChildrenNode == NULL ? NULL : new XmlNode (_node->xmlChildrenNode)); }
- xmlElementType type() const { return (_node->type); }
-
- // ---------------------------------- methods
-
- bool hasProp (const std::string & name) const;
- std::string getProp (const std::string & name, const std::string & deflt = "") const;
- std::string getValue (const std::string & name, const std::string & deflt = "") const;
- std::string getContent (void) const;
-
- bool equals (const std::string & n) const { return (strcasecmp (name().c_str(), n.c_str()) == 0); }
- bool isElement (void) const { return (type() == XML_ELEMENT_NODE); }
-
- const XmlNode_Ptr getNode (const std::string & name) const;
-
- // The former will get either a property or a tag, whereas the latter will
- // get only a property
-
- bool getIntValue (const std::string & name, int *value) const;
- int getIntValueDefault (const std::string & name, int def) const;
-
- bool getUnsignedIntValue (const std::string & name, unsigned int *value) const;
- unsigned int getUnsignedIntValueDefault (const std::string & name, unsigned int def) const;
-
- unsigned int getUnsignedIntPropDefault (const std::string & name, unsigned int def) const;
-
- unsigned int getUnsignedIntContentDefault (unsigned int def) const;
-
- void addTextChild (const std::string & name, const std::string & content);
-};
-
- ///////////////////////////////////////////////////////////////////
- };// namespace detail
- /////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////
- };// namespace solver
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
-};// namespace zypp
-/////////////////////////////////////////////////////////////////////////
-
-
-
-#endif // ZYPP_SOLVER_TEMPORARY_XMLNODE_H