From ffb51df395d5e0427ef00a6cff1f93a63eaa65e5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 26 Oct 2009 15:42:27 +0100 Subject: add bits of infrastructure needed for xmlprc code. This does not affect existing code in any way. Signed-off-by: Denys Vlasenko --- lib/Utils/xfuncs.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib/Utils/xfuncs.cpp') diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp index d256c19..9c8b0f1 100644 --- a/lib/Utils/xfuncs.cpp +++ b/lib/Utils/xfuncs.cpp @@ -5,6 +5,22 @@ */ #include "abrtlib.h" +/* Turn on nonblocking I/O on a fd */ +int ndelay_on(int fd) +{ + return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) | O_NONBLOCK); +} + +int ndelay_off(int fd) +{ + return fcntl(fd, F_SETFL, fcntl(fd,F_GETFL) & ~O_NONBLOCK); +} + +int close_on_exec_on(int fd) +{ + return fcntl(fd, F_SETFD, FD_CLOEXEC); +} + // Die if we can't allocate size bytes of memory. void* xmalloc(size_t size) { -- cgit From 68e616def90ece3bdde925dc106e51e8560fa05d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 2 Nov 2009 11:58:01 +0100 Subject: lib/Plugins/CCpp: respect DebugInfoCacheMB setting Signed-off-by: Denys Vlasenko --- lib/Utils/xfuncs.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'lib/Utils/xfuncs.cpp') diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp index 9c8b0f1..533fbfa 100644 --- a/lib/Utils/xfuncs.cpp +++ b/lib/Utils/xfuncs.cpp @@ -321,3 +321,37 @@ int is_regular_file(struct dirent *dent, const char *dirname) return r == 0 && S_ISREG(statbuf.st_mode); } + +/* Is it "." or ".."? */ +/* abrtlib candidate */ +bool dot_or_dotdot(const char *filename) +{ + if (filename[0] != '.') return false; + if (filename[1] == '\0') return true; + if (filename[1] != '.') return false; + if (filename[2] == '\0') return true; + return false; +} + +/* Find out if the last character of a string matches the one given. + * Don't underrun the buffer if the string length is 0. + */ +char *last_char_is(const char *s, int c) +{ + if (s && *s) { + s += strlen(s) - 1; + if ((unsigned char)*s == c) + return (char*)s; + } + return NULL; +} + +std::string concat_path_file(const char *path, const char *filename) +{ + char *lc; + + while (*filename == '/') + filename++; + lc = last_char_is(path, '/'); + return ssprintf("%s%s%s", path, (lc==NULL ? "/" : ""), filename); +} -- cgit From 64c5d35aebc38f93ce5c086c15c15de5acb21b2f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 5 Nov 2009 17:21:11 +0100 Subject: InformAllUsers support. enabled by default for Kerneloops. Tested wuth CCpp. Signed-off-by: Denys Vlasenko --- lib/Utils/xfuncs.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/Utils/xfuncs.cpp') diff --git a/lib/Utils/xfuncs.cpp b/lib/Utils/xfuncs.cpp index 533fbfa..97c2f76 100644 --- a/lib/Utils/xfuncs.cpp +++ b/lib/Utils/xfuncs.cpp @@ -355,3 +355,16 @@ std::string concat_path_file(const char *path, const char *filename) lc = last_char_is(path, '/'); return ssprintf("%s%s%s", path, (lc==NULL ? "/" : ""), filename); } + +bool string_to_bool(const char *s) +{ + if (s[0] == '1' && s[1] == '\0') + return true; + if (strcasecmp(s, "on") == 0) + return true; + if (strcasecmp(s, "yes") == 0) + return true; + if (strcasecmp(s, "true") == 0) + return true; + return false; +} -- cgit