]> git.saurik.com Git - apt.git/blame - apt-pkg/contrib/strutl.h
New http method
[apt.git] / apt-pkg / contrib / strutl.h
CommitLineData
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
23char *_strstrip(char *String);
24char *_strtabexpand(char *String,size_t Len);
25bool ParseQuoteWord(const char *&String,string &Res);
08e8f724 26bool ParseCWord(const char *String,string &Res);
6c139d6e
AL
27string QuoteString(string Str,const char *Bad);
28string SizeToStr(double Bytes);
29string TimeToStr(unsigned long Sec);
30string SubstVar(string Str,string Subst,string Contents);
31string Base64Encode(string Str);
ad00ae81 32string URItoFileName(string URI);
0a8a80e5 33string TimeRFC1123(time_t Date);
24231681 34bool StrToTime(string Val,time_t &Result);
0a8a80e5
AL
35string LookupTag(string Message,const char *Tag,const char *Default = 0);
36int StringToBool(string Text,int Default = -1);
37bool ReadMessages(int Fd, vector<string> &List);
6c139d6e
AL
38
39int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
9c14e3d6 40inline int stringcmp(const char *A,const char *AEnd,const char *B) {return stringcmp(A,AEnd,B,B+strlen(B));};
be4401bf 41inline int stringcmp(string A,const char *B) {return stringcmp(A.begin(),A.end(),B,B+strlen(B));};
6c139d6e 42int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
9c14e3d6 43inline int stringcasecmp(const char *A,const char *AEnd,const char *B) {return stringcasecmp(A,AEnd,B,B+strlen(B));};
be4401bf 44inline int stringcasecmp(string A,const char *B) {return stringcasecmp(A.begin(),A.end(),B,B+strlen(B));};
6c139d6e 45
93bf083d
AL
46class 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