diff options
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r-- | apt-pkg/contrib/cdromutl.h | 3 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 1 | ||||
-rw-r--r-- | apt-pkg/contrib/progress.cc | 3 | ||||
-rw-r--r-- | apt-pkg/contrib/sha256.cc | 6 | ||||
-rw-r--r-- | apt-pkg/contrib/sha256.h | 1 | ||||
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 44 | ||||
-rw-r--r-- | apt-pkg/contrib/strutl.h | 3 |
7 files changed, 57 insertions, 4 deletions
diff --git a/apt-pkg/contrib/cdromutl.h b/apt-pkg/contrib/cdromutl.h index 1264982a8..f24bb8c70 100644 --- a/apt-pkg/contrib/cdromutl.h +++ b/apt-pkg/contrib/cdromutl.h @@ -8,7 +8,7 @@ ##################################################################### */ /*}}}*/ #ifndef PKGLIB_CDROMUTL_H -#define PKGLIB_ACQUIRE_METHOD_H +#define PKGLIB_CDROMUTL_H #include <string> @@ -17,5 +17,6 @@ using std::string; 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/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 70ac52e30..d19a92e62 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -21,6 +21,7 @@ #include <apti18n.h> +#include <cstdlib> #include <iostream> #include <unistd.h> #include <fcntl.h> diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc index ffd1191e5..6ce6e950a 100644 --- a/apt-pkg/contrib/progress.cc +++ b/apt-pkg/contrib/progress.cc @@ -112,6 +112,8 @@ bool OpProgress::CheckChange(float Interval) if ((int)LastPercent == (int)Percent) return false; + + LastPercent = Percent; if (Interval == 0) return false; @@ -123,7 +125,6 @@ bool OpProgress::CheckChange(float Interval) if (Diff < Interval) return false; LastTime = Now; - LastPercent = Percent; return true; } /*}}}*/ diff --git a/apt-pkg/contrib/sha256.cc b/apt-pkg/contrib/sha256.cc index b75ce8a84..ecda3d8e8 100644 --- a/apt-pkg/contrib/sha256.cc +++ b/apt-pkg/contrib/sha256.cc @@ -18,6 +18,12 @@ * any later version. * */ + +#ifdef __GNUG__ +#pragma implementation "apt-pkg/sha256.h" +#endif + + #define SHA256_DIGEST_SIZE 32 #define SHA256_HMAC_BLOCK_SIZE 64 diff --git a/apt-pkg/contrib/sha256.h b/apt-pkg/contrib/sha256.h index 01b638d56..c490bfa4d 100644 --- a/apt-pkg/contrib/sha256.h +++ b/apt-pkg/contrib/sha256.h @@ -16,7 +16,6 @@ #include <string> #include <algorithm> -#include <stdint.h> using std::string; using std::min; diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index aa37a099a..006452af4 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -24,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 b8553ab58..ae1244ecd 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -36,7 +36,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); |