~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/poppler/poppler/Error.cc

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//========================================================================
 
2
//
 
3
// Error.cc
 
4
//
 
5
// Copyright 1996-2003 Glyph & Cog, LLC
 
6
//
 
7
//========================================================================
 
8
 
 
9
//========================================================================
 
10
//
 
11
// Modified under the Poppler project - http://poppler.freedesktop.org
 
12
//
 
13
// All changes made under the Poppler project to this file are licensed
 
14
// under GPL version 2 or later
 
15
//
 
16
// Copyright (C) 2005, 2007 Jeff Muizelaar <jeff@infidigm.net>
 
17
// Copyright (C) 2005 Albert Astals Cid <aacid@kde.org>
 
18
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
 
19
//
 
20
// To see a description of the changes please see the Changelog file that
 
21
// came with your tarball or type make ChangeLog if you are building from git
 
22
//
 
23
//========================================================================
 
24
 
 
25
#include <config.h>
 
26
 
 
27
#ifdef USE_GCC_PRAGMAS
 
28
#pragma implementation
 
29
#endif
 
30
 
 
31
#include <stdio.h>
 
32
#include <stddef.h>
 
33
#include <stdarg.h>
 
34
#include "GlobalParams.h"
 
35
#include "Error.h"
 
36
 
 
37
static void defaultErrorFunction(int pos, char *msg, va_list args)
 
38
{
 
39
  if (pos >= 0) {
 
40
    fprintf(stderr, "Error (%d): ", pos);
 
41
  } else {
 
42
    fprintf(stderr, "Error: ");
 
43
  }
 
44
  vfprintf(stderr, msg, args);
 
45
  fprintf(stderr, "\n");
 
46
  fflush(stderr);
 
47
}
 
48
 
 
49
static void (*errorFunction)(int, char *, va_list args) = defaultErrorFunction;
 
50
 
 
51
void setErrorFunction(void (* f)(int, char *, va_list args))
 
52
{
 
53
    errorFunction = f;
 
54
}
 
55
 
 
56
void CDECL error(int pos, char *msg, ...) {
 
57
  va_list args;
 
58
  // NB: this can be called before the globalParams object is created
 
59
  if (globalParams && globalParams->getErrQuiet()) {
 
60
    return;
 
61
  }
 
62
  va_start(args, msg);
 
63
  (*errorFunction)(pos, msg, args);
 
64
  va_end(args);
 
65
}
 
66
 
 
67
void warning(char *msg, ...) {
 
68
  va_list args;
 
69
  va_start(args, msg);
 
70
  vprintf(msg, args);
 
71
  va_end(args);
 
72
}