added psl_builtin_filename()

This commit is contained in:
Tim Ruehsen 2014-04-17 12:31:06 +02:00
parent 9a31e73751
commit ee0064532c
5 changed files with 26 additions and 4 deletions

View File

@ -14,5 +14,6 @@ psl_suffix_exception_count
psl_builtin_compile_time psl_builtin_compile_time
psl_builtin_file_time psl_builtin_file_time
psl_builtin_sha1sum psl_builtin_sha1sum
psl_builtin_filename
psl_is_cookie_domain_acceptable psl_is_cookie_domain_acceptable
</SECTION> </SECTION>

View File

@ -73,9 +73,12 @@ time_t
// returns mtime of PSL source file // returns mtime of PSL source file
time_t time_t
psl_builtin_file_time(void); 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 * const char *
psl_builtin_sha1sum(void); psl_builtin_sha1sum(void);
// returns file name of PSL source file
const char *
psl_builtin_filename(void);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -618,7 +618,6 @@ time_t psl_builtin_file_time(void)
return _psl_file_time; return _psl_file_time;
} }
// returns MD5 checksum (hex-encoded, lowercase) of PSL source file
/** /**
* psl_builtin_sha1sum: * psl_builtin_sha1sum:
* *
@ -636,6 +635,22 @@ const char *psl_builtin_sha1sum(void)
return _psl_sha1_checksum; 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_is_cookie_domain_acceptable:
* @psl: PSL context pointer * @psl: PSL context pointer

View File

@ -380,7 +380,8 @@ int main(int argc, const char **argv)
st.st_mtime = 0; st.st_mtime = 0;
fprintf(fpout, "static time_t _psl_file_time = %lu;\n", st.st_mtime); 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 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) if (fclose(fpout) != 0)
ret = 4; 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 _psl_entry_t suffix_exceptions[0];\n");
fprintf(fpout, "static time_t _psl_file_time;\n"); fprintf(fpout, "static time_t _psl_file_time;\n");
fprintf(fpout, "static time_t _psl_compile_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) if (fclose(fpout) != 0)
ret = 4; ret = 4;

View File

@ -142,6 +142,7 @@ int main(int argc, const char *const *argv)
if (psl) { if (psl) {
printf("builtin suffixes: %d\n", psl_suffix_count(psl)); printf("builtin suffixes: %d\n", psl_suffix_count(psl));
printf("builtin exceptions: %d\n", psl_suffix_exception_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 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 file time: %ld (%s)\n", psl_builtin_file_time(), time2str(psl_builtin_file_time()));
printf("builtin SHA1 file hash: %s\n", psl_builtin_sha1sum()); printf("builtin SHA1 file hash: %s\n", psl_builtin_sha1sum());