1 //      Everything needed by the C demo programs.
2 //      Created to avoid junking up plplot.h with this stuff.
3 //
4 
5 #ifndef __PLCDEMOS_H__
6 #define __PLCDEMOS_H__
7 
8 #include <math.h>
9 #include <string.h>
10 #include <ctype.h>
11 
12 #include "plConfig.h"
13 #include "plplot.h"
14 
15 // define PI if not defined by math.h
16 
17 // Actually M_PI seems to be more widely used so we deprecate PI.
18 #ifndef PI
19 #define PI    3.1415926535897932384
20 #endif
21 
22 #ifndef M_PI
23 #define M_PI    3.1415926535897932384
24 #endif
25 
26 // various utility macros
27 
28 #ifndef MAX
29 #define MAX( a, b )    ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
30 #endif
31 
32 #ifndef MIN
33 #define MIN( a, b )    ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
34 #endif
35 
36 #ifndef ROUND
37 #define ROUND( a )    (PLINT) ( ( a ) < 0. ? ( ( a ) - .5 ) : ( ( a ) + .5 ) )
38 #endif
39 
40 // Declarations for save string functions
41 
42 #ifdef PL_HAVE_SNPRINTF
43 // In case only _snprintf is declared (as for Visual C++ and
44 // Borland compiler toolset) we redefine the function names
45   #ifdef _PL_HAVE_SNPRINTF
46     #define snprintf    _snprintf
47     #define snscanf     _snscanf
48   #endif // _PL_HAVE_SNPRINTF
49 #else // !PL_HAVE_SNPRINTF
50 // declare dummy functions which just call the unsafe
51 // functions ignoring the size of the string
52 int plsnprintf( char *buffer, int n, const char *format, ... );
53 int plsnscanf( const char *buffer, int n, const char *format, ... );
54   #define snprintf    plsnprintf
55   #define snscanf     plsnscanf
56 #endif // PL_HAVE_SNPRINTF
57 
58 // Add in missing isnan definition if required
59 #if defined ( PL__HAVE_ISNAN )
60 #  define isnan    _isnan
61 #  if defined ( _MSC_VER )
62 #    include <float.h>
63 #  endif
64 #endif
65 
66 #if !defined ( PL_HAVE_ISNAN )
67 #  define isnan( x )    ( ( x ) != ( x ) )
68 #endif
69 
70 #endif  // __PLCDEMOS_H__
71