~ubuntu-branches/ubuntu/precise/boinc/precise

« back to all changes in this revision

Viewing changes to lib/str_util.h

Tags: 6.12.8+dfsg-1
* New upstream release.
* Simplified debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <string>
26
26
#include <vector>
27
27
 
28
 
#define KILO (1024.0)
29
 
#define MEGA (1048576.0)
30
 
#define GIGA (1024.*1048576.0)
31
 
 
32
 
#if !defined(HAVE_STRLCPY)
33
 
extern size_t strlcpy(char*, const char*, size_t);
34
 
#endif
35
 
 
36
 
#if !defined(HAVE_STRLCAT)
37
 
extern size_t strlcat(char *dst, const char *src, size_t size);
38
 
#endif
39
 
 
40
 
#if !defined(HAVE_STRCASESTR)
41
 
extern char *strcasestr(const char *s1, const char *s2);
42
 
#endif
43
 
 
44
28
extern int ndays_to_string(double x, int smallest_timescale, char *buf);
45
29
extern void nbytes_to_string(double nbytes, double total_bytes, char* str, int len);
46
30
extern int parse_command_line(char*, char**);
47
31
extern void c2x(char *what);
48
32
extern void strip_whitespace(char *str);
49
33
extern void strip_whitespace(std::string&);
50
 
extern void unescape_url(std::string& url);
51
 
extern void unescape_url(char *url);
52
 
extern void escape_url(std::string& url);
53
 
extern void escape_url(char *in, char*out);
54
 
extern void escape_url_readable(char* in, char* out);
55
 
extern void escape_project_url(char *in, char* out);
56
 
extern bool valid_master_url(char*);
57
 
extern void canonicalize_master_url(char *url);
58
 
extern void canonicalize_master_url(std::string&);
59
34
#define safe_strcpy(x, y) strlcpy(x, y, sizeof(x))
60
35
#define safe_strcat(x, y) if (strlen(x)+strlen(y)<sizeof(x)) strcat(x, y)
61
36
extern char* time_to_string(double);
74
49
 
75
50
inline void downcase_string(std::string& w) {
76
51
    for (std::string::iterator p = w.begin(); p != w.end(); ++p) {
77
 
        *p = tolower(*p);
 
52
        *p = (char)tolower((int)*p);
 
53
    }
 
54
}
 
55
 
 
56
inline void downcase_string(char* p) {
 
57
    while (*p) {
 
58
        *p = (char)tolower((int)*p);
 
59
        p++;
78
60
    }
79
61
}
80
62
 
93
75
extern const char* boincerror(int which_error);
94
76
extern const char* network_status_string(int);
95
77
extern const char* rpc_reason_string(int);
 
78
extern const char* suspend_reason_string(int reason);
 
79
extern const char* run_mode_string(int mode);
 
80
 
96
81
 
97
82
#endif