sdk_ret sdk_ipc_init(int module_id) { sdk_ret sret = SDK_EINNER; int ret = -1; if (g_init_flag) return SDK_EBADPARA; g_self_id = module_id; sret = init_mq(); if (SDK_OK != sret) goto err_mq; sret = init_sync(); if (SDK_OK != sret) goto err_sync; sret = init_notify(); if (SDK_OK != sret) goto err_notify; sret = init_socket(); if (SDK_OK != sret) goto err_sock; /* Create IPC main MQ */ g_main_mq = sdk_ipc_mq_create(); if (NULL == g_main_mq) goto err_sock; /* Start IPC recv thread */ g_run_flag = 1; ret = pthread_create(&g_recv_pid, NULL, recv_thread_routine, NULL); if (0 != ret) goto err_sock; /* Init OK */ g_init_flag = 1; return SDK_OK; err_sock: uninit_socket(); err_notify: uninit_notify(); err_sync: uninit_sync(); err_mq: uninit_mq(); return SDK_EINNER; }
int ns_init(int argc, char **argv) { struct sigaction sa = { .sa_handler = ns_sig_hand, .sa_flags = SA_RESTART, }; int ret, fd, status_pipe = STATUS_FD; char buf[128], *x; pid_t pid; bool reap; ret = fcntl(status_pipe, F_SETFD, FD_CLOEXEC); if (ret == -1) { fprintf(stderr, "fcntl failed %m\n"); exit(1); } if (init_notify()) { fprintf(stderr, "Can't init pre-dump notification: %m"); exit(1); } reap = getenv("ZDTM_NOREAP") == NULL; sigemptyset(&sa.sa_mask); sigaddset(&sa.sa_mask, SIGTERM); if (reap) sigaddset(&sa.sa_mask, SIGCHLD); if (sigaction(SIGTERM, &sa, NULL)) { fprintf(stderr, "Can't set SIGTERM handler: %m\n"); exit(1); } x = malloc(strlen(pidfile) + 3); sprintf(x, "%sns", pidfile); pidfile = x; /* Start test */ pid = fork(); if (pid < 0) { fprintf(stderr, "fork() failed: %m\n"); exit(1); } else if (pid == 0) { close(status_pipe); unsetenv("ZDTM_NEWNS"); return 0; /* Continue normal test startup */ } ret = -1; if (waitpid(pid, &ret, 0) < 0) fprintf(stderr, "waitpid() failed: %m\n"); else if (ret) fprintf(stderr, "The test returned non-zero code %d\n", ret); if (reap && sigaction(SIGCHLD, &sa, NULL)) { fprintf(stderr, "Can't set SIGCHLD handler: %m\n"); exit(1); } while (reap && 1) { int status; pid = waitpid(-1, &status, WNOHANG); if (pid == 0) break; if (pid < 0) { fprintf(stderr, "waitpid() failed: %m\n"); exit (1); } if (status) fprintf(stderr, "%d return %d\n", pid, status); } /* Daemonize */ write(status_pipe, &ret, sizeof(ret)); close(status_pipe); if (ret) exit(ret); /* suspend/resume */ test_waitsig(); fd = open(pidfile, O_RDONLY); if (fd == -1) { fprintf(stderr, "open(%s) failed: %m\n", pidfile); exit(1); } ret = read(fd, buf, sizeof(buf) - 1); buf[ret] = '\0'; if (ret == -1) { fprintf(stderr, "read() failed: %m\n"); exit(1); } pid = atoi(buf); fprintf(stderr, "kill(%d, SIGTERM)\n", pid); if (pid > 0) kill(pid, SIGTERM); ret = 0; if (reap) { while (true) { pid_t child; ret = -1; child = waitpid(-1, &ret, 0); if (child < 0) { fprintf(stderr, "Unable to wait a test process: %m"); exit(1); } if (child == pid) { fprintf(stderr, "The test returned 0x%x", ret); exit(!(ret == 0)); } if (ret) fprintf(stderr, "The %d process exited with 0x%x", child, ret); } } else { waitpid(pid, NULL, 0); } exit(1); }
int main(int argc, char *argv[]) { char *user_config_dir = get_user_config_dir(); int config_err = 0; parse_args(argc, argv); /* Make sure all written files are read/writeable only by the current user. */ umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); signal(SIGINT, catch_SIGINT); config_err = create_user_config_dir(user_config_dir); if (DATA_FILE == NULL ) { if (config_err) { DATA_FILE = strdup("data"); if (DATA_FILE == NULL) exit_toxic_err("failed in main", FATALERR_MEMORY); } else { DATA_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("data") + 1); if (DATA_FILE == NULL) exit_toxic_err("failed in main", FATALERR_MEMORY); strcpy(DATA_FILE, user_config_dir); strcat(DATA_FILE, CONFIGDIR); strcat(DATA_FILE, "data"); } } free(user_config_dir); /* init user_settings struct and load settings from conf file */ user_settings_ = calloc(1, sizeof(struct user_settings)); if (user_settings_ == NULL) exit_toxic_err("failed in main", FATALERR_MEMORY); char *p = arg_opts.config_path[0] ? arg_opts.config_path : NULL; int settings_err = settings_load(user_settings_, p); Tox *m = init_tox(arg_opts.use_ipv4); init_term(); if (m == NULL) exit_toxic_err("failed in main", FATALERR_NETWORKINIT); if (!arg_opts.ignore_data_file) load_data(m, DATA_FILE); prompt = init_windows(m); prompt_init_statusbar(prompt, m); /* thread for ncurses stuff */ if (pthread_mutex_init(&Winthread.lock, NULL) != 0) exit_toxic_err("failed in main", FATALERR_MUTEX_INIT); if (pthread_create(&Winthread.tid, NULL, thread_winref, (void *) m) != 0) exit_toxic_err("failed in main", FATALERR_THREAD_CREATE); #ifdef _AUDIO av = init_audio(prompt, m); set_primary_device(input, user_settings_->audio_in_dev); set_primary_device(output, user_settings_->audio_out_dev); #elif _SOUND_NOTIFY if ( init_devices() == de_InternalError ) line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to init devices"); #endif /* _AUDIO */ init_notify(60, 3000); #ifdef _SOUND_NOTIFY notify(prompt, self_log_in, 0); #endif /* _SOUND_NOTIFY */ const char *msg; if (config_err) { msg = "Unable to determine configuration directory. Defaulting to 'data' for a keyfile..."; line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, msg); } if (settings_err == -1) { msg = "Failed to load user settings"; line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, msg); } sort_friendlist_index(); uint64_t last_save = (uint64_t) time(NULL); while (true) { update_unix_time(); do_toxic(m, prompt); uint64_t cur_time = get_unix_time(); if (timed_out(last_save, cur_time, AUTOSAVE_FREQ)) { pthread_mutex_lock(&Winthread.lock); store_data(m, DATA_FILE); pthread_mutex_unlock(&Winthread.lock); last_save = cur_time; } usleep(40000); } return 0; }
int main(int argc, char *argv[]) { init_signal_catchers(); parse_args(argc, argv); /* Make sure all written files are read/writeable only by the current user. */ umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); int config_err = init_data_files(); /* init user_settings struct and load settings from conf file */ user_settings_ = calloc(1, sizeof(struct user_settings)); if (user_settings_ == NULL) exit_toxic_err("failed in main", FATALERR_MEMORY); char *p = arg_opts.config_path[0] ? arg_opts.config_path : NULL; int settings_err = settings_load(user_settings_, p); Tox *m = init_tox(); init_term(); /* enable stderr for debugging */ if (!arg_opts.debug) freopen("/dev/null", "w", stderr); if (m == NULL) exit_toxic_err("failed in main", FATALERR_NETWORKINIT); if (!arg_opts.ignore_data_file) load_data(m, DATA_FILE); prompt = init_windows(m); prompt_init_statusbar(prompt, m); /* thread for ncurses stuff */ if (pthread_mutex_init(&Winthread.lock, NULL) != 0) exit_toxic_err("failed in main", FATALERR_MUTEX_INIT); if (pthread_create(&Winthread.tid, NULL, thread_winref, (void *) m) != 0) exit_toxic_err("failed in main", FATALERR_THREAD_CREATE); #ifdef _AUDIO av = init_audio(prompt, m); set_primary_device(input, user_settings_->audio_in_dev); set_primary_device(output, user_settings_->audio_out_dev); #elif _SOUND_NOTIFY if ( init_devices() == de_InternalError ) line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to init devices"); #endif /* _AUDIO */ init_notify(60, 3000); #ifdef _SOUND_NOTIFY // sound_notify(prompt, self_log_in, 0, NULL); #endif /* _SOUND_NOTIFY */ const char *msg; if (config_err) { msg = "Unable to determine configuration directory. Defaulting to 'data' for data file..."; line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, msg); } if (settings_err == -1) line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to load user settings"); if (arg_opts.use_proxy && !arg_opts.force_tcp) { msg = "* WARNING: Using a proxy without disabling UDP may leak your real IP address."; line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, "%s", msg); msg = " Use the -t option to disable UDP."; line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, "%s", msg); } uint64_t last_save = (uint64_t) time(NULL); uint64_t looptimer = last_save; useconds_t msleepval = 40000; uint64_t loopcount = 0; while (true) { update_unix_time(); do_toxic(m, prompt); uint64_t cur_time = get_unix_time(); if (timed_out(last_save, cur_time, AUTOSAVE_FREQ)) { pthread_mutex_lock(&Winthread.lock); store_data(m, DATA_FILE); pthread_mutex_unlock(&Winthread.lock); last_save = cur_time; } msleepval = optimal_msleepval(&looptimer, &loopcount, cur_time, msleepval); usleep(msleepval); } return 0; }
int main(int argc, char **argv) { abrt_init(argv); /* I18n */ setlocale(LC_ALL, ""); #if ENABLE_NLS bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); #endif /* without this the name is set to argv[0] which confuses * desktops which uses the name to find the corresponding .desktop file * trac#180 */ gtk_init(&argc, &argv); /* Can't keep these strings/structs static: _() doesn't support that */ const char *program_usage_string = _( "\b [-vp] [DIR]...\n" "\n" "Shows list of ABRT dump directories in specified DIR(s)\n" "(default DIRs: "DEBUG_DUMPS_DIR" $HOME/.abrt/spool)" ); enum { OPT_v = 1 << 0, OPT_p = 1 << 1, }; /* Keep enum above and order of options below in sync! */ struct options program_options[] = { OPT__VERBOSE(&g_verbose), OPT_BOOL( 'p', NULL, NULL , _("Add program names to log")), OPT_END() }; unsigned opts = parse_opts(argc, argv, program_options, program_usage_string); export_abrt_envvars(opts & OPT_p); GtkWidget *main_window = create_main_window(); const char *default_dirs[] = { "/var/spool/abrt", NULL, NULL, }; argv += optind; if (!argv[0]) { char *home = getenv("HOME"); if (home) default_dirs[1] = concat_path_file(home, ".abrt/spool"); argv = (char**)default_dirs; } s_dirs = argv; init_notify(); scan_dirs_and_add_to_dirlist(); gtk_widget_show_all(main_window); sanitize_cursor(NULL); /* Set up signal pipe */ xpipe(s_signal_pipe); close_on_exec_on(s_signal_pipe[0]); close_on_exec_on(s_signal_pipe[1]); ndelay_on(s_signal_pipe[0]); ndelay_on(s_signal_pipe[1]); signal(SIGCHLD, handle_signal); g_io_add_watch(g_io_channel_unix_new(s_signal_pipe[0]), G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP | G_IO_NVAL, handle_signal_pipe, NULL); /* Enter main loop */ gtk_main(); return 0; }
int main(int argc, char **argv) { parse_args(argc, argv); /* Use the -b flag to enable stderr */ if (!arg_opts.debug) freopen("/dev/null", "w", stderr); if (arg_opts.encrypt_data && arg_opts.unencrypt_data) { arg_opts.encrypt_data = 0; arg_opts.unencrypt_data = 0; queue_init_message("Warning: Using --unencrypt-data and --encrypt-data simultaneously has no effect"); } /* Make sure all written files are read/writeable only by the current user. */ umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); init_default_data_files(); bool datafile_exists = file_exists(DATA_FILE); if (!datafile_exists && !arg_opts.unencrypt_data) first_time_encrypt("Creating new data file. Would you like to encrypt it? Y/n (q to quit)"); else if (arg_opts.encrypt_data) first_time_encrypt("Encrypt existing data file? Y/n (q to quit)"); /* init user_settings struct and load settings from conf file */ user_settings = calloc(1, sizeof(struct user_settings)); if (user_settings == NULL) exit_toxic_err("failed in main", FATALERR_MEMORY); const char *p = arg_opts.config_path[0] ? arg_opts.config_path : NULL; if (settings_load(user_settings, p) == -1) { queue_init_message("Failed to load user settings"); } int curl_init = curl_global_init(CURL_GLOBAL_ALL); int nameserver_ret = name_lookup_init(curl_init); if (nameserver_ret == -1) { queue_init_message("curl failed to initialize; name lookup service is disabled."); } else if (nameserver_ret == -2) { queue_init_message("Name lookup server list could not be found."); } else if (nameserver_ret == -3) { queue_init_message("Name lookup server list does not contain any valid entries."); } #ifdef X11 if (init_xtra(DnD_callback) == -1) queue_init_message("X failed to initialize"); #endif Tox *m = load_toxic(DATA_FILE); if (arg_opts.encrypt_data && !datafile_exists) arg_opts.encrypt_data = 0; init_term(); prompt = init_windows(m); prompt_init_statusbar(prompt, m); /* thread for ncurses stuff */ if (pthread_mutex_init(&Winthread.lock, NULL) != 0) exit_toxic_err("failed in main", FATALERR_MUTEX_INIT); if (pthread_create(&Winthread.tid, NULL, thread_winref, (void *) m) != 0) exit_toxic_err("failed in main", FATALERR_THREAD_CREATE); /* thread for message queue */ if (pthread_create(&cqueue_thread.tid, NULL, thread_cqueue, (void *) m) != 0) exit_toxic_err("failed in main", FATALERR_THREAD_CREATE); #ifdef AUDIO av = init_audio(prompt, m); #ifdef VIDEO init_video(prompt, m); #endif /* VIDEO */ /* AV thread */ if (pthread_create(&av_thread.tid, NULL, thread_av, (void *) av) != 0) exit_toxic_err("failed in main", FATALERR_THREAD_CREATE); set_primary_device(input, user_settings->audio_in_dev); set_primary_device(output, user_settings->audio_out_dev); #elif SOUND_NOTIFY if ( init_devices() == de_InternalError ) queue_init_message("Failed to init audio devices"); #endif /* AUDIO */ init_notify(60, 3000); /* screen/tmux auto-away timer */ if (init_mplex_away_timer(m) == -1) queue_init_message("Failed to init mplex auto-away."); int nodeslist_ret = load_DHT_nodeslist(); if (nodeslist_ret != 0) { queue_init_message("DHT nodeslist failed to load (error %d)", nodeslist_ret); } pthread_mutex_lock(&Winthread.lock); print_init_messages(prompt); pthread_mutex_unlock(&Winthread.lock); cleanup_init_messages(); /* set user avatar from config file. if no path is supplied tox_unset_avatar is called */ char avatarstr[MAX_STR_SIZE]; snprintf(avatarstr, sizeof(avatarstr), "/avatar \"%s\"", user_settings->avatar_path); execute(prompt->chatwin->history, prompt, m, avatarstr, GLOBAL_COMMAND_MODE); time_t last_save = get_unix_time(); while (true) { do_toxic(m); time_t cur_time = get_unix_time(); if (timed_out(last_save, AUTOSAVE_FREQ)) { pthread_mutex_lock(&Winthread.lock); if (store_data(m, DATA_FILE) != 0) line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, "WARNING: Failed to save to data file"); pthread_mutex_unlock(&Winthread.lock); last_save = cur_time; } usleep(tox_iteration_interval(m) * 1000); } return 0; }
int main(int argc,char *args[]) { int n,c; unsigned long long prof,start,end; end_of_data_ptr=sbrk(0); time_now=time(NULL); printf("\n"); printf(" ********************************************\n"); printf(" * Astonia 3 - The Conflict Server *\n"); printf(" * Version %d.%02d.%02d *\n",VERSION>>16,(VERSION>>8)&255,VERSION&255); printf(" ********************************************\n"); printf(" * Copyright (C) 2001-2008 Intent Software *\n"); printf(" * Copyright (C) 1997-2001 Daniel Brockhaus *\n"); printf(" ********************************************\n"); printf("\n"); if (argc>1) { while (1) { c=getopt(argc,args,"a:m:i:dhc"); if (c==-1) break; switch (c) { case 'a': if (optarg) areaID=atoi(optarg); break; case 'm': if (optarg) areaM=atoi(optarg); break; case 'd': demon=1; break; case 'h': fprintf(stderr,"Usage: %s [-a <areaID>] [-m <mirror>] [-n <use this class A net>] [-d] [-c]\n\n-d Demonize\n-c Disable concurrent database access\n\n",args[0]); exit(0); case 'c': multi=0; break; //case 'n': if (optarg) server_net=atoi(optarg); break; case 'i': if (optarg) serverID=atoi(optarg); break; } } } if (!areaID) { printf("No areaID given, assuming areaID=1\n"); areaID=1; } if (!areaM) { printf("No mirror given, assuming areaM=1\n"); areaM=1; } if (!serverID) { printf("No serverID given, assuming serverID=1\n"); serverID=1; } #ifdef STAFF while (!check_staff_start()) sleep(1); #endif // set character number limit depending on area switch(areaID) { case 1: maxchars=512; break; case 2: maxchars=896; break; case 3: maxchars=384; break; case 4: maxchars=2048; break; case 5: maxchars=768; break; case 6: maxchars=384; break; case 7: maxchars=1280; break; case 8: maxchars=384; break; case 9: maxchars=1280; break; case 10: maxchars=512; break; case 11: maxchars=384; break; case 12: maxitem=1024*48; maxchars=384; break; case 13: maxchars=9*50+200; break; case 14: maxchars=16*50+200; break; case 15: maxchars=384; break; case 16: maxchars=384; break; case 17: maxchars=512; break; case 18: maxchars=768; break; case 19: maxchars=384; break; case 20: maxchars=768; break; case 21: maxchars=768; break; case 22: maxchars=512; break; case 23: maxchars=512; break; case 24: maxchars=384; break; case 25: maxchars=384+8*25*2; break; case 26: maxchars=256; break; case 27: maxchars=2048; break; case 28: maxchars=384; break; case 29: maxchars=512; break; case 30: maxchars=384; break; case 31: maxitem=1024*40; maxchars=512; break; case 32: maxchars=1280; break; case 33: maxchars=1600; break; case 34: maxchars=1280; break; case 35: maxchars=768; break; case 36: maxchars=768; break; case 37: maxchars=1024; break; default: maxchars=768; break; } // set item and effect limit if (!maxitem) maxitem=max(maxchars*12+10240,20480); if (!maxeffect) maxeffect=max(maxchars*2,1024); printf("serverID=%d, areaID=%d, areaM=%d, maxchars=%d, maxitem=%d, maxeffect=%d\n\n", serverID,areaID,areaM,maxchars,maxitem,maxeffect); if (demon) { printf("Demonizing...\n\n"); if (fork()) exit(0); for (n=0; n<256; n++) close(n); setsid(); #ifndef STAFF nologin=1; #endif } // ignore the silly pipe errors: signal(SIGPIPE,SIG_IGN); // ignore sighup - just to be safe signal(SIGHUP,SIG_IGN); /*signal(SIGSEGV,sig_crash); signal(SIGFPE,sig_crash); signal(SIGBUS,sig_crash); signal(SIGSTKFLT,sig_crash);*/ // shutdown gracefully if possible: signal(SIGQUIT,sig_leave); signal(SIGINT,sig_leave); signal(SIGTERM,sig_leave); // show profile info on CTRL-Z signal(SIGTSTP,sig_showprof); // init random number generator srand(time_now); if (!init_smalloc()) exit(1); if (!init_mem()) exit(1); if (!init_prof()) exit(1); if (!init_log()) exit(1); if (!init_database()) exit(1); if (!init_lookup()) exit(1); if (!init_sector()) exit(1); if (!init_los()) exit(1); if (!init_timer()) exit(1); if (!init_notify()) exit(1); if (!init_create()) exit(1); if (!init_lib()) exit(1); if (!init_io()) exit(1); if (!init_path()) exit(1); if (!init_effect()) exit(1); if (!init_container()) exit(1); if (!init_store()) exit(1); if (!init_chat()) exit(1); init_sound_sector(); xlog("AreaID=%d, AreaM=%d, entering game loop...",areaID,areaM); dlog(0,0,"Server started"); prof_reset(); while (!quit) { sprintf(args[0],"./server -a %d -m %d -i %d # %d on %d%% load (busy)",areaID,areaM,serverID,online,(10000-server_idle)/100); start=rdtsc(); lock_server(); time_now=time(NULL); prof=prof_start(26); tick_date(); prof_stop(26,prof); prof=prof_start(22); tick_timer(); prof_stop(22,prof); prof=prof_start(4); tick_char(); prof_stop(4,prof); prof=prof_start(24); tick_effect(); prof_stop(24,prof); prof=prof_start(36); tick_clan(); prof_stop(36,prof); prof=prof_start(39); tick_club(); prof_stop(39,prof); prof=prof_start(5); tick_player(); prof_stop(5,prof); prof=prof_start(34); tick_login(); prof_stop(34,prof); prof=prof_start(6); pflush(); prof_stop(6,prof); prof=prof_start(7); io_loop(); prof_stop(7,prof); prof=prof_start(3); tick_chat(); prof_stop(3,prof); if (showprof) { show_prof(); showprof=0; } prof=prof_start(8); prof_update(); prof_stop(8,prof); end=rdtsc(); cycles=end-start; if ((ticker&2047)==0) { prof=prof_start(27); area_alive(0); prof_stop(27,prof); prof=prof_start(28); backup_players(); prof_stop(28,prof); call_stat_update(); read_motd(); reinit_log(); } if ((ticker&255)==0) { call_check_task(); call_area_load(); shutdown_warn(); #ifdef STAFF check_staff_stop(); #endif } if ((ticker&255)==168) { prof=prof_start(38); consistency_check_items(); consistency_check_map(); consistency_check_chars(); consistency_check_containers(); prof_stop(38,prof); } unlock_server(); sprintf(args[0],"./server -a %d -m %d -i %d # %d on %d%% load (idle)",areaID,areaM,serverID,online,(10000-server_idle)/100); prof=prof_start(1); tick_sleep(0); prof_stop(1,prof); ticker++; } xlog("Left game loop"); respawn_check(); for (n=1; n<MAXCHARS; n++) { if (ch[n].flags&CF_PLAYER) { exit_char(n); } } area_alive(1); show_prof(); dlog(0,0,"Server stopped"); xlog("map check"); check_map(); exit_lib(); exit_database(); xlog("Clean shutdown"); showmem(); exit_log(); exit_io(); return 0; }
gint main(gint argc, gchar *argv[]) { gint ret = 0; struct con_win *cwin; cwin = g_slice_new0(struct con_win); cwin->pixbuf = g_slice_new0(struct pixbuf); cwin->cpref = g_slice_new0(struct con_pref); cwin->cstate = g_slice_new0(struct con_state); cwin->cdbase = g_slice_new0(struct con_dbase); cwin->cmixer = g_slice_new0(struct con_mixer); cwin->clibao = g_slice_new0(struct con_libao); cwin->clastfm = g_slice_new0(struct con_lastfm); #if HAVE_GLIB_2_26 cwin->cmpris2 = g_slice_new0(struct con_mpris2); #endif if(init_first_state(cwin) == -1) return -1; debug_level = 0; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); if (init_dbus(cwin) == -1) { g_critical("Unable to init dbus connection"); return -1; } if (init_dbus_handlers(cwin) == -1) { g_critical("Unable to initialize DBUS filter handlers"); return -1; } if (init_options(cwin, argc, argv) == -1) return -1; /* Allow only one instance */ if (!cwin->cstate->unique_instance) return 0; if (init_config(cwin) == -1) { g_critical("Unable to init configuration"); return -1; } if (init_musicdbase(cwin) == -1) { g_critical("Unable to init music dbase"); return -1; } ret = init_audio(cwin); if (ret == -EINVAL) { g_critical("Unable to init audio"); return -1; } else if (ret == -ENODEV) { g_critical("Audio init failed, choose appropriate settings " "from the preferences."); } /* Init libcurl before spawning threads */ if (init_lastfm(cwin) == -1) { g_critical("Unable to initialize curl"); } if (init_threads(cwin) == -1) { g_critical("Unable to init threads"); return -1; } if (init_notify(cwin) == -1) { g_critical("Unable to initialize libnotify"); return -1; } #ifdef HAVE_LIBKEYBINDER if (init_keybinder(cwin) == -1) { g_critical("Unable to initialize keybinder"); return -1; } #endif #ifdef HAVE_LIBGLYR if (init_glyr_related(cwin) == -1) { g_critical("Unable to initialize libglyr"); } #endif #if HAVE_GLIB_2_26 if (mpris_init(cwin) == -1) { g_critical("Unable to initialize MPRIS"); return -1; } #endif gdk_threads_enter(); init_gui(argc, argv, cwin); CDEBUG(DBG_INFO, "Init done. Running ..."); gtk_main(); gdk_threads_leave(); return 0; }