コード例 #1
0
ファイル: DwSys.c プロジェクト: periapt/maradns
/* Process a signal received */
void process_signal(int number) {
    dw_str *filename = 0;
    char *fname_convert = 0;

#ifndef MINGW
    /* Clear the signal flag */
    got_signal = 0;
#endif /* MINGW */

    /* Write the cache contents to disk */
    filename = key_s[DWM_S_cache_file];
    if(cache != 0 && filename != 0) {
        dw_filename_sanitize(filename);
        fname_convert = (char *)dw_to_cstr(filename);
        dwh_write_hash(cache,fname_convert);
        free(fname_convert);
    }

#ifndef MINGW
    /* Exit if they requested it (*NIX only) */
    if(number == 1) { /* TERM */
        exit(0);
    } else if(number == 2) { /* HUP */
        exit(8); /* Use by Duende to indicate we exited with HUP */
    }
#endif /* MINGW */
}
コード例 #2
0
ファイル: DwSys.c プロジェクト: Jin-W-FS/deadwood
/* Initialize the cache */
void init_cache() {
        dw_str *filename = 0;
        char *fname_convert = 0;
        struct stat cache_st;

        dwh_process_mararc_params(); /* Get the cache size */
        if(cache != 0) { /* Don't init cache twice */
                return;
        }

        /* See if we can read the cache from a file */
        filename = key_s[DWM_S_cache_file];
        if(filename != 0 && do_read_cache == 1) {
                dw_filename_sanitize(filename);
                fname_convert = (char *)dw_to_cstr(filename);
                if(stat(fname_convert,&cache_st) == 0 &&
                   cache_st.st_mtime < mararc_st.st_mtime) {
                        dw_log_string(
                              "Cache older than rc file; not reading cache",0);
                } else {
                        cache = dwh_read_hash(fname_convert);
                }
                free(fname_convert);
        }

        if(cache == 0) { /* Just in case read from file failed */
                cache = dwh_hash_init(0); /* Size comes from dwood2rc */
        }
}
コード例 #3
0
ファイル: DwSys.c プロジェクト: periapt/maradns
/* Initialize the cache */
void init_cache() {
    dw_str *filename = 0;
    char *fname_convert = 0;

    dwh_process_mararc_params(); /* Get the cache size */
    if(cache != 0) { /* Don't init cache twice */
        return;
    }

    /* See if we can read the cache from a file */
    filename = key_s[DWM_S_cache_file];
    if(filename != 0) {
        dw_filename_sanitize(filename);
        fname_convert = (char *)dw_to_cstr(filename);
        cache = dwh_read_hash(fname_convert);
        free(fname_convert);
    }

    if(cache == 0) { /* Just in case read from file failed */
        cache = dwh_hash_init(0); /* Size comes from dwood2rc */
    }
}