Author: mlschroe
Date: Tue Mar 11 12:38:33 2008
New Revision: 9088
URL: http://svn.opensuse.org/viewcvs/zypp?rev=9088&view=rev
Log:
- make deptestomatic also look for .gz files
- do not fork zcat for decompression
Modified:
trunk/sat-solver/testsuite/CMakeLists.txt
trunk/sat-solver/testsuite/deptestomatic.c
Modified: trunk/sat-solver/testsuite/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/testsuite/CMakeLists.txt?rev=9088&r1=9087&r2=9088&view=diff
==============================================================================
--- trunk/sat-solver/testsuite/CMakeLists.txt (original)
+++ trunk/sat-solver/testsuite/CMakeLists.txt Tue Mar 11 12:38:33 2008
@@ -10,4 +10,4 @@
SET(deptestomatic_SOURCES deptestomatic.c)
ADD_EXECUTABLE(deptestomatic ${deptestomatic_SOURCES})
-TARGET_LINK_LIBRARIES(deptestomatic satsolver ${EXPAT_LIBRARY})
+TARGET_LINK_LIBRARIES(deptestomatic satsolver ${EXPAT_LIBRARY} ${ZLIB_LIBRARY})
Modified: trunk/sat-solver/testsuite/deptestomatic.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/testsuite/deptestomatic.c?rev=9088&r1=9087&r2=9088&view=diff
==============================================================================
--- trunk/sat-solver/testsuite/deptestomatic.c (original)
+++ trunk/sat-solver/testsuite/deptestomatic.c Tue Mar 11 12:38:33 2008
@@ -14,6 +14,8 @@
*
*/
+#define _GNU_SOURCE
+
#include
#include
#include
@@ -26,6 +28,7 @@
#include
#include
#include
+#include
#include "solver.h"
#include "repo_solv.h"
@@ -582,6 +585,39 @@
/*----------------------------------------------------------------*/
+static ssize_t
+cookie_gzread(void *cookie, char *buf, size_t nbytes)
+{
+ return gzread((gzFile *)cookie, buf, nbytes);
+}
+
+static int
+cookie_gzclose(void *cookie)
+{
+ return gzclose((gzFile *)cookie);
+}
+
+FILE *
+myfopen(const char *fn)
+{
+ cookie_io_functions_t cio;
+ char *suf;
+ gzFile *gzf;
+
+ if (!fn)
+ return 0;
+ suf = strrchr(fn, '.');
+ if (!suf || strcmp(suf, ".gz") != 0)
+ return fopen(fn, "r");
+ gzf = gzopen(fn, "r");
+ if (!gzf)
+ return 0;
+ memset(&cio, 0, sizeof(cio));
+ cio.read = cookie_gzread;
+ cio.close = cookie_gzclose;
+ return fopencookie(gzf, "r", cio);
+}
+
/*
* read repo from file as name
*
@@ -603,7 +639,6 @@
return NULL;
}
- int gzip = 0;
const char *ptr = file + l - 1;
while (*ptr)
{
@@ -611,8 +646,6 @@
break;
if (*ptr == '.')
{
- if (!strncmp( ptr, ".gz", 3))
- gzip = 1;
if (!strncmp( ptr, ".xml", 4 ))
{
l = ptr - file;
@@ -630,25 +663,26 @@
FILE *fp = fopen( solvname, "r" );
if (!fp)
{
- char command[PATH_MAX];
- if (gzip)
- snprintf(command, PATH_MAX, "zcat %s", file);
+ if (!access(file, R_OK))
+ fp = myfopen(file);
else
- snprintf(command, PATH_MAX, "cat %s", file);
- /* try to use the original helix xml file instead*/
- FILE *fpHelix = popen( command, "r" );
- if (!fpHelix)
{
- perror( file );
+ char gzfile[PATH_MAX];
+ snprintf(gzfile, PATH_MAX, "%s.gz", file);
+ fp = myfopen(gzfile);
+ }
+ if (!fp)
+ {
+ perror(file);
return NULL;
}
- repo_add_helix(s, fpHelix);
- pclose( fpHelix );
+ repo_add_helix(s, fp);
+ fclose(fp);
}
else
{
repo_add_solv(s, fp);
- fclose( fp );
+ fclose(fp);
}
return s;
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org