diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2011-01-14 14:02:07 +0100 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2011-01-14 14:02:07 +0100 |
commit | 6cff54c0b97d162e8c0461a28b10c260495458f2 (patch) | |
tree | 45742187276df0cf25b1a9b463eddeeced08c379 | |
parent | dc4d0c9a4034769089776755f80c20159ed26653 (diff) | |
download | abrt-6cff54c0b97d162e8c0461a28b10c260495458f2.tar.gz abrt-6cff54c0b97d162e8c0461a28b10c260495458f2.tar.xz abrt-6cff54c0b97d162e8c0461a28b10c260495458f2.zip |
preliminary cleanup patches
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r-- | src/daemon/abrt-handle-crashdump.c | 2 | ||||
-rw-r--r-- | src/include/abrtlib.h | 82 | ||||
-rw-r--r-- | src/lib/parse_options.c | 22 | ||||
-rw-r--r-- | src/lib/parse_options.h | 22 |
4 files changed, 61 insertions, 67 deletions
diff --git a/src/daemon/abrt-handle-crashdump.c b/src/daemon/abrt-handle-crashdump.c index 737de408..2286de60 100644 --- a/src/daemon/abrt-handle-crashdump.c +++ b/src/daemon/abrt-handle-crashdump.c @@ -64,7 +64,7 @@ int main(int argc, char **argv) unsigned opts = parse_opts(argc, argv, program_options, program_usage); if (!(opts & (OPT_e|OPT_l))) - parse_usage_and_die(program_usage, program_options); + show_usage_and_die(program_usage, program_options); putenv(xasprintf("ABRT_VERBOSE=%u", g_verbose)); if (opts & OPT_s) { diff --git a/src/include/abrtlib.h b/src/include/abrtlib.h index 88e52fff..0c0d4be4 100644 --- a/src/include/abrtlib.h +++ b/src/include/abrtlib.h @@ -147,24 +147,24 @@ int xatoi_positive(const char *numstr); //unsigned monotonic_sec(void); enum { - /* on return, pipefds[1] is fd to which parent may write - * and deliver data to child's stdin: */ - EXECFLG_INPUT = 1 << 0, - /* on return, pipefds[0] is fd from which parent may read - * child's stdout: */ - EXECFLG_OUTPUT = 1 << 1, - /* open child's stdin to /dev/null: */ - EXECFLG_INPUT_NUL = 1 << 2, - /* open child's stdout to /dev/null: */ - EXECFLG_OUTPUT_NUL = 1 << 3, - /* redirect child's stderr to stdout: */ - EXECFLG_ERR2OUT = 1 << 4, - /* open child's stderr to /dev/null: */ - EXECFLG_ERR_NUL = 1 << 5, - /* suppress perror_msg("Can't execute 'foo'") if exec fails */ - EXECFLG_QUIET = 1 << 6, - EXECFLG_SETGUID = 1 << 7, - EXECFLG_SETSID = 1 << 8, + /* on return, pipefds[1] is fd to which parent may write + * and deliver data to child's stdin: */ + EXECFLG_INPUT = 1 << 0, + /* on return, pipefds[0] is fd from which parent may read + * child's stdout: */ + EXECFLG_OUTPUT = 1 << 1, + /* open child's stdin to /dev/null: */ + EXECFLG_INPUT_NUL = 1 << 2, + /* open child's stdout to /dev/null: */ + EXECFLG_OUTPUT_NUL = 1 << 3, + /* redirect child's stderr to stdout: */ + EXECFLG_ERR2OUT = 1 << 4, + /* open child's stderr to /dev/null: */ + EXECFLG_ERR_NUL = 1 << 5, + /* suppress perror_msg("Can't execute 'foo'") if exec fails */ + EXECFLG_QUIET = 1 << 6, + EXECFLG_SETGUID = 1 << 7, + EXECFLG_SETSID = 1 << 8, }; /* Returns pid */ #define fork_execv_on_steroids abrt_fork_execv_on_steroids @@ -178,49 +178,9 @@ pid_t fork_execv_on_steroids(int flags, * 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); - -//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); + const char *cmd, + const char *dir, + size_t *size_p); /* Random utility functions */ diff --git a/src/lib/parse_options.c b/src/lib/parse_options.c index c1a2c297..6f022551 100644 --- a/src/lib/parse_options.c +++ b/src/lib/parse_options.c @@ -1,3 +1,21 @@ +/* + Copyright (C) 2010 ABRT team + Copyright (C) 2010 RedHat Inc + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ #include <getopt.h> #include "abrtlib.h" @@ -6,7 +24,7 @@ #define USAGE_OPTS_WIDTH 24 #define USAGE_GAP 2 -void parse_usage_and_die(const char *usage, const struct options *opt) +void show_usage_and_die(const char *usage, const struct options *opt) { fprintf(stderr, _("Usage: %s\n"), usage); @@ -144,7 +162,7 @@ unsigned parse_opts(int argc, char **argv, const struct options *opt, { free(longopts); strbuf_free(shortopts); - parse_usage_and_die(usage, opt); + show_usage_and_die(usage, opt); } for (ii = 0; ii < size; ++ii) diff --git a/src/lib/parse_options.h b/src/lib/parse_options.h index 218cc2bf..55ca0e2d 100644 --- a/src/lib/parse_options.h +++ b/src/lib/parse_options.h @@ -1,8 +1,24 @@ +/* + Copyright (C) 2010 ABRT team + Copyright (C) 2010 RedHat Inc + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ #ifndef PARSE_OPTIONS_H #define PARSE_OPTIONS_H - #ifdef __cplusplus extern "C" { #endif @@ -45,8 +61,8 @@ struct options { 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); +#define show_usage_and_die abrt_show_usage_and_die +void show_usage_and_die(const char *usage, const struct options *opt); #ifdef __cplusplus } |