-rw-r--r-- | noncore/settings/aqpkg/server.cpp | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index 64a9c26..9a239a5 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp | |||
@@ -21,10 +21,2 @@ | |||
21 | 21 | ||
22 | #include <stdio.h> | ||
23 | #include <string.h> | ||
24 | #include <stdlib.h> | ||
25 | |||
26 | #include <iostream> | ||
27 | #include <fstream> | ||
28 | using namespace std; | ||
29 | |||
30 | #include "server.h" | 22 | #include "server.h" |
@@ -32,2 +24,5 @@ using namespace std; | |||
32 | 24 | ||
25 | #include <qfile.h> | ||
26 | #include <qtextstream.h> | ||
27 | |||
33 | #ifdef QWS | 28 | #ifdef QWS |
@@ -75,3 +70,3 @@ void Server :: readStatusFile( QList<Destination> &destList ) | |||
75 | if ( path.right( 1 ) != "/" ) | 70 | if ( path.right( 1 ) != "/" ) |
76 | path += "/"; | 71 | path.append( "/" ); |
77 | 72 | ||
@@ -83,3 +78,4 @@ void Server :: readStatusFile( QList<Destination> &destList ) | |||
83 | 78 | ||
84 | packageFile = path + "usr/lib/ipkg/status"; | 79 | packageFile = path; |
80 | packageFile.append( "usr/lib/ipkg/status" ); | ||
85 | readPackageFile( 0, false, installingToRoot, &( *dest ) ); | 81 | readPackageFile( 0, false, installingToRoot, &( *dest ) ); |
@@ -90,3 +86,3 @@ void Server :: readStatusFile( QList<Destination> &destList ) | |||
90 | { | 86 | { |
91 | cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; | 87 | //cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; |
92 | packageFile = "/usr/lib/ipkg/status"; | 88 | packageFile = "/usr/lib/ipkg/status"; |
@@ -148,11 +144,11 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR | |||
148 | { | 144 | { |
149 | ifstream in( packageFile ); | 145 | QFile f( packageFile ); |
150 | if ( !in.is_open() ) | 146 | if ( !f.open( IO_ReadOnly ) ) |
151 | return; | 147 | return; |
148 | QTextStream t( &f ); | ||
152 | 149 | ||
153 | char line[5001]; | 150 | QString line; |
154 | char k[21]; | ||
155 | char v[5001]; | ||
156 | QString key; | 151 | QString key; |
157 | QString value; | 152 | QString value; |
153 | int pos; | ||
158 | 154 | ||
@@ -163,17 +159,13 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR | |||
163 | bool newPackage = true; | 159 | bool newPackage = true; |
164 | do | 160 | while ( !t.eof() ) |
165 | { | 161 | { |
166 | in.getline( line, 5000 ); | 162 | line = t.readLine(); |
167 | if ( in.eof() ) | ||
168 | continue; | ||
169 | |||
170 | k[0] = '\0'; | ||
171 | v[0] = '\0'; | ||
172 | |||
173 | sscanf( line, "%[^:]: %[^\n]", k, v ); | ||
174 | 163 | ||
175 | key = k; | 164 | pos = line.find( ':', 0 ); |
176 | value = v; | 165 | if ( pos > -1 ) |
177 | key = key.stripWhiteSpace(); | 166 | key = line.mid( 0, pos ).stripWhiteSpace(); |
178 | value = value.stripWhiteSpace(); | 167 | else |
168 | key = QString::null; | ||
169 | value = line.mid( pos+1, line.length()-pos ).stripWhiteSpace(); | ||
170 | |||
179 | if ( key == "Package" && newPackage ) | 171 | if ( key == "Package" && newPackage ) |
@@ -230,3 +222,3 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR | |||
230 | } | 222 | } |
231 | else if ( key == "" ) | 223 | else if ( key == QString::null ) |
232 | { | 224 | { |
@@ -234,5 +226,5 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR | |||
234 | } | 226 | } |
235 | } while ( !in.eof() ); | 227 | } |
236 | 228 | ||
237 | in.close(); | 229 | f.close(); |
238 | 230 | ||