summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r--apt-pkg/contrib/cdromutl.cc3
-rw-r--r--apt-pkg/contrib/cdromutl.h7
-rw-r--r--apt-pkg/contrib/cmndline.cc3
-rw-r--r--apt-pkg/contrib/cmndline.h4
-rw-r--r--apt-pkg/contrib/configuration.cc8
-rw-r--r--apt-pkg/contrib/configuration.h4
-rw-r--r--apt-pkg/contrib/crc-16.cc4
-rw-r--r--apt-pkg/contrib/crc-16.h4
-rw-r--r--apt-pkg/contrib/error.cc4
-rw-r--r--apt-pkg/contrib/error.h4
-rw-r--r--apt-pkg/contrib/fileutl.cc4
-rw-r--r--apt-pkg/contrib/fileutl.h3
-rw-r--r--apt-pkg/contrib/hashes.cc4
-rw-r--r--apt-pkg/contrib/hashes.h3
-rw-r--r--apt-pkg/contrib/md5.cc4
-rw-r--r--apt-pkg/contrib/md5.h3
-rw-r--r--apt-pkg/contrib/mmap.cc4
-rw-r--r--apt-pkg/contrib/mmap.h3
-rw-r--r--apt-pkg/contrib/progress.cc3
-rw-r--r--apt-pkg/contrib/progress.h3
-rw-r--r--apt-pkg/contrib/sha1.cc4
-rw-r--r--apt-pkg/contrib/sha1.h4
-rw-r--r--apt-pkg/contrib/sha256.h4
-rw-r--r--apt-pkg/contrib/strutl.cc48
-rw-r--r--apt-pkg/contrib/strutl.h8
25 files changed, 57 insertions, 90 deletions
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index ab170ec5a..6f00e1451 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -10,9 +10,6 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/cdromutl.h"
-#endif
#include <apt-pkg/cdromutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/md5.h>
diff --git a/apt-pkg/contrib/cdromutl.h b/apt-pkg/contrib/cdromutl.h
index 3180a03c7..f24bb8c70 100644
--- a/apt-pkg/contrib/cdromutl.h
+++ b/apt-pkg/contrib/cdromutl.h
@@ -8,18 +8,15 @@
##################################################################### */
/*}}}*/
#ifndef PKGLIB_CDROMUTL_H
-#define PKGLIB_ACQUIRE_METHOD_H
+#define PKGLIB_CDROMUTL_H
#include <string>
using std::string;
-#ifdef __GNUG__
-#pragma interface "apt-pkg/cdromutl.h"
-#endif
-
bool MountCdrom(string Path);
bool UnmountCdrom(string Path);
bool IdentCdrom(string CD,string &Res,unsigned int Version = 2);
+bool IsMounted(string &Path);
#endif
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index 2b3d7dc96..54c91d67d 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -11,9 +11,6 @@
##################################################################### */
/*}}}*/
// Include files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/cmndline.h"
-#endif
#include <apt-pkg/cmndline.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
diff --git a/apt-pkg/contrib/cmndline.h b/apt-pkg/contrib/cmndline.h
index 8f461296f..fad6d1da9 100644
--- a/apt-pkg/contrib/cmndline.h
+++ b/apt-pkg/contrib/cmndline.h
@@ -44,9 +44,7 @@
#ifndef PKGLIB_CMNDLINE_H
#define PKGLIB_CMNDLINE_H
-#ifdef __GNUG__
-#pragma interface "apt-pkg/cmndline.h"
-#endif
+
#include <apt-pkg/configuration.h>
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 14a000fa5..3109fd7a5 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -15,9 +15,6 @@
##################################################################### */
/*}}}*/
// Include files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/configuration.h"
-#endif
#include <apt-pkg/configuration.h>
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
@@ -425,6 +422,7 @@ bool Configuration::ExistsAny(const char *Name) const
string key = Name;
if (key.size() > 2 && key.end()[-2] == '/')
+ {
if (key.find_first_of("fdbi",key.size()-1) < key.size())
{
key.resize(key.size() - 2);
@@ -435,7 +433,7 @@ bool Configuration::ExistsAny(const char *Name) const
{
_error->Warning(_("Unrecognized type abbreviation: '%c'"), key.end()[-3]);
}
-
+ }
return Exists(Name);
}
/*}}}*/
@@ -509,7 +507,7 @@ bool ReadConfigFile(Configuration &Conf,const string &FName,bool AsSectional,
CurLine++;
// This should be made to work instead, but this is better than looping
if (F.fail() && !F.eof())
- return _error->Error(_("Line %d too long (max %d)"), CurLine, sizeof(Buffer));
+ return _error->Error(_("Line %d too long (max %u)"), CurLine, sizeof(Buffer));
_strtabexpand(Buffer,sizeof(Buffer));
_strstrip(Buffer);
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index 0d4078dab..2534692a3 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -28,9 +28,7 @@
#ifndef PKGLIB_CONFIGURATION_H
#define PKGLIB_CONFIGURATION_H
-#ifdef __GNUG__
-#pragma interface "apt-pkg/configuration.h"
-#endif
+
#include <string>
#include <iostream>
diff --git a/apt-pkg/contrib/crc-16.cc b/apt-pkg/contrib/crc-16.cc
index 52a551802..b300ed67e 100644
--- a/apt-pkg/contrib/crc-16.cc
+++ b/apt-pkg/contrib/crc-16.cc
@@ -15,10 +15,6 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/crc-16.h"
-#endif
-
#include <apt-pkg/crc-16.h>
/*}}}*/
diff --git a/apt-pkg/contrib/crc-16.h b/apt-pkg/contrib/crc-16.h
index 757104c54..f30678bac 100644
--- a/apt-pkg/contrib/crc-16.h
+++ b/apt-pkg/contrib/crc-16.h
@@ -10,10 +10,6 @@
#ifndef APTPKG_CRC16_H
#define APTPKG_CRC16_H
-#ifdef __GNUG__
-#pragma interface "apt-pkg/crc-16.h"
-#endif
-
#define INIT_FCS 0xffff
unsigned short AddCRC16(unsigned short fcs, void const *buf,
unsigned long len);
diff --git a/apt-pkg/contrib/error.cc b/apt-pkg/contrib/error.cc
index 5fe9bdfce..8c2d6cb19 100644
--- a/apt-pkg/contrib/error.cc
+++ b/apt-pkg/contrib/error.cc
@@ -14,10 +14,6 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/error.h"
-#endif
-
#include <apt-pkg/error.h>
#include <iostream>
diff --git a/apt-pkg/contrib/error.h b/apt-pkg/contrib/error.h
index a5fc1a223..a3be6a575 100644
--- a/apt-pkg/contrib/error.h
+++ b/apt-pkg/contrib/error.h
@@ -40,9 +40,7 @@
#ifndef PKGLIB_ERROR_H
#define PKGLIB_ERROR_H
-#ifdef __GNUG__
-#pragma interface "apt-pkg/error.h"
-#endif
+
#ifdef __GNUG__
// Methods have a hidden this parameter that is visible to this attribute
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 9fd71728e..d19a92e62 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -14,9 +14,6 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/fileutl.h"
-#endif
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
#include <apt-pkg/sptr.h>
@@ -24,6 +21,7 @@
#include <apti18n.h>
+#include <cstdlib>
#include <iostream>
#include <unistd.h>
#include <fcntl.h>
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 041aa3309..48bd95537 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -21,9 +21,6 @@
#ifndef PKGLIB_FILEUTL_H
#define PKGLIB_FILEUTL_H
-#ifdef __GNUG__
-#pragma interface "apt-pkg/fileutl.h"
-#endif
#include <string>
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 9b22a90d3..b725e9418 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -11,10 +11,6 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/hashes.h"
-#endif
-
#include <apt-pkg/hashes.h>
#include <unistd.h>
diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h
index eefa7bf41..b09ea9f6b 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -13,9 +13,6 @@
#ifndef APTPKG_HASHES_H
#define APTPKG_HASHES_H
-#ifdef __GNUG__
-#pragma interface "apt-pkg/hashes.h"
-#endif
#include <apt-pkg/md5.h>
#include <apt-pkg/sha1.h>
diff --git a/apt-pkg/contrib/md5.cc b/apt-pkg/contrib/md5.cc
index fded5c864..44242371a 100644
--- a/apt-pkg/contrib/md5.cc
+++ b/apt-pkg/contrib/md5.cc
@@ -35,10 +35,6 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/md5.h"
-#endif
-
#include <apt-pkg/md5.h>
#include <apt-pkg/strutl.h>
diff --git a/apt-pkg/contrib/md5.h b/apt-pkg/contrib/md5.h
index e280d714e..247b3fab9 100644
--- a/apt-pkg/contrib/md5.h
+++ b/apt-pkg/contrib/md5.h
@@ -23,9 +23,6 @@
#ifndef APTPKG_MD5_H
#define APTPKG_MD5_H
-#ifdef __GNUG__
-#pragma interface "apt-pkg/md5.h"
-#endif
#include <string>
#include <algorithm>
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index e395e6cc7..88e71e8e3 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -21,10 +21,6 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/mmap.h"
-#endif
-
#define _BSD_SOURCE
#include <apt-pkg/mmap.h>
#include <apt-pkg/error.h>
diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h
index e329b167a..19cf7582d 100644
--- a/apt-pkg/contrib/mmap.h
+++ b/apt-pkg/contrib/mmap.h
@@ -25,9 +25,6 @@
#ifndef PKGLIB_MMAP_H
#define PKGLIB_MMAP_H
-#ifdef __GNUG__
-#pragma interface "apt-pkg/mmap.h"
-#endif
#include <string>
#include <apt-pkg/fileutl.h>
diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc
index e3db9a45a..6ce6e950a 100644
--- a/apt-pkg/contrib/progress.cc
+++ b/apt-pkg/contrib/progress.cc
@@ -8,9 +8,6 @@
##################################################################### */
/*}}}*/
// Include Files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/progress.h"
-#endif
#include <apt-pkg/progress.h>
#include <apt-pkg/error.h>
#include <apt-pkg/configuration.h>
diff --git a/apt-pkg/contrib/progress.h b/apt-pkg/contrib/progress.h
index 20caf4cdf..7dd004f7e 100644
--- a/apt-pkg/contrib/progress.h
+++ b/apt-pkg/contrib/progress.h
@@ -21,9 +21,6 @@
#ifndef PKGLIB_PROGRESS_H
#define PKGLIB_PROGRESS_H
-#ifdef __GNUG__
-#pragma interface "apt-pkg/progress.h"
-#endif
#include <string>
#include <sys/time.h>
diff --git a/apt-pkg/contrib/sha1.cc b/apt-pkg/contrib/sha1.cc
index 72eafd4ca..b70f31dc6 100644
--- a/apt-pkg/contrib/sha1.cc
+++ b/apt-pkg/contrib/sha1.cc
@@ -29,10 +29,6 @@
*/
/*}}} */
// Include Files /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/sha1.h"
-#endif
-
#include <apt-pkg/sha1.h>
#include <apt-pkg/strutl.h>
diff --git a/apt-pkg/contrib/sha1.h b/apt-pkg/contrib/sha1.h
index db8ca7893..010ef802e 100644
--- a/apt-pkg/contrib/sha1.h
+++ b/apt-pkg/contrib/sha1.h
@@ -14,10 +14,6 @@
#ifndef APTPKG_SHA1_H
#define APTPKG_SHA1_H
-#ifdef __GNUG__
-#pragma interface "apt-pkg/sha1.h"
-#endif
-
#include <string>
#include <algorithm>
diff --git a/apt-pkg/contrib/sha256.h b/apt-pkg/contrib/sha256.h
index 70b3ae2ad..c490bfa4d 100644
--- a/apt-pkg/contrib/sha256.h
+++ b/apt-pkg/contrib/sha256.h
@@ -14,10 +14,6 @@
#ifndef APTPKG_SHA256_H
#define APTPKG_SHA256_H
-#ifdef __GNUG__
-#pragma interface "apt-pkg/sha256.h"
-#endif
-
#include <string>
#include <algorithm>
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index d96155917..006452af4 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -15,10 +15,6 @@
##################################################################### */
/*}}}*/
// Includes /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/strutl.h"
-#endif
-
#include <apt-pkg/strutl.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/error.h>
@@ -28,16 +24,60 @@
#include <ctype.h>
#include <string.h>
#include <stdio.h>
+#include <algorithm>
#include <unistd.h>
#include <regex.h>
#include <errno.h>
#include <stdarg.h>
+#include <iconv.h>
#include "config.h"
using namespace std;
/*}}}*/
+// UTF8ToCodeset - Convert some UTF-8 string for some codeset /*{{{*/
+// ---------------------------------------------------------------------
+/* This is handy to use before display some information for enduser */
+bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest)
+{
+ iconv_t cd;
+ const char *inbuf;
+ char *inptr, *outbuf, *outptr;
+ size_t insize, outsize;
+
+ cd = iconv_open(codeset, "UTF-8");
+ if (cd == (iconv_t)(-1)) {
+ // Something went wrong
+ if (errno == EINVAL)
+ _error->Error("conversion from 'UTF-8' to '%s' not available",
+ codeset);
+ else
+ perror("iconv_open");
+
+ // Clean the destination string
+ *dest = "";
+
+ return false;
+ }
+
+ insize = outsize = orig.size();
+ inbuf = orig.data();
+ inptr = (char *)inbuf;
+ outbuf = new char[insize+1];
+ outptr = outbuf;
+
+ iconv(cd, &inptr, &insize, &outptr, &outsize);
+ *outptr = '\0';
+
+ *dest = outbuf;
+ delete[] outbuf;
+
+ iconv_close(cd);
+
+ return true;
+}
+ /*}}}*/
// strstrip - Remove white space from the front and back of a string /*{{{*/
// ---------------------------------------------------------------------
/* This is handy to use when parsing a file. It also removes \n's left
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h
index 6ec2b7811..53146ced7 100644
--- a/apt-pkg/contrib/strutl.h
+++ b/apt-pkg/contrib/strutl.h
@@ -16,12 +16,11 @@
#ifndef STRUTL_H
#define STRUTL_H
-#ifdef __GNUG__
-#pragma interface "apt-pkg/strutl.h"
-#endif
+
#include <stdlib.h>
#include <string>
+#include <cstring>
#include <vector>
#include <iostream>
#include <time.h>
@@ -38,7 +37,8 @@ using std::ostream;
#define APT_FORMAT2
#define APT_FORMAT3
#endif
-
+
+bool UTF8ToCodeset(const char *codeset, const string &orig, string *dest);
char *_strstrip(char *String);
char *_strtabexpand(char *String,size_t Len);
bool ParseQuoteWord(const char *&String,string &Res);