// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: strutl.cc,v 1.25 1999/06/24 04:34:25 jgg Exp $
+// $Id: strutl.cc,v 1.27 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
String Util - Some usefull string functions.
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 /*{{{*/
// ---------------------------------------------------------------------
// Find the colon...
I = FirstColon + 1;
+ if (I > SingleSlash)
+ I = SingleSlash;
for (; I < SingleSlash && *I != ':'; I++);
string::const_iterator SecondColon = I;
Password = string(U,SecondColon - U.begin() + 1,At - SecondColon - 1);
}
- // Now we parse off a pot number from the hostname
+ // Now we parse off a port number from the hostname
Port = 0;
string::size_type Pos = Host.rfind(':');
if (Pos == string::npos)