Example #1
0
static void main_window_load(Window *window) {    
  init_globe(main_window);
  init_time(main_window);
  init_battery(main_window);
  update_time();
}
Example #2
0
int
main(int argc, char **argv)
{
    struct server *s = NULL;
    pthread_t pt, ctl;
    int c, is_forward = 0;
    const char *config = SR_CONFIG_FILE;
    int daemon = 0;
    while ((c = getopt(argc,argv,"c:vhfd")) != -1)
    {
        switch(c)
        {
            case 'c':
                config = optarg;
                break;
            case 'h':
                help(argv[0]);
                exit(0);
                break;
            case 'f':
                is_forward = 1;
                break;
            case 'd':
                daemon = 1;
                break;
            case '?':
                printf("Try -h please\n");
                exit(0);
                break;
            case 'v':
                printf("dnspod-sr 0.01\n");
                exit(0);
                break;
            default:
                exit(0);
                break;
        }
    }
    sanity_test(0);
    drop_privilege("./");
    daemonrize(daemon);
    trig_signals(1);
    global_now = time(NULL);    //for read root.z
    g_nameservers[0] = g_nameservers[1] = NULL;
    init_globe();
    init_mempool();
    s = server_init();
    s->is_forward = is_forward;
    read_config(config, (char *)s->logpath, s->forward, g_nameservers);
    // add default dns server 8.8.8.8, 114.114.114.114
    if (g_nameservers[0] == NULL) {
        assert(g_nameservers[1] == NULL);
        g_nameservers[0] = strdup("119.29.29.29");
        g_nameservers[1] = strdup("8.8.4.4");
    }
    if (g_nameservers[1] == NULL) {
        if (strcmp(g_nameservers[0], "119.29.29.29") == 0) {
            g_nameservers[1] = strdup("8.8.4.4");
        } else {
            g_nameservers[1] = strdup("119.29.29.29");
        }
    }
    //
    if (create_fetcher(s, s->nfetcher) < 0)
        dns_error(0, "create worker");
    if (create_author(s, s->nquizzer) < 0)
        dns_error(0, "create author");
    if (pthread_create(&pt, NULL, (void *) time_cron, s) != 0)
        dns_error(0, "time cron error");
    if (pthread_create(&ctl, NULL, (void *)recv_update, s) != 0) {
        dns_error(0, "recv update thread error");
    }
    read_root(s->datasets, s->ttlexp);
    print_basic_debug();
    global_serv = s;
    run_sentinel(s);
    return 0;
}