1 // -*- mode: cpp; mode: fold -*-
3 // $Id: strutl.h,v 1.2 1999/10/24 06:53:12 jgg Exp $
4 /* ######################################################################
6 String Util - These are some usefull string functions
8 _strstrip is a function to remove whitespace from the front and end
11 This source is placed in the Public Domain, do with it what you will
12 It was originally written by Jason Gunthorpe <jgg@gpu.srv.ualberta.ca>
14 ##################################################################### */
20 #pragma interface "dsync/strutl.h"
30 char *_strstrip(char *String);
31 char *_strtabexpand(char *String,size_t Len);
32 bool ParseQuoteWord(const char *&String,string &Res);
33 bool ParseCWord(const char *String,string &Res);
34 string QuoteString(string Str,const char *Bad);
35 string DeQuoteString(string Str);
36 string SizeToStr(double Bytes);
37 string TimeToStr(unsigned long Sec);
38 string SubstVar(string Str,string Subst,string Contents);
39 string Base64Encode(string Str);
40 string URItoFileName(string URI);
41 string TimeRFC1123(time_t Date);
42 bool StrToTime(string Val,time_t &Result);
43 string LookupTag(string Message,const char *Tag,const char *Default = 0);
44 int StringToBool(string Text,int Default = -1);
45 bool ReadMessages(int Fd, vector<string> &List);
46 bool StrToNum(const char *Str,unsigned long &Res,unsigned Len,unsigned Base = 0);
47 bool Hex2Num(const char *Start,const char *End,unsigned char *Num,
50 int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
51 inline int stringcmp(const char *A,const char *AEnd,const char *B) {return stringcmp(A,AEnd,B,B+strlen(B));};
52 inline int stringcmp(string A,const char *B) {return stringcmp(A.c_str(),A.c_str()+strlen(A.c_str()),B,B+strlen(B));};
53 int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
54 inline int stringcasecmp(const char *A,const char *AEnd,const char *B) {return stringcasecmp(A,AEnd,B,B+strlen(B));};
55 inline int stringcasecmp(string A,const char *B) {return stringcasecmp(A.c_str(),A.c_str()+strlen(A.c_str()),B,B+strlen(B));};
59 void CopyFrom(string From);
71 inline void operator =(string From) {CopyFrom(From);};
72 inline bool empty() {return Access.empty();};
74 URI(string Path) {CopyFrom(Path);};