1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-15 17:47:09 +00:00

Merge remote branch 'origin/master' into lua-config

Conflicts:
	src/conky.cc
This commit is contained in:
Pavel Labath 2010-11-16 22:45:06 +01:00
commit ad79c87376
5 changed files with 67 additions and 28 deletions

View File

@ -40,7 +40,7 @@ struct combine_data {
char *right;
};
void parse_combine_arg(struct text_object *obj, const char *arg, void *free_at_crash)
void parse_combine_arg(struct text_object *obj, const char *arg)
{
struct combine_data *cd;
unsigned int i,j;
@ -89,7 +89,7 @@ void parse_combine_arg(struct text_object *obj, const char *arg, void *free_at_c
extract_variable_text_internal(obj->sub->sub, cd->right);
obj->data.opaque = cd;
} else {
CRIT_ERR(obj, free_at_crash, "combine needs arguments: <text1> <text2>");
throw combine_needs_2_args_error();
}
}

View File

@ -30,7 +30,7 @@
#ifndef _COMBINE_H
#define _COMBINE_H
void parse_combine_arg(struct text_object *, const char *, void *);
void parse_combine_arg(struct text_object *, const char *);
void print_combine(struct text_object *, char *, int);
void free_combine(struct text_object *);

View File

@ -2893,7 +2893,7 @@ void initialisation(int argc, char **argv) {
break;
case '?':
throw std::runtime_error("Unknown argument");
throw unknown_arg_throw();
}
}
@ -2930,7 +2930,7 @@ void initialisation(int argc, char **argv) {
fprintf(stderr, PACKAGE_NAME": forked to background, pid is %d\n",
pid);
fflush(stderr);
exit(EXIT_SUCCESS);
throw fork_throw();
}
}
@ -3048,37 +3048,39 @@ int main(int argc, char **argv)
try {
conky::export_symbols(*state);
#ifdef BUILD_WEATHER_XOAP
/* Load xoap keys, if existing */
load_xoap_keys();
#endif /* BUILD_WEATHER_XOAP */
#ifdef HAVE_SYS_INOTIFY_H
// the file descriptor will be automatically closed on exit
inotify_fd = inotify_init();
if(inotify_fd != -1) {
fcntl(inotify_fd, F_SETFL, fcntl(inotify_fd, F_GETFL) | O_NONBLOCK);
fcntl(inotify_fd, F_SETFD, fcntl(inotify_fd, F_GETFD) | FD_CLOEXEC);
}
#endif /* HAVE_SYS_INOTIFY_H */
initialisation(argc, argv);
first_pass = 0; /* don't ever call fork() again */
main_loop();
}
catch(conky::critical_error &e) {
std::cerr << "caught critical exception: " << e.what() << std::endl;
return EXIT_FAILURE;
}
catch(std::runtime_error &e) {
std::cerr << "caught exception: " << e.what() << std::endl;
catch(fork_throw &e) { return EXIT_SUCCESS; }
catch(unknown_arg_throw &e) { return EXIT_FAILURE; }
catch(obj_create_error &e) {
std::cerr << e.what() << std::endl;
clean_up(NULL, NULL);
return EXIT_FAILURE;
}
#ifdef BUILD_WEATHER_XOAP
/* Load xoap keys, if existing */
load_xoap_keys();
#endif /* BUILD_WEATHER_XOAP */
#ifdef HAVE_SYS_INOTIFY_H
// the file descriptor will be automatically closed on exit
inotify_fd = inotify_init();
if(inotify_fd != -1) {
fcntl(inotify_fd, F_SETFL, fcntl(inotify_fd, F_GETFL) | O_NONBLOCK);
fcntl(inotify_fd, F_SETFD, fcntl(inotify_fd, F_GETFD) | FD_CLOEXEC);
}
#endif /* HAVE_SYS_INOTIFY_H */
//////////// XXX ////////////////////////////////
main_loop();
disk_cleanup();
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)

View File

@ -1707,8 +1707,14 @@ struct text_object *construct_text_object(char *s, const char *arg, long
parse_scroll_arg(obj, arg, free_at_crash, s);
obj->callbacks.print = &print_scroll;
obj->callbacks.free = &free_scroll;
END OBJ_ARG(combine, 0, "combine needs arguments: <text1> <text2>")
parse_combine_arg(obj, arg, free_at_crash);
END OBJ(combine, 0)
try {
parse_combine_arg(obj, arg);
}
catch(combine_needs_2_args_error &e) {
free(obj);
throw obj_create_error(e.what());
}
obj->callbacks.print = &print_combine;
obj->callbacks.free = &free_combine;
#ifdef BUILD_NVIDIA
@ -1936,8 +1942,15 @@ int extract_variable_text_internal(struct text_object *retval, const char *const
tmp_p++;
}
obj = construct_text_object(buf, arg,
try {
obj = construct_text_object(buf, arg,
line, &ifblock_opaque, orig_p);
}
catch(obj_create_error &e) {
free(buf);
free(orig_p);
throw e;
}
if (obj != NULL) {
append_object(retval, obj);
}

View File

@ -34,6 +34,30 @@
#include <stdexcept>
#include "i18n.h"
class fork_throw : public std::runtime_error {
public:
fork_throw() : std::runtime_error("Fork happened") {}
fork_throw(const std::string &msg) : std::runtime_error(msg) {}
};
class unknown_arg_throw : public std::runtime_error {
public:
unknown_arg_throw() : std::runtime_error("Unknown argumunt given") {}
unknown_arg_throw(const std::string &msg) : std::runtime_error(msg) {}
};
class combine_needs_2_args_error : public std::runtime_error {
public:
combine_needs_2_args_error() : std::runtime_error("combine needs arguments: <text1> <text2>") {}
combine_needs_2_args_error(const std::string &msg) : std::runtime_error(msg) {}
};
class obj_create_error : public std::runtime_error {
public:
obj_create_error() : std::runtime_error("Failed to create object") {}
obj_create_error(const std::string &msg) : std::runtime_error(msg) {}
};
void clean_up(void *memtofree1, void* memtofree2);
void clean_up_without_threads(void *memtofree1, void* memtofree2);