|
Packit Service |
779887 |
/*
|
|
Packit Service |
779887 |
Copyright (C) 2010 ABRT team
|
|
Packit Service |
779887 |
Copyright (C) 2010 RedHat Inc
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
This program is free software; you can redistribute it and/or modify
|
|
Packit Service |
779887 |
it under the terms of the GNU General Public License as published by
|
|
Packit Service |
779887 |
the Free Software Foundation; either version 2 of the License, or
|
|
Packit Service |
779887 |
(at your option) any later version.
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
This program is distributed in the hope that it will be useful,
|
|
Packit Service |
779887 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
779887 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
779887 |
GNU General Public License for more details.
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
You should have received a copy of the GNU General Public License along
|
|
Packit Service |
779887 |
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
Packit Service |
779887 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#ifndef LIBREPORT_INTERNAL_H_
|
|
Packit Service |
779887 |
#define LIBREPORT_INTERNAL_H_
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#include <assert.h>
|
|
Packit Service |
779887 |
#include <ctype.h>
|
|
Packit Service |
779887 |
#include <dirent.h>
|
|
Packit Service |
779887 |
#include <errno.h>
|
|
Packit Service |
779887 |
#include <fcntl.h>
|
|
Packit Service |
779887 |
#include <inttypes.h>
|
|
Packit Service |
779887 |
#include <setjmp.h>
|
|
Packit Service |
779887 |
#include <signal.h>
|
|
Packit Service |
779887 |
#include <stdio.h>
|
|
Packit Service |
779887 |
#include <stdlib.h>
|
|
Packit Service |
779887 |
#include <stdarg.h>
|
|
Packit Service |
779887 |
#include <stddef.h>
|
|
Packit Service |
779887 |
#include <string.h>
|
|
Packit Service |
779887 |
#include <syslog.h>
|
|
Packit Service |
779887 |
#include <sys/poll.h>
|
|
Packit Service |
779887 |
#include <sys/mman.h>
|
|
Packit Service |
779887 |
#include <sys/socket.h>
|
|
Packit Service |
779887 |
#include <sys/stat.h>
|
|
Packit Service |
779887 |
#include <sys/time.h>
|
|
Packit Service |
779887 |
#include <sys/types.h>
|
|
Packit Service |
779887 |
#include <sys/wait.h>
|
|
Packit Service |
779887 |
#include <arpa/inet.h> /* sockaddr_in, sockaddr_in6 etc */
|
|
Packit Service |
779887 |
#include <termios.h>
|
|
Packit Service |
779887 |
#include <time.h>
|
|
Packit Service |
779887 |
#include <unistd.h>
|
|
Packit Service |
779887 |
/* Try to pull in PATH_MAX */
|
|
Packit Service |
779887 |
#include <limits.h>
|
|
Packit Service |
779887 |
#include <sys/param.h>
|
|
Packit Service |
779887 |
#ifndef PATH_MAX
|
|
Packit Service |
779887 |
# define PATH_MAX 256
|
|
Packit Service |
779887 |
#endif
|
|
Packit Service |
779887 |
#include <pwd.h>
|
|
Packit Service |
779887 |
#include <grp.h>
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
779887 |
# include "config.h"
|
|
Packit Service |
779887 |
#endif
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Must be after #include "config.h" */
|
|
Packit Service |
779887 |
#if ENABLE_NLS
|
|
Packit Service |
779887 |
# include <libintl.h>
|
|
Packit Service |
779887 |
# define _(S) dgettext(PACKAGE, S)
|
|
Packit Service |
779887 |
#else
|
|
Packit Service |
779887 |
# define _(S) (S)
|
|
Packit Service |
779887 |
#endif
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#if HAVE_LOCALE_H
|
|
Packit Service |
779887 |
# include <locale.h>
|
|
Packit Service |
779887 |
#endif /* HAVE_LOCALE_H */
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Some libc's forget to declare these, do it ourself */
|
|
Packit Service |
779887 |
extern char **environ;
|
|
Packit Service |
779887 |
#if defined(__GLIBC__) && __GLIBC__ < 2
|
|
Packit Service |
779887 |
int vdprintf(int d, const char *format, va_list ap);
|
|
Packit Service |
779887 |
#endif
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#undef NORETURN
|
|
Packit Service |
779887 |
#define NORETURN __attribute__ ((noreturn))
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#undef ERR_PTR
|
|
Packit Service |
779887 |
#define ERR_PTR ((void*)(uintptr_t)1)
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#undef ARRAY_SIZE
|
|
Packit Service |
779887 |
#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* consts used across whole libreport */
|
|
Packit Service |
779887 |
#define CREATE_PRIVATE_TICKET "ABRT_CREATE_PRIVATE_TICKET"
|
|
Packit Service |
779887 |
#define STOP_ON_NOT_REPORTABLE "ABRT_STOP_ON_NOT_REPORTABLE"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* path of user's local config, path is relative to user's home */
|
|
Packit Service |
779887 |
#define USER_HOME_CONFIG_PATH "/.config/libreport"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Pull in entire public libreport API */
|
|
Packit Service |
779887 |
#include "global_configuration.h"
|
|
Packit Service |
779887 |
#include "dump_dir.h"
|
|
Packit Service |
779887 |
#include "event_config.h"
|
|
Packit Service |
779887 |
#include "problem_data.h"
|
|
Packit Service |
779887 |
#include "report.h"
|
|
Packit Service |
779887 |
#include "run_event.h"
|
|
Packit Service |
779887 |
#include "workflow.h"
|
|
Packit Service |
779887 |
#include "file_obj.h"
|
|
Packit Service |
779887 |
#include "libreport_types.h"
|
|
Packit Service |
779887 |
#include "reporters.h"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#ifdef __cplusplus
|
|
Packit Service |
779887 |
extern "C" {
|
|
Packit Service |
779887 |
#endif
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define prefixcmp libreport_prefixcmp
|
|
Packit Service |
779887 |
int prefixcmp(const char *str, const char *prefix);
|
|
Packit Service |
779887 |
#define suffixcmp libreport_suffixcmp
|
|
Packit Service |
779887 |
int suffixcmp(const char *str, const char *suffix);
|
|
Packit Service |
779887 |
#define trim_all_whitespace libreport_trim_all_whitespace
|
|
Packit Service |
779887 |
char *trim_all_whitespace(const char *str);
|
|
Packit Service |
779887 |
#define shorten_string_to_length libreport_shorten_string_to_length
|
|
Packit Service |
779887 |
char *shorten_string_to_length(const char *str, unsigned length);
|
|
Packit Service |
779887 |
#define strtrim libreport_strtrim
|
|
Packit Service |
779887 |
char *strtrim(char *str);
|
|
Packit Service |
779887 |
#define strtrimch libreport_strtrimch
|
|
Packit Service |
779887 |
char *strtrimch(char *str, int ch);
|
|
Packit Service |
779887 |
#define strremovech libreport_strremovech
|
|
Packit Service |
779887 |
char *strremovech(char *str, int ch);
|
|
Packit Service |
779887 |
#define append_to_malloced_string libreport_append_to_malloced_string
|
|
Packit Service |
779887 |
char *append_to_malloced_string(char *mstr, const char *append);
|
|
Packit Service |
779887 |
#define skip_blank libreport_skip_blank
|
|
Packit Service |
779887 |
char* skip_blank(const char *s);
|
|
Packit Service |
779887 |
#define skip_whitespace libreport_skip_whitespace
|
|
Packit Service |
779887 |
char* skip_whitespace(const char *s);
|
|
Packit Service |
779887 |
#define skip_non_whitespace libreport_skip_non_whitespace
|
|
Packit Service |
779887 |
char* skip_non_whitespace(const char *s);
|
|
Packit Service |
779887 |
/* Like strcpy but can copy overlapping strings. */
|
|
Packit Service |
779887 |
#define overlapping_strcpy libreport_overlapping_strcpy
|
|
Packit Service |
779887 |
void overlapping_strcpy(char *dst, const char *src);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define concat_path_file libreport_concat_path_file
|
|
Packit Service |
779887 |
char *concat_path_file(const char *path, const char *filename);
|
|
Packit Service |
779887 |
/*
|
|
Packit Service |
779887 |
* Used to construct a name in a different directory with the basename
|
|
Packit Service |
779887 |
* similar to the old name, if possible.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define concat_path_basename libreport_concat_path_basename
|
|
Packit Service |
779887 |
char *concat_path_basename(const char *path, const char *filename);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Allows all printable characters except '/',
|
|
Packit Service |
779887 |
* the string must not exceed 64 characters of length
|
|
Packit Service |
779887 |
* and must not equal neither "." nor ".." (these strings may appear in the string) */
|
|
Packit Service |
779887 |
#define str_is_correct_filename libreport_str_is_correct_filename
|
|
Packit Service |
779887 |
bool str_is_correct_filename(const char *str);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* A-la fgets, but malloced and of unlimited size */
|
|
Packit Service |
779887 |
#define xmalloc_fgets libreport_xmalloc_fgets
|
|
Packit Service |
779887 |
char *xmalloc_fgets(FILE *file);
|
|
Packit Service |
779887 |
/* Similar, but removes trailing \n */
|
|
Packit Service |
779887 |
#define xmalloc_fgetline libreport_xmalloc_fgetline
|
|
Packit Service |
779887 |
char *xmalloc_fgetline(FILE *file);
|
|
Packit Service |
779887 |
/* Useful for easy reading of various /proc files */
|
|
Packit Service |
779887 |
#define xmalloc_fopen_fgetline_fclose libreport_xmalloc_fopen_fgetline_fclose
|
|
Packit Service |
779887 |
char *xmalloc_fopen_fgetline_fclose(const char *filename);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
typedef enum {
|
|
Packit Service |
779887 |
COPYFD_SPARSE = 1 << 0,
|
|
Packit Service |
779887 |
} libreport_copyfd_flags;
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Writes up to 'size' Bytes from a file descriptor to a file in a directory
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* If you need to write all Bytes of the file descriptor, pass 0 as the size.
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* @param src The source file descriptor
|
|
Packit Service |
779887 |
* @param dir_fd A file descriptor for the parent directory of the destination file
|
|
Packit Service |
779887 |
* @param name The destination file name
|
|
Packit Service |
779887 |
* @param mode The destination file open mode
|
|
Packit Service |
779887 |
* @param uid The destination file's uid
|
|
Packit Service |
779887 |
* @param gid The destination file's gid
|
|
Packit Service |
779887 |
* @param open_flags The destination file open flags
|
|
Packit Service |
779887 |
* @param copy_flags libreport_copyfd_flags
|
|
Packit Service |
779887 |
* @param size The upper limit for written bytes (0 for no limit).
|
|
Packit Service |
779887 |
* @return Number of read Bytes on success. On errors, return -1 and prints out
|
|
Packit Service |
779887 |
* reasonable good error messages.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define copyfd_ext_at libreport_copyfd_ext_at
|
|
Packit Service |
779887 |
off_t copyfd_ext_at(int src, int dir_fd, const char *name, int mode,
|
|
Packit Service |
779887 |
uid_t uid, gid_t gid, int open_flags, int copy_flags, off_t size);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* On error, copyfd_XX prints error messages and returns -1 */
|
|
Packit Service |
779887 |
#define copyfd_eof libreport_copyfd_eof
|
|
Packit Service |
779887 |
off_t copyfd_eof(int src_fd, int dst_fd, int flags);
|
|
Packit Service |
779887 |
#define copyfd_size libreport_copyfd_size
|
|
Packit Service |
779887 |
off_t copyfd_size(int src_fd, int dst_fd, off_t size, int flags);
|
|
Packit Service |
779887 |
#define copyfd_exact_size libreport_copyfd_exact_size
|
|
Packit Service |
779887 |
void copyfd_exact_size(int src_fd, int dst_fd, off_t size);
|
|
Packit Service |
779887 |
#define copy_file_ext_2at libreport_copy_file_ext_2at
|
|
Packit Service |
779887 |
off_t copy_file_ext_2at(int src_dir_fd, const char *src_name, int dir_fd, const char *name, int mode, uid_t uid, gid_t gid, int src_flags, int dst_flags);
|
|
Packit Service |
779887 |
#define copy_file_ext_at libreport_copy_file_ext_at
|
|
Packit Service |
779887 |
off_t copy_file_ext_at(const char *src_name, int dir_fd, const char *name, int mode, uid_t uid, gid_t gid, int src_flags, int dst_flags);
|
|
Packit Service |
779887 |
#define copy_file_ext(src_name, dst_name, mode, uid, gid, src_flags, dst_flags) \
|
|
Packit Service |
779887 |
copy_file_ext_at(src_name, AT_FDCWD, dst_name, mode, uid, gid, src_flags, dst_flags)
|
|
Packit Service |
779887 |
#define copy_file libreport_copy_file
|
|
Packit Service |
779887 |
off_t copy_file(const char *src_name, const char *dst_name, int mode);
|
|
Packit Service |
779887 |
#define copy_file_at libreport_copy_file_at
|
|
Packit Service |
779887 |
off_t copy_file_at(const char *src_name, int dir_fd, const char *name, int mode);
|
|
Packit Service |
779887 |
#define copy_file_recursive libreport_copy_file_recursive
|
|
Packit Service |
779887 |
int copy_file_recursive(const char *source, const char *dest);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define decompress_fd libreport_decompress_fd
|
|
Packit Service |
779887 |
int decompress_fd(int fdi, int fdo);
|
|
Packit Service |
779887 |
#define decompress_file libreport_decompress_file
|
|
Packit Service |
779887 |
int decompress_file(const char *path_in, const char *path_out, mode_t mode_out);
|
|
Packit Service |
779887 |
#define decompress_file_ext_at libreport_decompress_file_ext_at
|
|
Packit Service |
779887 |
int decompress_file_ext_at(const char *path_in, int dir_fd, const char *path_out,
|
|
Packit Service |
779887 |
mode_t mode_out, uid_t uid, gid_t gid, int src_flags, int dst_flags);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
// NB: will return short read on error, not -1,
|
|
Packit Service |
779887 |
// if some data was read before error occurred
|
|
Packit Service |
779887 |
#define xread libreport_xread
|
|
Packit Service |
779887 |
void xread(int fd, void *buf, size_t count);
|
|
Packit Service |
779887 |
#define safe_read libreport_safe_read
|
|
Packit Service |
779887 |
ssize_t safe_read(int fd, void *buf, size_t count);
|
|
Packit Service |
779887 |
#define safe_write libreport_safe_write
|
|
Packit Service |
779887 |
ssize_t safe_write(int fd, const void *buf, size_t count);
|
|
Packit Service |
779887 |
#define full_read libreport_full_read
|
|
Packit Service |
779887 |
ssize_t full_read(int fd, void *buf, size_t count);
|
|
Packit Service |
779887 |
#define full_write libreport_full_write
|
|
Packit Service |
779887 |
ssize_t full_write(int fd, const void *buf, size_t count);
|
|
Packit Service |
779887 |
#define full_write_str libreport_full_write_str
|
|
Packit Service |
779887 |
ssize_t full_write_str(int fd, const char *buf);
|
|
Packit Service |
779887 |
#define xmalloc_read libreport_xmalloc_read
|
|
Packit Service |
779887 |
void* xmalloc_read(int fd, size_t *maxsz_p);
|
|
Packit Service |
779887 |
#define xmalloc_open_read_close libreport_xmalloc_open_read_close
|
|
Packit Service |
779887 |
void* xmalloc_open_read_close(const char *filename, size_t *maxsz_p);
|
|
Packit Service |
779887 |
#define xmalloc_xopen_read_close libreport_xmalloc_xopen_read_close
|
|
Packit Service |
779887 |
void* xmalloc_xopen_read_close(const char *filename, size_t *maxsz_p);
|
|
Packit Service |
779887 |
#define malloc_readlink libreport_malloc_readlink
|
|
Packit Service |
779887 |
char* malloc_readlink(const char *linkname);
|
|
Packit Service |
779887 |
#define malloc_readlinkat libreport_malloc_readlinkat
|
|
Packit Service |
779887 |
char* malloc_readlinkat(int dir_fd, const char *linkname);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Returns malloc'ed block */
|
|
Packit Service |
779887 |
#define encode_base64 libreport_encode_base64
|
|
Packit Service |
779887 |
char *encode_base64(const void *src, int length);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Returns NULL if the string needs no sanitizing.
|
|
Packit Service |
779887 |
* control_chars_to_sanitize is a bit mask.
|
|
Packit Service |
779887 |
* If Nth bit is set, Nth control char will be sanitized (replaced by [XX]).
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define sanitize_utf8 libreport_sanitize_utf8
|
|
Packit Service |
779887 |
char *sanitize_utf8(const char *src, uint32_t control_chars_to_sanitize);
|
|
Packit Service |
779887 |
enum {
|
|
Packit Service |
779887 |
SANITIZE_ALL = 0xffffffff,
|
|
Packit Service |
779887 |
SANITIZE_TAB = (1 << 9),
|
|
Packit Service |
779887 |
SANITIZE_LF = (1 << 10),
|
|
Packit Service |
779887 |
SANITIZE_CR = (1 << 13),
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define SHA1_RESULT_LEN (5 * 4)
|
|
Packit Service |
779887 |
typedef struct sha1_ctx_t {
|
|
Packit Service |
779887 |
uint8_t wbuffer[64]; /* always correctly aligned for uint64_t */
|
|
Packit Service |
779887 |
/* for sha256: void (*process_block)(struct md5_ctx_t*); */
|
|
Packit Service |
779887 |
uint64_t total64; /* must be directly before hash[] */
|
|
Packit Service |
779887 |
uint32_t hash[8]; /* 4 elements for md5, 5 for sha1, 8 for sha256 */
|
|
Packit Service |
779887 |
} sha1_ctx_t;
|
|
Packit Service |
779887 |
#define sha1_begin libreport_sha1_begin
|
|
Packit Service |
779887 |
void sha1_begin(sha1_ctx_t *ctx);
|
|
Packit Service |
779887 |
#define sha1_hash libreport_sha1_hash
|
|
Packit Service |
779887 |
void sha1_hash(sha1_ctx_t *ctx, const void *buffer, size_t len);
|
|
Packit Service |
779887 |
#define sha1_end libreport_sha1_end
|
|
Packit Service |
779887 |
void sha1_end(sha1_ctx_t *ctx, void *resbuf);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Helpers to hash a string: */
|
|
Packit Service |
779887 |
#define str_to_sha1 libreport_str_to_sha1
|
|
Packit Service |
779887 |
const uint8_t *str_to_sha1(uint8_t result[SHA1_RESULT_LEN], const char *str);
|
|
Packit Service |
779887 |
#define str_to_sha1str libreport_str_to_sha1str
|
|
Packit Service |
779887 |
const char *str_to_sha1str(char result[SHA1_RESULT_LEN*2 + 1], const char *str);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define try_atou libreport_try_atou
|
|
Packit Service |
779887 |
int try_atou(const char *numstr, unsigned *value);
|
|
Packit Service |
779887 |
#define xatou libreport_xatou
|
|
Packit Service |
779887 |
unsigned xatou(const char *numstr);
|
|
Packit Service |
779887 |
#define try_atoi libreport_try_atoi
|
|
Packit Service |
779887 |
int try_atoi(const char *numstr, int *value);
|
|
Packit Service |
779887 |
#define xatoi libreport_xatoi
|
|
Packit Service |
779887 |
int xatoi(const char *numstr);
|
|
Packit Service |
779887 |
/* Using xatoi() instead of naive atoi() is not always convenient -
|
|
Packit Service |
779887 |
* in many places people want *non-negative* values, but store them
|
|
Packit Service |
779887 |
* in signed int. Therefore we need this one:
|
|
Packit Service |
779887 |
* dies if input is not in [0, INT_MAX] range. Also will reject '-0' etc.
|
|
Packit Service |
779887 |
* It should really be named xatoi_nonnegative (since it allows 0),
|
|
Packit Service |
779887 |
* but that would be too long.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define try_atoi_positive libreport_try_atoi_positive
|
|
Packit Service |
779887 |
int try_atoi_positive(const char *numstr, int *value);
|
|
Packit Service |
779887 |
#define xatoi_positive libreport_xatoi_positive
|
|
Packit Service |
779887 |
int xatoi_positive(const char *numstr);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
//unused for now
|
|
Packit Service |
779887 |
//unsigned long long monotonic_ns(void);
|
|
Packit Service |
779887 |
//unsigned long long monotonic_us(void);
|
|
Packit Service |
779887 |
//unsigned monotonic_sec(void);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define safe_waitpid libreport_safe_waitpid
|
|
Packit Service |
779887 |
pid_t safe_waitpid(pid_t pid, int *wstat, int options);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
enum {
|
|
Packit Service |
779887 |
/* on return, pipefds[1] is fd to which parent may write
|
|
Packit Service |
779887 |
* and deliver data to child's stdin: */
|
|
Packit Service |
779887 |
EXECFLG_INPUT = 1 << 0,
|
|
Packit Service |
779887 |
/* on return, pipefds[0] is fd from which parent may read
|
|
Packit Service |
779887 |
* child's stdout: */
|
|
Packit Service |
779887 |
EXECFLG_OUTPUT = 1 << 1,
|
|
Packit Service |
779887 |
/* open child's stdin to /dev/null: */
|
|
Packit Service |
779887 |
EXECFLG_INPUT_NUL = 1 << 2,
|
|
Packit Service |
779887 |
/* open child's stdout to /dev/null: */
|
|
Packit Service |
779887 |
EXECFLG_OUTPUT_NUL = 1 << 3,
|
|
Packit Service |
779887 |
/* redirect child's stderr to stdout: */
|
|
Packit Service |
779887 |
EXECFLG_ERR2OUT = 1 << 4,
|
|
Packit Service |
779887 |
/* open child's stderr to /dev/null: */
|
|
Packit Service |
779887 |
EXECFLG_ERR_NUL = 1 << 5,
|
|
Packit Service |
779887 |
/* suppress perror_msg("Can't execute 'foo'") if exec fails */
|
|
Packit Service |
779887 |
EXECFLG_QUIET = 1 << 6,
|
|
Packit Service |
779887 |
EXECFLG_SETGUID = 1 << 7,
|
|
Packit Service |
779887 |
EXECFLG_SETSID = 1 << 8,
|
|
Packit Service |
779887 |
EXECFLG_SETPGID = 1 << 9,
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
/*
|
|
Packit Service |
779887 |
* env_vec: list of variables to set in environment (if string has
|
|
Packit Service |
779887 |
* "VAR=VAL" form) or unset in environment (if string has no '=' char).
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* Returns pid.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define fork_execv_on_steroids libreport_fork_execv_on_steroids
|
|
Packit Service |
779887 |
pid_t fork_execv_on_steroids(int flags,
|
|
Packit Service |
779887 |
char **argv,
|
|
Packit Service |
779887 |
int *pipefds,
|
|
Packit Service |
779887 |
char **env_vec,
|
|
Packit Service |
779887 |
const char *dir,
|
|
Packit Service |
779887 |
uid_t uid);
|
|
Packit Service |
779887 |
/* Returns malloc'ed string. NULs are retained, and extra one is appended
|
|
Packit Service |
779887 |
* after the last byte (this NUL is not accounted for in *size_p) */
|
|
Packit Service |
779887 |
#define run_in_shell_and_save_output libreport_run_in_shell_and_save_output
|
|
Packit Service |
779887 |
char *run_in_shell_and_save_output(int flags,
|
|
Packit Service |
779887 |
const char *cmd,
|
|
Packit Service |
779887 |
const char *dir,
|
|
Packit Service |
779887 |
size_t *size_p);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Random utility functions */
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define is_in_string_list libreport_is_in_string_list
|
|
Packit Service |
779887 |
bool is_in_string_list(const char *name, const char *const *v);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define index_of_string_in_list libreport_index_of_string_in_list
|
|
Packit Service |
779887 |
int index_of_string_in_list(const char *name, const char *const *v);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define is_in_comma_separated_list libreport_is_in_comma_separated_list
|
|
Packit Service |
779887 |
bool is_in_comma_separated_list(const char *value, const char *list);
|
|
Packit Service |
779887 |
#define is_in_comma_separated_list_of_glob_patterns libreport_is_in_comma_separated_list_of_glob_patterns
|
|
Packit Service |
779887 |
bool is_in_comma_separated_list_of_glob_patterns(const char *value, const char *list);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Calls GLib version appropriate initialization function.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define glib_init libreport_glib_init
|
|
Packit Service |
779887 |
void glib_init(void);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Frees every element'd data using free(),
|
|
Packit Service |
779887 |
* then frees list itself using g_list_free(list):
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define list_free_with_free libreport_list_free_with_free
|
|
Packit Service |
779887 |
void list_free_with_free(GList *list);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define get_dirsize libreport_get_dirsize
|
|
Packit Service |
779887 |
double get_dirsize(const char *pPath);
|
|
Packit Service |
779887 |
#define get_dirsize_find_largest_dir libreport_get_dirsize_find_largest_dir
|
|
Packit Service |
779887 |
double get_dirsize_find_largest_dir(
|
|
Packit Service |
779887 |
const char *pPath,
|
|
Packit Service |
779887 |
char **worst_dir, /* can be NULL */
|
|
Packit Service |
779887 |
const char *excluded /* can be NULL */
|
|
Packit Service |
779887 |
);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define ndelay_on libreport_ndelay_on
|
|
Packit Service |
779887 |
int ndelay_on(int fd);
|
|
Packit Service |
779887 |
#define ndelay_off libreport_ndelay_off
|
|
Packit Service |
779887 |
int ndelay_off(int fd);
|
|
Packit Service |
779887 |
#define close_on_exec_on libreport_close_on_exec_on
|
|
Packit Service |
779887 |
int close_on_exec_on(int fd);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define xmalloc libreport_xmalloc
|
|
Packit Service |
779887 |
void* xmalloc(size_t size);
|
|
Packit Service |
779887 |
#define xrealloc libreport_xrealloc
|
|
Packit Service |
779887 |
void* xrealloc(void *ptr, size_t size);
|
|
Packit Service |
779887 |
#define xzalloc libreport_xzalloc
|
|
Packit Service |
779887 |
void* xzalloc(size_t size);
|
|
Packit Service |
779887 |
#define xstrdup libreport_xstrdup
|
|
Packit Service |
779887 |
char* xstrdup(const char *s);
|
|
Packit Service |
779887 |
#define xstrndup libreport_xstrndup
|
|
Packit Service |
779887 |
char* xstrndup(const char *s, int n);
|
|
Packit Service |
779887 |
#define xstrdup_between libreport_xstrdup_between
|
|
Packit Service |
779887 |
char* xstrdup_between(const char *s, const char *open, const char *close);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define xpipe libreport_xpipe
|
|
Packit Service |
779887 |
void xpipe(int filedes[2]);
|
|
Packit Service |
779887 |
#define xdup libreport_xdup
|
|
Packit Service |
779887 |
int xdup(int from);
|
|
Packit Service |
779887 |
#define xdup2 libreport_xdup2
|
|
Packit Service |
779887 |
void xdup2(int from, int to);
|
|
Packit Service |
779887 |
#define xmove_fd libreport_xmove_fd
|
|
Packit Service |
779887 |
void xmove_fd(int from, int to);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define xwrite libreport_xwrite
|
|
Packit Service |
779887 |
void xwrite(int fd, const void *buf, size_t count);
|
|
Packit Service |
779887 |
#define xwrite_str libreport_xwrite_str
|
|
Packit Service |
779887 |
void xwrite_str(int fd, const char *str);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define xlseek libreport_xlseek
|
|
Packit Service |
779887 |
off_t xlseek(int fd, off_t offset, int whence);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define xchdir libreport_xchdir
|
|
Packit Service |
779887 |
void xchdir(const char *path);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define xvasprintf libreport_xvasprintf
|
|
Packit Service |
779887 |
char* xvasprintf(const char *format, va_list p);
|
|
Packit Service |
779887 |
#define xasprintf libreport_xasprintf
|
|
Packit Service |
779887 |
char* xasprintf(const char *format, ...);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define xsetenv libreport_xsetenv
|
|
Packit Service |
779887 |
void xsetenv(const char *key, const char *value);
|
|
Packit Service |
779887 |
/*
|
|
Packit Service |
779887 |
* Utility function to unsetenv a string which was possibly putenv'ed.
|
|
Packit Service |
779887 |
* The problem here is that "natural" optimization:
|
|
Packit Service |
779887 |
* strchrnul(var_val, '=')[0] = '\0';
|
|
Packit Service |
779887 |
* unsetenv(var_val);
|
|
Packit Service |
779887 |
* is BUGGY: if string was put into environment via putenv,
|
|
Packit Service |
779887 |
* its modification (s/=/NUL/) is illegal, and unsetenv will fail to unset it.
|
|
Packit Service |
779887 |
* Of course, saving/restoring the char wouldn't work either.
|
|
Packit Service |
779887 |
* This helper creates a copy up to '=', unsetenv's it, and frees:
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define safe_unsetenv libreport_safe_unsetenv
|
|
Packit Service |
779887 |
void safe_unsetenv(const char *var_val);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define xsocket libreport_xsocket
|
|
Packit Service |
779887 |
int xsocket(int domain, int type, int protocol);
|
|
Packit Service |
779887 |
#define xbind libreport_xbind
|
|
Packit Service |
779887 |
void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
|
|
Packit Service |
779887 |
#define xlisten libreport_xlisten
|
|
Packit Service |
779887 |
void xlisten(int s, int backlog);
|
|
Packit Service |
779887 |
#define xsendto libreport_xsendto
|
|
Packit Service |
779887 |
ssize_t xsendto(int s, const void *buf, size_t len,
|
|
Packit Service |
779887 |
const struct sockaddr *to, socklen_t tolen);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define xstat libreport_xstat
|
|
Packit Service |
779887 |
void xstat(const char *name, struct stat *stat_buf);
|
|
Packit Service |
779887 |
#define fstat_st_size_or_die libreport_fstat_st_size_or_die
|
|
Packit Service |
779887 |
off_t fstat_st_size_or_die(int fd);
|
|
Packit Service |
779887 |
#define stat_st_size_or_die libreport_stat_st_size_or_die
|
|
Packit Service |
779887 |
off_t stat_st_size_or_die(const char *filename);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define xopen3 libreport_xopen3
|
|
Packit Service |
779887 |
int xopen3(const char *pathname, int flags, int mode);
|
|
Packit Service |
779887 |
#define xopen libreport_xopen
|
|
Packit Service |
779887 |
int xopen(const char *pathname, int flags);
|
|
Packit Service |
779887 |
#define xunlink libreport_xunlink
|
|
Packit Service |
779887 |
void xunlink(const char *pathname);
|
|
Packit Service |
779887 |
#define xunlinkat libreport_xunlinkat
|
|
Packit Service |
779887 |
void xunlinkat(int dir_fd, const char *pathname, int flags);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Just testing dent->d_type == DT_REG is wrong: some filesystems
|
|
Packit Service |
779887 |
* do not report the type, they report DT_UNKNOWN for every dirent
|
|
Packit Service |
779887 |
* (and this is not a bug in filesystem, this is allowed by standards).
|
|
Packit Service |
779887 |
* This function handles this case. Note: it returns 0 on symlinks
|
|
Packit Service |
779887 |
* even if they point to regular files.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define is_regular_file libreport_is_regular_file
|
|
Packit Service |
779887 |
int is_regular_file(struct dirent *dent, const char *dirname);
|
|
Packit Service |
779887 |
#define is_regular_file_at libreport_is_regular_file_at
|
|
Packit Service |
779887 |
int is_regular_file_at(struct dirent *dent, int dir_fd);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define dot_or_dotdot libreport_dot_or_dotdot
|
|
Packit Service |
779887 |
bool dot_or_dotdot(const char *filename);
|
|
Packit Service |
779887 |
#define last_char_is libreport_last_char_is
|
|
Packit Service |
779887 |
char *last_char_is(const char *s, int c);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define string_to_bool libreport_string_to_bool
|
|
Packit Service |
779887 |
bool string_to_bool(const char *s);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define xseteuid libreport_xseteuid
|
|
Packit Service |
779887 |
void xseteuid(uid_t euid);
|
|
Packit Service |
779887 |
#define xsetegid libreport_xsetegid
|
|
Packit Service |
779887 |
void xsetegid(gid_t egid);
|
|
Packit Service |
779887 |
#define xsetreuid libreport_xsetreuid
|
|
Packit Service |
779887 |
void xsetreuid(uid_t ruid, uid_t euid);
|
|
Packit Service |
779887 |
#define xsetregid libreport_xsetregid
|
|
Packit Service |
779887 |
void xsetregid(gid_t rgid, gid_t egid);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define xfdopen libreport_xfdopen
|
|
Packit Service |
779887 |
FILE *xfdopen(int fd, const char *mode);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Emit a string of hex representation of bytes */
|
|
Packit Service |
779887 |
#define bin2hex libreport_bin2hex
|
|
Packit Service |
779887 |
char* bin2hex(char *dst, const char *str, int count);
|
|
Packit Service |
779887 |
/* Convert "xxxxxxxx" hex string to binary, no more than COUNT bytes */
|
|
Packit Service |
779887 |
#define hex2bin libreport_hex2bin
|
|
Packit Service |
779887 |
char* hex2bin(char *dst, const char *str, int count);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
enum {
|
|
Packit Service |
779887 |
LOGMODE_NONE = 0,
|
|
Packit Service |
779887 |
LOGMODE_STDIO = (1 << 0),
|
|
Packit Service |
779887 |
LOGMODE_SYSLOG = (1 << 1),
|
|
Packit Service |
779887 |
LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO,
|
|
Packit Service |
779887 |
LOGMODE_CUSTOM = (1 << 2),
|
|
Packit Service |
779887 |
LOGMODE_JOURNAL = (1 << 3),
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
enum libreport_diemode {
|
|
Packit Service |
779887 |
DIEMODE_EXIT = 0,
|
|
Packit Service |
779887 |
DIEMODE_ABORT = 1,
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define g_custom_logger libreport_g_custom_logger
|
|
Packit Service |
779887 |
extern void (*g_custom_logger)(const char*);
|
|
Packit Service |
779887 |
#define msg_prefix libreport_msg_prefix
|
|
Packit Service |
779887 |
extern const char *msg_prefix;
|
|
Packit Service |
779887 |
#define msg_eol libreport_msg_eol
|
|
Packit Service |
779887 |
extern const char *msg_eol;
|
|
Packit Service |
779887 |
#define logmode libreport_logmode
|
|
Packit Service |
779887 |
extern int logmode;
|
|
Packit Service |
779887 |
#define xfunc_error_retval libreport_xfunc_error_retval
|
|
Packit Service |
779887 |
extern int xfunc_error_retval;
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* A few magic exit codes */
|
|
Packit Service |
779887 |
#define EXIT_CANCEL_BY_USER 69
|
|
Packit Service |
779887 |
#define EXIT_STOP_EVENT_RUN 70
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define set_xfunc_error_retval libreport_set_xfunc_error_retval
|
|
Packit Service |
779887 |
void set_xfunc_error_retval(int retval);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define set_xfunc_diemode libreport_set_xfunc_diemode
|
|
Packit Service |
779887 |
void set_xfunc_diemode(enum libreport_diemode mode);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Verbosity level */
|
|
Packit Service |
779887 |
#define g_verbose libreport_g_verbose
|
|
Packit Service |
779887 |
extern int g_verbose;
|
|
Packit Service |
779887 |
/* VERB1 log_warning("what you sometimes want to see, even on a production box") */
|
|
Packit Service |
779887 |
#define VERB1 if (g_verbose >= 1)
|
|
Packit Service |
779887 |
/* VERB2 log_warning("debug message, not going into insanely small details") */
|
|
Packit Service |
779887 |
#define VERB2 if (g_verbose >= 2)
|
|
Packit Service |
779887 |
/* VERB3 log_warning("lots and lots of details") */
|
|
Packit Service |
779887 |
#define VERB3 if (g_verbose >= 3)
|
|
Packit Service |
779887 |
/* there is no level > 3 */
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define libreport_
|
|
Packit Service |
779887 |
#define xfunc_die libreport_xfunc_die
|
|
Packit Service |
779887 |
void xfunc_die(void) NORETURN;
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define die_out_of_memory libreport_die_out_of_memory
|
|
Packit Service |
779887 |
void die_out_of_memory(void) NORETURN;
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* It's a macro, not function, since it collides with log_warning() from math.h */
|
|
Packit Service |
779887 |
#undef log
|
|
Packit Service |
779887 |
#define log_warning(...) log_standard(LOG_WARNING, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define log_debug(...) log_standard(LOG_DEBUG, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define log_info(...) log_standard(LOG_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define log_notice(...) log_standard(LOG_NOTICE, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define log_warning(...) log_standard(LOG_WARNING, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define log_error(...) log_standard(LOG_ERR, __FILE__, __LINE__, __func__, __VA_ARGS__)
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
// specific subsystem debugging
|
|
Packit Service |
779887 |
#define log_parser(...) if(0) log_debug(__VA_ARGS__)
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define log_standard(level, file, line, func, ...) log_wrapper(level, __FILE__, __LINE__, __func__, false, false, __VA_ARGS__)
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
// level, file, line, func, perror, custom logger, format & args
|
|
Packit Service |
779887 |
#define log_error_and_die(...) log_wrapper(LOG_ERR, __FILE__, __LINE__, __func__, false, false,__VA_ARGS__)
|
|
Packit Service |
779887 |
#define log_perror(...) log_wrapper(LOG_ERR, __FILE__, __LINE__, __func__, true, false, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define log_perror_and_die(...) log_wrapper(LOG_ERR, __FILE__, __LINE__, __func__, true, false, __VA_ARGS__)
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define error_msg(...) log_wrapper(LOG_ERR, __FILE__, __LINE__, __func__, false, true, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define perror_msg(...) log_wrapper(LOG_ERR, __FILE__, __LINE__, __func__, true, true, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define warn_msg(...) log_wrapper(LOG_WARNING, __FILE__, __LINE__, __func__, false, true, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define pwarn_msg(...) log_wrapper(LOG_WARNING, __FILE__, __LINE__, __func__, true, true, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define notice_msg(...) log_wrapper(LOG_NOTICE, __FILE__, __LINE__, __func__, false, true, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define pnotice_msg(...) log_wrapper(LOG_NOTICE, __FILE__, __LINE__, __func__, true, true, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define error_msg_and_die(...) log_and_die_wrapper(LOG_ERR, __FILE__, __LINE__, __func__, false, true, __VA_ARGS__)
|
|
Packit Service |
779887 |
#define perror_msg_and_die(...) log_and_die_wrapper(LOG_ERR, __FILE__, __LINE__, __func__, true, true, __VA_ARGS__)
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
void log_wrapper(int level,
|
|
Packit Service |
779887 |
const char *file,
|
|
Packit Service |
779887 |
int line,
|
|
Packit Service |
779887 |
const char *func,
|
|
Packit Service |
779887 |
bool process_perror,
|
|
Packit Service |
779887 |
bool use_custom_logger,
|
|
Packit Service |
779887 |
const char *format, ...) __attribute__ ((format (printf, 7,8)));
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
void log_and_die_wrapper(int level,
|
|
Packit Service |
779887 |
const char *file,
|
|
Packit Service |
779887 |
int line,
|
|
Packit Service |
779887 |
const char *func,
|
|
Packit Service |
779887 |
bool process_perror,
|
|
Packit Service |
779887 |
bool use_custom_logger,
|
|
Packit Service |
779887 |
const char *format, ...) __attribute__ ((noreturn, format (printf, 7,8)));
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
struct strbuf
|
|
Packit Service |
779887 |
{
|
|
Packit Service |
779887 |
/* Size of the allocated buffer. Always > 0. */
|
|
Packit Service |
779887 |
int alloc;
|
|
Packit Service |
779887 |
/* Length of the string, without the ending \0. */
|
|
Packit Service |
779887 |
int len;
|
|
Packit Service |
779887 |
char *buf;
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/**
|
|
Packit Service |
779887 |
* Creates and initializes a new string buffer.
|
|
Packit Service |
779887 |
* @returns
|
|
Packit Service |
779887 |
* It never returns NULL. The returned pointer must be released by
|
|
Packit Service |
779887 |
* calling the function strbuf_free().
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define strbuf_new libreport_strbuf_new
|
|
Packit Service |
779887 |
struct strbuf *strbuf_new(void);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/**
|
|
Packit Service |
779887 |
* Releases the memory held by the string buffer.
|
|
Packit Service |
779887 |
* @param strbuf
|
|
Packit Service |
779887 |
* If the strbuf is NULL, no operation is performed.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define strbuf_free libreport_strbuf_free
|
|
Packit Service |
779887 |
void strbuf_free(struct strbuf *strbuf);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/**
|
|
Packit Service |
779887 |
* Releases the strbuf, but not the internal buffer. The internal
|
|
Packit Service |
779887 |
* string buffer is returned. Caller is responsible to release the
|
|
Packit Service |
779887 |
* returned memory using free().
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define strbuf_free_nobuf libreport_strbuf_free_nobuf
|
|
Packit Service |
779887 |
char* strbuf_free_nobuf(struct strbuf *strbuf);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/**
|
|
Packit Service |
779887 |
* The string content is set to an empty string, erasing any previous
|
|
Packit Service |
779887 |
* content and leaving its length at 0 characters.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define strbuf_clear libreport_strbuf_clear
|
|
Packit Service |
779887 |
void strbuf_clear(struct strbuf *strbuf);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/**
|
|
Packit Service |
779887 |
* The current content of the string buffer is extended by adding a
|
|
Packit Service |
779887 |
* character c at its end.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define strbuf_append_char libreport_strbuf_append_char
|
|
Packit Service |
779887 |
struct strbuf *strbuf_append_char(struct strbuf *strbuf, char c);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/**
|
|
Packit Service |
779887 |
* The current content of the string buffer is extended by adding a
|
|
Packit Service |
779887 |
* string str at its end.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define strbuf_append_str libreport_strbuf_append_str
|
|
Packit Service |
779887 |
struct strbuf *strbuf_append_str(struct strbuf *strbuf,
|
|
Packit Service |
779887 |
const char *str);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/**
|
|
Packit Service |
779887 |
* The current content of the string buffer is extended by inserting a
|
|
Packit Service |
779887 |
* string str at its beginning.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define strbuf_prepend_str libreport_strbuf_prepend_str
|
|
Packit Service |
779887 |
struct strbuf *strbuf_prepend_str(struct strbuf *strbuf,
|
|
Packit Service |
779887 |
const char *str);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/**
|
|
Packit Service |
779887 |
* The current content of the string buffer is extended by adding a
|
|
Packit Service |
779887 |
* sequence of data formatted as the format argument specifies.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define strbuf_append_strf libreport_strbuf_append_strf
|
|
Packit Service |
779887 |
struct strbuf *strbuf_append_strf(struct strbuf *strbuf,
|
|
Packit Service |
779887 |
const char *format, ...);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/**
|
|
Packit Service |
779887 |
* Same as strbuf_append_strf except that va_list is passed instead of
|
|
Packit Service |
779887 |
* variable number of arguments.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define strbuf_append_strfv libreport_strbuf_append_strfv
|
|
Packit Service |
779887 |
struct strbuf *strbuf_append_strfv(struct strbuf *strbuf,
|
|
Packit Service |
779887 |
const char *format, va_list p);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/**
|
|
Packit Service |
779887 |
* The current content of the string buffer is extended by inserting a
|
|
Packit Service |
779887 |
* sequence of data formatted as the format argument specifies at the
|
|
Packit Service |
779887 |
* buffer beginning.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define strbuf_prepend_strf libreport_strbuf_prepend_strf
|
|
Packit Service |
779887 |
struct strbuf *strbuf_prepend_strf(struct strbuf *strbuf,
|
|
Packit Service |
779887 |
const char *format, ...);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/**
|
|
Packit Service |
779887 |
* Same as strbuf_prepend_strf except that va_list is passed instead of
|
|
Packit Service |
779887 |
* variable number of arguments.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define strbuf_prepend_strfv libreport_strbuf_prepend_strfv
|
|
Packit Service |
779887 |
struct strbuf *strbuf_prepend_strfv(struct strbuf *strbuf,
|
|
Packit Service |
779887 |
const char *format, va_list p);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Returns command line of running program.
|
|
Packit Service |
779887 |
* Caller is responsible to free() the returned value.
|
|
Packit Service |
779887 |
* If the pid is not valid or command line can not be obtained,
|
|
Packit Service |
779887 |
* empty string is returned.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define open_proc_pid_dir libreport_open_proc_pid_dir
|
|
Packit Service |
779887 |
int open_proc_pid_dir(pid_t pid);
|
|
Packit Service |
779887 |
#define get_cmdline_at libreport_get_cmdline_at
|
|
Packit Service |
779887 |
char* get_cmdline_at(pid_t pid);
|
|
Packit Service |
779887 |
#define get_cmdline libreport_get_cmdline
|
|
Packit Service |
779887 |
char* get_cmdline(pid_t pid);
|
|
Packit Service |
779887 |
#define get_environ_at libreport_get_environ_at
|
|
Packit Service |
779887 |
char* get_environ_at(pid_t pid);
|
|
Packit Service |
779887 |
#define get_environ libreport_get_environ
|
|
Packit Service |
779887 |
char* get_environ(pid_t pid);
|
|
Packit Service |
779887 |
#define get_executable_at libreport_get_executable_at
|
|
Packit Service |
779887 |
char *get_executable_at(pid_t pid);
|
|
Packit Service |
779887 |
#define get_executable libreport_get_executable
|
|
Packit Service |
779887 |
char *get_executable(pid_t pid);
|
|
Packit Service |
779887 |
#define get_cwd_at libreport_get_cwd_at
|
|
Packit Service |
779887 |
char* get_cwd_at(pid_t pid);
|
|
Packit Service |
779887 |
#define get_cwd libreport_get_cwd
|
|
Packit Service |
779887 |
char* get_cwd(pid_t pid);
|
|
Packit Service |
779887 |
#define get_rootdir_at libreport_get_rootdir_at
|
|
Packit Service |
779887 |
char* get_rootdir_at(pid_t pid);
|
|
Packit Service |
779887 |
#define get_rootdir libreport_get_rootdir
|
|
Packit Service |
779887 |
char* get_rootdir(pid_t pid);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define get_fsuid libreport_get_fsuid
|
|
Packit Service |
779887 |
int get_fsuid(const char *proc_pid_status);
|
|
Packit Service |
779887 |
#define get_fsgid libreport_get_fsgid
|
|
Packit Service |
779887 |
int get_fsgid(const char *proc_pid_status);
|
|
Packit Service |
779887 |
#define dump_fd_info_at libreport_dump_fd_info_at
|
|
Packit Service |
779887 |
int dump_fd_info_at(int pid_proc_fd, FILE *dest);
|
|
Packit Service |
779887 |
#define dump_fd_info_ext libreport_dump_fd_info_ext
|
|
Packit Service |
779887 |
int dump_fd_info_ext(const char *dest_filename, const char *proc_pid_fd_path, uid_t uid, gid_t gid);
|
|
Packit Service |
779887 |
#define dump_fd_info libreport_dump_fd_info
|
|
Packit Service |
779887 |
int dump_fd_info(const char *dest_filename, const char *proc_pid_fd_path);
|
|
Packit Service |
779887 |
#define get_env_variable_ext libreport_get_env_variable_ext
|
|
Packit Service |
779887 |
int get_env_variable_ext(int fd, char delim, const char *name, char **value);
|
|
Packit Service |
779887 |
#define get_env_variable libreport_get_env_variable
|
|
Packit Service |
779887 |
int get_env_variable(pid_t pid, const char *name, char **value);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define PROC_NS_UNSUPPORTED ((ino_t)-1)
|
|
Packit Service |
779887 |
#define PROC_NS_ID_IPC 0
|
|
Packit Service |
779887 |
#define PROC_NS_ID_MNT 1
|
|
Packit Service |
779887 |
#define PROC_NS_ID_NET 2
|
|
Packit Service |
779887 |
#define PROC_NS_ID_PID 3
|
|
Packit Service |
779887 |
#define PROC_NS_ID_USER 4
|
|
Packit Service |
779887 |
#define PROC_NS_ID_UTS 5
|
|
Packit Service |
779887 |
#define PROC_NS_ID_CGROUP 6
|
|
Packit Service |
779887 |
static const char * libreport_proc_namespaces[] = { "ipc", "mnt", "net", "pid", "uts", "user", "cgroup", "pid_for_children" };
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
struct ns_ids {
|
|
Packit Service |
779887 |
ino_t nsi_ids[ARRAY_SIZE(libreport_proc_namespaces)];
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define get_ns_ids_at libreport_get_ns_ids_at
|
|
Packit Service |
779887 |
int get_ns_ids_at(int pid_proc_fd, struct ns_ids *ids);
|
|
Packit Service |
779887 |
#define get_ns_ids libreport_get_ns_ids
|
|
Packit Service |
779887 |
int get_ns_ids(pid_t pid, struct ns_ids *ids);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* These functions require a privileged user and does not work correctly in
|
|
Packit Service |
779887 |
* processes running in own PID namespace
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define process_has_own_root_at libreport_process_has_own_root_at
|
|
Packit Service |
779887 |
int process_has_own_root_at(int proc_pid_fd);
|
|
Packit Service |
779887 |
#define process_has_own_root libreport_process_has_own_root
|
|
Packit Service |
779887 |
int process_has_own_root(pid_t pid);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define get_pid_of_container_at libreport_get_pid_of_container_at
|
|
Packit Service |
779887 |
int get_pid_of_container_at(int pid_proc_fd, pid_t *init_pid);
|
|
Packit Service |
779887 |
#define get_pid_of_container libreport_get_pid_of_container
|
|
Packit Service |
779887 |
int get_pid_of_container(pid_t pid, pid_t *init_pid);
|
|
Packit Service |
779887 |
#define dump_namespace_diff_at libreport_dump_namespace_diff_at
|
|
Packit Service |
779887 |
int dump_namespace_diff_at(int base_pid_proc_fd, int tested_pid_proc_fd, FILE *dest);
|
|
Packit Service |
779887 |
#define dump_namespace_diff_ext libreport_dump_namespace_diff_ext
|
|
Packit Service |
779887 |
int dump_namespace_diff_ext(const char *dest_filename, pid_t base_pid, pid_t tested_pid, uid_t uid, gid_t gid);
|
|
Packit Service |
779887 |
#define dump_namespace_diff libreport_dump_namespace_diff
|
|
Packit Service |
779887 |
int dump_namespace_diff(const char *dest_filename, pid_t base_pid, pid_t tested_pid);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
enum
|
|
Packit Service |
779887 |
{
|
|
Packit Service |
779887 |
MOUNTINFO_INDEX_MOUNT_ID,
|
|
Packit Service |
779887 |
MOUNTINFO_INDEX_PARENT_ID,
|
|
Packit Service |
779887 |
MOUNTINFO_INDEX_MAJOR_MINOR,
|
|
Packit Service |
779887 |
MOUNTINFO_INDEX_ROOT,
|
|
Packit Service |
779887 |
MOUNTINFO_INDEX_MOUNT_POINT,
|
|
Packit Service |
779887 |
MOUNTINFO_INDEX_MOUNT_OPTIONS,
|
|
Packit Service |
779887 |
MOUNTINFO_INDEX_OPTIONAL_FIELDS,
|
|
Packit Service |
779887 |
MOUNTINFO_INDEX_FS_TYPE,
|
|
Packit Service |
779887 |
MOUNTINFO_INDEX_MOUNT_SOURCE,
|
|
Packit Service |
779887 |
MOUNTINFO_INDEX_SUPER_OPITONS,
|
|
Packit Service |
779887 |
_MOUNTINFO_INDEX_MAX,
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define MOUNTINFO_ROOT(val) (val.mntnf_items[MOUNTINFO_INDEX_ROOT])
|
|
Packit Service |
779887 |
#define MOUNTINFO_MOUNT_POINT(val) (val.mntnf_items[MOUNTINFO_INDEX_MOUNT_POINT])
|
|
Packit Service |
779887 |
#define MOUNTINFO_MOUNT_SOURCE(val) (val.mntnf_items[MOUNTINFO_INDEX_MOUNT_SOURCE])
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
struct mountinfo
|
|
Packit Service |
779887 |
{
|
|
Packit Service |
779887 |
/* 4 : root of the mount within the filesystem */
|
|
Packit Service |
779887 |
/* 5 : mount point relative to the process's root */
|
|
Packit Service |
779887 |
/* 10 : mount source: filesystem specific information or "none" */
|
|
Packit Service |
779887 |
/* but it mount source is preceded by 0 or more optional fields */
|
|
Packit Service |
779887 |
/* so the effective value is 9 */
|
|
Packit Service |
779887 |
char *mntnf_items[_MOUNTINFO_INDEX_MAX];
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
#define mountinfo_destroy libreport_mountinfo_destroy
|
|
Packit Service |
779887 |
void mountinfo_destroy(struct mountinfo *mntnf);
|
|
Packit Service |
779887 |
#define get_mountinfo_for_mount_point libreport_get_mountinfo_for_mount_point
|
|
Packit Service |
779887 |
int get_mountinfo_for_mount_point(FILE *fin, struct mountinfo *mntnf, const char *mnt_point);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Takes ptr to time_t, or NULL if you want to use current time.
|
|
Packit Service |
779887 |
* Returns "YYYY-MM-DD-hh:mm:ss" string.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define iso_date_string libreport_iso_date_string
|
|
Packit Service |
779887 |
char *iso_date_string(const time_t *pt);
|
|
Packit Service |
779887 |
#define LIBREPORT_ISO_DATE_STRING_SAMPLE "YYYY-MM-DD-hh:mm:ss"
|
|
Packit Service |
779887 |
#define LIBREPORT_ISO_DATE_STRING_FORMAT "%Y-%m-%d-%H:%M:%S"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Parses date into integer UNIX time stamp
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* @param date The parsed date string
|
|
Packit Service |
779887 |
* @param pt Return value
|
|
Packit Service |
779887 |
* @return 0 on success; otherwise non-0 number. -EINVAL if the parameter date
|
|
Packit Service |
779887 |
* does not match LIBREPORT_ISO_DATE_STRING_FORMAT
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define iso_date_string_parse libreport_iso_date_string_parse
|
|
Packit Service |
779887 |
int iso_date_string_parse(const char *date, time_t *pt);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
enum {
|
|
Packit Service |
779887 |
MAKEDESC_SHOW_FILES = (1 << 0),
|
|
Packit Service |
779887 |
MAKEDESC_SHOW_MULTILINE = (1 << 1),
|
|
Packit Service |
779887 |
MAKEDESC_SHOW_ONLY_LIST = (1 << 2),
|
|
Packit Service |
779887 |
MAKEDESC_WHITELIST = (1 << 3),
|
|
Packit Service |
779887 |
/* Include all URLs from FILENAME_REPORTED_TO element in the description text */
|
|
Packit Service |
779887 |
MAKEDESC_SHOW_URLS = (1 << 4),
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
#define make_description libreport_make_description
|
|
Packit Service |
779887 |
char *make_description(problem_data_t *problem_data, char **names_to_skip, unsigned max_text_size, unsigned desc_flags);
|
|
Packit Service |
779887 |
#define make_description_logger libreport_make_description_logger
|
|
Packit Service |
779887 |
char* make_description_logger(problem_data_t *problem_data, unsigned max_text_size);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* See man os-release(5) for details */
|
|
Packit Service |
779887 |
#define OSINFO_ID "ID"
|
|
Packit Service |
779887 |
#define OSINFO_NAME "NAME"
|
|
Packit Service |
779887 |
#define OSINFO_VERSION_ID "VERSION_ID"
|
|
Packit Service |
779887 |
#define OSINFO_PRETTY_NAME "PRETTY_NAME"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* @brief Loads a text in format of os-release(5) in to a map
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* Function doesn't check for format errors much. It just tries to avoid
|
|
Packit Service |
779887 |
* program errors. In case of error the function prints out a log message and
|
|
Packit Service |
779887 |
* continues in parsing.
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* @param osinfo_bytes Non-NULL pointer to osinfo bytes.
|
|
Packit Service |
779887 |
* @param osinfo The map where result is stored
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define parse_osinfo libreport_parse_osinfo
|
|
Packit Service |
779887 |
void parse_osinfo(const char *osinfo_bytes, map_string_t *osinfo);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* @brief Builds product string and product's version string for Bugzilla
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* At first tries to get strings from the os specific variables
|
|
Packit Service |
779887 |
* (REDHAT_BUGZILLA_PRODUCT, REDHAT_BUGZILLA_PRODUCT_VERSION) if no such
|
|
Packit Service |
779887 |
* variables are found, uses NAME key for the product and VERSION_ID key for
|
|
Packit Service |
779887 |
* the product's version. If neither NAME nor VERSION_ID are provided fallbacks
|
|
Packit Service |
779887 |
* to parsing of os_release which should be stored under PRETTY_NAME key.
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* https://bugzilla.redhat.com/show_bug.cgi?id=950373
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* @param osinfo Input data from which the values are built
|
|
Packit Service |
779887 |
* @param produc Non-NULL pointer where pointer to malloced string will be stored. Memory must be released by free()
|
|
Packit Service |
779887 |
* @param version Non-NULL pointer where pointer to malloced string will be stored. Memory must be released by free()
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define parse_osinfo_for_bz libreport_parse_osinfo_for_bz
|
|
Packit Service |
779887 |
void parse_osinfo_for_bz(map_string_t *osinfo, char **product, char **version);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* @brief Extract BUG_REPORT_URL from os-release
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* A default location for bug reports can be stored in os-release.
|
|
Packit Service |
779887 |
* This extracts the value if present and stores it in url.
|
|
Packit Service |
779887 |
* If unset, url will become NULL
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* https://github.com/abrt/libreport/issues/459
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* @param osinfo Input data from which the values are built
|
|
Packit Service |
779887 |
* @param url Non-NULL pointer where pointer to malloced string will be stored. Memory must be released by free()
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define parse_osinfo_for_bug_url libreport_parse_osinfo_for_bug_url
|
|
Packit Service |
779887 |
void parse_osinfo_for_bug_url(map_string_t *osinfo, char** url);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* @brief Builds product string and product's version string for Red Hat Support
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* At first tries to get strings from the os specific variables
|
|
Packit Service |
779887 |
* (REDHAT_SUPPORT_PRODUCT, REDHAT_SUPPORT_PRODUCT_VERSION) if no such
|
|
Packit Service |
779887 |
* variables are found, uses NAME key for the product and VERSION_ID key for
|
|
Packit Service |
779887 |
* the product's version. If no NAME nor VERSION_ID are provided fallbacks to
|
|
Packit Service |
779887 |
* parsing of os_release which should be stored under PRETTY_NAME key.
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* https://bugzilla.redhat.com/show_bug.cgi?id=950373
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* @param osinfo Input data from which the values are built
|
|
Packit Service |
779887 |
* @param produc Non-NULL pointer where pointer to malloced string will be stored. Memory must be released by free()
|
|
Packit Service |
779887 |
* @param version Non-NULL pointer where pointer to malloced string will be stored. Memory must be released by free()
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define parse_osinfo_for_rhts libreport_parse_osinfo_for_rhts
|
|
Packit Service |
779887 |
void parse_osinfo_for_rhts(map_string_t *osinfo, char **product, char **version);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define parse_release_for_bz libreport_parse_release_for_bz
|
|
Packit Service |
779887 |
void parse_release_for_bz(const char *pRelease, char **product, char **version);
|
|
Packit Service |
779887 |
#define parse_release_for_rhts libreport_parse_release_for_rhts
|
|
Packit Service |
779887 |
void parse_release_for_rhts(const char *pRelease, char **product, char **version);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/**
|
|
Packit Service |
779887 |
* Loads settings and stores it in second parameter. On success it
|
|
Packit Service |
779887 |
* returns true, otherwise returns false.
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* @param path A path of config file.
|
|
Packit Service |
779887 |
* Config file consists of "key=value" lines.
|
|
Packit Service |
779887 |
* @param settings A read plugin's settings.
|
|
Packit Service |
779887 |
* @param skipKeysWithoutValue
|
|
Packit Service |
779887 |
* If true, lines in format "key=" (without value) are skipped.
|
|
Packit Service |
779887 |
* Otherwise empty value "" is inserted into pSettings.
|
|
Packit Service |
779887 |
* TODO: all callers pass "false" here, drop this parameter
|
|
Packit Service |
779887 |
* in mid-2013 if no user for it is identified.
|
|
Packit Service |
779887 |
* @return if it success it returns true, otherwise it returns false.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define load_conf_file libreport_load_conf_file
|
|
Packit Service |
779887 |
bool load_conf_file(const char *pPath, map_string_t *settings, bool skipKeysWithoutValue);
|
|
Packit Service |
779887 |
#define load_plugin_conf_file libreport_load_plugin_conf_file
|
|
Packit Service |
779887 |
bool load_plugin_conf_file(const char *name, map_string_t *settings, bool skipKeysWithoutValue);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define get_user_conf_base_dir libreport_get_user_conf_base_dir
|
|
Packit Service |
779887 |
const char *get_user_conf_base_dir(void);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define load_conf_file_from_dirs libreport_load_conf_file_from_dirs
|
|
Packit Service |
779887 |
bool load_conf_file_from_dirs(const char *base_name, const char *const *directories, map_string_t *settings, bool skipKeysWithoutValue);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
enum {
|
|
Packit Service |
779887 |
CONF_DIR_FLAG_NONE = 0,
|
|
Packit Service |
779887 |
CONF_DIR_FLAG_OPTIONAL = 1,
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define load_conf_file_from_dirs_ext libreport_load_conf_file_from_dirs_ext
|
|
Packit Service |
779887 |
bool load_conf_file_from_dirs_ext(const char *base_name, const char *const *directories,
|
|
Packit Service |
779887 |
const int * dir_flags, map_string_t *settings,
|
|
Packit Service |
779887 |
bool skipKeysWithoutValue);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define save_conf_file libreport_save_conf_file
|
|
Packit Service |
779887 |
bool save_conf_file(const char *path, map_string_t *settings);
|
|
Packit Service |
779887 |
#define save_plugin_conf_file libreport_save_plugin_conf_file
|
|
Packit Service |
779887 |
bool save_plugin_conf_file(const char *name, map_string_t *settings);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define save_app_conf_file libreport_save_app_conf_file
|
|
Packit Service |
779887 |
bool save_app_conf_file(const char* application_name, map_string_t *settings);
|
|
Packit Service |
779887 |
#define load_app_conf_file libreport_load_app_conf_file
|
|
Packit Service |
779887 |
bool load_app_conf_file(const char *application_name, map_string_t *settings);
|
|
Packit Service |
779887 |
#define set_app_user_setting libreport_set_app_user_setting
|
|
Packit Service |
779887 |
void set_app_user_setting(map_string_t *settings, const char *name, const char *value);
|
|
Packit Service |
779887 |
#define get_app_user_setting libreport_get_app_user_setting
|
|
Packit Service |
779887 |
const char *get_app_user_setting(map_string_t *settings, const char *name);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define save_user_settings libreport_save_user_settings
|
|
Packit Service |
779887 |
bool save_user_settings(void);
|
|
Packit Service |
779887 |
#define load_user_settings libreport_load_user_settings
|
|
Packit Service |
779887 |
bool load_user_settings(const char *application_name);
|
|
Packit Service |
779887 |
#define set_user_setting libreport_set_user_setting
|
|
Packit Service |
779887 |
void set_user_setting(const char *name, const char *value);
|
|
Packit Service |
779887 |
#define get_user_setting libreport_get_user_setting
|
|
Packit Service |
779887 |
const char *get_user_setting(const char *name);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* filename is expected to exist in CONF_DIR
|
|
Packit Service |
779887 |
* usually /etc/libreport
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define load_forbidden_words libreport_load_forbidden_words
|
|
Packit Service |
779887 |
GList *load_words_from_file(const char *filename);
|
|
Packit Service |
779887 |
#define get_file_list libreport_get_file_list
|
|
Packit Service |
779887 |
GList *get_file_list(const char *path, const char *ext);
|
|
Packit Service |
779887 |
#define free_file_list libreport_free_file_list
|
|
Packit Service |
779887 |
void free_file_list(GList *filelist);
|
|
Packit Service |
779887 |
#define new_file_obj libreport_new_file_obj
|
|
Packit Service |
779887 |
file_obj_t *new_file_obj(const char* fullpath, const char* filename);
|
|
Packit Service |
779887 |
#define free_file_obj libreport_free_file_obj
|
|
Packit Service |
779887 |
void free_file_obj(file_obj_t *f);
|
|
Packit Service |
779887 |
#define parse_delimited_list libreport_parse_delimited_list
|
|
Packit Service |
779887 |
GList *parse_delimited_list(char* list, const char *delim);
|
|
Packit Service |
779887 |
#define parse_list libreport_parse_list
|
|
Packit Service |
779887 |
GList *parse_list(const char* list);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Connect to abrtd over unix domain socket, issue DELETE command */
|
|
Packit Service |
779887 |
int delete_dump_dir_possibly_using_abrtd(const char *dump_dir_name);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Tries to create a copy of dump_dir_name in base_dir, with same or similar basename.
|
|
Packit Service |
779887 |
* Returns NULL if copying failed. In this case, logs a message before returning. */
|
|
Packit Service |
779887 |
#define steal_directory libreport_steal_directory
|
|
Packit Service |
779887 |
struct dump_dir *steal_directory(const char *base_dir, const char *dump_dir_name);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Resolves if the given user is in given group
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* @param uid user ID
|
|
Packit Service |
779887 |
* @param gid group ID
|
|
Packit Service |
779887 |
* @returns TRUE in case the user is in the group otherwise returns FALSE
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define uid_in_group libreport_uid_in_group
|
|
Packit Service |
779887 |
bool uid_in_group(uid_t uid, gid_t gid);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Tries to open dump_dir_name with writing access. If function needs to steal
|
|
Packit Service |
779887 |
* directory calls ask_continue(new base dir, dump dir) callback to ask user
|
|
Packit Service |
779887 |
* for permission. If ask_continue param is NULL the function thinks that an
|
|
Packit Service |
779887 |
* answer is positive and steals directory.
|
|
Packit Service |
779887 |
* Returns NULL if opening failed or if stealing was dismissed. In this case,
|
|
Packit Service |
779887 |
* logs a message before returning. */
|
|
Packit Service |
779887 |
#define open_directory_for_writing libreport_open_directory_for_writing
|
|
Packit Service |
779887 |
struct dump_dir *open_directory_for_writing(
|
|
Packit Service |
779887 |
const char *dump_dir_name,
|
|
Packit Service |
779887 |
bool (*ask_continue)(const char *, const char *));
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
// Files bigger than this are never considered to be text.
|
|
Packit Service |
779887 |
//
|
|
Packit Service |
779887 |
// Started at 64k limit. But _some_ limit is necessary:
|
|
Packit Service |
779887 |
// fields declared "text" may end up in editing fields and such.
|
|
Packit Service |
779887 |
// We don't want to accidentally end up with 100meg text in a textbox!
|
|
Packit Service |
779887 |
// So, don't remove this. If you really need to, raise the limit.
|
|
Packit Service |
779887 |
//
|
|
Packit Service |
779887 |
// Bumped up to 200k: saw 124740 byte /proc/PID/smaps file
|
|
Packit Service |
779887 |
// Bumped up to 500k: saw 375252 byte anaconda traceback file
|
|
Packit Service |
779887 |
// Bumped up to 1M: bugzilla.redhat.com/show_bug.cgi?id=746727
|
|
Packit Service |
779887 |
// mentions 853646 byte anaconda-tb-* file.
|
|
Packit Service |
779887 |
// Bumped up to 8M: bugzilla.redhat.com/show_bug.cgi?id=887570
|
|
Packit Service |
779887 |
// (anaconda-tb file of 1.38 MBytes)
|
|
Packit Service |
779887 |
//
|
|
Packit Service |
779887 |
#define CD_MAX_TEXT_SIZE (8*1024*1024)
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
// Text bigger than this usually is attached, not added inline
|
|
Packit Service |
779887 |
// was 2k, 20kb is too much, let's try 4kb
|
|
Packit Service |
779887 |
//
|
|
Packit Service |
779887 |
// For bug databases
|
|
Packit Service |
779887 |
#define CD_TEXT_ATT_SIZE_BZ (4*1024)
|
|
Packit Service |
779887 |
// For dumping problem data into a text file, email, etc
|
|
Packit Service |
779887 |
#define CD_TEXT_ATT_SIZE_LOGGER (CD_MAX_TEXT_SIZE)
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
// Filenames in problem directory:
|
|
Packit Service |
779887 |
// filled by a hook:
|
|
Packit Service |
779887 |
#define FILENAME_TIME "time" /* mandatory */
|
|
Packit Service |
779887 |
#define FILENAME_LAST_OCCURRENCE "last_occurrence" /* optional */
|
|
Packit Service |
779887 |
#define FILENAME_REASON "reason" /* mandatory? */
|
|
Packit Service |
779887 |
#define FILENAME_UID "uid" /* mandatory? */
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/*
|
|
Packit Service |
779887 |
* "analyzer" is to be gradually changed to "type":
|
|
Packit Service |
779887 |
* For now, we fetch and look at "analyzer" element,
|
|
Packit Service |
779887 |
* but we always save both "analyzer" and "type" (with same contents).
|
|
Packit Service |
779887 |
* By 2013, we switch to looking at "type". Then we will stop generating
|
|
Packit Service |
779887 |
* "analyzer" element.
|
|
Packit Service |
779887 |
* ----
|
|
Packit Service |
779887 |
* Update 2015: based on the recent changes where we have introduced several
|
|
Packit Service |
779887 |
* tools generating one problem type, we have decided to retain 'analyzer'
|
|
Packit Service |
779887 |
* file, but it shall contain string identifier of a tool that created the
|
|
Packit Service |
779887 |
* problem.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define FILENAME_ANALYZER "analyzer"
|
|
Packit Service |
779887 |
#define FILENAME_TYPE "type"
|
|
Packit Service |
779887 |
#define FILENAME_EXECUTABLE "executable"
|
|
Packit Service |
779887 |
#define FILENAME_PID "pid"
|
|
Packit Service |
779887 |
#define FILENAME_TID "tid"
|
|
Packit Service |
779887 |
#define FILENAME_GLOBAL_PID "global_pid"
|
|
Packit Service |
779887 |
#define FILENAME_PWD "pwd"
|
|
Packit Service |
779887 |
#define FILENAME_ROOTDIR "rootdir"
|
|
Packit Service |
779887 |
#define FILENAME_BINARY "binary"
|
|
Packit Service |
779887 |
#define FILENAME_CMDLINE "cmdline"
|
|
Packit Service |
779887 |
#define FILENAME_COREDUMP "coredump"
|
|
Packit Service |
779887 |
#define FILENAME_CGROUP "cgroup"
|
|
Packit Service |
779887 |
#define FILENAME_BACKTRACE "backtrace"
|
|
Packit Service |
779887 |
#define FILENAME_MAPS "maps"
|
|
Packit Service |
779887 |
#define FILENAME_SMAPS "smaps"
|
|
Packit Service |
779887 |
#define FILENAME_PROC_PID_STATUS "proc_pid_status"
|
|
Packit Service |
779887 |
#define FILENAME_ENVIRON "environ"
|
|
Packit Service |
779887 |
#define FILENAME_LIMITS "limits"
|
|
Packit Service |
779887 |
#define FILENAME_OPEN_FDS "open_fds"
|
|
Packit Service |
779887 |
#define FILENAME_MOUNTINFO "mountinfo"
|
|
Packit Service |
779887 |
#define FILENAME_NAMESPACES "namespaces"
|
|
Packit Service |
779887 |
#define FILENAME_CPUINFO "cpuinfo"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Global problem identifier which is usually generated by some "analyze_*"
|
|
Packit Service |
779887 |
* event because it may take a lot of time to obtain strong problem
|
|
Packit Service |
779887 |
* identification */
|
|
Packit Service |
779887 |
#define FILENAME_DUPHASH "duphash"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
// Name of the function where the application crashed.
|
|
Packit Service |
779887 |
// Optional.
|
|
Packit Service |
779887 |
#define FILENAME_CRASH_FUNCTION "crash_function"
|
|
Packit Service |
779887 |
#define FILENAME_ARCHITECTURE "architecture"
|
|
Packit Service |
779887 |
#define FILENAME_KERNEL "kernel"
|
|
Packit Service |
779887 |
/*
|
|
Packit Service |
779887 |
* From /etc/os-release
|
|
Packit Service |
779887 |
* os_release filename name is alredy occupied by /etc/redhat-release (see
|
|
Packit Service |
779887 |
* below) in sake of backward compatibility /etc/os-release is stored in
|
|
Packit Service |
779887 |
* os_info file
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define FILENAME_OS_INFO "os_info"
|
|
Packit Service |
779887 |
#define FILENAME_OS_INFO_IN_ROOTDIR "os_info_in_rootdir"
|
|
Packit Service |
779887 |
// From /etc/system-release or /etc/redhat-release
|
|
Packit Service |
779887 |
#define FILENAME_OS_RELEASE "os_release"
|
|
Packit Service |
779887 |
#define FILENAME_OS_RELEASE_IN_ROOTDIR "os_release_in_rootdir"
|
|
Packit Service |
779887 |
// Filled by <what?>
|
|
Packit Service |
779887 |
#define FILENAME_PACKAGE "package"
|
|
Packit Service |
779887 |
#define FILENAME_COMPONENT "component"
|
|
Packit Service |
779887 |
#define FILENAME_COMMENT "comment"
|
|
Packit Service |
779887 |
#define FILENAME_RATING "backtrace_rating"
|
|
Packit Service |
779887 |
#define FILENAME_HOSTNAME "hostname"
|
|
Packit Service |
779887 |
// Optional. Set to "1" by abrt-handle-upload for every unpacked dump
|
|
Packit Service |
779887 |
#define FILENAME_REMOTE "remote"
|
|
Packit Service |
779887 |
#define FILENAME_TAINTED "kernel_tainted"
|
|
Packit Service |
779887 |
#define FILENAME_TAINTED_SHORT "kernel_tainted_short"
|
|
Packit Service |
779887 |
#define FILENAME_TAINTED_LONG "kernel_tainted_long"
|
|
Packit Service |
779887 |
#define FILENAME_VMCORE "vmcore"
|
|
Packit Service |
779887 |
#define FILENAME_KERNEL_LOG "kernel_log"
|
|
Packit Service |
779887 |
// File created by createAlertSignature() from libreport's python module
|
|
Packit Service |
779887 |
// The file should contain a description of an alert
|
|
Packit Service |
779887 |
#define FILENAME_DESCRIPTION "description"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Local problem identifier (weaker than global identifier) designed for fast
|
|
Packit Service |
779887 |
* local for fast local duplicate identification. This file is usually provided
|
|
Packit Service |
779887 |
* by crashed application (problem creator).
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define FILENAME_UUID "uuid"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define FILENAME_COUNT "count"
|
|
Packit Service |
779887 |
/* Multi-line list of places problem was reported.
|
|
Packit Service |
779887 |
* Recommended line format:
|
|
Packit Service |
779887 |
* "Reporter: VAR=VAL VAR=VAL"
|
|
Packit Service |
779887 |
* Use add_reported_to(dd, "line_without_newline"): it adds line
|
|
Packit Service |
779887 |
* only if it is not already there.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define FILENAME_REPORTED_TO "reported_to"
|
|
Packit Service |
779887 |
#define FILENAME_EVENT_LOG "event_log"
|
|
Packit Service |
779887 |
/*
|
|
Packit Service |
779887 |
* If exists, should contain a full sentence (with trailing period)
|
|
Packit Service |
779887 |
* which describes why this problem should not be reported.
|
|
Packit Service |
779887 |
* Example: "Your laptop firmware 1.9a is buggy, version 1.10 contains the fix."
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define FILENAME_NOT_REPORTABLE "not-reportable"
|
|
Packit Service |
779887 |
#define FILENAME_CORE_BACKTRACE "core_backtrace"
|
|
Packit Service |
779887 |
#define FILENAME_REMOTE_RESULT "remote_result"
|
|
Packit Service |
779887 |
#define FILENAME_PKG_EPOCH "pkg_epoch"
|
|
Packit Service |
779887 |
#define FILENAME_PKG_NAME "pkg_name"
|
|
Packit Service |
779887 |
#define FILENAME_PKG_VERSION "pkg_version"
|
|
Packit Service |
779887 |
#define FILENAME_PKG_RELEASE "pkg_release"
|
|
Packit Service |
779887 |
#define FILENAME_PKG_ARCH "pkg_arch"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* RHEL packages - Red Hat, Inc. */
|
|
Packit Service |
779887 |
#define FILENAME_PKG_VENDOR "pkg_vendor"
|
|
Packit Service |
779887 |
/* RHEL keys - https://access.redhat.com/security/team/key */
|
|
Packit Service |
779887 |
#define FILENAME_PKG_FINGERPRINT "pkg_fingerprint"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define FILENAME_USERNAME "username"
|
|
Packit Service |
779887 |
#define FILENAME_ABRT_VERSION "abrt_version"
|
|
Packit Service |
779887 |
#define FILENAME_EXPLOITABLE "exploitable"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* reproducible element is used by functions from problem_data.h */
|
|
Packit Service |
779887 |
#define FILENAME_REPRODUCIBLE "reproducible"
|
|
Packit Service |
779887 |
#define FILENAME_REPRODUCER "reproducer"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* File names related to Anaconda problems
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define FILENAME_KICKSTART_CFG "ks.cfg"
|
|
Packit Service |
779887 |
#define FILENAME_ANACONDA_TB "anaconda-tb"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Containers
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define FILENAME_CONTAINER "container"
|
|
Packit Service |
779887 |
#define FILENAME_CONTAINER_ID "container_id"
|
|
Packit Service |
779887 |
#define FILENAME_CONTAINER_UUID "container_uuid"
|
|
Packit Service |
779887 |
#define FILENAME_CONTAINER_IMAGE "container_image"
|
|
Packit Service |
779887 |
#define FILENAME_CONTAINER_CMDLINE "container_cmdline"
|
|
Packit Service |
779887 |
/* Container root file-system directory as seen from the host. */
|
|
Packit Service |
779887 |
#define FILENAME_CONTAINER_ROOTFS "container_rootfs"
|
|
Packit Service |
779887 |
#define FILENAME_DOCKER_INSPECT "docker_inspect"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Type of catched exception
|
|
Packit Service |
779887 |
* Optional.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define FILENAME_EXCEPTION_TYPE "exception_type"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
// Not stored as files, added "on the fly":
|
|
Packit Service |
779887 |
#define CD_DUMPDIR "Directory"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define cmp_problem_data libreport_cmp_problem_data
|
|
Packit Service |
779887 |
gint cmp_problem_data(gconstpointer a, gconstpointer b, gpointer filename);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
//UNUSED:
|
|
Packit Service |
779887 |
//// "Which events are possible (make sense) on this dump dir?"
|
|
Packit Service |
779887 |
//// (a string with "\n" terminated event names)
|
|
Packit Service |
779887 |
//#define CD_EVENTS "Events"
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* FILENAME_EVENT_LOG is trimmed to below LOW_WATERMARK
|
|
Packit Service |
779887 |
* when it reaches HIGH_WATERMARK size
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
enum {
|
|
Packit Service |
779887 |
EVENT_LOG_HIGH_WATERMARK = 30 * 1024,
|
|
Packit Service |
779887 |
EVENT_LOG_LOW_WATERMARK = 20 * 1024,
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define log_problem_data libreport_log_problem_data
|
|
Packit Service |
779887 |
void log_problem_data(problem_data_t *problem_data, const char *pfx);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
extern int g_libreport_inited;
|
|
Packit Service |
779887 |
void libreport_init(void);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define INITIALIZE_LIBREPORT() \
|
|
Packit Service |
779887 |
do \
|
|
Packit Service |
779887 |
{ \
|
|
Packit Service |
779887 |
if (!g_libreport_inited) \
|
|
Packit Service |
779887 |
{ \
|
|
Packit Service |
779887 |
g_libreport_inited = 1; \
|
|
Packit Service |
779887 |
libreport_init(); \
|
|
Packit Service |
779887 |
} \
|
|
Packit Service |
779887 |
} \
|
|
Packit Service |
779887 |
while (0)
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
const char *abrt_init(char **argv);
|
|
Packit Service |
779887 |
#define export_abrt_envvars libreport_export_abrt_envvars
|
|
Packit Service |
779887 |
void export_abrt_envvars(int pfx);
|
|
Packit Service |
779887 |
#define g_progname libreport_g_progname
|
|
Packit Service |
779887 |
extern const char *g_progname;
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
enum parse_opt_type {
|
|
Packit Service |
779887 |
OPTION_BOOL,
|
|
Packit Service |
779887 |
OPTION_GROUP,
|
|
Packit Service |
779887 |
OPTION_STRING,
|
|
Packit Service |
779887 |
OPTION_INTEGER,
|
|
Packit Service |
779887 |
OPTION_OPTSTRING,
|
|
Packit Service |
779887 |
OPTION_LIST,
|
|
Packit Service |
779887 |
OPTION_END,
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
struct options {
|
|
Packit Service |
779887 |
enum parse_opt_type type;
|
|
Packit Service |
779887 |
int short_name;
|
|
Packit Service |
779887 |
const char *long_name;
|
|
Packit Service |
779887 |
void *value;
|
|
Packit Service |
779887 |
const char *argh;
|
|
Packit Service |
779887 |
const char *help;
|
|
Packit Service |
779887 |
};
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/*
|
|
Packit Service |
779887 |
* s - short_name
|
|
Packit Service |
779887 |
* l - long_name
|
|
Packit Service |
779887 |
* v - value
|
|
Packit Service |
779887 |
* a - option parameter name (for help text)
|
|
Packit Service |
779887 |
* h - help
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define OPT_END() { OPTION_END }
|
|
Packit Service |
779887 |
#define OPT_GROUP(h) { OPTION_GROUP, 0, NULL, NULL, NULL, (h) }
|
|
Packit Service |
779887 |
#define OPT_BOOL( s, l, v, h) { OPTION_BOOL , (s), (l), (v), NULL , (h) }
|
|
Packit Service |
779887 |
#define OPT_INTEGER( s, l, v, h) { OPTION_INTEGER , (s), (l), (v), "NUM", (h) }
|
|
Packit Service |
779887 |
#define OPT_STRING( s, l, v, a, h) { OPTION_STRING , (s), (l), (v), (a) , (h) }
|
|
Packit Service |
779887 |
#define OPT_OPTSTRING(s, l, v, a, h) { OPTION_OPTSTRING, (s), (l), (v), (a) , (h) }
|
|
Packit Service |
779887 |
#define OPT_LIST( s, l, v, a, h) { OPTION_LIST , (s), (l), (v), (a) , (h) }
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define OPT__VERBOSE(v) OPT_BOOL('v', "verbose", (v), _("Be verbose"))
|
|
Packit Service |
779887 |
#define OPT__DUMP_DIR(v) OPT_STRING('d', "problem-dir", (v), "DIR", _("Problem directory"))
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define parse_opts libreport_parse_opts
|
|
Packit Service |
779887 |
unsigned parse_opts(int argc, char **argv, const struct options *opt,
|
|
Packit Service |
779887 |
const char *usage);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#define show_usage_and_die libreport_show_usage_and_die
|
|
Packit Service |
779887 |
void show_usage_and_die(const char *usage, const struct options *opt) NORETURN;
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Can't include "abrt_curl.h", it's not a public API.
|
|
Packit Service |
779887 |
* Resorting to just forward-declaring the struct we need.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
struct abrt_post_state;
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
/* Decomposes uri to its base elements, removes userinfo out of the hostname and
|
|
Packit Service |
779887 |
* composes a new uri without userinfo.
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* The function does not validate the url.
|
|
Packit Service |
779887 |
*
|
|
Packit Service |
779887 |
* @param uri The uri that might contain userinfo
|
|
Packit Service |
779887 |
* @param result The userinfo free uri will be store here. Cannot be null. Must
|
|
Packit Service |
779887 |
* be de-allocated by free.
|
|
Packit Service |
779887 |
* @param scheme Scheme of the uri. Can be NULL. Result can be NULL. Result
|
|
Packit Service |
779887 |
* must be de-allocated by free.
|
|
Packit Service |
779887 |
* @param hostname Hostname of the uri. Can be NULL. Result can be NULL. Result
|
|
Packit Service |
779887 |
* must be de-allocated by free.
|
|
Packit Service |
779887 |
* @param username Username of the uri. Can be NULL. Result can be NULL. Result
|
|
Packit Service |
779887 |
* must be de-allocated by free.
|
|
Packit Service |
779887 |
* @param password Password of the uri. Can be NULL. Result can be NULL. Result
|
|
Packit Service |
779887 |
* must be de-allocated by free.
|
|
Packit Service |
779887 |
* @param location Location of the uri. Can be NULL. Result is never NULL. Result
|
|
Packit Service |
779887 |
* must be de-allocated by free.
|
|
Packit Service |
779887 |
*/
|
|
Packit Service |
779887 |
#define uri_userinfo_remove libreport_uri_userinfo_remove
|
|
Packit Service |
779887 |
int uri_userinfo_remove(const char *uri, char **result, char **scheme, char **hostname, char **username, char **password, char **location);
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#ifdef __cplusplus
|
|
Packit Service |
779887 |
}
|
|
Packit Service |
779887 |
#endif
|
|
Packit Service |
779887 |
|
|
Packit Service |
779887 |
#endif
|