summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/strutl.cc
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:54:23 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:54:23 +0000
commitddc1d8d08eaff6c71c6062654ddd9d8981799ae9 (patch)
tree745d470d679bf169cab6da3f3322f40121e1f81c /apt-pkg/contrib/strutl.cc
parent727f18afe9c2eec15ee446cb667d9561644b5bf6 (diff)
Minor cleanups, fix for checksum lowercase bug
Author: jgg Date: 1999-07-26 17:46:07 GMT Minor cleanups, fix for checksum lowercase bug
Diffstat (limited to 'apt-pkg/contrib/strutl.cc')
-rw-r--r--apt-pkg/contrib/strutl.cc29
1 files changed, 28 insertions, 1 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 6c3009462..fb5f6683c 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: strutl.cc,v 1.26 1999/06/27 04:55:54 jgg Exp $
+// $Id: strutl.cc,v 1.27 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
String Util - Some usefull string functions.
@@ -666,6 +666,33 @@ bool StrToTime(string Val,time_t &Result)
return true;
}
/*}}}*/
+// StrToNum - Convert a fixed length string to a number /*{{{*/
+// ---------------------------------------------------------------------
+/* This is used in decoding the crazy fixed length string headers in
+ tar and ar files. */
+bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base)
+{
+ char S[30];
+ if (Len >= sizeof(S))
+ return false;
+ memcpy(S,Str,Len);
+ S[Len] = 0;
+
+ // All spaces is a zero
+ Res = 0;
+ unsigned I;
+ for (I = 0; S[I] == ' '; I++);
+ if (S[I] == 0)
+ return true;
+
+ char *End;
+ Res = strtoul(S,&End,Base);
+ if (End == S)
+ return false;
+
+ return true;
+}
+ /*}}}*/
// URI::CopyFrom - Copy from an object /*{{{*/
// ---------------------------------------------------------------------