X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fpdf%2Fpopplercompat.cc;fp=lib%2Fpdf%2Fpopplercompat.cc;h=4da1a6fbac05358546f00e910785e87aeccc0d6a;hb=2fd59711482471414d72dfb34bca72e4b4fd04df;hp=0000000000000000000000000000000000000000;hpb=fabf01ae05897e5a9ec0e357324503f582320c32;p=swftools.git diff --git a/lib/pdf/popplercompat.cc b/lib/pdf/popplercompat.cc new file mode 100644 index 0000000..4da1a6f --- /dev/null +++ b/lib/pdf/popplercompat.cc @@ -0,0 +1,52 @@ +#include +#include +#include +#include "popplercompat.h" + +#ifdef HAVE_POPPLER +static char* getTempDir() +{ +#ifdef WIN32 + char*dir = getenv("TMP"); + if(!dir) dir = getenv("TEMP"); + if(!dir) dir = getenv("tmp"); + if(!dir) dir = getenv("temp"); + if(!dir) dir = "C:\\"; +#else + char* dir = "/tmp/"; +#endif + return dir; +} + +char* mktmpname(char*ptr) { + static char tmpbuf[128]; + char*dir = getTempDir(); + int l = strlen(dir); + char*sep = ""; + if(!ptr) + ptr = tmpbuf; + if(l && dir[l-1]!='/' && dir[l-1]!='\\') { +#ifdef WIN32 + sep = "\\"; +#else + sep = "/"; +#endif + } + + // used to be mktemp. This does remove the warnings, but + // It's not exactly an improvement. +#ifdef HAVE_LRAND48 + sprintf(ptr, "%s%s%08x%08x",dir,sep,(unsigned int)lrand48(),(unsigned int)lrand48()); +#else +# ifdef HAVE_RAND + sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand()); +# else + static int count = 1; + sprintf(ptr, "%s%s%08x%04x%04x",dir,sep,time(0),(unsigned int)tmpbuf^((unsigned int)tmpbuf)>>16,count); + count ++; +# endif +#endif + return ptr; +} + +#endif