~ubuntu-branches/ubuntu/precise/plib/precise

« back to all changes in this revision

Viewing changes to src/psl/pslError.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Frauenfelder
  • Date: 2004-08-26 23:31:16 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040826233116-vqusvk3ytn6lq3rl
Tags: 1.8.3-2
* Corrected C++ syntax in ssgAux/ssgaSky.h. Thanks to
  neuro.harald AT surfeu.at for the patch. Closes: #260355
* Build-Depends on libx11-dev, libxmu-dev instead of xlibs-dev
* Removed build depends on g++, libc6.
* Changed (build) depends on libgl-dev to xlibmesa-gl-dev | libgl-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
     PLIB - A Suite of Portable Game Libraries
 
3
     Copyright (C) 1998,2002  Steve Baker
 
4
 
 
5
     This library is free software; you can redistribute it and/or
 
6
     modify it under the terms of the GNU Library General Public
 
7
     License as published by the Free Software Foundation; either
 
8
     version 2 of the License, or (at your option) any later version.
 
9
 
 
10
     This library is distributed in the hope that it will be useful,
 
11
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
     Library General Public License for more details.
 
14
 
 
15
     You should have received a copy of the GNU Library General Public
 
16
     License along with this library; if not, write to the Free Software
 
17
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
18
 
 
19
     For further information visit http://plib.sourceforge.net
 
20
 
 
21
     $Id: pslError.cxx,v 1.8 2002/09/15 14:32:53 ude Exp $
 
22
*/
 
23
 
 
24
 
 
25
#include "pslLocal.h"
 
26
 
 
27
static char _pslErrorBuffer [ 1024 ] = { '\0' } ;                     
 
28
 
 
29
 
 
30
void (*_pslErrorCB) ( pslProgram *p, int severity, const char *progname,
 
31
                                 int line_no , const char *message ) = NULL ;
 
32
 
 
33
 
 
34
void pslSetErrorCallback ( void (*CB) ( pslProgram *, int, const char *,
 
35
                                                      int, const char * ) )
 
36
{
 
37
  _pslErrorCB = CB ;
 
38
}
 
39
 
 
40
 
 
41
 
 
42
int pslCompiler::warning ( const char *fmt, ... )
 
43
{
 
44
  va_list argp;
 
45
  va_start ( argp, fmt ) ;
 
46
  vsprintf ( _pslErrorBuffer, fmt, argp ) ;
 
47
  va_end ( argp ) ;
 
48
 
 
49
  if ( _pslErrorCB != NULL )
 
50
    (*_pslErrorCB)( program, PSL_COMPILETIME_WARNING,
 
51
                       _pslGetFname(), _pslGetLineNo(), _pslErrorBuffer ) ;
 
52
  else
 
53
    fprintf ( stderr, "PSL: \"%s\" line %3d: WARNING - %s\n",
 
54
                       _pslGetFname(), _pslGetLineNo(), _pslErrorBuffer ) ;
 
55
 
 
56
  bumpWarnings () ;
 
57
  return FALSE ;
 
58
}
 
59
 
 
60
 
 
61
 
 
62
int pslCompiler::error ( const char *fmt, ... )
 
63
{
 
64
  va_list argp;
 
65
  va_start ( argp, fmt ) ;
 
66
  vsprintf ( _pslErrorBuffer, fmt, argp ) ;
 
67
  va_end ( argp ) ;
 
68
 
 
69
  if ( _pslErrorCB != NULL )
 
70
    (*_pslErrorCB)( program, PSL_COMPILETIME_ERROR,
 
71
                       _pslGetFname(), _pslGetLineNo(), _pslErrorBuffer ) ;
 
72
  else
 
73
    fprintf ( stderr, "PSL: \"%s\" line %3d: *ERROR* - %s\n",
 
74
                       _pslGetFname(), _pslGetLineNo(), _pslErrorBuffer ) ;
 
75
 
 
76
  bumpErrors () ;
 
77
  return FALSE ;
 
78
}
 
79
 
 
80
 
 
81
 
 
82
void pslContext::warning ( const char *fmt, ... )
 
83
{
 
84
  va_list argp;
 
85
  va_start ( argp, fmt ) ;
 
86
  vsprintf ( _pslErrorBuffer, fmt, argp ) ;
 
87
  va_end ( argp ) ;
 
88
 
 
89
  if ( _pslErrorCB != NULL )
 
90
    (*_pslErrorCB)( program, PSL_RUNTIME_WARNING,
 
91
                       getProgName(), getLineNo(), _pslErrorBuffer ) ;
 
92
  else
 
93
  if ( getLineNo () >= 0 )
 
94
    fprintf ( stderr, "PSL: \"%s\" Line %d: WARNING - %s\n",
 
95
                       getProgName(), getLineNo(), _pslErrorBuffer ) ;
 
96
  else
 
97
    fprintf ( stderr, "PSL: \"%s\": WARNING - %s\n",
 
98
                       getProgName(), _pslErrorBuffer ) ;
 
99
 
 
100
  bumpWarnings () ;
 
101
}
 
102
 
 
103
 
 
104
 
 
105
void pslContext::error ( const char *fmt, ... )
 
106
{
 
107
  va_list argp;
 
108
  va_start ( argp, fmt ) ;
 
109
  vsprintf ( _pslErrorBuffer, fmt, argp ) ;
 
110
  va_end ( argp ) ;
 
111
 
 
112
  if ( _pslErrorCB != NULL )
 
113
    (*_pslErrorCB)( program, PSL_RUNTIME_ERROR,
 
114
                       getProgName(), getLineNo(), _pslErrorBuffer ) ;
 
115
  else
 
116
  if ( getLineNo () >= 0 )
 
117
    fprintf ( stderr, "PSL: \"%s\" Line %d: *ERROR* - %s\n",
 
118
                       getProgName(), getLineNo(), _pslErrorBuffer ) ;
 
119
  else
 
120
    fprintf ( stderr, "PSL: \"%s\": *ERROR* - %s\n",
 
121
                       getProgName(), _pslErrorBuffer ) ;
 
122
 
 
123
  bumpErrors () ;
 
124
}
 
125
 
 
126