2008-04-29 12:55:25 +00:00
|
|
|
#include <qpdf/QTC.hh>
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <qpdf/QUtil.hh>
|
|
|
|
|
|
|
|
static bool tc_active(char const* const scope)
|
|
|
|
{
|
|
|
|
std::string value;
|
|
|
|
return (QUtil::get_env("TC_SCOPE", &value) && (value == scope));
|
|
|
|
}
|
|
|
|
|
|
|
|
void QTC::TC(char const* const scope, char const* const ccase, int n)
|
|
|
|
{
|
|
|
|
static std::set<std::pair<std::string, int> > cache;
|
|
|
|
|
|
|
|
if (! tc_active(scope))
|
|
|
|
{
|
2022-02-08 14:18:08 +00:00
|
|
|
return;
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string filename;
|
|
|
|
#ifdef _WIN32
|
|
|
|
# define TC_ENV "TC_WIN_FILENAME"
|
|
|
|
#else
|
|
|
|
# define TC_ENV "TC_FILENAME"
|
|
|
|
#endif
|
|
|
|
if (! QUtil::get_env(TC_ENV, &filename))
|
|
|
|
{
|
2022-02-08 14:18:08 +00:00
|
|
|
return;
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
#undef TC_ENV
|
|
|
|
|
|
|
|
if (cache.count(std::make_pair(ccase, n)))
|
|
|
|
{
|
2022-02-08 14:18:08 +00:00
|
|
|
return;
|
2008-04-29 12:55:25 +00:00
|
|
|
}
|
|
|
|
cache.insert(std::make_pair(ccase, n));
|
|
|
|
|
2013-02-28 21:45:11 +00:00
|
|
|
FILE* tc = QUtil::safe_fopen(filename.c_str(), "ab");
|
2008-04-29 12:55:25 +00:00
|
|
|
fprintf(tc, "%s %d\n", ccase, n);
|
|
|
|
fclose(tc);
|
|
|
|
}
|