diff options
Diffstat (limited to 'Build/source/libs/poppler/poppler-0.12.4/goo')
24 files changed, 4647 insertions, 0 deletions
diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/FixedPoint.cc b/Build/source/libs/poppler/poppler-0.12.4/goo/FixedPoint.cc new file mode 100644 index 00000000000..79a6a9ae1f4 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/FixedPoint.cc @@ -0,0 +1,120 @@ +//======================================================================== +// +// FixedPoint.cc +// +// Fixed point type, with C++ operators. +// +// Copyright 2004 Glyph & Cog, LLC +// +//======================================================================== + +#include <config.h> + +#if USE_FIXEDPOINT + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include "FixedPoint.h" + +#define ln2 ((FixedPoint)0.69314718) + +#define ln2 ((FixedPoint)0.69314718) + +FixedPoint FixedPoint::sqrt(FixedPoint x) { + FixedPoint y0, y1, z; + + if (x.val <= 0) { + y1.val = 0; + } else { + y1.val = x.val == 1 ? 2 : x.val >> 1; + do { + y0.val = y1.val; + z = x / y0; + y1.val = (y0.val + z.val) >> 1; + } while (::abs(y0.val - y1.val) > 1); + } + return y1; +} + +FixedPoint FixedPoint::pow(FixedPoint x, FixedPoint y) { + FixedPoint t, t2, lnx0, lnx, z0, z; + int d, n, i; + + if (y.val <= 0) { + z.val = 0; + } else { + // y * ln(x) + t = (x - 1) / (x + 1); + t2 = t * t; + d = 1; + lnx = 0; + do { + lnx0 = lnx; + lnx += t / d; + t *= t2; + d += 2; + } while (::abs(lnx.val - lnx0.val) > 2); + lnx.val <<= 1; + t = y * lnx; + // exp(y * ln(x)) + n = floor(t / ln2); + t -= ln2 * n; + t2 = t; + d = 1; + i = 1; + z = 1; + do { + z0 = z; + z += t2 / d; + t2 *= t; + ++i; + d *= i; + } while (::abs(z.val - z0.val) > 2 && d < (1 << fixptShift)); + if (n >= 0) { + z.val <<= n; + } else if (n < 0) { + z.val >>= -n; + } + } + return z; +} + +int FixedPoint::mul(int x, int y) { +#if 1 //~tmp + return ((FixPtInt64)x * y) >> fixptShift; +#else + int ah0, ah, bh, al, bl; + ah0 = x & fixptMaskH; + ah = x >> fixptShift; + al = x - ah0; + bh = y >> fixptShift; + bl = y - (bh << fixptShift); + return ah0 * bh + ah * bl + al * bh + ((al * bl) >> fixptShift); +#endif +} + +int FixedPoint::div(int x, int y) { +#if 1 //~tmp + return ((FixPtInt64)x << fixptShift) / y; +#else +#endif +} + +GBool FixedPoint::divCheck(FixedPoint x, FixedPoint y, FixedPoint *result) { +#if 1 //~tmp + FixPtInt64 z; + + z = ((FixPtInt64)x.val << fixptShift) / y.val; + if ((z == 0 && x != 0) || + z >= ((FixPtInt64)1 << 31) || z < -((FixPtInt64)1 << 31)) { + return gFalse; + } + result->val = z; + return gTrue; +#else +#endif +} + +#endif // USE_FIXEDPOINT diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/FixedPoint.h b/Build/source/libs/poppler/poppler-0.12.4/goo/FixedPoint.h new file mode 100644 index 00000000000..08936bc6f2a --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/FixedPoint.h @@ -0,0 +1,155 @@ +//======================================================================== +// +// FixedPoint.h +// +// Fixed point type, with C++ operators. +// +// Copyright 2004 Glyph & Cog, LLC +// +//======================================================================== + +#ifndef FIXEDPOINT_H +#define FIXEDPOINT_H + +#include "poppler/poppler-config.h" + +#if USE_FIXEDPOINT + +#ifdef USE_GCC_PRAGMAS +#pragma interface +#endif + +#include <stdio.h> +#include <stdlib.h> +#include "gtypes.h" + +#define fixptShift 16 +#define fixptMaskL ((1 << fixptShift) - 1) +#define fixptMaskH (~fixptMaskL) + +typedef long long FixPtInt64; + +class FixedPoint { +public: + + FixedPoint() { val = 0; } + FixedPoint(const FixedPoint &x) { val = x.val; } + FixedPoint(double x) { val = (int)(x * (1 << fixptShift) + 0.5); } + FixedPoint(int x) { val = x << fixptShift; } + FixedPoint(long x) { val = x << fixptShift; } + + operator float() + { return (float) val * ((float)1 / (float)(1 << fixptShift)); } + operator double() + { return (double) val * (1.0 / (double)(1 << fixptShift)); } + operator int() + { return val >> fixptShift; } + + int getRaw() { return val; } + + FixedPoint operator =(FixedPoint x) { val = x.val; return *this; } + + int operator ==(FixedPoint x) { return val == x.val; } + int operator ==(double x) { return *this == (FixedPoint)x; } + int operator ==(int x) { return *this == (FixedPoint)x; } + int operator ==(long x) { return *this == (FixedPoint)x; } + + int operator !=(FixedPoint x) { return val != x.val; } + int operator !=(double x) { return *this != (FixedPoint)x; } + int operator !=(int x) { return *this != (FixedPoint)x; } + int operator !=(long x) { return *this != (FixedPoint)x; } + + int operator <(FixedPoint x) { return val < x.val; } + int operator <(double x) { return *this < (FixedPoint)x; } + int operator <(int x) { return *this < (FixedPoint)x; } + int operator <(long x) { return *this < (FixedPoint)x; } + + int operator <=(FixedPoint x) { return val <= x.val; } + int operator <=(double x) { return *this <= (FixedPoint)x; } + int operator <=(int x) { return *this <= (FixedPoint)x; } + int operator <=(long x) { return *this <= (FixedPoint)x; } + + int operator >(FixedPoint x) { return val > x.val; } + int operator >(double x) { return *this > (FixedPoint)x; } + int operator >(int x) { return *this > (FixedPoint)x; } + int operator >(long x) { return *this > (FixedPoint)x; } + + int operator >=(FixedPoint x) { return val >= x.val; } + int operator >=(double x) { return *this >= (FixedPoint)x; } + int operator >=(int x) { return *this >= (FixedPoint)x; } + int operator >=(long x) { return *this >= (FixedPoint)x; } + + FixedPoint operator -() { return make(-val); } + + FixedPoint operator +(FixedPoint x) { return make(val + x.val); } + FixedPoint operator +(double x) { return *this + (FixedPoint)x; } + FixedPoint operator +(int x) { return *this + (FixedPoint)x; } + FixedPoint operator +(long x) { return *this + (FixedPoint)x; } + + FixedPoint operator +=(FixedPoint x) { val = val + x.val; return *this; } + FixedPoint operator +=(double x) { return *this += (FixedPoint)x; } + FixedPoint operator +=(int x) { return *this += (FixedPoint)x; } + FixedPoint operator +=(long x) { return *this += (FixedPoint)x; } + + FixedPoint operator -(FixedPoint x) { return make(val - x.val); } + FixedPoint operator -(double x) { return *this - (FixedPoint)x; } + FixedPoint operator -(int x) { return *this - (FixedPoint)x; } + FixedPoint operator -(long x) { return *this - (FixedPoint)x; } + + FixedPoint operator -=(FixedPoint x) { val = val - x.val; return *this; } + FixedPoint operator -=(double x) { return *this -= (FixedPoint)x; } + FixedPoint operator -=(int x) { return *this -= (FixedPoint)x; } + FixedPoint operator -=(long x) { return *this -= (FixedPoint)x; } + + FixedPoint operator *(FixedPoint x) { return make(mul(val, x.val)); } + FixedPoint operator *(double x) { return *this * (FixedPoint)x; } + FixedPoint operator *(int x) { return *this * (FixedPoint)x; } + FixedPoint operator *(long x) { return *this * (FixedPoint)x; } + + FixedPoint operator *=(FixedPoint x) { val = mul(val, x.val); return *this; } + FixedPoint operator *=(double x) { return *this *= (FixedPoint)x; } + FixedPoint operator *=(int x) { return *this *= (FixedPoint)x; } + FixedPoint operator *=(long x) { return *this *= (FixedPoint)x; } + + FixedPoint operator /(FixedPoint x) { return make(div(val, x.val)); } + FixedPoint operator /(double x) { return *this / (FixedPoint)x; } + FixedPoint operator /(int x) { return *this / (FixedPoint)x; } + FixedPoint operator /(long x) { return *this / (FixedPoint)x; } + + FixedPoint operator /=(FixedPoint x) { val = div(val, x.val); return *this; } + FixedPoint operator /=(double x) { return *this /= (FixedPoint)x; } + FixedPoint operator /=(int x) { return *this /= (FixedPoint)x; } + FixedPoint operator /=(long x) { return *this /= (FixedPoint)x; } + + static FixedPoint abs(FixedPoint x) { return make(::abs(x.val)); } + + static int floor(FixedPoint x) { return x.val >> fixptShift; } + + static int ceil(FixedPoint x) + { return (x.val & fixptMaskL) ? ((x.val >> fixptShift) + 1) + : (x.val >> fixptShift); } + + static int round(FixedPoint x) + { return (x.val + (1 << (fixptShift - 1))) >> fixptShift; } + + static FixedPoint sqrt(FixedPoint x); + + static FixedPoint pow(FixedPoint x, FixedPoint y); + + // Compute *result = x/y; return false if there is an underflow or + // overflow. + static GBool divCheck(FixedPoint x, FixedPoint y, FixedPoint *result); + +private: + + static FixedPoint make(int valA) { FixedPoint x; x.val = valA; return x; } + + static int mul(int x, int y); + static int div(int x, int y); + + int val; // 16.16 fixed point +}; + +#endif // USE_FIXEDPOINT + +#endif diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/GooHash.cc b/Build/source/libs/poppler/poppler-0.12.4/goo/GooHash.cc new file mode 100644 index 00000000000..5da9d69f82c --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/GooHash.cc @@ -0,0 +1,380 @@ +//======================================================================== +// +// GooHash.cc +// +// Copyright 2001-2003 Glyph & Cog, LLC +// +//======================================================================== + +#include <config.h> + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include "gmem.h" +#include "GooString.h" +#include "GooHash.h" + +//------------------------------------------------------------------------ + +struct GooHashBucket { + GooString *key; + union { + void *p; + int i; + } val; + GooHashBucket *next; +}; + +struct GooHashIter { + int h; + GooHashBucket *p; +}; + +//------------------------------------------------------------------------ + +GooHash::GooHash(GBool deleteKeysA) { + int h; + + deleteKeys = deleteKeysA; + size = 7; + tab = (GooHashBucket **)gmallocn(size, sizeof(GooHashBucket *)); + for (h = 0; h < size; ++h) { + tab[h] = NULL; + } + len = 0; +} + +GooHash::~GooHash() { + GooHashBucket *p; + int h; + + for (h = 0; h < size; ++h) { + while (tab[h]) { + p = tab[h]; + tab[h] = p->next; + if (deleteKeys) { + delete p->key; + } + delete p; + } + } + gfree(tab); +} + +void GooHash::add(GooString *key, void *val) { + GooHashBucket *p; + int h; + + // expand the table if necessary + if (len >= size) { + expand(); + } + + // add the new symbol + p = new GooHashBucket; + p->key = key; + p->val.p = val; + h = hash(key); + p->next = tab[h]; + tab[h] = p; + ++len; +} + +void GooHash::add(GooString *key, int val) { + GooHashBucket *p; + int h; + + // expand the table if necessary + if (len >= size) { + expand(); + } + + // add the new symbol + p = new GooHashBucket; + p->key = key; + p->val.i = val; + h = hash(key); + p->next = tab[h]; + tab[h] = p; + ++len; +} + +void GooHash::replace(GooString *key, void *val) { + GooHashBucket *p; + int h; + + if ((p = find(key, &h))) { + p->val.p = val; + delete key; + } else { + add(key, val); + } +} + +void GooHash::replace(GooString *key, int val) { + GooHashBucket *p; + int h; + + if ((p = find(key, &h))) { + p->val.i = val; + delete key; + } else { + add(key, val); + } +} + +void *GooHash::lookup(GooString *key) { + GooHashBucket *p; + int h; + + if (!(p = find(key, &h))) { + return NULL; + } + return p->val.p; +} + +int GooHash::lookupInt(GooString *key) { + GooHashBucket *p; + int h; + + if (!(p = find(key, &h))) { + return 0; + } + return p->val.i; +} + +void *GooHash::lookup(char *key) { + GooHashBucket *p; + int h; + + if (!(p = find(key, &h))) { + return NULL; + } + return p->val.p; +} + +int GooHash::lookupInt(char *key) { + GooHashBucket *p; + int h; + + if (!(p = find(key, &h))) { + return 0; + } + return p->val.i; +} + +void *GooHash::remove(GooString *key) { + GooHashBucket *p; + GooHashBucket **q; + void *val; + int h; + + if (!(p = find(key, &h))) { + return NULL; + } + q = &tab[h]; + while (*q != p) { + q = &((*q)->next); + } + *q = p->next; + if (deleteKeys) { + delete p->key; + } + val = p->val.p; + delete p; + --len; + return val; +} + +int GooHash::removeInt(GooString *key) { + GooHashBucket *p; + GooHashBucket **q; + int val; + int h; + + if (!(p = find(key, &h))) { + return 0; + } + q = &tab[h]; + while (*q != p) { + q = &((*q)->next); + } + *q = p->next; + if (deleteKeys) { + delete p->key; + } + val = p->val.i; + delete p; + --len; + return val; +} + +void *GooHash::remove(char *key) { + GooHashBucket *p; + GooHashBucket **q; + void *val; + int h; + + if (!(p = find(key, &h))) { + return NULL; + } + q = &tab[h]; + while (*q != p) { + q = &((*q)->next); + } + *q = p->next; + if (deleteKeys) { + delete p->key; + } + val = p->val.p; + delete p; + --len; + return val; +} + +int GooHash::removeInt(char *key) { + GooHashBucket *p; + GooHashBucket **q; + int val; + int h; + + if (!(p = find(key, &h))) { + return 0; + } + q = &tab[h]; + while (*q != p) { + q = &((*q)->next); + } + *q = p->next; + if (deleteKeys) { + delete p->key; + } + val = p->val.i; + delete p; + --len; + return val; +} + +void GooHash::startIter(GooHashIter **iter) { + *iter = new GooHashIter; + (*iter)->h = -1; + (*iter)->p = NULL; +} + +GBool GooHash::getNext(GooHashIter **iter, GooString **key, void **val) { + if (!*iter) { + return gFalse; + } + if ((*iter)->p) { + (*iter)->p = (*iter)->p->next; + } + while (!(*iter)->p) { + if (++(*iter)->h == size) { + delete *iter; + *iter = NULL; + return gFalse; + } + (*iter)->p = tab[(*iter)->h]; + } + *key = (*iter)->p->key; + *val = (*iter)->p->val.p; + return gTrue; +} + +GBool GooHash::getNext(GooHashIter **iter, GooString **key, int *val) { + if (!*iter) { + return gFalse; + } + if ((*iter)->p) { + (*iter)->p = (*iter)->p->next; + } + while (!(*iter)->p) { + if (++(*iter)->h == size) { + delete *iter; + *iter = NULL; + return gFalse; + } + (*iter)->p = tab[(*iter)->h]; + } + *key = (*iter)->p->key; + *val = (*iter)->p->val.i; + return gTrue; +} + +void GooHash::killIter(GooHashIter **iter) { + delete *iter; + *iter = NULL; +} + +void GooHash::expand() { + GooHashBucket **oldTab; + GooHashBucket *p; + int oldSize, h, i; + + oldSize = size; + oldTab = tab; + size = 2*size + 1; + tab = (GooHashBucket **)gmallocn(size, sizeof(GooHashBucket *)); + for (h = 0; h < size; ++h) { + tab[h] = NULL; + } + for (i = 0; i < oldSize; ++i) { + while (oldTab[i]) { + p = oldTab[i]; + oldTab[i] = oldTab[i]->next; + h = hash(p->key); + p->next = tab[h]; + tab[h] = p; + } + } + gfree(oldTab); +} + +GooHashBucket *GooHash::find(GooString *key, int *h) { + GooHashBucket *p; + + *h = hash(key); + for (p = tab[*h]; p; p = p->next) { + if (!p->key->cmp(key)) { + return p; + } + } + return NULL; +} + +GooHashBucket *GooHash::find(char *key, int *h) { + GooHashBucket *p; + + *h = hash(key); + for (p = tab[*h]; p; p = p->next) { + if (!p->key->cmp(key)) { + return p; + } + } + return NULL; +} + +int GooHash::hash(GooString *key) { + char *p; + unsigned int h; + int i; + + h = 0; + for (p = key->getCString(), i = 0; i < key->getLength(); ++p, ++i) { + h = 17 * h + (int)(*p & 0xff); + } + return (int)(h % size); +} + +int GooHash::hash(char *key) { + char *p; + unsigned int h; + + h = 0; + for (p = key; *p; ++p) { + h = 17 * h + (int)(*p & 0xff); + } + return (int)(h % size); +} diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/GooHash.h b/Build/source/libs/poppler/poppler-0.12.4/goo/GooHash.h new file mode 100644 index 00000000000..bdcf1c43ece --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/GooHash.h @@ -0,0 +1,76 @@ +//======================================================================== +// +// GooHash.h +// +// Copyright 2001-2003 Glyph & Cog, LLC +// +//======================================================================== + +#ifndef GHASH_H +#define GHASH_H + +#ifdef USE_GCC_PRAGMAS +#pragma interface +#endif + +#include "gtypes.h" + +class GooString; +struct GooHashBucket; +struct GooHashIter; + +//------------------------------------------------------------------------ + +class GooHash { +public: + + GooHash(GBool deleteKeysA = gFalse); + ~GooHash(); + void add(GooString *key, void *val); + void add(GooString *key, int val); + void replace(GooString *key, void *val); + void replace(GooString *key, int val); + void *lookup(GooString *key); + int lookupInt(GooString *key); + void *lookup(char *key); + int lookupInt(char *key); + void *remove(GooString *key); + int removeInt(GooString *key); + void *remove(char *key); + int removeInt(char *key); + int getLength() { return len; } + void startIter(GooHashIter **iter); + GBool getNext(GooHashIter **iter, GooString **key, void **val); + GBool getNext(GooHashIter **iter, GooString **key, int *val); + void killIter(GooHashIter **iter); + +private: + + void expand(); + GooHashBucket *find(GooString *key, int *h); + GooHashBucket *find(char *key, int *h); + int hash(GooString *key); + int hash(char *key); + + GBool deleteKeys; // set if key strings should be deleted + int size; // number of buckets + int len; // number of entries + GooHashBucket **tab; +}; + +#define deleteGooHash(hash, T) \ + do { \ + GooHash *_hash = (hash); \ + { \ + GooHashIter *_iter; \ + GooString *_key; \ + void *_p; \ + _hash->startIter(&_iter); \ + while (_hash->getNext(&_iter, &_key, &_p)) { \ + delete (T*)_p; \ + } \ + delete _hash; \ + } \ + } while(0) + +#endif diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/GooList.cc b/Build/source/libs/poppler/poppler-0.12.4/goo/GooList.cc new file mode 100644 index 00000000000..dc6e4e21e00 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/GooList.cc @@ -0,0 +1,97 @@ +//======================================================================== +// +// GooList.cc +// +// Copyright 2001-2003 Glyph & Cog, LLC +// +//======================================================================== + +#include <config.h> + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include <stdlib.h> +#include <string.h> +#include "gmem.h" +#include "GooList.h" + +//------------------------------------------------------------------------ +// GooList +//------------------------------------------------------------------------ + +GooList::GooList() { + size = 8; + data = (void **)gmallocn(size, sizeof(void*)); + length = 0; + inc = 0; +} + +GooList::GooList(int sizeA) { + size = sizeA; + data = (void **)gmallocn(size, sizeof(void*)); + length = 0; + inc = 0; +} + +GooList::~GooList() { + gfree(data); +} + +void GooList::append(void *p) { + if (length >= size) { + expand(); + } + data[length++] = p; +} + +void GooList::append(GooList *list) { + int i; + + while (length + list->length > size) { + expand(); + } + for (i = 0; i < list->length; ++i) { + data[length++] = list->data[i]; + } +} + +void GooList::insert(int i, void *p) { + if (length >= size) { + expand(); + } + if (i < length) { + memmove(data+i+1, data+i, (length - i) * sizeof(void *)); + } + data[i] = p; + ++length; +} + +void *GooList::del(int i) { + void *p; + + p = data[i]; + if (i < length - 1) { + memmove(data+i, data+i+1, (length - i - 1) * sizeof(void *)); + } + --length; + if (size - length >= ((inc > 0) ? inc : size/2)) { + shrink(); + } + return p; +} + +void GooList::sort(int (*cmp)(const void *obj1, const void *obj2)) { + qsort(data, length, sizeof(void *), cmp); +} + +void GooList::expand() { + size += (inc > 0) ? inc : size; + data = (void **)greallocn(data, size, sizeof(void*)); +} + +void GooList::shrink() { + size -= (inc > 0) ? inc : size/2; + data = (void **)greallocn(data, size, sizeof(void*)); +} diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/GooList.h b/Build/source/libs/poppler/poppler-0.12.4/goo/GooList.h new file mode 100644 index 00000000000..576f3e8142d --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/GooList.h @@ -0,0 +1,94 @@ +//======================================================================== +// +// GooList.h +// +// Copyright 2001-2003 Glyph & Cog, LLC +// +//======================================================================== + +#ifndef GLIST_H +#define GLIST_H + +#ifdef USE_GCC_PRAGMAS +#pragma interface +#endif + +#include "gtypes.h" + +//------------------------------------------------------------------------ +// GooList +//------------------------------------------------------------------------ + +class GooList { +public: + + // Create an empty list. + GooList(); + + // Create an empty list with space for <size1> elements. + GooList(int sizeA); + + // Destructor - does not free pointed-to objects. + ~GooList(); + + //----- general + + // Get the number of elements. + int getLength() { return length; } + + //----- ordered list support + + // Return the <i>th element. + // Assumes 0 <= i < length. + void *get(int i) { return data[i]; } + + // Append an element to the end of the list. + void append(void *p); + + // Append another list to the end of this one. + void append(GooList *list); + + // Insert an element at index <i>. + // Assumes 0 <= i <= length. + void insert(int i, void *p); + + // Deletes and returns the element at index <i>. + // Assumes 0 <= i < length. + void *del(int i); + + // Sort the list accoring to the given comparison function. + // NB: this sorts an array of pointers, so the pointer args need to + // be double-dereferenced. + void sort(int (*cmp)(const void *ptr1, const void *ptr2)); + + //----- control + + // Set allocation increment to <inc>. If inc > 0, that many + // elements will be allocated every time the list is expanded. + // If inc <= 0, the list will be doubled in size. + void setAllocIncr(int incA) { inc = incA; } + +private: + + void expand(); + void shrink(); + + void **data; // the list elements + int size; // size of data array + int length; // number of elements on list + int inc; // allocation increment +}; + +#define deleteGooList(list, T) \ + do { \ + GooList *_list = (list); \ + { \ + int _i; \ + for (_i = 0; _i < _list->getLength(); ++_i) { \ + delete (T*)_list->get(_i); \ + } \ + delete _list; \ + } \ + } while (0) + +#endif diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/GooMutex.h b/Build/source/libs/poppler/poppler-0.12.4/goo/GooMutex.h new file mode 100644 index 00000000000..3f53a626a67 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/GooMutex.h @@ -0,0 +1,63 @@ +//======================================================================== +// +// GooMutex.h +// +// Portable mutex macros. +// +// Copyright 2002-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#ifndef GMUTEX_H +#define GMUTEX_H + +// Usage: +// +// GooMutex m; +// gInitMutex(&m); +// ... +// gLockMutex(&m); +// ... critical section ... +// gUnlockMutex(&m); +// ... +// gDestroyMutex(&m); + +#ifdef _WIN32 + +#include <windows.h> + +typedef CRITICAL_SECTION GooMutex; + +#define gInitMutex(m) InitializeCriticalSection(m) +#define gDestroyMutex(m) DeleteCriticalSection(m) +#define gLockMutex(m) EnterCriticalSection(m) +#define gUnlockMutex(m) LeaveCriticalSection(m) + +#else // assume pthreads + +#include <pthread.h> + +typedef pthread_mutex_t GooMutex; + +#define gInitMutex(m) pthread_mutex_init(m, NULL) +#define gDestroyMutex(m) pthread_mutex_destroy(m) +#define gLockMutex(m) pthread_mutex_lock(m) +#define gUnlockMutex(m) pthread_mutex_unlock(m) + +#endif + +#endif diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/GooString.cc b/Build/source/libs/poppler/poppler-0.12.4/goo/GooString.cc new file mode 100644 index 00000000000..0d4cb73fa11 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/GooString.cc @@ -0,0 +1,804 @@ +//======================================================================== +// +// GooString.cc +// +// Simple variable-length string type. +// +// Copyright 1996-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> +// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> +// Copyright (C) 2007 Jeff Muizelaar <jeff@infidigm.net> +// Copyright (C) 2008, 2009 Albert Astals Cid <aacid@kde.org> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#include <config.h> + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include <stdlib.h> +#include <stddef.h> +#include <string.h> +#include <ctype.h> +#include <assert.h> +#include <math.h> +#include "gmem.h" +#include "GooString.h" + +static const int MAXIMUM_DOUBLE_PREC = 16; + +//------------------------------------------------------------------------ + +union GooStringFormatArg { + int i; + Guint ui; + long l; + Gulong ul; + double f; + char c; + char *s; + GooString *gs; +}; + +enum GooStringFormatType { + fmtIntDecimal, + fmtIntHex, + fmtIntOctal, + fmtIntBinary, + fmtUIntDecimal, + fmtUIntHex, + fmtUIntOctal, + fmtUIntBinary, + fmtLongDecimal, + fmtLongHex, + fmtLongOctal, + fmtLongBinary, + fmtULongDecimal, + fmtULongHex, + fmtULongOctal, + fmtULongBinary, + fmtDouble, + fmtDoubleTrimSmallAware, + fmtDoubleTrim, + fmtChar, + fmtString, + fmtGooString, + fmtSpace +}; + +static char *formatStrings[] = { + "d", "x", "o", "b", "ud", "ux", "uo", "ub", + "ld", "lx", "lo", "lb", "uld", "ulx", "ulo", "ulb", + "f", "gs", "g", + "c", + "s", + "t", + "w", + NULL +}; + +//------------------------------------------------------------------------ + +int inline GooString::roundedSize(int len) { + int delta; + if (len <= STR_STATIC_SIZE-1) + return STR_STATIC_SIZE; + delta = len < 256 ? 7 : 255; + return ((len + 1) + delta) & ~delta; +} + +// Make sure that the buffer is big enough to contain <newLength> characters +// plus terminating 0. +// We assume that if this is being called from the constructor, <s> was set +// to NULL and <length> was set to 0 to indicate unused string before calling us. +void inline GooString::resize(int newLength) { + char *s1 = s; + + if (!s || (roundedSize(length) != roundedSize(newLength))) { + // requires re-allocating data for string + if (newLength < STR_STATIC_SIZE) { + s1 = sStatic; + } else { + // allocate a rounded amount + if (s == sStatic) + s1 = (char*)gmalloc(roundedSize(newLength)); + else + s1 = (char*)grealloc(s, roundedSize(newLength)); + } + if (s == sStatic || s1 == sStatic) { + // copy the minimum, we only need to if are moving to or + // from sStatic. + // assert(s != s1) the roundedSize condition ensures this + if (newLength < length) { + memcpy(s1, s, newLength); + } else { + memcpy(s1, s, length); + } + } + + } + + s = s1; + length = newLength; + s[length] = '\0'; +} + +GooString* GooString::Set(const char *s1, int s1Len, const char *s2, int s2Len) +{ + int newLen = 0; + char *p; + + if (s1) { + if (CALC_STRING_LEN == s1Len) { + s1Len = strlen(s1); + } else + assert(s1Len >= 0); + newLen += s1Len; + } + + if (s2) { + if (CALC_STRING_LEN == s2Len) { + s2Len = strlen(s2); + } else + assert(s2Len >= 0); + newLen += s2Len; + } + + resize(newLen); + p = s; + if (s1) { + memcpy(p, s1, s1Len); + p += s1Len; + } + if (s2) { + memcpy(p, s2, s2Len); + p += s2Len; + } + return this; +} + +GooString::GooString() { + s = NULL; + length = 0; + Set(NULL); +} + +GooString::GooString(const char *sA) { + s = NULL; + length = 0; + Set(sA, CALC_STRING_LEN); +} + +GooString::GooString(const char *sA, int lengthA) { + s = NULL; + length = 0; + Set(sA, lengthA); +} + +GooString::GooString(GooString *str, int idx, int lengthA) { + s = NULL; + length = 0; + assert(idx + lengthA <= str->length); + Set(str->getCString() + idx, lengthA); +} + +GooString::GooString(GooString *str) { + s = NULL; + length = 0; + Set(str->getCString(), str->length); +} + +GooString::GooString(GooString *str1, GooString *str2) { + s = NULL; + length = 0; + Set(str1->getCString(), str1->length, str2->getCString(), str2->length); +} + +GooString *GooString::fromInt(int x) { + char buf[24]; // enough space for 64-bit ints plus a little extra + char *p; + int len; + formatInt(x, buf, sizeof(buf), gFalse, 0, 10, &p, &len); + return new GooString(p, len); +} + +GooString *GooString::format(char *fmt, ...) { + va_list argList; + GooString *s; + + s = new GooString(); + va_start(argList, fmt); + s->appendfv(fmt, argList); + va_end(argList); + return s; +} + +GooString *GooString::formatv(char *fmt, va_list argList) { + GooString *s; + + s = new GooString(); + s->appendfv(fmt, argList); + return s; +} + +GooString::~GooString() { + if (s != sStatic) + free(s); +} + +GooString *GooString::clear() { + resize(0); + return this; +} + +GooString *GooString::append(char c) { + return append((const char*)&c, 1); +} + +GooString *GooString::append(GooString *str) { + return append(str->getCString(), str->getLength()); +} + +GooString *GooString::append(const char *str, int lengthA) { + int prevLen = length; + if (CALC_STRING_LEN == lengthA) + lengthA = strlen(str); + resize(length + lengthA); + memcpy(s + prevLen, str, lengthA); + return this; +} + +GooString *GooString::appendf(char *fmt, ...) { + va_list argList; + + va_start(argList, fmt); + appendfv(fmt, argList); + va_end(argList); + return this; +} + +GooString *GooString::appendfv(char *fmt, va_list argList) { + GooStringFormatArg *args; + int argsLen, argsSize; + GooStringFormatArg arg; + int idx, width, prec; + GBool reverseAlign, zeroFill; + GooStringFormatType ft; + char buf[65]; + int len, i; + char *p0, *p1, *str; + + argsLen = 0; + argsSize = 8; + args = (GooStringFormatArg *)gmallocn(argsSize, sizeof(GooStringFormatArg)); + + p0 = fmt; + while (*p0) { + if (*p0 == '{') { + ++p0; + if (*p0 == '{') { + ++p0; + append('{'); + } else { + + // parse the format string + if (!(*p0 >= '0' && *p0 <= '9')) { + break; + } + idx = *p0 - '0'; + for (++p0; *p0 >= '0' && *p0 <= '9'; ++p0) { + idx = 10 * idx + (*p0 - '0'); + } + if (*p0 != ':') { + break; + } + ++p0; + if (*p0 == '-') { + reverseAlign = gTrue; + ++p0; + } else { + reverseAlign = gFalse; + } + width = 0; + zeroFill = *p0 == '0'; + for (; *p0 >= '0' && *p0 <= '9'; ++p0) { + width = 10 * width + (*p0 - '0'); + } + if (*p0 == '.') { + ++p0; + prec = 0; + for (; *p0 >= '0' && *p0 <= '9'; ++p0) { + prec = 10 * prec + (*p0 - '0'); + } + } else { + prec = 0; + } + for (ft = (GooStringFormatType)0; + formatStrings[ft]; + ft = (GooStringFormatType)(ft + 1)) { + if (!strncmp(p0, formatStrings[ft], strlen(formatStrings[ft]))) { + break; + } + } + if (!formatStrings[ft]) { + break; + } + p0 += strlen(formatStrings[ft]); + if (*p0 != '}') { + break; + } + ++p0; + + // fetch the argument + if (idx > argsLen) { + break; + } + if (idx == argsLen) { + if (argsLen == argsSize) { + argsSize *= 2; + args = (GooStringFormatArg *)greallocn(args, argsSize, + sizeof(GooStringFormatArg)); + } + switch (ft) { + case fmtIntDecimal: + case fmtIntHex: + case fmtIntOctal: + case fmtIntBinary: + case fmtSpace: + args[argsLen].i = va_arg(argList, int); + break; + case fmtUIntDecimal: + case fmtUIntHex: + case fmtUIntOctal: + case fmtUIntBinary: + args[argsLen].ui = va_arg(argList, Guint); + break; + case fmtLongDecimal: + case fmtLongHex: + case fmtLongOctal: + case fmtLongBinary: + args[argsLen].l = va_arg(argList, long); + break; + case fmtULongDecimal: + case fmtULongHex: + case fmtULongOctal: + case fmtULongBinary: + args[argsLen].ul = va_arg(argList, Gulong); + break; + case fmtDouble: + case fmtDoubleTrim: + case fmtDoubleTrimSmallAware: + args[argsLen].f = va_arg(argList, double); + break; + case fmtChar: + args[argsLen].c = (char)va_arg(argList, int); + break; + case fmtString: + args[argsLen].s = va_arg(argList, char *); + break; + case fmtGooString: + args[argsLen].gs = va_arg(argList, GooString *); + break; + } + ++argsLen; + } + + // format the argument + arg = args[idx]; + switch (ft) { + case fmtIntDecimal: + formatInt(arg.i, buf, sizeof(buf), zeroFill, width, 10, &str, &len); + break; + case fmtIntHex: + formatInt(arg.i, buf, sizeof(buf), zeroFill, width, 16, &str, &len); + break; + case fmtIntOctal: + formatInt(arg.i, buf, sizeof(buf), zeroFill, width, 8, &str, &len); + break; + case fmtIntBinary: + formatInt(arg.i, buf, sizeof(buf), zeroFill, width, 2, &str, &len); + break; + case fmtUIntDecimal: + formatUInt(arg.ui, buf, sizeof(buf), zeroFill, width, 10, + &str, &len); + break; + case fmtUIntHex: + formatUInt(arg.ui, buf, sizeof(buf), zeroFill, width, 16, + &str, &len); + break; + case fmtUIntOctal: + formatUInt(arg.ui, buf, sizeof(buf), zeroFill, width, 8, &str, &len); + break; + case fmtUIntBinary: + formatUInt(arg.ui, buf, sizeof(buf), zeroFill, width, 2, &str, &len); + break; + case fmtLongDecimal: + formatInt(arg.l, buf, sizeof(buf), zeroFill, width, 10, &str, &len); + break; + case fmtLongHex: + formatInt(arg.l, buf, sizeof(buf), zeroFill, width, 16, &str, &len); + break; + case fmtLongOctal: + formatInt(arg.l, buf, sizeof(buf), zeroFill, width, 8, &str, &len); + break; + case fmtLongBinary: + formatInt(arg.l, buf, sizeof(buf), zeroFill, width, 2, &str, &len); + break; + case fmtULongDecimal: + formatUInt(arg.ul, buf, sizeof(buf), zeroFill, width, 10, + &str, &len); + break; + case fmtULongHex: + formatUInt(arg.ul, buf, sizeof(buf), zeroFill, width, 16, + &str, &len); + break; + case fmtULongOctal: + formatUInt(arg.ul, buf, sizeof(buf), zeroFill, width, 8, &str, &len); + break; + case fmtULongBinary: + formatUInt(arg.ul, buf, sizeof(buf), zeroFill, width, 2, &str, &len); + break; + case fmtDouble: + formatDouble(arg.f, buf, sizeof(buf), prec, gFalse, &str, &len); + break; + case fmtDoubleTrim: + formatDouble(arg.f, buf, sizeof(buf), prec, gTrue, &str, &len); + break; + case fmtDoubleTrimSmallAware: + formatDoubleSmallAware(arg.f, buf, sizeof(buf), prec, gTrue, &str, &len); + break; + case fmtChar: + buf[0] = arg.c; + str = buf; + len = 1; + reverseAlign = !reverseAlign; + break; + case fmtString: + str = arg.s; + len = strlen(str); + reverseAlign = !reverseAlign; + break; + case fmtGooString: + str = arg.gs->getCString(); + len = arg.gs->getLength(); + reverseAlign = !reverseAlign; + break; + case fmtSpace: + str = buf; + len = 0; + width = arg.i; + break; + } + + // append the formatted arg, handling width and alignment + if (!reverseAlign && len < width) { + for (i = len; i < width; ++i) { + append(' '); + } + } + append(str, len); + if (reverseAlign && len < width) { + for (i = len; i < width; ++i) { + append(' '); + } + } + } + + } else if (*p0 == '}') { + ++p0; + if (*p0 == '}') { + ++p0; + } + append('}'); + + } else { + for (p1 = p0 + 1; *p1 && *p1 != '{' && *p1 != '}'; ++p1) ; + append(p0, p1 - p0); + p0 = p1; + } + } + + gfree(args); + return this; +} + +void GooString::formatInt(long x, char *buf, int bufSize, + GBool zeroFill, int width, int base, + char **p, int *len) { + static char vals[17] = "0123456789abcdef"; + GBool neg; + int start, i, j; + + i = bufSize; + if ((neg = x < 0)) { + x = -x; + } + start = neg ? 1 : 0; + if (x == 0) { + buf[--i] = '0'; + } else { + while (i > start && x) { + buf[--i] = vals[x % base]; + x /= base; + } + } + if (zeroFill) { + for (j = bufSize - i; i > start && j < width - start; ++j) { + buf[--i] = '0'; + } + } + if (neg) { + buf[--i] = '-'; + } + *p = buf + i; + *len = bufSize - i; +} + +void GooString::formatUInt(Gulong x, char *buf, int bufSize, + GBool zeroFill, int width, int base, + char **p, int *len) { + static char vals[17] = "0123456789abcdef"; + int i, j; + + i = bufSize; + if (x == 0) { + buf[--i] = '0'; + } else { + while (i > 0 && x) { + buf[--i] = vals[x % base]; + x /= base; + } + } + if (zeroFill) { + for (j = bufSize - i; i > 0 && j < width; ++j) { + buf[--i] = '0'; + } + } + *p = buf + i; + *len = bufSize - i; +} + +void GooString::formatDouble(double x, char *buf, int bufSize, int prec, + GBool trim, char **p, int *len) { + GBool neg, started; + double x2; + int d, i, j; + + if ((neg = x < 0)) { + x = -x; + } + x = floor(x * pow((double)10, prec) + 0.5); + i = bufSize; + started = !trim; + for (j = 0; j < prec && i > 1; ++j) { + x2 = floor(0.1 * (x + 0.5)); + d = (int)floor(x - 10 * x2 + 0.5); + if (started || d != 0) { + buf[--i] = '0' + d; + started = gTrue; + } + x = x2; + } + if (i > 1 && started) { + buf[--i] = '.'; + } + if (i > 1) { + do { + x2 = floor(0.1 * (x + 0.5)); + d = (int)floor(x - 10 * x2 + 0.5); + buf[--i] = '0' + d; + x = x2; + } while (i > 1 && x); + } + if (neg) { + buf[--i] = '-'; + } + *p = buf + i; + *len = bufSize - i; +} + +void GooString::formatDoubleSmallAware(double x, char *buf, int bufSize, int prec, + GBool trim, char **p, int *len) +{ + double absX = fabs(x); + if (absX >= 0.1) { + formatDouble(x, buf, bufSize, prec, trim, p, len); + } else { + while (absX < 0.1 && prec < MAXIMUM_DOUBLE_PREC) + { + absX = absX * 10; + prec++; + } + formatDouble(x, buf, bufSize, prec, trim, p, len); + } +} + +GooString *GooString::insert(int i, char c) { + return insert(i, (const char*)&c, 1); +} + +GooString *GooString::insert(int i, GooString *str) { + return insert(i, str->getCString(), str->getLength()); +} + +GooString *GooString::insert(int i, const char *str, int lengthA) { + int j; + int prevLen = length; + if (CALC_STRING_LEN == lengthA) + lengthA = strlen(str); + + resize(length + lengthA); + for (j = prevLen; j >= i; --j) + s[j+lengthA] = s[j]; + memcpy(s+i, str, lengthA); + return this; +} + +GooString *GooString::del(int i, int n) { + int j; + + if (n > 0) { + if (i + n > length) { + n = length - i; + } + for (j = i; j <= length - n; ++j) { + s[j] = s[j + n]; + } + resize(length - n); + } + return this; +} + +GooString *GooString::upperCase() { + int i; + + for (i = 0; i < length; ++i) { + if (islower(s[i])) + s[i] = toupper(s[i]); + } + return this; +} + +GooString *GooString::lowerCase() { + int i; + + for (i = 0; i < length; ++i) { + if (isupper(s[i])) + s[i] = tolower(s[i]); + } + return this; +} + +int GooString::cmp(GooString *str) { + int n1, n2, i, x; + char *p1, *p2; + + n1 = length; + n2 = str->length; + for (i = 0, p1 = s, p2 = str->s; i < n1 && i < n2; ++i, ++p1, ++p2) { + x = *p1 - *p2; + if (x != 0) { + return x; + } + } + return n1 - n2; +} + +int GooString::cmpN(GooString *str, int n) { + int n1, n2, i, x; + char *p1, *p2; + + n1 = length; + n2 = str->length; + for (i = 0, p1 = s, p2 = str->s; + i < n1 && i < n2 && i < n; + ++i, ++p1, ++p2) { + x = *p1 - *p2; + if (x != 0) { + return x; + } + } + if (i == n) { + return 0; + } + return n1 - n2; +} + +int GooString::cmp(const char *sA) { + int n1, i, x; + const char *p1, *p2; + + n1 = length; + for (i = 0, p1 = s, p2 = sA; i < n1 && *p2; ++i, ++p1, ++p2) { + x = *p1 - *p2; + if (x != 0) { + return x; + } + } + if (i < n1) { + return 1; + } + if (*p2) { + return -1; + } + return 0; +} + +int GooString::cmpN(const char *sA, int n) { + int n1, i, x; + const char *p1, *p2; + + n1 = length; + for (i = 0, p1 = s, p2 = sA; i < n1 && *p2 && i < n; ++i, ++p1, ++p2) { + x = *p1 - *p2; + if (x != 0) { + return x; + } + } + if (i == n) { + return 0; + } + if (i < n1) { + return 1; + } + if (*p2) { + return -1; + } + return 0; +} + +GBool GooString::hasUnicodeMarker(void) +{ + return (s[0] & 0xff) == 0xfe && (s[1] & 0xff) == 0xff; +} + +GooString *GooString::sanitizedName(GBool psmode) +{ + GooString *name; + char buf[8]; + int i; + char c; + + name = new GooString(); + + if (psmode) + { + // ghostscript chokes on names that begin with out-of-limits + // numbers, e.g., 1e4foo is handled correctly (as a name), but + // 1e999foo generates a limitcheck error + c = getChar(0); + if (c >= '0' && c <= '9') { + name->append('f'); + } + } + + for (i = 0; i < getLength(); ++i) { + c = getChar(i); + if (c <= (char)0x20 || c >= (char)0x7f || + c == ' ' || + c == '(' || c == ')' || c == '<' || c == '>' || + c == '[' || c == ']' || c == '{' || c == '}' || + c == '/' || c == '%' || c == '#') { + sprintf(buf, "#%02x", c & 0xff); + name->append(buf); + } else { + name->append(c); + } + } + return name; +} diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/GooString.h b/Build/source/libs/poppler/poppler-0.12.4/goo/GooString.h new file mode 100644 index 00000000000..731f640693b --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/GooString.h @@ -0,0 +1,176 @@ +//======================================================================== +// +// GooString.h +// +// Simple variable-length string type. +// +// Copyright 1996-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> +// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com> +// Copyright (C) 2008, 2009 Albert Astals Cid <aacid@kde.org> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#ifndef GooString_H +#define GooString_H + +#ifdef USE_GCC_PRAGMAS +#pragma interface +#endif + +#include <stdarg.h> +#include <stdlib.h> // for NULL +#include "gtypes.h" + +class GooString { +public: + + // Create an empty string. + GooString(); + + // Create a string from a C string. + GooString(const char *sA); + + // Create a string from <lengthA> chars at <sA>. This string + // can contain null characters. + GooString(const char *sA, int lengthA); + + // Create a string from <lengthA> chars at <idx> in <str>. + GooString(GooString *str, int idx, int lengthA); + + // Set content of a string to concatination of <s1> and <s2>. They can both + // be NULL. if <s1Len> or <s2Len> is CALC_STRING_LEN, then length of the string + // will be calculated with strlen(). Otherwise we assume they are a valid + // length of string (or its substring) + GooString* Set(const char *s1, int s1Len=CALC_STRING_LEN, const char *s2=NULL, int s2Len=CALC_STRING_LEN); + + // Copy a string. + GooString(GooString *str); + GooString *copy() { return new GooString(this); } + + // Concatenate two strings. + GooString(GooString *str1, GooString *str2); + + // Convert an integer to a string. + static GooString *fromInt(int x); + + // Create a formatted string. Similar to printf, but without the + // string overflow issues. Formatting elements consist of: + // {<arg>:[<width>][.<precision>]<type>} + // where: + // - <arg> is the argument number (arg 0 is the first argument + // following the format string) -- NB: args must be first used in + // order; they can be reused in any order + // - <width> is the field width -- negative to reverse the alignment; + // starting with a leading zero to zero-fill (for integers) + // - <precision> is the number of digits to the right of the decimal + // point (for floating point numbers) + // - <type> is one of: + // d, x, o, b -- int in decimal, hex, octal, binary + // ud, ux, uo, ub -- unsigned int + // ld, lx, lo, lb, uld, ulx, ulo, ulb -- long, unsigned long + // f, g -- double + // c -- char + // s -- string (char *) + // t -- GooString * + // w -- blank space; arg determines width + // To get literal curly braces, use {{ or }}. + static GooString *format(char *fmt, ...); + static GooString *formatv(char *fmt, va_list argList); + + // Destructor. + ~GooString(); + + // Get length. + int getLength() { return length; } + + // Get C string. + char *getCString() { return s; } + + // Get <i>th character. + char getChar(int i) { return s[i]; } + + // Change <i>th character. + void setChar(int i, char c) { s[i] = c; } + + // Clear string to zero length. + GooString *clear(); + + // Append a character or string. + GooString *append(char c); + GooString *append(GooString *str); + GooString *append(const char *str, int lengthA=CALC_STRING_LEN); + + // Append a formatted string. + GooString *appendf(char *fmt, ...); + GooString *appendfv(char *fmt, va_list argList); + + // Insert a character or string. + GooString *insert(int i, char c); + GooString *insert(int i, GooString *str); + GooString *insert(int i, const char *str, int lengthA=CALC_STRING_LEN); + + // Delete a character or range of characters. + GooString *del(int i, int n = 1); + + // Convert string to all-upper/all-lower case. + GooString *upperCase(); + GooString *lowerCase(); + + // Compare two strings: -1:< 0:= +1:> + int cmp(GooString *str); + int cmpN(GooString *str, int n); + int cmp(const char *sA); + int cmpN(const char *sA, int n); + + GBool hasUnicodeMarker(void); + + // Sanitizes the string so that it does + // not contain any ( ) < > [ ] { } / % + // The postscript mode also has some more strict checks + // The caller owns the return value + GooString *sanitizedName(GBool psmode); + +private: + // you can tweak this number for a different speed/memory usage tradeoffs. + // In libc malloc() rounding is 16 so it's best to choose a value that + // results in sizeof(GooString) be a multiple of 16. + // 24 makes sizeof(GooString) to be 32. + static const int STR_STATIC_SIZE = 24; + // a special value telling that the length of the string is not given + // so it must be calculated from the strings + static const int CALC_STRING_LEN = -1; + + int roundedSize(int len); + + char sStatic[STR_STATIC_SIZE]; + int length; + char *s; + + void resize(int newLength); + static void formatInt(long x, char *buf, int bufSize, + GBool zeroFill, int width, int base, + char **p, int *len); + static void formatUInt(Gulong x, char *buf, int bufSize, + GBool zeroFill, int width, int base, + char **p, int *len); + static void formatDouble(double x, char *buf, int bufSize, int prec, + GBool trim, char **p, int *len); + static void formatDoubleSmallAware(double x, char *buf, int bufSize, int prec, + GBool trim, char **p, int *len); +}; + +#endif diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/GooTimer.cc b/Build/source/libs/poppler/poppler-0.12.4/goo/GooTimer.cc new file mode 100644 index 00000000000..769fd639775 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/GooTimer.cc @@ -0,0 +1,94 @@ +//======================================================================== +// +// GooTimer.cc +// +// This file is licensed under GPLv2 or later +// +// Copyright 2005 Jonathan Blandford <jrb@redhat.com> +// Copyright 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com> +// Inspired by gtimer.c in glib, which is Copyright 2000 by the GLib Team +// +//======================================================================== + +#include <config.h> + +#ifdef USE_GCC_PRAGMAS +#pragma implementation +#endif + +#include "GooTimer.h" +#include <string.h> + +#define USEC_PER_SEC 1000000 + +//------------------------------------------------------------------------ +// GooTimer +//------------------------------------------------------------------------ + +GooTimer::GooTimer() { + start(); +} + +void GooTimer::start() { +#ifdef HAVE_GETTIMEOFDAY + gettimeofday(&start_time, NULL); +#elif defined(_MSC_VER) + QueryPerformanceCounter(&start_time); +#endif + active = true; +} + +void GooTimer::stop() { +#ifdef HAVE_GETTIMEOFDAY + gettimeofday(&end_time, NULL); +#elif defined(_MSC_VER) + QueryPerformanceCounter(&end_time); +#endif + active = false; +} + +#ifdef HAVE_GETTIMEOFDAY +double GooTimer::getElapsed() +{ + double total; + struct timeval elapsed; + + if (active) + gettimeofday(&end_time, NULL); + + if (start_time.tv_usec > end_time.tv_usec) { + end_time.tv_usec += USEC_PER_SEC; + end_time.tv_sec--; + } + + elapsed.tv_usec = end_time.tv_usec - start_time.tv_usec; + elapsed.tv_sec = end_time.tv_sec - start_time.tv_sec; + + total = elapsed.tv_sec + ((double) elapsed.tv_usec / 1e6); + if (total < 0) + total = 0; + + return total; +} +#elif defined(_MSC_VER) +double GooTimer::getElapsed() +{ + LARGE_INTEGER freq; + double time_in_secs; + QueryPerformanceFrequency(&freq); + + if (active) + QueryPerformanceCounter(&end_time); + + time_in_secs = (double)(end_time.QuadPart-start_time.QuadPart)/(double)freq.QuadPart; + return time_in_secs * 1000.0; + +} +#else +double GooTimer::getElapsed() +{ +#warning "no support for GooTimer" + return 0; +} +#endif + diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/GooTimer.h b/Build/source/libs/poppler/poppler-0.12.4/goo/GooTimer.h new file mode 100755 index 00000000000..f03413c21e6 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/GooTimer.h @@ -0,0 +1,54 @@ +//======================================================================== +// +// GooTimer.cc +// +// This file is licensed under GPLv2 or later +// +// Copyright 2005 Jonathan Blandford <jrb@redhat.com> +// Copyright 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com> +// Inspired by gtimer.c in glib, which is Copyright 2000 by the GLib Team +// +//======================================================================== + +#ifndef GOOTIMER_H +#define GOOTIMER_H + +#ifdef USE_GCC_PRAGMAS +#pragma interface +#endif + +#include "gtypes.h" +#ifdef HAVE_GETTIMEOFDAY +#include <sys/time.h> +#endif + +#ifdef _MSC_VER +#include <windows.h> +#endif + +//------------------------------------------------------------------------ +// GooTimer +//------------------------------------------------------------------------ + +class GooTimer { +public: + + // Create a new timer. + GooTimer(); + + void start(); + void stop(); + double getElapsed(); + +private: +#ifdef HAVE_GETTIMEOFDAY + struct timeval start_time; + struct timeval end_time; +#elif defined(_MSC_VER) + LARGE_INTEGER start_time; + LARGE_INTEGER end_time; +#endif + GBool active; +}; + +#endif diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/GooVector.h b/Build/source/libs/poppler/poppler-0.12.4/goo/GooVector.h new file mode 100644 index 00000000000..31a72e9bbe5 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/GooVector.h @@ -0,0 +1,113 @@ +//======================================================================== +// +// This file comes from pdftohtml project +// http://pdftohtml.sourceforge.net +// +// Copyright from: +// Gueorgui Ovtcharov +// Rainer Dorsch <http://www.ra.informatik.uni-stuttgart.de/~rainer/> +// Mikhail Kruk <meshko@cs.brandeis.edu> +// +//======================================================================== + +#ifndef GOO_VECTOR_H +#define GOO_VECTOR_H +#include "goo/gtypes.h" + + +template<class T> +class GooVector{ +private: + + int _size; + T* last; + T* storage; + + void resize(){ + if (_size==0) _size=2;else _size=2*_size; + T *tmp=new T[_size]; + if (storage){ + last=copy(storage,last,tmp); + delete [] storage; + } + else last=tmp; + storage=tmp; + } + + T* copy(T* src1,T* src2,T* dest){ + T* tmp=src1; + T* d=dest; + while(tmp!=src2){ + *d=*tmp; + d++;tmp++; + } + return d; + } + +public: + typedef T* iterator; + + GooVector(){ + _size=0; + last=0; + storage=0; +} + + + +virtual ~GooVector(){ + delete[] storage ; +} + +void reset(){ + last=storage; +} + +int size(){ + return (last-storage); +} +void push_back(const T& elem){ + if (!storage||(size() >=_size)) resize(); + *last=elem; + last++; + + +} + + +T pop_back() { + if (last!=storage) last--; + + return *last; +} + + +T operator[](unsigned int i){ + return *(storage+i); +} + + +GBool isEmpty() const{ + return !_size || (last==storage) ; +} + + + +iterator begin() const{ + return storage; +} + +iterator end() const { + return last; +} +}; +#endif + + + + + + + + + diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/Makefile.am b/Build/source/libs/poppler/poppler-0.12.4/goo/Makefile.am new file mode 100644 index 00000000000..f10fd150458 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/Makefile.am @@ -0,0 +1,35 @@ +noinst_LTLIBRARIES = libgoo.la + +if ENABLE_XPDF_HEADERS + +poppler_goo_includedir = $(includedir)/poppler/goo +poppler_goo_include_HEADERS = \ + GooHash.h \ + GooList.h \ + GooTimer.h \ + GooMutex.h \ + GooString.h \ + GooVector.h \ + gtypes.h \ + gmem.h \ + gfile.h \ + FixedPoint.h \ + PNGWriter.h \ + gstrtod.h + +endif + +INCLUDES = \ + -I$(top_srcdir) + +libgoo_la_SOURCES = \ + gfile.cc \ + gmempp.cc \ + GooHash.cc \ + GooList.cc \ + GooTimer.cc \ + GooString.cc \ + gmem.cc \ + FixedPoint.cc \ + PNGWriter.cc \ + gstrtod.cc diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/Makefile.in b/Build/source/libs/poppler/poppler-0.12.4/goo/Makefile.in new file mode 100644 index 00000000000..c4b58fba847 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/Makefile.in @@ -0,0 +1,647 @@ +# Makefile.in generated by automake 1.11 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = goo +DIST_COMMON = $(am__poppler_goo_include_HEADERS_DIST) \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/acx_pthread.m4 \ + $(top_srcdir)/m4/define-dir.m4 $(top_srcdir)/m4/gtk-doc.m4 \ + $(top_srcdir)/m4/libjpeg.m4 $(top_srcdir)/m4/libpng.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/qt.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h \ + $(top_builddir)/poppler/poppler-config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libgoo_la_LIBADD = +am_libgoo_la_OBJECTS = gfile.lo gmempp.lo GooHash.lo GooList.lo \ + GooTimer.lo GooString.lo gmem.lo FixedPoint.lo PNGWriter.lo \ + gstrtod.lo +libgoo_la_OBJECTS = $(am_libgoo_la_OBJECTS) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) -I$(top_builddir)/poppler +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_$(V)) +am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY)) +am__v_CXX_0 = @echo " CXX " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CXXLD = $(am__v_CXXLD_$(V)) +am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CXXLD_0 = @echo " CXXLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(libgoo_la_SOURCES) +DIST_SOURCES = $(libgoo_la_SOURCES) +am__poppler_goo_include_HEADERS_DIST = GooHash.h GooList.h GooTimer.h \ + GooMutex.h GooString.h GooVector.h gtypes.h gmem.h gfile.h \ + FixedPoint.h PNGWriter.h gstrtod.h +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(poppler_goo_includedir)" +HEADERS = $(poppler_goo_include_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ABIWORD_CFLAGS = @ABIWORD_CFLAGS@ +ABIWORD_LIBS = @ABIWORD_LIBS@ +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CAIRO_CFLAGS = @CAIRO_CFLAGS@ +CAIRO_FEATURE = @CAIRO_FEATURE@ +CAIRO_LIBS = @CAIRO_LIBS@ +CAIRO_REQ = @CAIRO_REQ@ +CAIRO_VERSION = @CAIRO_VERSION@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ +FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ +FREETYPE_CFLAGS = @FREETYPE_CFLAGS@ +FREETYPE_CONFIG = @FREETYPE_CONFIG@ +FREETYPE_LIBS = @FREETYPE_LIBS@ +GDK_CFLAGS = @GDK_CFLAGS@ +GDK_FEATURE = @GDK_FEATURE@ +GDK_LIBS = @GDK_LIBS@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GREP = @GREP@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTK_TEST_CFLAGS = @GTK_TEST_CFLAGS@ +GTK_TEST_LIBS = @GTK_TEST_LIBS@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LCMS_CFLAGS = @LCMS_CFLAGS@ +LCMS_LIBS = @LCMS_LIBS@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBJPEG_LIBS = @LIBJPEG_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBOPENJPEG_LIBS = @LIBOPENJPEG_LIBS@ +LIBPNG_LIBS = @LIBPNG_LIBS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MOCQT4 = @MOCQT4@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PC_REQUIRES = @PC_REQUIRES@ +PC_REQUIRES_PRIVATE = @PC_REQUIRES_PRIVATE@ +PKG_CONFIG = @PKG_CONFIG@ +POPPLER_DATADIR = @POPPLER_DATADIR@ +POPPLER_GLIB_CFLAGS = @POPPLER_GLIB_CFLAGS@ +POPPLER_GLIB_DISABLE_DEPRECATED = @POPPLER_GLIB_DISABLE_DEPRECATED@ +POPPLER_GLIB_DISABLE_SINGLE_INCLUDES = @POPPLER_GLIB_DISABLE_SINGLE_INCLUDES@ +POPPLER_GLIB_LIBS = @POPPLER_GLIB_LIBS@ +POPPLER_MAJOR_VERSION = @POPPLER_MAJOR_VERSION@ +POPPLER_MICRO_VERSION = @POPPLER_MICRO_VERSION@ +POPPLER_MINOR_VERSION = @POPPLER_MINOR_VERSION@ +POPPLER_QT4_CFLAGS = @POPPLER_QT4_CFLAGS@ +POPPLER_QT4_CXXFLAGS = @POPPLER_QT4_CXXFLAGS@ +POPPLER_QT4_LIBS = @POPPLER_QT4_LIBS@ +POPPLER_QT4_TEST_CFLAGS = @POPPLER_QT4_TEST_CFLAGS@ +POPPLER_QT4_TEST_LIBS = @POPPLER_QT4_TEST_LIBS@ +POPPLER_QT_CXXFLAGS = @POPPLER_QT_CXXFLAGS@ +POPPLER_QT_LIBS = @POPPLER_QT_LIBS@ +PTHREAD_CC = @PTHREAD_CC@ +PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ +PTHREAD_LIBS = @PTHREAD_LIBS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +ZLIB_LIBS = @ZLIB_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +acx_pthread_config = @acx_pthread_config@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +auto_import_flags = @auto_import_flags@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +create_shared_lib = @create_shared_lib@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +win32_libs = @win32_libs@ +noinst_LTLIBRARIES = libgoo.la +@ENABLE_XPDF_HEADERS_TRUE@poppler_goo_includedir = $(includedir)/poppler/goo +@ENABLE_XPDF_HEADERS_TRUE@poppler_goo_include_HEADERS = \ +@ENABLE_XPDF_HEADERS_TRUE@ GooHash.h \ +@ENABLE_XPDF_HEADERS_TRUE@ GooList.h \ +@ENABLE_XPDF_HEADERS_TRUE@ GooTimer.h \ +@ENABLE_XPDF_HEADERS_TRUE@ GooMutex.h \ +@ENABLE_XPDF_HEADERS_TRUE@ GooString.h \ +@ENABLE_XPDF_HEADERS_TRUE@ GooVector.h \ +@ENABLE_XPDF_HEADERS_TRUE@ gtypes.h \ +@ENABLE_XPDF_HEADERS_TRUE@ gmem.h \ +@ENABLE_XPDF_HEADERS_TRUE@ gfile.h \ +@ENABLE_XPDF_HEADERS_TRUE@ FixedPoint.h \ +@ENABLE_XPDF_HEADERS_TRUE@ PNGWriter.h \ +@ENABLE_XPDF_HEADERS_TRUE@ gstrtod.h + +INCLUDES = \ + -I$(top_srcdir) + +libgoo_la_SOURCES = \ + gfile.cc \ + gmempp.cc \ + GooHash.cc \ + GooList.cc \ + GooTimer.cc \ + GooString.cc \ + gmem.cc \ + FixedPoint.cc \ + PNGWriter.cc \ + gstrtod.cc + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cc .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign goo/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign goo/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libgoo.la: $(libgoo_la_OBJECTS) $(libgoo_la_DEPENDENCIES) + $(AM_V_CXXLD)$(CXXLINK) $(libgoo_la_OBJECTS) $(libgoo_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FixedPoint.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GooHash.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GooList.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GooString.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GooTimer.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PNGWriter.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gfile.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gmem.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gmempp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gstrtod.Plo@am__quote@ + +.cc.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cc.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cc.lo: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-poppler_goo_includeHEADERS: $(poppler_goo_include_HEADERS) + @$(NORMAL_INSTALL) + test -z "$(poppler_goo_includedir)" || $(MKDIR_P) "$(DESTDIR)$(poppler_goo_includedir)" + @list='$(poppler_goo_include_HEADERS)'; test -n "$(poppler_goo_includedir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(poppler_goo_includedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(poppler_goo_includedir)" || exit $$?; \ + done + +uninstall-poppler_goo_includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(poppler_goo_include_HEADERS)'; test -n "$(poppler_goo_includedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(poppler_goo_includedir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(poppler_goo_includedir)" && rm -f $$files + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(poppler_goo_includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-poppler_goo_includeHEADERS + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-poppler_goo_includeHEADERS + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-poppler_goo_includeHEADERS \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am \ + uninstall-poppler_goo_includeHEADERS + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/PNGWriter.cc b/Build/source/libs/poppler/poppler-0.12.4/goo/PNGWriter.cc new file mode 100644 index 00000000000..864c976bc2b --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/PNGWriter.cc @@ -0,0 +1,110 @@ +//======================================================================== +// +// PNGWriter.cc +// +// This file is licensed under the GPLv2 or later +// +// Copyright (C) 2009 Warren Toomey <wkt@tuhs.org> +// Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com> +// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> +// +//======================================================================== + +#include "PNGWriter.h" + +#ifdef ENABLE_LIBPNG + +#include "poppler/Error.h" + +PNGWriter::PNGWriter() +{ +} + +PNGWriter::~PNGWriter() +{ + /* cleanup heap allocation */ + png_destroy_write_struct(&png_ptr, &info_ptr); +} + +bool PNGWriter::init(FILE *f, int width, int height) +{ + /* initialize stuff */ + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png_ptr) { + error(-1, "png_create_write_struct failed"); + return false; + } + + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) { + error(-1, "png_create_info_struct failed"); + return false; + } + + if (setjmp(png_jmpbuf(png_ptr))) { + error(-1, "png_jmpbuf failed"); + return false; + } + + /* write header */ + png_init_io(png_ptr, f); + if (setjmp(png_jmpbuf(png_ptr))) { + error(-1, "Error during writing header"); + return false; + } + + // Set up the type of PNG image and the compression level + png_set_compression_level(png_ptr, Z_BEST_COMPRESSION); + + png_byte bit_depth = 8; + png_byte color_type = PNG_COLOR_TYPE_RGB; + png_byte interlace_type = PNG_INTERLACE_NONE; + + png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, color_type, interlace_type, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + + png_write_info(png_ptr, info_ptr); + if (setjmp(png_jmpbuf(png_ptr))) { + error(-1, "error during writing png info bytes"); + return false; + } + + return true; +} + +bool PNGWriter::writePointers(png_bytep *rowPointers) +{ + png_write_image(png_ptr, rowPointers); + /* write bytes */ + if (setjmp(png_jmpbuf(png_ptr))) { + error(-1, "Error during writing bytes"); + return false; + } + + return true; +} + +bool PNGWriter::writeRow(png_bytep *row) +{ + // Write the row to the file + png_write_rows(png_ptr, row, 1); + if (setjmp(png_jmpbuf(png_ptr))) { + error(-1, "error during png row write"); + return false; + } + + return true; +} + +bool PNGWriter::close() +{ + /* end write */ + png_write_end(png_ptr, info_ptr); + if (setjmp(png_jmpbuf(png_ptr))) { + error(-1, "Error during end of write"); + return false; + } + + return true; +} + +#endif diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/PNGWriter.h b/Build/source/libs/poppler/poppler-0.12.4/goo/PNGWriter.h new file mode 100644 index 00000000000..0540bd7dfa2 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/PNGWriter.h @@ -0,0 +1,43 @@ +//======================================================================== +// +// PNGWriter.h +// +// This file is licensed under the GPLv2 or later +// +// Copyright (C) 2009 Warren Toomey <wkt@tuhs.org> +// Copyright (C) 2009 Shen Liang <shenzhuxi@gmail.com> +// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> +// +//======================================================================== + +#ifndef PNGWRITER_H +#define PNGWRITER_H + +#include <config.h> + +#ifdef ENABLE_LIBPNG + +#include <cstdio> +#include <png.h> + +class PNGWriter +{ + public: + PNGWriter(); + ~PNGWriter(); + + bool init(FILE *f, int width, int height); + + bool writePointers(png_bytep *rowPointers); + bool writeRow(png_bytep *row); + + bool close(); + + private: + png_structp png_ptr; + png_infop info_ptr; +}; + +#endif + +#endif
\ No newline at end of file diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/gfile.cc b/Build/source/libs/poppler/poppler-0.12.4/goo/gfile.cc new file mode 100644 index 00000000000..e87563057e1 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/gfile.cc @@ -0,0 +1,723 @@ +//======================================================================== +// +// gfile.cc +// +// Miscellaneous file and directory name manipulation. +// +// Copyright 1996-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> +// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> +// Copyright (C) 2008 Adam Batkin <adam@batkin.net> +// Copyright (C) 2008 Hib Eris <hib@hiberis.nl> +// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#include <config.h> + +#ifdef _WIN32 +# include <time.h> +#else +# if defined(MACOS) +# include <sys/stat.h> +# elif !defined(ACORN) +# include <sys/types.h> +# include <sys/stat.h> +# include <fcntl.h> +# endif +# include <limits.h> +# include <string.h> +# if !defined(VMS) && !defined(ACORN) && !defined(MACOS) +# include <pwd.h> +# endif +# if defined(VMS) && (__DECCXX_VER < 50200000) +# include <unixlib.h> +# endif +#endif // _WIN32 +#include "GooString.h" +#include "gfile.h" + +// Some systems don't define this, so just make it something reasonably +// large. +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif + +//------------------------------------------------------------------------ + +GooString *getHomeDir() { +#ifdef VMS + //---------- VMS ---------- + return new GooString("SYS$LOGIN:"); + +#elif defined(__EMX__) || defined(_WIN32) + //---------- OS/2+EMX and Win32 ---------- + char *s; + GooString *ret; + + if ((s = getenv("HOME"))) + ret = new GooString(s); + else + ret = new GooString("."); + return ret; + +#elif defined(ACORN) + //---------- RISCOS ---------- + return new GooString("@"); + +#elif defined(MACOS) + //---------- MacOS ---------- + return new GooString(":"); + +#else + //---------- Unix ---------- + char *s; + struct passwd *pw; + GooString *ret; + + if ((s = getenv("HOME"))) { + ret = new GooString(s); + } else { + if ((s = getenv("USER"))) + pw = getpwnam(s); + else + pw = getpwuid(getuid()); + if (pw) + ret = new GooString(pw->pw_dir); + else + ret = new GooString("."); + } + return ret; +#endif +} + +GooString *getCurrentDir() { + char buf[PATH_MAX+1]; + +#if defined(__EMX__) + if (_getcwd2(buf, sizeof(buf))) +#elif defined(_WIN32) + if (GetCurrentDirectory(sizeof(buf), buf)) +#elif defined(ACORN) + if (strcpy(buf, "@")) +#elif defined(MACOS) + if (strcpy(buf, ":")) +#else + if (getcwd(buf, sizeof(buf))) +#endif + return new GooString(buf); + return new GooString(); +} + +GooString *appendToPath(GooString *path, char *fileName) { +#if defined(VMS) + //---------- VMS ---------- + //~ this should handle everything necessary for file + //~ requesters, but it's certainly not complete + char *p0, *p1, *p2; + char *q1; + + p0 = path->getCString(); + p1 = p0 + path->getLength() - 1; + if (!strcmp(fileName, "-")) { + if (*p1 == ']') { + for (p2 = p1; p2 > p0 && *p2 != '.' && *p2 != '['; --p2) ; + if (*p2 == '[') + ++p2; + path->del(p2 - p0, p1 - p2); + } else if (*p1 == ':') { + path->append("[-]"); + } else { + path->clear(); + path->append("[-]"); + } + } else if ((q1 = strrchr(fileName, '.')) && !strncmp(q1, ".DIR;", 5)) { + if (*p1 == ']') { + path->insert(p1 - p0, '.'); + path->insert(p1 - p0 + 1, fileName, q1 - fileName); + } else if (*p1 == ':') { + path->append('['); + path->append(']'); + path->append(fileName, q1 - fileName); + } else { + path->clear(); + path->append(fileName, q1 - fileName); + } + } else { + if (*p1 != ']' && *p1 != ':') + path->clear(); + path->append(fileName); + } + return path; + +#elif defined(_WIN32) + //---------- Win32 ---------- + GooString *tmp; + char buf[256]; + char *fp; + + tmp = new GooString(path); + tmp->append('/'); + tmp->append(fileName); + GetFullPathName(tmp->getCString(), sizeof(buf), buf, &fp); + delete tmp; + path->clear(); + path->append(buf); + return path; + +#elif defined(ACORN) + //---------- RISCOS ---------- + char *p; + int i; + + path->append("."); + i = path->getLength(); + path->append(fileName); + for (p = path->getCString() + i; *p; ++p) { + if (*p == '/') { + *p = '.'; + } else if (*p == '.') { + *p = '/'; + } + } + return path; + +#elif defined(MACOS) + //---------- MacOS ---------- + char *p; + int i; + + path->append(":"); + i = path->getLength(); + path->append(fileName); + for (p = path->getCString() + i; *p; ++p) { + if (*p == '/') { + *p = ':'; + } else if (*p == '.') { + *p = ':'; + } + } + return path; + +#elif defined(__EMX__) + //---------- OS/2+EMX ---------- + int i; + + // appending "." does nothing + if (!strcmp(fileName, ".")) + return path; + + // appending ".." goes up one directory + if (!strcmp(fileName, "..")) { + for (i = path->getLength() - 2; i >= 0; --i) { + if (path->getChar(i) == '/' || path->getChar(i) == '\\' || + path->getChar(i) == ':') + break; + } + if (i <= 0) { + if (path->getChar(0) == '/' || path->getChar(0) == '\\') { + path->del(1, path->getLength() - 1); + } else if (path->getLength() >= 2 && path->getChar(1) == ':') { + path->del(2, path->getLength() - 2); + } else { + path->clear(); + path->append(".."); + } + } else { + if (path->getChar(i-1) == ':') + ++i; + path->del(i, path->getLength() - i); + } + return path; + } + + // otherwise, append "/" and new path component + if (path->getLength() > 0 && + path->getChar(path->getLength() - 1) != '/' && + path->getChar(path->getLength() - 1) != '\\') + path->append('/'); + path->append(fileName); + return path; + +#else + //---------- Unix ---------- + int i; + + // appending "." does nothing + if (!strcmp(fileName, ".")) + return path; + + // appending ".." goes up one directory + if (!strcmp(fileName, "..")) { + for (i = path->getLength() - 2; i >= 0; --i) { + if (path->getChar(i) == '/') + break; + } + if (i <= 0) { + if (path->getChar(0) == '/') { + path->del(1, path->getLength() - 1); + } else { + path->clear(); + path->append(".."); + } + } else { + path->del(i, path->getLength() - i); + } + return path; + } + + // otherwise, append "/" and new path component + if (path->getLength() > 0 && + path->getChar(path->getLength() - 1) != '/') + path->append('/'); + path->append(fileName); + return path; +#endif +} + +GooString *grabPath(char *fileName) { +#ifdef VMS + //---------- VMS ---------- + char *p; + + if ((p = strrchr(fileName, ']'))) + return new GooString(fileName, p + 1 - fileName); + if ((p = strrchr(fileName, ':'))) + return new GooString(fileName, p + 1 - fileName); + return new GooString(); + +#elif defined(__EMX__) || defined(_WIN32) + //---------- OS/2+EMX and Win32 ---------- + char *p; + + if ((p = strrchr(fileName, '/'))) + return new GooString(fileName, p - fileName); + if ((p = strrchr(fileName, '\\'))) + return new GooString(fileName, p - fileName); + if ((p = strrchr(fileName, ':'))) + return new GooString(fileName, p + 1 - fileName); + return new GooString(); + +#elif defined(ACORN) + //---------- RISCOS ---------- + char *p; + + if ((p = strrchr(fileName, '.'))) + return new GooString(fileName, p - fileName); + return new GooString(); + +#elif defined(MACOS) + //---------- MacOS ---------- + char *p; + + if ((p = strrchr(fileName, ':'))) + return new GooString(fileName, p - fileName); + return new GooString(); + +#else + //---------- Unix ---------- + char *p; + + if ((p = strrchr(fileName, '/'))) + return new GooString(fileName, p - fileName); + return new GooString(); +#endif +} + +GBool isAbsolutePath(char *path) { +#ifdef VMS + //---------- VMS ---------- + return strchr(path, ':') || + (path[0] == '[' && path[1] != '.' && path[1] != '-'); + +#elif defined(__EMX__) || defined(_WIN32) + //---------- OS/2+EMX and Win32 ---------- + return path[0] == '/' || path[0] == '\\' || path[1] == ':'; + +#elif defined(ACORN) + //---------- RISCOS ---------- + return path[0] == '$'; + +#elif defined(MACOS) + //---------- MacOS ---------- + return path[0] != ':'; + +#else + //---------- Unix ---------- + return path[0] == '/'; +#endif +} + +GooString *makePathAbsolute(GooString *path) { +#ifdef VMS + //---------- VMS ---------- + char buf[PATH_MAX+1]; + + if (!isAbsolutePath(path->getCString())) { + if (getcwd(buf, sizeof(buf))) { + path->insert(0, buf); + } + } + return path; + +#elif defined(_WIN32) + //---------- Win32 ---------- + char buf[_MAX_PATH]; + char *fp; + + buf[0] = '\0'; + if (!GetFullPathName(path->getCString(), _MAX_PATH, buf, &fp)) { + path->clear(); + return path; + } + path->clear(); + path->append(buf); + return path; + +#elif defined(ACORN) + //---------- RISCOS ---------- + path->insert(0, '@'); + return path; + +#elif defined(MACOS) + //---------- MacOS ---------- + path->del(0, 1); + return path; + +#else + //---------- Unix and OS/2+EMX ---------- + struct passwd *pw; + char buf[PATH_MAX+1]; + GooString *s; + char *p1, *p2; + int n; + + if (path->getChar(0) == '~') { + if (path->getChar(1) == '/' || +#ifdef __EMX__ + path->getChar(1) == '\\' || +#endif + path->getLength() == 1) { + path->del(0, 1); + s = getHomeDir(); + path->insert(0, s); + delete s; + } else { + p1 = path->getCString() + 1; +#ifdef __EMX__ + for (p2 = p1; *p2 && *p2 != '/' && *p2 != '\\'; ++p2) ; +#else + for (p2 = p1; *p2 && *p2 != '/'; ++p2) ; +#endif + if ((n = p2 - p1) > PATH_MAX) + n = PATH_MAX; + strncpy(buf, p1, n); + buf[n] = '\0'; + if ((pw = getpwnam(buf))) { + path->del(0, p2 - p1 + 1); + path->insert(0, pw->pw_dir); + } + } + } else if (!isAbsolutePath(path->getCString())) { + if (getcwd(buf, sizeof(buf))) { +#ifndef __EMX__ + path->insert(0, '/'); +#endif + path->insert(0, buf); + } + } + return path; +#endif +} + +time_t getModTime(char *fileName) { +#ifdef _WIN32 + //~ should implement this, but it's (currently) only used in xpdf + return 0; +#else + struct stat statBuf; + + if (stat(fileName, &statBuf)) { + return 0; + } + return statBuf.st_mtime; +#endif +} + +GBool openTempFile(GooString **name, FILE **f, char *mode) { +#if defined(_WIN32) + //---------- Win32 ---------- + char *tempDir; + GooString *s, *s2; + char buf[32]; + FILE *f2; + int t, i; + + // this has the standard race condition problem, but I haven't found + // a better way to generate temp file names with extensions on + // Windows + if ((tempDir = getenv("TEMP"))) { + s = new GooString(tempDir); + s->append('\\'); + } else { + s = new GooString(); + } + s->append("x"); + t = (int)time(NULL); + for (i = 0; i < 1000; ++i) { + sprintf(buf, "%d", t + i); + s2 = s->copy()->append(buf); + if (!(f2 = fopen(s2->getCString(), "r"))) { + if (!(f2 = fopen(s2->getCString(), mode))) { + delete s2; + delete s; + return gFalse; + } + *name = s2; + *f = f2; + delete s; + return gTrue; + } + fclose(f2); + delete s2; + } + delete s; + return gFalse; +#elif defined(VMS) || defined(__EMX__) || defined(ACORN) || defined(MACOS) + //---------- non-Unix ---------- + char *s; + + // There is a security hole here: an attacker can create a symlink + // with this file name after the tmpnam call and before the fopen + // call. I will happily accept fixes to this function for non-Unix + // OSs. + if (!(s = tmpnam(NULL))) { + return gFalse; + } + *name = new GooString(s); + if (!(*f = fopen((*name)->getCString(), mode))) { + delete (*name); + return gFalse; + } + return gTrue; +#else + //---------- Unix ---------- + char *s; + int fd; + +#if HAVE_MKSTEMP + if ((s = getenv("TMPDIR"))) { + *name = new GooString(s); + } else { + *name = new GooString("/tmp"); + } + (*name)->append("/XXXXXX"); + fd = mkstemp((*name)->getCString()); +#else // HAVE_MKSTEMP + if (!(s = tmpnam(NULL))) { + return gFalse; + } + *name = new GooString(s); + fd = open((*name)->getCString(), O_WRONLY | O_CREAT | O_EXCL, 0600); +#endif // HAVE_MKSTEMP + if (fd < 0 || !(*f = fdopen(fd, mode))) { + delete *name; + return gFalse; + } + return gTrue; +#endif +} + +GBool executeCommand(char *cmd) { +#ifdef VMS + return system(cmd) ? gTrue : gFalse; +#else + return system(cmd) ? gFalse : gTrue; +#endif +} + +char *getLine(char *buf, int size, FILE *f) { + int c, i; + + i = 0; + while (i < size - 1) { + if ((c = fgetc(f)) == EOF) { + break; + } + buf[i++] = (char)c; + if (c == '\x0a') { + break; + } + if (c == '\x0d') { + c = fgetc(f); + if (c == '\x0a' && i < size - 1) { + buf[i++] = (char)c; + } else if (c != EOF) { + ungetc(c, f); + } + break; + } + } + buf[i] = '\0'; + if (i == 0) { + return NULL; + } + return buf; +} + +//------------------------------------------------------------------------ +// GDir and GDirEntry +//------------------------------------------------------------------------ + +GDirEntry::GDirEntry(char *dirPath, char *nameA, GBool doStat) { +#ifdef VMS + char *p; +#elif defined(_WIN32) + DWORD fa; +#elif defined(ACORN) +#else + struct stat st; +#endif + + name = new GooString(nameA); + dir = gFalse; + fullPath = new GooString(dirPath); + appendToPath(fullPath, nameA); + if (doStat) { +#ifdef VMS + if (!strcmp(nameA, "-") || + ((p = strrchr(nameA, '.')) && !strncmp(p, ".DIR;", 5))) + dir = gTrue; +#elif defined(ACORN) +#else +#ifdef _WIN32 + fa = GetFileAttributes(fullPath->getCString()); + dir = (fa != 0xFFFFFFFF && (fa & FILE_ATTRIBUTE_DIRECTORY)); +#else + if (stat(fullPath->getCString(), &st) == 0) + dir = S_ISDIR(st.st_mode); +#endif +#endif + } +} + +GDirEntry::~GDirEntry() { + delete fullPath; + delete name; +} + +GDir::GDir(char *name, GBool doStatA) { + path = new GooString(name); + doStat = doStatA; +#if defined(_WIN32) + GooString *tmp; + + tmp = path->copy(); + tmp->append("/*.*"); + hnd = FindFirstFile(tmp->getCString(), &ffd); + delete tmp; +#elif defined(ACORN) +#elif defined(MACOS) +#else + dir = opendir(name); +#ifdef VMS + needParent = strchr(name, '[') != NULL; +#endif +#endif +} + +GDir::~GDir() { + delete path; +#if defined(_WIN32) + if (hnd != INVALID_HANDLE_VALUE) { + FindClose(hnd); + hnd = INVALID_HANDLE_VALUE; + } +#elif defined(ACORN) +#elif defined(MACOS) +#else + if (dir) + closedir(dir); +#endif +} + +GDirEntry *GDir::getNextEntry() { + GDirEntry *e; + +#if defined(_WIN32) + if (hnd != INVALID_HANDLE_VALUE) { + e = new GDirEntry(path->getCString(), ffd.cFileName, doStat); + if (!FindNextFile(hnd, &ffd)) { + FindClose(hnd); + hnd = INVALID_HANDLE_VALUE; + } + } else { + e = NULL; + } +#elif defined(ACORN) +#elif defined(MACOS) +#elif defined(VMS) + struct dirent *ent; + e = NULL; + if (dir) { + if (needParent) { + e = new GDirEntry(path->getCString(), "-", doStat); + needParent = gFalse; + return e; + } + ent = readdir(dir); + if (ent) { + e = new GDirEntry(path->getCString(), ent->d_name, doStat); + } + } +#else + struct dirent *ent; + e = NULL; + if (dir) { + do { + ent = readdir(dir); + } + while (ent && (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))); + if (ent) { + e = new GDirEntry(path->getCString(), ent->d_name, doStat); + } + } +#endif + + return e; +} + +void GDir::rewind() { +#ifdef _WIN32 + GooString *tmp; + + if (hnd != INVALID_HANDLE_VALUE) + FindClose(hnd); + tmp = path->copy(); + tmp->append("/*.*"); + hnd = FindFirstFile(tmp->getCString(), &ffd); + delete tmp; +#elif defined(ACORN) +#elif defined(MACOS) +#else + if (dir) + rewinddir(dir); +#ifdef VMS + needParent = strchr(path->getCString(), '[') != NULL; +#endif +#endif +} diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/gfile.h b/Build/source/libs/poppler/poppler-0.12.4/goo/gfile.h new file mode 100644 index 00000000000..17aea024d51 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/gfile.h @@ -0,0 +1,158 @@ +//======================================================================== +// +// gfile.h +// +// Miscellaneous file and directory name manipulation. +// +// Copyright 1996-2003 Glyph & Cog, LLC +// +//======================================================================== + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2006 Kristian Høgsberg <krh@redhat.com> +// Copyright (C) 2009 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2009 Kovid Goyal <kovid@kovidgoyal.net> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#ifndef GFILE_H +#define GFILE_H + +#include <stdio.h> +#include <stdlib.h> +#include <stddef.h> +extern "C" { +#if defined(_WIN32) +# include <sys/stat.h> +# ifdef FPTEX +# include <win32lib.h> +# else +# include <windows.h> +# endif +#elif defined(ACORN) +#elif defined(MACOS) +# include <ctime.h> +#else +# include <unistd.h> +# include <sys/types.h> +# ifdef VMS +# include "vms_dirent.h" +# elif HAVE_DIRENT_H +# include <dirent.h> +# define NAMLEN(d) strlen((d)->d_name) +# else +# define dirent direct +# define NAMLEN(d) (d)->d_namlen +# if HAVE_SYS_NDIR_H +# include <sys/ndir.h> +# endif +# if HAVE_SYS_DIR_H +# include <sys/dir.h> +# endif +# if HAVE_NDIR_H +# include <ndir.h> +# endif +# endif +#endif +} +#include "gtypes.h" + +class GooString; + +//------------------------------------------------------------------------ + +// Get home directory path. +extern GooString *getHomeDir(); + +// Get current directory. +extern GooString *getCurrentDir(); + +// Append a file name to a path string. <path> may be an empty +// string, denoting the current directory). Returns <path>. +extern GooString *appendToPath(GooString *path, char *fileName); + +// Grab the path from the front of the file name. If there is no +// directory component in <fileName>, returns an empty string. +extern GooString *grabPath(char *fileName); + +// Is this an absolute path or file name? +extern GBool isAbsolutePath(char *path); + +// Make this path absolute by prepending current directory (if path is +// relative) or prepending user's directory (if path starts with '~'). +extern GooString *makePathAbsolute(GooString *path); + +// Get the modification time for <fileName>. Returns 0 if there is an +// error. +extern time_t getModTime(char *fileName); + +// Create a temporary file and open it for writing. If <ext> is not +// NULL, it will be used as the file name extension. Returns both the +// name and the file pointer. For security reasons, all writing +// should be done to the returned file pointer; the file may be +// reopened later for reading, but not for writing. The <mode> string +// should be "w" or "wb". Returns true on success. +extern GBool openTempFile(GooString **name, FILE **f, char *mode); + +// Execute <command>. Returns true on success. +extern GBool executeCommand(char *cmd); + +// Just like fgets, but handles Unix, Mac, and/or DOS end-of-line +// conventions. +extern char *getLine(char *buf, int size, FILE *f); + +//------------------------------------------------------------------------ +// GDir and GDirEntry +//------------------------------------------------------------------------ + +class GDirEntry { +public: + + GDirEntry(char *dirPath, char *nameA, GBool doStat); + ~GDirEntry(); + GooString *getName() { return name; } + GooString *getFullPath() { return fullPath; } + GBool isDir() { return dir; } + +private: + + GooString *name; // dir/file name + GooString *fullPath; + GBool dir; // is it a directory? +}; + +class GDir { +public: + + GDir(char *name, GBool doStatA = gTrue); + ~GDir(); + GDirEntry *getNextEntry(); + void rewind(); + +private: + + GooString *path; // directory path + GBool doStat; // call stat() for each entry? +#if defined(_WIN32) + WIN32_FIND_DATA ffd; + HANDLE hnd; +#elif defined(ACORN) +#elif defined(MACOS) +#else + DIR *dir; // the DIR structure from opendir() +#ifdef VMS + GBool needParent; // need to return an entry for [-] +#endif +#endif +}; + +#endif diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/gmem.cc b/Build/source/libs/poppler/poppler-0.12.4/goo/gmem.cc new file mode 100644 index 00000000000..af3e19ef74b --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/gmem.cc @@ -0,0 +1,346 @@ +/* + * gmem.c + * + * Memory routines with out-of-memory checking. + * + * Copyright 1996-2003 Glyph & Cog, LLC + */ + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2005 Takashi Iwai <tiwai@suse.de> +// Copyright (C) 2007-2009 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008 Jonathan Kew <jonathan_kew@sil.org> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#include <config.h> +#include <stdio.h> +#include <stdlib.h> +#include <stddef.h> +#include <string.h> +#include <limits.h> +#include "gmem.h" + +#ifdef DEBUG_MEM + +typedef struct _GMemHdr { + unsigned int magic; + int size; + int index; + struct _GMemHdr *next, *prev; +} GMemHdr; + +#define gMemHdrSize ((sizeof(GMemHdr) + 7) & ~7) +#define gMemTrlSize (sizeof(long)) + +#define gMemMagic 0xabcd9999 + +#if gmemTrlSize==8 +#define gMemDeadVal 0xdeadbeefdeadbeefUL +#else +#define gMemDeadVal 0xdeadbeefUL +#endif + +/* round data size so trailer will be aligned */ +#define gMemDataSize(size) \ + ((((size) + gMemTrlSize - 1) / gMemTrlSize) * gMemTrlSize) + +static GMemHdr *gMemHead = NULL; +static GMemHdr *gMemTail = NULL; + +static int gMemIndex = 0; +static int gMemAlloc = 0; +static int gMemInUse = 0; + +#endif /* DEBUG_MEM */ + +inline static void *gmalloc(size_t size, bool checkoverflow) GMEM_EXCEP { +#ifdef DEBUG_MEM + int size1; + char *mem; + GMemHdr *hdr; + void *data; + unsigned long *trl, *p; + + if (size <= 0) { + return NULL; + } + size1 = gMemDataSize(size); + if (!(mem = (char *)malloc(size1 + gMemHdrSize + gMemTrlSize))) { +#if USE_EXCEPTIONS + throw GMemException(); +#else + fprintf(stderr, "Out of memory\n"); + if (checkoverflow) return NULL; + else exit(1); +#endif + } + hdr = (GMemHdr *)mem; + data = (void *)(mem + gMemHdrSize); + trl = (unsigned long *)(mem + gMemHdrSize + size1); + hdr->magic = gMemMagic; + hdr->size = size; + hdr->index = gMemIndex++; + if (gMemTail) { + gMemTail->next = hdr; + hdr->prev = gMemTail; + gMemTail = hdr; + } else { + hdr->prev = NULL; + gMemHead = gMemTail = hdr; + } + hdr->next = NULL; + ++gMemAlloc; + gMemInUse += size; + for (p = (unsigned long *)data; p <= trl; ++p) { + *p = gMemDeadVal; + } + return data; +#else + void *p; + + if (size <= 0) { + return NULL; + } + if (!(p = malloc(size))) { +#if USE_EXCEPTIONS + throw GMemException(); +#else + fprintf(stderr, "Out of memory\n"); + if (checkoverflow) return NULL; + else exit(1); +#endif + } + return p; +#endif +} + +void *gmalloc(size_t size) GMEM_EXCEP { + return gmalloc(size, false); +} + +void *gmalloc_checkoverflow(size_t size) GMEM_EXCEP { + return gmalloc(size, true); +} + +inline static void *grealloc(void *p, size_t size, bool checkoverflow) GMEM_EXCEP { +#ifdef DEBUG_MEM + GMemHdr *hdr; + void *q; + int oldSize; + + if (size <= 0) { + if (p) { + gfree(p); + } + return NULL; + } + if (p) { + hdr = (GMemHdr *)((char *)p - gMemHdrSize); + oldSize = hdr->size; + q = gmalloc(size, checkoverflow); + memcpy(q, p, size < oldSize ? size : oldSize); + gfree(p); + } else { + q = gmalloc(size, checkoverflow); + } + return q; +#else + void *q; + + if (size <= 0) { + if (p) { + free(p); + } + return NULL; + } + if (p) { + q = realloc(p, size); + } else { + q = malloc(size); + } + if (!q) { +#if USE_EXCEPTIONS + throw GMemException(); +#else + fprintf(stderr, "Out of memory\n"); + if (checkoverflow) return NULL; + else exit(1); +#endif + } + return q; +#endif +} + +void *grealloc(void *p, size_t size) GMEM_EXCEP { + return grealloc(p, size, false); +} + +void *grealloc_checkoverflow(void *p, size_t size) GMEM_EXCEP { + return grealloc(p, size, true); +} + +inline static void *gmallocn(int nObjs, int objSize, bool checkoverflow) GMEM_EXCEP { + int n; + + if (nObjs == 0) { + return NULL; + } + n = nObjs * objSize; + if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) { +#if USE_EXCEPTIONS + throw GMemException(); +#else + fprintf(stderr, "Bogus memory allocation size\n"); + if (checkoverflow) return NULL; + else exit(1); +#endif + } + return gmalloc(n, checkoverflow); +} + +void *gmallocn(int nObjs, int objSize) GMEM_EXCEP { + return gmallocn(nObjs, objSize, false); +} + +void *gmallocn_checkoverflow(int nObjs, int objSize) GMEM_EXCEP { + return gmallocn(nObjs, objSize, true); +} + +inline static void *gmallocn3(int a, int b, int c, bool checkoverflow) GMEM_EXCEP { + int n = a * b; + if (b <= 0 || a < 0 || a >= INT_MAX / b) { +#if USE_EXCEPTIONS + throw GMemException(); +#else + fprintf(stderr, "Bogus memory allocation size\n"); + if (checkoverflow) return NULL; + else exit(1); +#endif + } + return gmallocn(n, c, checkoverflow); +} + +void *gmallocn3(int a, int b, int c) GMEM_EXCEP { + return gmallocn3(a, b, c, false); +} + +void *gmallocn3_checkoverflow(int a, int b, int c) GMEM_EXCEP { + return gmallocn3(a, b, c, true); +} + +inline static void *greallocn(void *p, int nObjs, int objSize, bool checkoverflow) GMEM_EXCEP { + int n; + + if (nObjs == 0) { + if (p) { + gfree(p); + } + return NULL; + } + n = nObjs * objSize; + if (objSize <= 0 || nObjs < 0 || nObjs >= INT_MAX / objSize) { +#if USE_EXCEPTIONS + throw GMemException(); +#else + fprintf(stderr, "Bogus memory allocation size\n"); + if (checkoverflow) return NULL; + else exit(1); +#endif + } + return grealloc(p, n, checkoverflow); +} + +void *greallocn(void *p, int nObjs, int objSize) GMEM_EXCEP { + return greallocn(p, nObjs, objSize, false); +} + +void *greallocn_checkoverflow(void *p, int nObjs, int objSize) GMEM_EXCEP { + return greallocn(p, nObjs, objSize, true); +} + +void gfree(void *p) { +#ifdef DEBUG_MEM + int size; + GMemHdr *hdr; + unsigned long *trl, *clr; + + if (p) { + hdr = (GMemHdr *)((char *)p - gMemHdrSize); + if (hdr->magic == gMemMagic && + ((hdr->prev == NULL) == (hdr == gMemHead)) && + ((hdr->next == NULL) == (hdr == gMemTail))) { + if (hdr->prev) { + hdr->prev->next = hdr->next; + } else { + gMemHead = hdr->next; + } + if (hdr->next) { + hdr->next->prev = hdr->prev; + } else { + gMemTail = hdr->prev; + } + --gMemAlloc; + gMemInUse -= hdr->size; + size = gMemDataSize(hdr->size); + trl = (unsigned long *)((char *)hdr + gMemHdrSize + size); + if (*trl != gMemDeadVal) { + fprintf(stderr, "Overwrite past end of block %d at address %p\n", + hdr->index, p); + } + for (clr = (unsigned long *)hdr; clr <= trl; ++clr) { + *clr = gMemDeadVal; + } + free(hdr); + } else { + fprintf(stderr, "Attempted to free bad address %p\n", p); + } + } +#else + if (p) { + free(p); + } +#endif +} + +#ifdef DEBUG_MEM +void gMemReport(FILE *f) { + GMemHdr *p; + + fprintf(f, "%d memory allocations in all\n", gMemIndex); + if (gMemAlloc > 0) { + fprintf(f, "%d memory blocks left allocated:\n", gMemAlloc); + fprintf(f, " index size\n"); + fprintf(f, "-------- --------\n"); + for (p = gMemHead; p; p = p->next) { + fprintf(f, "%8d %8d\n", p->index, p->size); + } + } else { + fprintf(f, "No memory blocks left allocated\n"); + } +} +#endif + +char *copyString(char *s) { + char *s1; + + s1 = (char *)gmalloc(strlen(s) + 1); + strcpy(s1, s); + return s1; +} + +char *gstrndup(const char *s, size_t n) { + char *s1 = (char*)gmalloc(n + 1); /* cannot return NULL for size > 0 */ + s1[n] = '\0'; + memcpy(s1, s, n); + return s1; +} diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/gmem.h b/Build/source/libs/poppler/poppler-0.12.4/goo/gmem.h new file mode 100644 index 00000000000..ea75fb946f1 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/gmem.h @@ -0,0 +1,108 @@ +/* + * gmem.h + * + * Memory routines with out-of-memory checking. + * + * Copyright 1996-2003 Glyph & Cog, LLC + */ + +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2005 Takashi Iwai <tiwai@suse.de> +// Copyright (C) 2007-2009 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2008 Jonathan Kew <jonathan_kew@sil.org> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + +#ifndef GMEM_H +#define GMEM_H + +#include <stdio.h> +#include "poppler/poppler-config.h" + +#if USE_EXCEPTIONS + +class GMemException { +public: + GMemException() {} + ~GMemException() {} +}; + +#define GMEM_EXCEP throw(GMemException) + +#else // USE_EXCEPTIONS + +#define GMEM_EXCEP + +#endif // USE_EXCEPTIONS + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Same as malloc, but prints error message and exits if malloc() + * returns NULL. + */ +extern void *gmalloc(size_t size) GMEM_EXCEP; +extern void *gmalloc_checkoverflow(size_t size) GMEM_EXCEP; + +/* + * Same as realloc, but prints error message and exits if realloc() + * returns NULL. If <p> is NULL, calls malloc instead of realloc(). + */ +extern void *grealloc(void *p, size_t size) GMEM_EXCEP; +extern void *grealloc_checkoverflow(size_t size) GMEM_EXCEP; + +/* + * These are similar to gmalloc and grealloc, but take an object count + * and size. The result is similar to allocating nObjs * objSize + * bytes, but there is an additional error check that the total size + * doesn't overflow an int. + * The gmallocn_checkoverflow variant returns NULL instead of exiting + * the application if a overflow is detected + */ +extern void *gmallocn(int nObjs, int objSize) GMEM_EXCEP; +extern void *gmallocn_checkoverflow(int nObjs, int objSize) GMEM_EXCEP; +extern void *gmallocn3(int a, int b, int c) GMEM_EXCEP; +extern void *gmallocn3_checkoverflow(int a, int b, int c) GMEM_EXCEP; +extern void *greallocn(void *p, int nObjs, int objSize) GMEM_EXCEP; +extern void *greallocn_checkoverflow(void *p, int nObjs, int objSize) GMEM_EXCEP; + +/* + * Same as free, but checks for and ignores NULL pointers. + */ +extern void gfree(void *p); + +#ifdef DEBUG_MEM +/* + * Report on unfreed memory. + */ +extern void gMemReport(FILE *f); +#else +#define gMemReport(f) +#endif + +/* + * Allocate memory and copy a string into it. + */ +extern char *copyString(char *s); + +/* + * Allocate memory and copy a limited-length string to it. + */ +extern char *gstrndup(const char *s, size_t n); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/gmempp.cc b/Build/source/libs/poppler/poppler-0.12.4/goo/gmempp.cc new file mode 100644 index 00000000000..a70338ca3ce --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/gmempp.cc @@ -0,0 +1,32 @@ +//======================================================================== +// +// gmempp.cc +// +// Use gmalloc/gfree for C++ new/delete operators. +// +// Copyright 1996-2003 Glyph & Cog, LLC +// +//======================================================================== + +#include <config.h> +#include "gmem.h" + +#ifdef DEBUG_MEM + +void *operator new(size_t size) { + return gmalloc((int)size); +} + +void *operator new[](size_t size) { + return gmalloc((int)size); +} + +void operator delete(void *p) { + gfree(p); +} + +void operator delete[](void *p) { + gfree(p); +} + +#endif diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/gstrtod.cc b/Build/source/libs/poppler/poppler-0.12.4/goo/gstrtod.cc new file mode 100644 index 00000000000..e6c3a00741f --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/gstrtod.cc @@ -0,0 +1,147 @@ +/* This file is part of Libspectre. + * + * Copyright (C) 2007 Albert Astals Cid <aacid@kde.org> + * Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org> + * + * Libspectre is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * Libspectre is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* This function comes from spectre-utils from libspectre */ + +#include "gstrtod.h" + +#include <clocale> +#include <cerrno> +#include <cstdlib> +#include <cstring> + +#define ascii_isspace(c) \ + (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v') +#define ascii_isdigit(c) \ + (c >= '0' && c <= '9') + +double gatof(const char *nptr) +{ + return gstrtod(nptr, NULL); +} + +double gstrtod(const char *nptr, char **endptr) +{ + char *fail_pos; + double val; + struct lconv *locale_data; + const char *decimal_point; + int decimal_point_len; + const char *p, *decimal_point_pos; + const char *end = NULL; /* Silence gcc */ + int strtod_errno; + + fail_pos = NULL; + + locale_data = localeconv (); + decimal_point = locale_data->decimal_point; + decimal_point_len = strlen (decimal_point); + + decimal_point_pos = NULL; + end = NULL; + + if (decimal_point[0] != '.' || decimal_point[1] != 0) { + p = nptr; + /* Skip leading space */ + while (ascii_isspace (*p)) + p++; + + /* Skip leading optional sign */ + if (*p == '+' || *p == '-') + p++; + + if (ascii_isdigit (*p) || *p == '.') { + while (ascii_isdigit (*p)) + p++; + + if (*p == '.') + decimal_point_pos = p++; + + while (ascii_isdigit (*p)) + p++; + + if (*p == 'e' || *p == 'E') + p++; + if (*p == '+' || *p == '-') + p++; + while (ascii_isdigit (*p)) + p++; + + end = p; + } + /* For the other cases, we need not convert the decimal point */ + } + + if (decimal_point_pos) { + char *copy, *c; + + /* We need to convert the '.' to the locale specific decimal point */ + copy = (char *) malloc (end - nptr + 1 + decimal_point_len); + + c = copy; + memcpy (c, nptr, decimal_point_pos - nptr); + c += decimal_point_pos - nptr; + memcpy (c, decimal_point, decimal_point_len); + c += decimal_point_len; + memcpy (c, decimal_point_pos + 1, end - (decimal_point_pos + 1)); + c += end - (decimal_point_pos + 1); + *c = 0; + + errno = 0; + val = strtod (copy, &fail_pos); + strtod_errno = errno; + + if (fail_pos) { + if (fail_pos - copy > decimal_point_pos - nptr) + fail_pos = (char *)nptr + (fail_pos - copy) - (decimal_point_len - 1); + else + fail_pos = (char *)nptr + (fail_pos - copy); + } + + free (copy); + } else if (end) { + char *copy; + + copy = (char *) malloc (end - (char *)nptr + 1); + memcpy (copy, nptr, end - nptr); + *(copy + (end - (char *)nptr)) = 0; + + errno = 0; + val = strtod (copy, &fail_pos); + strtod_errno = errno; + + if (fail_pos) { + fail_pos = (char *)nptr + (fail_pos - copy); + } + + free (copy); + } else { + errno = 0; + val = strtod (nptr, &fail_pos); + strtod_errno = errno; + } + + if (endptr) + *endptr = fail_pos; + + errno = strtod_errno; + + return val; +} diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/gstrtod.h b/Build/source/libs/poppler/poppler-0.12.4/goo/gstrtod.h new file mode 100644 index 00000000000..e8abdadf53e --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/gstrtod.h @@ -0,0 +1,43 @@ +/* This file is part of Libspectre. + * + * Copyright (C) 2007 Albert Astals Cid <aacid@kde.org> + * Copyright (C) 2007 Carlos Garcia Campos <carlosgc@gnome.org> + * + * Libspectre is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * Libspectre is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/* This function comes from spectre-utils from libspectre */ + +#ifndef GSTRTOD_H +#define GSTRTOD_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* This function behaves like the standard atof()/(strtod() function + * does in the C locale. It does this without actually changing + * the current locale, since that would not be thread-safe. + * A limitation of the implementation is that this function + * will still accept localized versions of infinities and NANs. + */ +double gatof(const char *nptr); +double gstrtod(const char *nptr, char **endptr); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Build/source/libs/poppler/poppler-0.12.4/goo/gtypes.h b/Build/source/libs/poppler/poppler-0.12.4/goo/gtypes.h new file mode 100644 index 00000000000..9f64f57d4a1 --- /dev/null +++ b/Build/source/libs/poppler/poppler-0.12.4/goo/gtypes.h @@ -0,0 +1,29 @@ +/* + * gtypes.h + * + * Some useful simple types. + * + * Copyright 1996-2003 Glyph & Cog, LLC + */ + +#ifndef GTYPES_H +#define GTYPES_H + +/* + * These have stupid names to avoid conflicts with some (but not all) + * C++ compilers which define them. + */ +typedef int GBool; +#define gTrue 1 +#define gFalse 0 + +/* + * These have stupid names to avoid conflicts with <sys/types.h>, + * which on various systems defines some random subset of these. + */ +typedef unsigned char Guchar; +typedef unsigned short Gushort; +typedef unsigned int Guint; +typedef unsigned long Gulong; + +#endif |