]>
Commit | Line | Data |
---|---|---|
6c139d6e AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
be4401bf | 3 | // $Id: strutl.h,v 1.9 1998/11/01 05:27:38 jgg Exp $ |
6c139d6e AL |
4 | /* ###################################################################### |
5 | ||
6 | String Util - These are some usefull string functions | |
7 | ||
8 | _strstrip is a function to remove whitespace from the front and end | |
9 | of a string. | |
10 | ||
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> | |
13 | ||
14 | ##################################################################### */ | |
15 | /*}}}*/ | |
6c139d6e AL |
16 | #ifndef STRUTL_H |
17 | #define STRUTL_H | |
18 | ||
19 | #include <stdlib.h> | |
20 | #include <string> | |
0a8a80e5 | 21 | #include <vector> |
6c139d6e AL |
22 | |
23 | char *_strstrip(char *String); | |
24 | char *_strtabexpand(char *String,size_t Len); | |
25 | bool ParseQuoteWord(const char *&String,string &Res); | |
08e8f724 | 26 | bool ParseCWord(const char *String,string &Res); |
6c139d6e AL |
27 | string QuoteString(string Str,const char *Bad); |
28 | string SizeToStr(double Bytes); | |
29 | string TimeToStr(unsigned long Sec); | |
30 | string SubstVar(string Str,string Subst,string Contents); | |
31 | string Base64Encode(string Str); | |
ad00ae81 | 32 | string URItoFileName(string URI); |
0a8a80e5 | 33 | string TimeRFC1123(time_t Date); |
24231681 | 34 | bool StrToTime(string Val,time_t &Result); |
0a8a80e5 AL |
35 | string LookupTag(string Message,const char *Tag,const char *Default = 0); |
36 | int StringToBool(string Text,int Default = -1); | |
37 | bool ReadMessages(int Fd, vector<string> &List); | |
6c139d6e AL |
38 | |
39 | int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd); | |
9c14e3d6 | 40 | inline int stringcmp(const char *A,const char *AEnd,const char *B) {return stringcmp(A,AEnd,B,B+strlen(B));}; |
be4401bf | 41 | inline int stringcmp(string A,const char *B) {return stringcmp(A.begin(),A.end(),B,B+strlen(B));}; |
6c139d6e | 42 | int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd); |
9c14e3d6 | 43 | inline int stringcasecmp(const char *A,const char *AEnd,const char *B) {return stringcasecmp(A,AEnd,B,B+strlen(B));}; |
be4401bf | 44 | inline int stringcasecmp(string A,const char *B) {return stringcasecmp(A.begin(),A.end(),B,B+strlen(B));}; |
6c139d6e | 45 | |
93bf083d AL |
46 | class URI |
47 | { | |
be4401bf AL |
48 | void CopyFrom(string From); |
49 | ||
93bf083d AL |
50 | public: |
51 | ||
52 | string Access; | |
53 | string User; | |
54 | string Password; | |
55 | string Host; | |
56 | string Path; | |
57 | unsigned int Port; | |
58 | ||
be4401bf AL |
59 | inline operator string(); |
60 | inline operator =(string From) {CopyFrom(From);}; | |
61 | inline bool empty() {return Access.empty();}; | |
93bf083d | 62 | |
be4401bf AL |
63 | URI(string Path) {CopyFrom(Path);}; |
64 | URI() : Port(0) {}; | |
93bf083d AL |
65 | }; |
66 | ||
6c139d6e | 67 | #endif |