From ddc1d8d08eaff6c71c6062654ddd9d8981799ae9 Mon Sep 17 00:00:00 2001 From: Arch Librarian Date: Mon, 20 Sep 2004 16:54:23 +0000 Subject: Minor cleanups, fix for checksum lowercase bug Author: jgg Date: 1999-07-26 17:46:07 GMT Minor cleanups, fix for checksum lowercase bug --- apt-pkg/contrib/strutl.cc | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'apt-pkg/contrib/strutl.cc') 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 /*{{{*/ // --------------------------------------------------------------------- -- cgit v1.2.3