summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-12-08 16:07:31 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2010-12-08 16:07:31 +0100
commitdc3c5b79ba1ee6fd7a98842fde43d072e004f93b (patch)
tree131a23c0e5ac6c6be1f23872753ac1ae62e7f7fa /src
parentcba369350c57dc763814376ac4cba8a011962fc7 (diff)
downloadabrt-dc3c5b79ba1ee6fd7a98842fde43d072e004f93b.tar.gz
abrt-dc3c5b79ba1ee6fd7a98842fde43d072e004f93b.tar.xz
abrt-dc3c5b79ba1ee6fd7a98842fde43d072e004f93b.zip
add abrt_ prefixes to abrt-internal functions in libabrt.so
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/cli/CLI.cpp2
-rw-r--r--src/daemon/Settings.cpp2
-rw-r--r--src/hooks/abrt-hook-ccpp.c6
-rw-r--r--src/include/abrt_crash_dump.h2
-rw-r--r--src/include/abrt_types.h3
-rw-r--r--src/include/abrtlib.h120
-rw-r--r--src/include/xfuncs.h38
-rw-r--r--src/lib/hash_md5.h3
-rw-r--r--src/lib/hash_sha1.h3
-rw-r--r--src/lib/hooklib.h8
-rw-r--r--src/lib/logging.h29
-rw-r--r--src/lib/parse_options.h2
-rw-r--r--src/lib/read_write.h6
-rw-r--r--src/lib/strbuf.c2
-rw-r--r--src/lib/strbuf.h11
-rw-r--r--src/lib/xatonum.c4
-rw-r--r--src/lib/xfuncs.c10
-rw-r--r--src/plugins/CCpp.cpp2
-rw-r--r--src/plugins/abrt-action-analyze-c.c2
-rw-r--r--src/plugins/abrt-action-bugzilla.cpp2
-rw-r--r--src/plugins/abrt-action-generate-backtrace.c2
-rw-r--r--src/plugins/abrt-action-mailx.cpp2
22 files changed, 184 insertions, 77 deletions
diff --git a/src/cli/CLI.cpp b/src/cli/CLI.cpp
index cdce6b8a..aeb1d461 100644
--- a/src/cli/CLI.cpp
+++ b/src/cli/CLI.cpp
@@ -164,7 +164,7 @@ static char *guess_crash_id(const char *str)
unsigned num_crashinfos = ci->len;
if (str[0] == '@') /* "--report @N" syntax */
{
- unsigned position = xatoi_u(str + 1);
+ unsigned position = xatoi_positive(str + 1);
if (position >= num_crashinfos)
error_msg_and_die("There are only %u crash infos", num_crashinfos);
crash_data_t *info = get_crash_data(ci, position);
diff --git a/src/daemon/Settings.cpp b/src/daemon/Settings.cpp
index 5b9972ba..abdd0324 100644
--- a/src/daemon/Settings.cpp
+++ b/src/daemon/Settings.cpp
@@ -207,7 +207,7 @@ static int ParseCommon()
it = s_mapSectionCommon.find("MaxCrashReportsSize");
if (it != end)
{
- g_settings_nMaxCrashReportsSize = xatoi_u(it->second.c_str());
+ g_settings_nMaxCrashReportsSize = xatoi_positive(it->second.c_str());
}
it = s_mapSectionCommon.find("ProcessUnpackaged");
if (it != end)
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
index bcdc8547..fba36a5e 100644
--- a/src/hooks/abrt-hook-ccpp.c
+++ b/src/hooks/abrt-hook-ccpp.c
@@ -272,10 +272,10 @@ int main(int argc, char** argv)
errno = 0;
const char* dddir = argv[1];
- pid_t pid = xatoi_u(argv[2]);
+ pid_t pid = xatoi_positive(argv[2]);
const char* signal_str = argv[3];
- int signal_no = xatoi_u(argv[3]);
- uid_t uid = xatoi_u(argv[4]);
+ int signal_no = xatoi_positive(argv[3]);
+ uid_t uid = xatoi_positive(argv[4]);
off_t ulimit_c = strtoull(argv[5], NULL, 10);
if (ulimit_c < 0) /* unlimited? */
{
diff --git a/src/include/abrt_crash_dump.h b/src/include/abrt_crash_dump.h
index 3a23285a..9ecbf56d 100644
--- a/src/include/abrt_crash_dump.h
+++ b/src/include/abrt_crash_dump.h
@@ -75,8 +75,10 @@
extern "C" {
#endif
+#define is_editable_file abrt_is_editable_file
bool is_editable_file(const char *file_name);
+#define log_map_crash_data abrt_log_map_crash_data
void log_map_crash_data(crash_data_t *crash_data, const char *pfx);
#ifdef __cplusplus
diff --git a/src/include/abrt_types.h b/src/include/abrt_types.h
index 3ebd1697..858c0c79 100644
--- a/src/include/abrt_types.h
+++ b/src/include/abrt_types.h
@@ -31,8 +31,11 @@ extern "C" {
*/
typedef GHashTable map_string_h;
+#define new_map_string abrt_new_map_string
map_string_h *new_map_string(void);
+#define free_map_string abrt_free_map_string
void free_map_string(map_string_h *ms);
+#define get_map_string_item_or_empty abrt_get_map_string_item_or_empty
const char *get_map_string_item_or_empty(map_string_h *ms, const char *key);
static inline
const char *get_map_string_item_or_NULL(map_string_h *ms, const char *key)
diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h
index d8dd361a..d3f355e9 100644
--- a/src/include/abrtlib.h
+++ b/src/include/abrtlib.h
@@ -87,43 +87,64 @@ int vdprintf(int d, const char *format, va_list ap);
extern "C" {
#endif
+#define prefixcmp abrt_prefixcmp
int prefixcmp(const char *str, const char *prefix);
+#define suffixcmp abrt_suffixcmp
int suffixcmp(const char *str, const char *suffix);
+#define concat_path_file abrt_concat_path_file
char *concat_path_file(const char *path, const char *filename);
+#define append_to_malloced_string abrt_append_to_malloced_string
char *append_to_malloced_string(char *mstr, const char *append);
+#define skip_whitespace abrt_skip_whitespace
char* skip_whitespace(const char *s);
+#define skip_non_whitespace abrt_skip_non_whitespace
char* skip_non_whitespace(const char *s);
/* Like strcpy but can copy overlapping strings. */
+#define overlapping_strcpy abrt_overlapping_strcpy
void overlapping_strcpy(char *dst, const char *src);
/* A-la fgets, but malloced and of unlimited size */
+#define xmalloc_fgets abrt_xmalloc_fgets
char *xmalloc_fgets(FILE *file);
/* Similar, but removes trailing \n */
+#define xmalloc_fgetline abrt_xmalloc_fgetline
char *xmalloc_fgetline(FILE *file);
/* On error, copyfd_XX prints error messages and returns -1 */
enum {
COPYFD_SPARSE = 1 << 0,
};
+#define copyfd_eof abrt_copyfd_eof
off_t copyfd_eof(int src_fd, int dst_fd, int flags);
+#define copyfd_size abrt_copyfd_size
off_t copyfd_size(int src_fd, int dst_fd, off_t size, int flags);
+#define copyfd_exact_size abrt_copyfd_exact_size
void copyfd_exact_size(int src_fd, int dst_fd, off_t size);
+#define copy_file abrt_copy_file
off_t copy_file(const char *src_name, const char *dst_name, int mode);
/* Returns malloc'ed block */
+#define encode_base64 abrt_encode_base64
char *encode_base64(const void *src, int length);
+#define xatou abrt_xatou
unsigned xatou(const char *numstr);
+#define xatoi abrt_xatoi
int xatoi(const char *numstr);
/* Using xatoi() instead of naive atoi() is not always convenient -
* in many places people want *non-negative* values, but store them
* in signed int. Therefore we need this one:
- * dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc */
-int xatoi_u(const char *numstr);
+ * dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc.
+ * It should really be named xatoi_nonnegative (since it allows 0),
+ * but that would be too long.
+ */
+#define xatoi_positive abrt_xatoi_positive
+int xatoi_positive(const char *numstr);
-unsigned long long monotonic_ns(void);
-unsigned long long monotonic_us(void);
-unsigned monotonic_sec(void);
+//unused for now
+//unsigned long long monotonic_ns(void);
+//unsigned long long monotonic_us(void);
+//unsigned monotonic_sec(void);
enum {
/* on return, pipefds[1] is fd to which parent may write
@@ -146,6 +167,7 @@ enum {
EXECFLG_SETSID = 1 << 8,
};
/* Returns pid */
+#define fork_execv_on_steroids abrt_fork_execv_on_steroids
pid_t fork_execv_on_steroids(int flags,
char **argv,
int *pipefds,
@@ -154,53 +176,57 @@ pid_t fork_execv_on_steroids(int flags,
uid_t uid);
/* Returns malloc'ed string. NULs are retained, and extra one is appended
* after the last byte (this NUL is not accounted for in *size_p) */
+#define run_in_shell_and_save_output abrt_run_in_shell_and_save_output
char *run_in_shell_and_save_output(int flags,
const char *cmd,
const char *dir,
size_t *size_p);
-/* Networking helpers */
-typedef struct len_and_sockaddr {
- socklen_t len;
- union {
- struct sockaddr sa;
- struct sockaddr_in sin;
- struct sockaddr_in6 sin6;
- } u;
-} len_and_sockaddr;
-enum {
- LSA_LEN_SIZE = offsetof(len_and_sockaddr, u),
- LSA_SIZEOF_SA = sizeof(struct sockaddr) > sizeof(struct sockaddr_in6) ?
- sizeof(struct sockaddr) : sizeof(struct sockaddr_in6),
-};
-void setsockopt_reuseaddr(int fd);
-int setsockopt_broadcast(int fd);
-int setsockopt_bindtodevice(int fd, const char *iface);
-len_and_sockaddr* get_sock_lsa(int fd);
-void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen);
-unsigned lookup_port(const char *port, const char *protocol, unsigned default_port);
-int get_nport(const struct sockaddr *sa);
-void set_nport(len_and_sockaddr *lsa, unsigned port);
-len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af);
-len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af);
-len_and_sockaddr* host2sockaddr(const char *host, int port);
-len_and_sockaddr* xhost2sockaddr(const char *host, int port);
-len_and_sockaddr* xdotted2sockaddr(const char *host, int port);
-int xsocket_type(len_and_sockaddr **lsap, int family, int sock_type);
-int xsocket_stream(len_and_sockaddr **lsap);
-int create_and_bind_stream_or_die(const char *bindaddr, int port);
-int create_and_bind_dgram_or_die(const char *bindaddr, int port);
-int create_and_connect_stream_or_die(const char *peer, int port);
-int xconnect_stream(const len_and_sockaddr *lsa);
-char* xmalloc_sockaddr2host(const struct sockaddr *sa);
-char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa);
-char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa);
-char* xmalloc_sockaddr2dotted(const struct sockaddr *sa);
-char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa);
+//unused for now
+///* Networking helpers */
+//typedef struct len_and_sockaddr {
+// socklen_t len;
+// union {
+// struct sockaddr sa;
+// struct sockaddr_in sin;
+// struct sockaddr_in6 sin6;
+// } u;
+//} len_and_sockaddr;
+//enum {
+// LSA_LEN_SIZE = offsetof(len_and_sockaddr, u),
+// LSA_SIZEOF_SA = sizeof(struct sockaddr) > sizeof(struct sockaddr_in6) ?
+// sizeof(struct sockaddr) : sizeof(struct sockaddr_in6),
+//};
+//void setsockopt_reuseaddr(int fd);
+//int setsockopt_broadcast(int fd);
+//int setsockopt_bindtodevice(int fd, const char *iface);
+//len_and_sockaddr* get_sock_lsa(int fd);
+//void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen);
+//unsigned lookup_port(const char *port, const char *protocol, unsigned default_port);
+//int get_nport(const struct sockaddr *sa);
+//void set_nport(len_and_sockaddr *lsa, unsigned port);
+//len_and_sockaddr* host_and_af2sockaddr(const char *host, int port, sa_family_t af);
+//len_and_sockaddr* xhost_and_af2sockaddr(const char *host, int port, sa_family_t af);
+//len_and_sockaddr* host2sockaddr(const char *host, int port);
+//len_and_sockaddr* xhost2sockaddr(const char *host, int port);
+//len_and_sockaddr* xdotted2sockaddr(const char *host, int port);
+//int xsocket_type(len_and_sockaddr **lsap, int family, int sock_type);
+//int xsocket_stream(len_and_sockaddr **lsap);
+//int create_and_bind_stream_or_die(const char *bindaddr, int port);
+//int create_and_bind_dgram_or_die(const char *bindaddr, int port);
+//int create_and_connect_stream_or_die(const char *peer, int port);
+//int xconnect_stream(const len_and_sockaddr *lsa);
+//char* xmalloc_sockaddr2host(const struct sockaddr *sa);
+//char* xmalloc_sockaddr2host_noport(const struct sockaddr *sa);
+//char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa);
+//char* xmalloc_sockaddr2dotted(const struct sockaddr *sa);
+//char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa);
/* Random utility functions */
+#define get_dirsize abrt_get_dirsize
double get_dirsize(const char *pPath);
+#define get_dirsize_find_largest_dir abrt_get_dirsize_find_largest_dir
double get_dirsize_find_largest_dir(
const char *pPath,
char **worst_dir, /* can be NULL */
@@ -212,16 +238,23 @@ double get_dirsize_find_largest_dir(
* If the pid is not valid or command line can not be obtained,
* empty string is returned.
*/
+#define get_cmdline abrt_get_cmdline
char* get_cmdline(pid_t pid);
/* Returns 1 if abrtd daemon is running, 0 otherwise. */
+#define daemon_is_ok abrt_daemon_is_ok
int daemon_is_ok();
+#define make_description_bz abrt_make_description_bz
char* make_description_bz(crash_data_t *crash_data);
+#define make_description_reproduce_comment abrt_make_description_reproduce_comment
char* make_description_reproduce_comment(crash_data_t *crash_data);
+#define make_description_logger abrt_make_description_logger
char* make_description_logger(crash_data_t *crash_data);
+#define make_description_mailx abrt_make_description_mailx
char* make_description_mailx(crash_data_t *crash_data);
+#define parse_release abrt_parse_release
void parse_release(const char *pRelease, char **product, char **version);
/**
@@ -236,6 +269,7 @@ void parse_release(const char *pRelease, char **product, char **version);
* Otherwise empty value "" is inserted into pSettings.
* @return if it success it returns true, otherwise it returns false.
*/
+#define load_conf_file abrt_load_conf_file
bool load_conf_file(const char *pPath, map_string_h *settings, bool skipKeysWithoutValue);
#ifdef __cplusplus
diff --git a/src/include/xfuncs.h b/src/include/xfuncs.h
index 20284564..61188c81 100644
--- a/src/include/xfuncs.h
+++ b/src/include/xfuncs.h
@@ -29,43 +29,69 @@
extern "C" {
#endif
+#define ndelay_on abrt_ndelay_on
int ndelay_on(int fd);
+#define ndelay_off abrt_ndelay_off
int ndelay_off(int fd);
+#define close_on_exec_on abrt_close_on_exec_on
int close_on_exec_on(int fd);
-void* xcalloc(size_t nmemb, size_t size);
+#define xmalloc abrt_xmalloc
void* xmalloc(size_t size);
+#define xrealloc abrt_xrealloc
void* xrealloc(void *ptr, size_t size);
+#define xzalloc abrt_xzalloc
void* xzalloc(size_t size);
+#define xstrdup abrt_xstrdup
char* xstrdup(const char *s);
+#define xstrndup abrt_xstrndup
char* xstrndup(const char *s, int n);
+#define xpipe abrt_xpipe
void xpipe(int filedes[2]);
+#define xdup abrt_xdup
void xdup(int from);
+#define xdup2 abrt_xdup2
void xdup2(int from, int to);
+#define xmove_fd abrt_xmove_fd
void xmove_fd(int from, int to);
+#define xwrite abrt_xwrite
void xwrite(int fd, const void *buf, size_t count);
+#define xwrite_str abrt_xwrite_str
void xwrite_str(int fd, const char *str);
+#define xlseek abrt_xlseek
off_t xlseek(int fd, off_t offset, int whence);
+#define xchdir abrt_xchdir
void xchdir(const char *path);
+#define xvasprintf abrt_xvasprintf
char* xvasprintf(const char *format, va_list p);
+#define xasprintf abrt_xasprintf
char* xasprintf(const char *format, ...);
+#define xsetenv abrt_xsetenv
void xsetenv(const char *key, const char *value);
+#define xsocket abrt_xsocket
int xsocket(int domain, int type, int protocol);
+#define xbind abrt_xbind
void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
+#define xlisten abrt_xlisten
void xlisten(int s, int backlog);
+#define xsendto abrt_xsendto
ssize_t xsendto(int s, const void *buf, size_t len,
const struct sockaddr *to, socklen_t tolen);
+#define xstat abrt_xstat
void xstat(const char *name, struct stat *stat_buf);
+#define xopen3 abrt_xopen3
int xopen3(const char *pathname, int flags, int mode);
+#define xopen abrt_xopen
int xopen(const char *pathname, int flags);
+#define xunlink abrt_xunlink
void xunlink(const char *pathname);
/* Just testing dent->d_type == DT_REG is wrong: some filesystems
@@ -74,18 +100,28 @@ void xunlink(const char *pathname);
* This function handles this case. Note: it returns 0 on symlinks
* even if they point to regular files.
*/
+#define is_regular_file abrt_is_regular_file
int is_regular_file(struct dirent *dent, const char *dirname);
+
+#define dot_or_dotdot abrt_dot_or_dotdot
bool dot_or_dotdot(const char *filename);
+#define last_char_is abrt_last_char_is
char *last_char_is(const char *s, int c);
+#define string_to_bool abrt_string_to_bool
bool string_to_bool(const char *s);
+#define xseteuid abrt_xseteuid
void xseteuid(uid_t euid);
+#define xsetegid abrt_xsetegid
void xsetegid(gid_t egid);
+#define xsetreuid abrt_xsetreuid
void xsetreuid(uid_t ruid, uid_t euid);
+#define xsetregid abrt_xsetregid
void xsetregid(gid_t rgid, gid_t egid);
/* Returns getpwuid(uid)->pw_dir or NULL */
+#define get_home_dir abrt_get_home_dir
const char *get_home_dir(uid_t uid);
#ifdef __cplusplus
diff --git a/src/lib/hash_md5.h b/src/lib/hash_md5.h
index cc1d2c43..f7e9f398 100644
--- a/src/lib/hash_md5.h
+++ b/src/lib/hash_md5.h
@@ -24,6 +24,9 @@ typedef struct md5_ctx_t {
uint32_t buflen;
char buffer[128];
} md5_ctx_t;
+#define md5_begin abrt_md5_begin
void md5_begin(md5_ctx_t *ctx);
+#define md5_hash abrt_md5_hash
void md5_hash(const void *data, size_t length, md5_ctx_t *ctx);
+#define md5_end abrt_md5_end
void md5_end(void *resbuf, md5_ctx_t *ctx);
diff --git a/src/lib/hash_sha1.h b/src/lib/hash_sha1.h
index 02978ea4..09f50d12 100644
--- a/src/lib/hash_sha1.h
+++ b/src/lib/hash_sha1.h
@@ -31,8 +31,11 @@ typedef struct sha1_ctx_t {
void (*process_block)(struct sha1_ctx_t*);
} sha1_ctx_t;
+#define sha1_begin abrt_sha1_begin
void sha1_begin(sha1_ctx_t *ctx);
+#define sha1_hash abrt_sha1_hash
void sha1_hash(const void *buffer, size_t len, sha1_ctx_t *ctx);
+#define sha1_end abrt_sha1_end
void sha1_end(void *resbuf, sha1_ctx_t *ctx);
#ifdef __cplusplus
diff --git a/src/lib/hooklib.h b/src/lib/hooklib.h
index ba76efbc..84b31a5f 100644
--- a/src/lib/hooklib.h
+++ b/src/lib/hooklib.h
@@ -20,8 +20,14 @@
extern "C" {
#endif
-void parse_conf(const char *additional_conf, unsigned *setting_MaxCrashReportsSize, bool *setting_MakeCompatCore, bool *setting_SaveBinaryImage);
+#define parse_conf abrt_parse_conf
+void parse_conf(const char *additional_conf,
+ unsigned *setting_MaxCrashReportsSize,
+ bool *setting_MakeCompatCore,
+ bool *setting_SaveBinaryImage);
+#define check_free_space abrt_check_free_space
void check_free_space(unsigned setting_MaxCrashReportsSize);
+#define trim_debug_dumps abrt_trim_debug_dumps
void trim_debug_dumps(unsigned setting_MaxCrashReportsSize, const char *exclude_path);
#ifdef __cplusplus
diff --git a/src/lib/logging.h b/src/lib/logging.h
index 8a038bc7..316c1a22 100644
--- a/src/lib/logging.h
+++ b/src/lib/logging.h
@@ -33,14 +33,6 @@ extern "C" {
#define NORETURN __attribute__ ((noreturn))
-/* VERB1 log("what you sometimes want to see, even on a production box") */
-#define VERB1 if (g_verbose >= 1)
-/* VERB2 log("debug message, not going into insanely small details") */
-#define VERB2 if (g_verbose >= 2)
-/* VERB3 log("lots and lots of details") */
-#define VERB3 if (g_verbose >= 3)
-/* there is no level > 3 */
-
enum {
LOGMODE_NONE = 0,
LOGMODE_STDIO = (1 << 0),
@@ -49,26 +41,47 @@ enum {
LOGMODE_CUSTOM = (1 << 2),
};
+#define g_custom_logger abrt_g_custom_logger
extern void (*g_custom_logger)(const char*);
+#define msg_prefix abrt_msg_prefix
extern const char *msg_prefix;
+#define msg_eol abrt_msg_eol
extern const char *msg_eol;
+#define logmode abrt_logmode
extern int logmode;
+#define xfunc_error_retval abrt_xfunc_error_retval
extern int xfunc_error_retval;
/* Verbosity level */
+#define g_verbose abrt_g_verbose
extern int g_verbose;
+/* VERB1 log("what you sometimes want to see, even on a production box") */
+#define VERB1 if (g_verbose >= 1)
+/* VERB2 log("debug message, not going into insanely small details") */
+#define VERB2 if (g_verbose >= 2)
+/* VERB3 log("lots and lots of details") */
+#define VERB3 if (g_verbose >= 3)
+/* there is no level > 3 */
+#define abrt_
+#define xfunc_die abrt_xfunc_die
void xfunc_die(void) NORETURN;
+#define log_msg abrt_log_msg
void log_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
/* It's a macro, not function, since it collides with log() from math.h */
#undef log
#define log(...) log_msg(__VA_ARGS__)
/* error_msg family will use g_custom_logger. log_msg does not. */
+#define error_msg abrt_error_msg
void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
+#define error_msg_and_die abrt_error_msg_and_die
void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
/* Reports error message with libc's errno error description attached. */
+#define perror_msg abrt_perror_msg
void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
+#define perror_msg_and_die abrt_perror_msg_and_die
void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
+#define die_out_of_memory abrt_die_out_of_memory
void die_out_of_memory(void) NORETURN;
#ifdef __cplusplus
diff --git a/src/lib/parse_options.h b/src/lib/parse_options.h
index 105f081c..98138063 100644
--- a/src/lib/parse_options.h
+++ b/src/lib/parse_options.h
@@ -41,9 +41,11 @@ struct options {
#define OPT__VERBOSE(v) OPT_BOOL('v', "verbose", (v), "be verbose")
+#define parse_opts abrt_parse_opts
unsigned parse_opts(int argc, char **argv, const struct options *opt,
const char *usage);
+#define parse_usage_and_die abrt_parse_usage_and_die
void parse_usage_and_die(const char *usage, const struct options *opt);
#ifdef __cplusplus
diff --git a/src/lib/read_write.h b/src/lib/read_write.h
index 054a1a9a..dc85f33b 100644
--- a/src/lib/read_write.h
+++ b/src/lib/read_write.h
@@ -32,14 +32,20 @@ extern "C" {
// NB: will return short read on error, not -1,
// if some data was read before error occurred
+#define xread abrt_xread
void xread(int fd, void *buf, size_t count);
+#define safe_read abrt_safe_read
ssize_t safe_read(int fd, void *buf, size_t count);
+#define safe_write abrt_safe_write
ssize_t safe_write(int fd, const void *buf, size_t count);
+#define full_read abrt_full_read
ssize_t full_read(int fd, void *buf, size_t count);
+#define full_write abrt_full_write
ssize_t full_write(int fd, const void *buf, size_t count);
+#define full_write_str abrt_full_write_str
ssize_t full_write_str(int fd, const char *buf);
#ifdef __cplusplus
diff --git a/src/lib/strbuf.c b/src/lib/strbuf.c
index 04a35998..f56815a0 100644
--- a/src/lib/strbuf.c
+++ b/src/lib/strbuf.c
@@ -37,7 +37,7 @@ int suffixcmp(const char *str, const char *suffix)
return strcmp(str + len_minus_suflen, suffix);
}
-struct strbuf *strbuf_new()
+struct strbuf *strbuf_new(void)
{
struct strbuf *buf = xzalloc(sizeof(*buf));
/*buf->len = 0; - done by xzalloc */
diff --git a/src/lib/strbuf.h b/src/lib/strbuf.h
index dc45a199..44c6599a 100644
--- a/src/lib/strbuf.h
+++ b/src/lib/strbuf.h
@@ -39,13 +39,15 @@ struct strbuf
* It never returns NULL. The returned pointer must be released by
* calling the function strbuf_free().
*/
-struct strbuf *strbuf_new();
+#define strbuf_new abrt_strbuf_new
+struct strbuf *strbuf_new(void);
/**
* Releases the memory held by the string buffer.
* @param strbuf
* If the strbuf is NULL, no operation is performed.
*/
+#define strbuf_free abrt_strbuf_free
void strbuf_free(struct strbuf *strbuf);
/**
@@ -53,24 +55,28 @@ void strbuf_free(struct strbuf *strbuf);
* string buffer is returned. Caller is responsible to release the
* returned memory using free().
*/
+#define strbuf_free_nobuf abrt_strbuf_free_nobuf
char* strbuf_free_nobuf(struct strbuf *strbuf);
/**
* The string content is set to an empty string, erasing any previous
* content and leaving its length at 0 characters.
*/
+#define strbuf_clear abrt_strbuf_clear
void strbuf_clear(struct strbuf *strbuf);
/**
* The current content of the string buffer is extended by adding a
* character c at its end.
*/
+#define strbuf_append_char abrt_strbuf_append_char
struct strbuf *strbuf_append_char(struct strbuf *strbuf, char c);
/**
* The current content of the string buffer is extended by adding a
* string str at its end.
*/
+#define strbuf_append_str abrt_strbuf_append_str
struct strbuf *strbuf_append_str(struct strbuf *strbuf,
const char *str);
@@ -78,6 +84,7 @@ struct strbuf *strbuf_append_str(struct strbuf *strbuf,
* The current content of the string buffer is extended by inserting a
* string str at its beginning.
*/
+#define strbuf_prepend_str abrt_strbuf_prepend_str
struct strbuf *strbuf_prepend_str(struct strbuf *strbuf,
const char *str);
@@ -85,6 +92,7 @@ struct strbuf *strbuf_prepend_str(struct strbuf *strbuf,
* The current content of the string buffer is extended by adding a
* sequence of data formatted as the format argument specifies.
*/
+#define strbuf_append_strf abrt_strbuf_append_strf
struct strbuf *strbuf_append_strf(struct strbuf *strbuf,
const char *format, ...);
@@ -93,6 +101,7 @@ struct strbuf *strbuf_append_strf(struct strbuf *strbuf,
* sequence of data formatted as the format argument specifies at the
* buffer beginning.
*/
+#define strbuf_prepend_strf abrt_strbuf_prepend_strf
struct strbuf *strbuf_prepend_strf(struct strbuf *strbuf,
const char *format, ...);
diff --git a/src/lib/xatonum.c b/src/lib/xatonum.c
index 3b22071f..1a92db7f 100644
--- a/src/lib/xatonum.c
+++ b/src/lib/xatonum.c
@@ -28,7 +28,7 @@ inval:
error_msg_and_die("invalid number '%s'", numstr);
}
-int xatoi_u(const char *numstr)
+int xatoi_positive(const char *numstr)
{
unsigned r = xatou(numstr);
if (r > (unsigned)INT_MAX)
@@ -41,7 +41,7 @@ int xatoi(const char *numstr)
unsigned r;
if (*numstr != '-')
- return xatoi_u(numstr);
+ return xatoi_positive(numstr);
r = xatou(numstr + 1);
if (r > (unsigned)INT_MAX + 1)
diff --git a/src/lib/xfuncs.c b/src/lib/xfuncs.c
index d5166037..71796371 100644
--- a/src/lib/xfuncs.c
+++ b/src/lib/xfuncs.c
@@ -39,16 +39,6 @@ int close_on_exec_on(int fd)
return fcntl(fd, F_SETFD, FD_CLOEXEC);
}
-#if 0 /* unused */
-void *xcalloc(size_t nmemb, size_t size)
-{
- void *ptr = calloc(nmemb, size);
- if (!ptr && nmemb && size)
- die_out_of_memory();
- return ptr;
-}
-#endif
-
// Die if we can't allocate size bytes of memory.
void* xmalloc(size_t size)
{
diff --git a/src/plugins/CCpp.cpp b/src/plugins/CCpp.cpp
index 19860290..d88a593d 100644
--- a/src/plugins/CCpp.cpp
+++ b/src/plugins/CCpp.cpp
@@ -240,7 +240,7 @@ void CAnalyzerCCpp::SetSettings(const map_plugin_settings_t& pSettings)
it = pSettings.find("GdbTimeoutSec");
if (it != end)
{
- m_nGdbTimeoutSec = xatoi_u(it->second.c_str());
+ m_nGdbTimeoutSec = xatoi_positive(it->second.c_str());
}
it = pSettings.find("InstallDebugInfo");
if (it == end) //compat, remove after 0.0.11
diff --git a/src/plugins/abrt-action-analyze-c.c b/src/plugins/abrt-action-analyze-c.c
index 6d8ac1b4..e45e39cf 100644
--- a/src/plugins/abrt-action-analyze-c.c
+++ b/src/plugins/abrt-action-analyze-c.c
@@ -52,7 +52,7 @@ static char *run_unstrip_n(const char *dump_dir_name, unsigned timeout_sec)
return NULL;
char *uid_str = dd_load_text(dd, FILENAME_UID);
dd_close(dd);
- unsigned uid = xatoi_u(uid_str);
+ unsigned uid = xatoi_positive(uid_str);
free(uid_str);
int flags = EXECFLG_INPUT_NUL | EXECFLG_OUTPUT | EXECFLG_SETGUID | EXECFLG_SETSID | EXECFLG_QUIET;
diff --git a/src/plugins/abrt-action-bugzilla.cpp b/src/plugins/abrt-action-bugzilla.cpp
index d1bd271a..db492051 100644
--- a/src/plugins/abrt-action-bugzilla.cpp
+++ b/src/plugins/abrt-action-bugzilla.cpp
@@ -465,7 +465,7 @@ xmlrpc_int32 ctx::new_bug(crash_data_t *crash_data, int depend_on_bugno)
if (tainted_str && analyzer
&& (strcmp(analyzer, "Kerneloops") == 0)
) {
- unsigned long tainted = xatoi_u(tainted_str);
+ unsigned long tainted = xatoi_positive(tainted_str);
const char *tainted_warning = tainted_string(tainted);
if (tainted_warning)
strbuf_append_strf(buf_summary, ": TAINTED %s", tainted_warning);
diff --git a/src/plugins/abrt-action-generate-backtrace.c b/src/plugins/abrt-action-generate-backtrace.c
index 64ce4082..a575a191 100644
--- a/src/plugins/abrt-action-generate-backtrace.c
+++ b/src/plugins/abrt-action-generate-backtrace.c
@@ -131,7 +131,7 @@ static char* exec_vp(char **args, uid_t uid, int redirect_stderr, int *status)
static char *get_backtrace(struct dump_dir *dd)
{
char *uid_str = dd_load_text(dd, FILENAME_UID);
- uid_t uid = xatoi_u(uid_str);
+ uid_t uid = xatoi_positive(uid_str);
free(uid_str);
char *executable = dd_load_text(dd, FILENAME_EXECUTABLE);
dd_close(dd);
diff --git a/src/plugins/abrt-action-mailx.cpp b/src/plugins/abrt-action-mailx.cpp
index 6c53c504..8f613047 100644
--- a/src/plugins/abrt-action-mailx.cpp
+++ b/src/plugins/abrt-action-mailx.cpp
@@ -108,7 +108,7 @@ static void create_and_send_email(
log(_("Sending an email..."));
const char *uid_str = get_crash_item_content_or_NULL(crash_data, FILENAME_UID);
- exec_and_feed_input(xatoi_u(uid_str), dsc, args);
+ exec_and_feed_input(xatoi_positive(uid_str), dsc, args);
free(dsc);