mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=2161
This commit is contained in:
parent
6641b7f87e
commit
5a219364ae
|
@ -2,18 +2,18 @@
|
||||||
// Version 1.0 (the "License"); you may not use this file except in
|
// Version 1.0 (the "License"); you may not use this file except in
|
||||||
// compliance with the License. You may obtain a copy of the License at
|
// compliance with the License. You may obtain a copy of the License at
|
||||||
// http://boinc.berkeley.edu/license_1.0.txt
|
// http://boinc.berkeley.edu/license_1.0.txt
|
||||||
//
|
//
|
||||||
// Software distributed under the License is distributed on an "AS IS"
|
// Software distributed under the License is distributed on an "AS IS"
|
||||||
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||||
// License for the specific language governing rights and limitations
|
// License for the specific language governing rights and limitations
|
||||||
// under the License.
|
// under the License.
|
||||||
//
|
//
|
||||||
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
// The Original Code is the Berkeley Open Infrastructure for Network Computing.
|
||||||
//
|
//
|
||||||
// The Initial Developer of the Original Code is the SETI@home project.
|
// The Initial Developer of the Original Code is the SETI@home project.
|
||||||
// Portions created by the SETI@home project are Copyright (C) 2002
|
// Portions created by the SETI@home project are Copyright (C) 2002
|
||||||
// University of California at Berkeley. All Rights Reserved.
|
// University of California at Berkeley. All Rights Reserved.
|
||||||
//
|
//
|
||||||
// Contributor(s):
|
// Contributor(s):
|
||||||
//
|
//
|
||||||
|
|
||||||
|
@ -28,16 +28,6 @@
|
||||||
|
|
||||||
#include "account.h"
|
#include "account.h"
|
||||||
|
|
||||||
inline bool ends_with(string const& s, string const& suffix) {
|
|
||||||
return
|
|
||||||
s.size()>=suffix.size() &&
|
|
||||||
s.substr(s.size()-suffix.size()) == suffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool starts_with(string const& s, string const& prefix) {
|
|
||||||
return s.substr(0, prefix.size()) == prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline string filename_to_project_dirname(const string& filename) {
|
static inline string filename_to_project_dirname(const string& filename) {
|
||||||
assert(starts_with(filename, "account_"));
|
assert(starts_with(filename, "account_"));
|
||||||
assert(ends_with(filename, ".xml"));
|
assert(ends_with(filename, ".xml"));
|
||||||
|
|
|
@ -404,7 +404,7 @@ void canonicalize_master_url(char *xurl) {
|
||||||
strcpy(xurl, url.c_str());
|
strcpy(xurl, url.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void safe_strncpy(char* dst, char* src, int len) {
|
void safe_strncpy(char* dst, const char* src, int len) {
|
||||||
strncpy(dst, src, len);
|
strncpy(dst, src, len);
|
||||||
dst[len-1]=0;
|
dst[len-1]=0;
|
||||||
}
|
}
|
||||||
|
|
12
lib/util.h
12
lib/util.h
|
@ -40,13 +40,23 @@ extern void unescape_url(char *url);
|
||||||
extern void escape_url(char *in, char*out);
|
extern void escape_url(char *in, char*out);
|
||||||
extern void escape_url_readable(char* in, char* out);
|
extern void escape_url_readable(char* in, char* out);
|
||||||
extern void canonicalize_master_url(char *url);
|
extern void canonicalize_master_url(char *url);
|
||||||
extern void safe_strncpy(char*, char*, int);
|
extern void safe_strncpy(char*, const char*, int);
|
||||||
#define safe_strcpy(x, y) safe_strncpy(x, y, sizeof(x))
|
#define safe_strcpy(x, y) safe_strncpy(x, y, sizeof(x))
|
||||||
#define safe_strcat(x, y) if (strlen(x)+strlen(y)<sizeof(x)) strcat(x, y)
|
#define safe_strcat(x, y) if (strlen(x)+strlen(y)<sizeof(x)) strcat(x, y)
|
||||||
extern char* timestamp();
|
extern char* timestamp();
|
||||||
string timediff_format(long tdiff);
|
string timediff_format(long tdiff);
|
||||||
int read_file_string(const char* pathname, string& result);
|
int read_file_string(const char* pathname, string& result);
|
||||||
|
|
||||||
|
inline bool ends_with(string const& s, string const& suffix) {
|
||||||
|
return
|
||||||
|
s.size()>=suffix.size() &&
|
||||||
|
s.substr(s.size()-suffix.size()) == suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool starts_with(string const& s, string const& prefix) {
|
||||||
|
return s.substr(0, prefix.size()) == prefix;
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: use #include <functional> to get max,min
|
// NOTE: use #include <functional> to get max,min
|
||||||
|
|
||||||
// the __attribute((format...)) tags are GCC extensions that let the compiler
|
// the __attribute((format...)) tags are GCC extensions that let the compiler
|
||||||
|
|
Loading…
Reference in New Issue