added psl_builtin_filename()
This commit is contained in:
parent
9a31e73751
commit
ee0064532c
|
@ -14,5 +14,6 @@ psl_suffix_exception_count
|
|||
psl_builtin_compile_time
|
||||
psl_builtin_file_time
|
||||
psl_builtin_sha1sum
|
||||
psl_builtin_filename
|
||||
psl_is_cookie_domain_acceptable
|
||||
</SECTION>
|
||||
|
|
|
@ -73,9 +73,12 @@ time_t
|
|||
// returns mtime of PSL source file
|
||||
time_t
|
||||
psl_builtin_file_time(void);
|
||||
// returns MD5 checksum (hex-encoded, lowercase) of PSL source file
|
||||
// returns SHA1 checksum (hex-encoded, lowercase) of PSL source file
|
||||
const char *
|
||||
psl_builtin_sha1sum(void);
|
||||
// returns file name of PSL source file
|
||||
const char *
|
||||
psl_builtin_filename(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
17
src/psl.c
17
src/psl.c
|
@ -618,7 +618,6 @@ time_t psl_builtin_file_time(void)
|
|||
return _psl_file_time;
|
||||
}
|
||||
|
||||
// returns MD5 checksum (hex-encoded, lowercase) of PSL source file
|
||||
/**
|
||||
* psl_builtin_sha1sum:
|
||||
*
|
||||
|
@ -636,6 +635,22 @@ const char *psl_builtin_sha1sum(void)
|
|||
return _psl_sha1_checksum;
|
||||
}
|
||||
|
||||
/**
|
||||
* psl_builtin_filename:
|
||||
*
|
||||
* This function returns the file name of the Publix Suffix List file that has been built in.
|
||||
*
|
||||
* If the generation of built-in data has been disabled during compilation, an empty string will be returned.
|
||||
*
|
||||
* Returns: String containing the PSL file name or an empty string.
|
||||
*
|
||||
* Since: 0.1
|
||||
*/
|
||||
const char *psl_builtin_filename(void)
|
||||
{
|
||||
return _psl_filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* psl_is_cookie_domain_acceptable:
|
||||
* @psl: PSL context pointer
|
||||
|
|
|
@ -380,7 +380,8 @@ int main(int argc, const char **argv)
|
|||
st.st_mtime = 0;
|
||||
fprintf(fpout, "static time_t _psl_file_time = %lu;\n", st.st_mtime);
|
||||
fprintf(fpout, "static time_t _psl_compile_time = %lu;\n", time(NULL));
|
||||
fprintf(fpout, "static char _psl_sha1_checksum[] = \"%s\";\n", checksum);
|
||||
fprintf(fpout, "static const char _psl_sha1_checksum[] = \"%s\";\n", checksum);
|
||||
fprintf(fpout, "static const char _psl_filename[] = \"%s\";\n", checksum);
|
||||
|
||||
if (fclose(fpout) != 0)
|
||||
ret = 4;
|
||||
|
@ -396,7 +397,8 @@ int main(int argc, const char **argv)
|
|||
fprintf(fpout, "static _psl_entry_t suffix_exceptions[0];\n");
|
||||
fprintf(fpout, "static time_t _psl_file_time;\n");
|
||||
fprintf(fpout, "static time_t _psl_compile_time;\n");
|
||||
fprintf(fpout, "static char _psl_sha1_checksum[]= \"\";\n");
|
||||
fprintf(fpout, "static const char _psl_sha1_checksum[] = \"\";\n");
|
||||
fprintf(fpout, "static const char _psl_filename[] = \"\";\n");
|
||||
|
||||
if (fclose(fpout) != 0)
|
||||
ret = 4;
|
||||
|
|
|
@ -142,6 +142,7 @@ int main(int argc, const char *const *argv)
|
|||
if (psl) {
|
||||
printf("builtin suffixes: %d\n", psl_suffix_count(psl));
|
||||
printf("builtin exceptions: %d\n", psl_suffix_exception_count(psl));
|
||||
printf("builtin filename: %s\n", psl_builtin_filename());
|
||||
printf("builtin compile time: %ld (%s)\n", psl_builtin_compile_time(), time2str(psl_builtin_compile_time()));
|
||||
printf("builtin file time: %ld (%s)\n", psl_builtin_file_time(), time2str(psl_builtin_file_time()));
|
||||
printf("builtin SHA1 file hash: %s\n", psl_builtin_sha1sum());
|
||||
|
|
Loading…
Reference in New Issue