/* * Initialize the flickcurl connection */ static int flickr_init() { char *conf_path; char *login; flickcurl_init(); fc = flickcurl_new(); conf_path = get_conf_path(); if(!conf_path) return FAIL; if(check_conf_file(conf_path, fc)) return FAIL; /* Read from the config file, ~/.flickcurl.conf */ if(flickcurl_config_read_ini(fc, conf_path, "flickr", fc, flickcurl_config_var_handler)) return FAIL; login = flickcurl_test_login(fc); if(!login) return FAIL; free(login); free(conf_path); return SUCCESS; }
/* Entry point */ int main(int argc, char **argv) { int report_stopped = true; /* Init debugging level */ debug = 0; /* Initialise daemon_mode */ __set_bit(DAEMON_VRRP, &daemon_mode); __set_bit(DAEMON_CHECKERS, &daemon_mode); /* * Parse command line and set debug level. * bits 0..7 reserved by main.c */ parse_cmdline(argc, argv); openlog(PROG, LOG_PID | ((__test_bit(LOG_CONSOLE_BIT, &debug)) ? LOG_CONS : 0) , log_facility); #ifdef GIT_COMMIT log_message(LOG_INFO, "Starting %s, git commit %s", VERSION_STRING, GIT_COMMIT); #else log_message(LOG_INFO, "Starting %s", VERSION_STRING); #endif #ifdef _MEM_CHECK_ mem_log_init(PROG); #endif /* Handle any core file requirements */ core_dump_init(); /* Check if keepalived is already running */ if (keepalived_running(daemon_mode)) { log_message(LOG_INFO, "daemon is already running"); report_stopped = false; goto end; } if (__test_bit(LOG_CONSOLE_BIT, &debug)) enable_console_log(); /* daemonize process */ if (!__test_bit(DONT_FORK_BIT, &debug)) xdaemon(0, 0, 0); /* Check we can read the configuration file(s). NOTE: the working directory will be / if we forked, but will be the current working directory when keepalived was run if we haven't forked. This means that if any config file names are not absolute file names, the behaviour will be different depending on whether we forked or not. */ if (!check_conf_file(conf_file)) goto end; /* write the father's pidfile */ if (!pidfile_write(main_pidfile, getpid())) goto end; #ifndef _DEBUG_ /* Signal handling initialization */ signal_init(); #endif /* Create the master thread */ master = thread_make_master(); /* Init daemon */ start_keepalived(); #ifndef _DEBUG_ /* Launch the scheduling I/O multiplexer */ launch_scheduler(); /* Finish daemon process */ stop_keepalived(); #endif /* * Reached when terminate signal catched. * finally return from system */ end: if (report_stopped) { #ifdef GIT_COMMIT log_message(LOG_INFO, "Stopped %s, git commit %s", VERSION_STRING, GIT_COMMIT); #else log_message(LOG_INFO, "Stopped %s", VERSION_STRING); #endif } /* Restore original core_pattern if necessary */ if (orig_core_dump_pattern) update_core_dump_pattern(orig_core_dump_pattern); closelog(); exit(0); }