7da99fabe7a4ab015869507e6c613671bca91086
[freeglut] / freeglut-1.3 / freeglut_state.c
1 /*
2  * freeglut_state.c
3  *
4  * Freeglut state query methods.
5  *
6  * Copyright (c) 1999-2000 Pawel W. Olszta. All Rights Reserved.
7  * Written by Pawel W. Olszta, <olszta@sourceforge.net>
8  * Creation date: Thu Dec 16 1999
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23  * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
24  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  */
27
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31
32 #define  G_LOG_DOMAIN  "freeglut-state"
33
34 #include "../include/GL/freeglut.h"
35 #include "freeglut_internal.h"
36
37 /*
38  * TODO BEFORE THE STABLE RELEASE:
39  *
40  *  glutGet()               -- X11 tests passed, but check if all enums handled (what about Win32?)
41  *  glutDeviceGet()         -- X11 tests passed, but check if all enums handled (what about Win32?)
42  *  glutGetModifiers()      -- OK, but could also remove the limitation
43  *  glutLayerGet()          -- what about GLUT_NORMAL_DAMAGED?
44  *
45  * The fail-on-call policy will help adding the most needed things imho.
46  */
47
48 /* -- LOCAL DEFINITIONS ---------------------------------------------------- */
49
50 /* -- PRIVATE FUNCTIONS ---------------------------------------------------- */
51
52 #if TARGET_HOST_UNIX_X11
53 /*
54  * Queries the GL context about some attributes
55  */
56 static int fghGetConfig( int attribute )
57 {
58   int returnValue ;
59
60   /*
61    * Return nothing if there is no current window set
62    */
63   if( fgStructure.Window == NULL )
64     return( 0 );
65
66   /*
67    * glXGetConfig should work fine
68    */
69   glXGetConfig( fgDisplay.Display, fgStructure.Window->Window.VisualInfo, attribute, &returnValue );
70
71
72   /*
73    * Have the query results returned
74    */
75   return ( returnValue ) ;
76 }
77 #endif
78
79 /* -- INTERFACE FUNCTIONS -------------------------------------------------- */
80
81 /*
82  * General settings assignment method
83  */
84 void FGAPIENTRY glutSetOption( GLenum eWhat, int value )
85 {
86   freeglut_assert_ready;
87
88   /*
89    * Check what is the caller querying for. In chronological code add order.
90    */
91   switch( eWhat )
92   {
93   case GLUT_INIT_WINDOW_X:          fgState.Position.X          = (GLint)value ;
94                                     break ;
95   case GLUT_INIT_WINDOW_Y:          fgState.Position.Y          = (GLint)value ;
96                                     break ;
97   case GLUT_INIT_WINDOW_WIDTH:      fgState.Size.X              = (GLint)value ;
98                                     break ;
99   case GLUT_INIT_WINDOW_HEIGHT:     fgState.Size.Y              = (GLint)value ;
100                                     break ;
101   case GLUT_INIT_DISPLAY_MODE:      fgState.DisplayMode         = (unsigned int)value ;
102                                     break ;
103
104   case GLUT_ACTION_ON_WINDOW_CLOSE: fgState.ActionOnWindowClose = value ;
105                                     break ;
106
107   case GLUT_WINDOW_CURSOR:
108       if( fgStructure.Window != NULL ) fgStructure.Window->State.Cursor = value ;
109       break ;
110
111   default:
112       /*
113        * Just have it reported, so that we can see what needs to be implemented
114        */
115       fgWarning( "glutSetOption(): missing enum handle %i\n", eWhat );
116       break;
117   }
118 }
119
120 /*
121  * General settings query method
122  */
123 int FGAPIENTRY glutGet( GLenum eWhat )
124 {
125   int returnValue ;
126   GLboolean boolValue ;
127
128   if ( eWhat == GLUT_INIT_STATE )
129     return ( fgState.Time.Set ) ;
130
131     freeglut_assert_ready;
132
133     /*
134      * Check what is the caller querying for. In chronological code add order.
135      */
136     switch( eWhat )
137     {
138     case GLUT_ELAPSED_TIME:
139         /*
140          * This is easy and nicely portable, as we are using GLib...
141          */
142         return( fgElapsedTime() );
143
144     /*
145      * Following values are stored in fgState and fgDisplay global structures
146      */
147     case GLUT_SCREEN_WIDTH:         return( fgDisplay.ScreenWidth    );
148     case GLUT_SCREEN_HEIGHT:        return( fgDisplay.ScreenHeight   );
149     case GLUT_SCREEN_WIDTH_MM:      return( fgDisplay.ScreenWidthMM  );
150     case GLUT_SCREEN_HEIGHT_MM:     return( fgDisplay.ScreenHeightMM );
151     case GLUT_INIT_WINDOW_X:        return( fgState.Position.X       );
152     case GLUT_INIT_WINDOW_Y:        return( fgState.Position.Y       );
153     case GLUT_INIT_WINDOW_WIDTH:    return( fgState.Size.X           );
154     case GLUT_INIT_WINDOW_HEIGHT:   return( fgState.Size.Y           );
155     case GLUT_INIT_DISPLAY_MODE:    return( fgState.DisplayMode      );
156
157     /*
158      * The window/context specific queries are handled mostly by fghGetConfig().
159      */
160     case GLUT_WINDOW_NUM_SAMPLES:
161         /*
162          * Multisampling. Return what I know about multisampling.
163          */
164         return( 0 );
165
166 #if TARGET_HOST_UNIX_X11
167     /*
168      * The rest of GLX queries under X are general enough to use a macro to check them
169      */
170 #   define GLX_QUERY(a,b) case a: return( fghGetConfig( b ) );
171
172     GLX_QUERY( GLUT_WINDOW_RGBA,                GLX_RGBA                );
173     GLX_QUERY( GLUT_WINDOW_DOUBLEBUFFER,        GLX_DOUBLEBUFFER        );
174     GLX_QUERY( GLUT_WINDOW_BUFFER_SIZE,         GLX_BUFFER_SIZE         );
175     GLX_QUERY( GLUT_WINDOW_STENCIL_SIZE,        GLX_STENCIL_SIZE        );
176     GLX_QUERY( GLUT_WINDOW_DEPTH_SIZE,          GLX_DEPTH_SIZE          );
177     GLX_QUERY( GLUT_WINDOW_RED_SIZE,            GLX_RED_SIZE            );
178     GLX_QUERY( GLUT_WINDOW_GREEN_SIZE,          GLX_GREEN_SIZE          );
179     GLX_QUERY( GLUT_WINDOW_BLUE_SIZE,           GLX_BLUE_SIZE           );
180     GLX_QUERY( GLUT_WINDOW_ALPHA_SIZE,          GLX_ALPHA_SIZE          );
181     GLX_QUERY( GLUT_WINDOW_ACCUM_RED_SIZE,      GLX_ACCUM_RED_SIZE      );
182     GLX_QUERY( GLUT_WINDOW_ACCUM_GREEN_SIZE,    GLX_ACCUM_GREEN_SIZE    );
183     GLX_QUERY( GLUT_WINDOW_ACCUM_BLUE_SIZE,     GLX_ACCUM_BLUE_SIZE     );
184     GLX_QUERY( GLUT_WINDOW_ACCUM_ALPHA_SIZE,    GLX_ACCUM_ALPHA_SIZE    );
185     GLX_QUERY( GLUT_WINDOW_STEREO,              GLX_STEREO              );
186
187 #   undef GLX_QUERY
188
189     /*
190      * Colormap size is handled in a bit different way than all the rest
191      */
192     case GLUT_WINDOW_COLORMAP_SIZE:
193         /*
194          * Check for the visual type
195          */
196         if( (fghGetConfig( GLX_RGBA )) || (fgStructure.Window == NULL) )
197         {
198             /*
199              * We've got a RGBA visual, so there is no colormap at all.
200              * The other possibility is that we have no current window set.
201              */
202             return( 0 );
203         }
204
205         /*
206          * Otherwise return the number of entries in the colormap
207          */
208         return( fgStructure.Window->Window.VisualInfo->visual->map_entries );
209
210     /*
211      * Those calls are somewhat similiar, as they use XGetWindowAttributes() function
212      */
213     case GLUT_WINDOW_X:
214     case GLUT_WINDOW_Y:
215     {
216         XWindowAttributes winAttributes;
217         Window another, window;
218         int x, y;
219
220         /*
221          * Return zero if there is no current window set
222          */
223         if( fgStructure.Window == NULL )
224             return( 0 );
225
226         /*
227          * So, grab the current window's position
228          */
229         window = fgStructure.Window->Window.Handle;
230
231         /*
232          * Grab the current window's attributes now
233          */
234         XGetWindowAttributes(
235             fgDisplay.Display,
236             window,
237             &winAttributes
238         );
239
240         /*
241          * Correct the results for the parental relation and border size
242          */
243         XTranslateCoordinates(
244             fgDisplay.Display,
245             window,
246             winAttributes.root,
247             -winAttributes.border_width,
248             -winAttributes.border_width,
249             &x, &y,
250             &another
251         );
252
253         /*
254          * See if we have to return the X or Y coordinate
255          */
256         return( eWhat == GLUT_WINDOW_X ? x : y );
257     }
258
259     case GLUT_WINDOW_WIDTH:
260     case GLUT_WINDOW_HEIGHT:
261     {
262         XWindowAttributes winAttributes;
263
264         /*
265          * Return zero if there is no current window set
266          */
267         if( fgStructure.Window == NULL )
268             return( 0 );
269
270         /*
271          * Checking for window's size is much easier:
272          */
273         XGetWindowAttributes(
274             fgDisplay.Display,
275             fgStructure.Window->Window.Handle,
276             &winAttributes
277         );
278
279         /*
280          * See if to return the window's width or height
281          */
282         return( eWhat == GLUT_WINDOW_WIDTH ? winAttributes.width : winAttributes.height );
283     }
284
285     /*
286      * I do not know yet if there will be a fgChooseVisual() function for Win32
287      */
288     case GLUT_DISPLAY_MODE_POSSIBLE:
289         /*
290          * Check if the current display mode is possible
291          */
292         return( fgChooseVisual() == NULL ? 0 : 1 );
293
294     /*
295      * This is system-dependant
296      */
297     case GLUT_WINDOW_FORMAT_ID:
298         /*
299          * Return the visual ID, if there is a current window naturally:
300          */
301         if( fgStructure.Window == NULL )
302             return( 0 );
303
304         return( fgStructure.Window->Window.VisualInfo->visualid );
305
306 #elif TARGET_HOST_WIN32
307
308     /*
309      * Handle the OpenGL inquiries
310      */
311     case GLUT_WINDOW_RGBA:
312       glGetBooleanv ( GL_RGBA_MODE, &boolValue ) ;         /* True if color buffers store RGBA */
313       returnValue = boolValue ? 1 : 0 ;
314       return ( returnValue ) ;
315     case GLUT_WINDOW_DOUBLEBUFFER:
316       glGetBooleanv ( GL_DOUBLEBUFFER, &boolValue ) ;      /* True if front and back buffers exist */
317       returnValue = boolValue ? 1 : 0 ;
318       return ( returnValue ) ;
319     case GLUT_WINDOW_STEREO:
320       glGetBooleanv ( GL_STEREO, &boolValue ) ;            /* True if left and right buffers exist */
321       returnValue = boolValue ? 1 : 0 ;
322       return ( returnValue ) ;
323
324     case GLUT_WINDOW_RED_SIZE:
325       glGetIntegerv ( GL_RED_BITS, &returnValue ) ;          /* Number of bits per red component in color buffers */
326       return ( returnValue ) ;
327     case GLUT_WINDOW_GREEN_SIZE:
328       glGetIntegerv ( GL_GREEN_BITS, &returnValue ) ;        /* Number of bits per green component in color buffers */
329       return ( returnValue ) ;
330     case GLUT_WINDOW_BLUE_SIZE:
331       glGetIntegerv ( GL_BLUE_BITS, &returnValue ) ;         /* Number of bits per blue component in color buffers */
332       return ( returnValue ) ;
333     case GLUT_WINDOW_ALPHA_SIZE:
334       glGetIntegerv ( GL_ALPHA_BITS, &returnValue ) ;        /* Number of bits per alpha component in color buffers */
335       return ( returnValue ) ;
336     case GLUT_WINDOW_ACCUM_RED_SIZE:
337       glGetIntegerv ( GL_ACCUM_RED_BITS, &returnValue ) ;    /* Number of bits per red component in the accumulation buffer */
338       return ( returnValue ) ;
339     case GLUT_WINDOW_ACCUM_GREEN_SIZE:
340       glGetIntegerv ( GL_ACCUM_GREEN_BITS, &returnValue ) ;  /* Number of bits per green component in the accumulation buffer */
341       return ( returnValue ) ;
342     case GLUT_WINDOW_ACCUM_BLUE_SIZE:
343       glGetIntegerv ( GL_ACCUM_BLUE_BITS, &returnValue ) ;   /* Number of bits per blue component in the accumulation buffer */
344       return ( returnValue ) ;
345     case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
346       glGetIntegerv ( GL_ACCUM_ALPHA_BITS, &returnValue ) ;  /* Number of bits per alpha component in the accumulation buffer */
347       return ( returnValue ) ;
348     case GLUT_WINDOW_DEPTH_SIZE:
349       glGetIntegerv ( GL_DEPTH_BITS, &returnValue ) ;        /* Number of depth-buffer bitplanes */
350       return ( returnValue ) ;
351
352     case GLUT_WINDOW_BUFFER_SIZE:
353       returnValue = 1 ;                                      /* ????? */
354       return ( returnValue ) ;
355     case GLUT_WINDOW_STENCIL_SIZE:
356       returnValue = 0 ;                                      /* ????? */
357       return ( returnValue ) ;
358
359     /*
360      * Window position and size
361      */
362     case GLUT_WINDOW_X:
363     case GLUT_WINDOW_Y:
364     case GLUT_WINDOW_WIDTH:
365     case GLUT_WINDOW_HEIGHT:
366     {
367         RECT winRect;
368
369         /*
370          * Check if there is a window to be queried for dimensions:
371          */
372         freeglut_return_val_if_fail( fgStructure.Window != NULL, 0 );
373
374         /*
375          * We need to call GetWindowRect() first...
376          */
377         GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
378
379         /*
380          * ...then we've got to correct the results we've just received...
381          */
382         if ( fgStructure.Window->Parent == NULL )
383         {
384           winRect.left   += GetSystemMetrics( SM_CXSIZEFRAME );
385           winRect.right  -= GetSystemMetrics( SM_CXSIZEFRAME );
386           winRect.top    += GetSystemMetrics( SM_CYSIZEFRAME ) + GetSystemMetrics( SM_CYCAPTION );
387           winRect.bottom -= GetSystemMetrics( SM_CYSIZEFRAME );
388         }
389
390         /*
391          * ...and finally return the caller the desired value:
392          */
393         switch( eWhat )
394         {
395         case GLUT_WINDOW_X:      return( winRect.left                 );
396         case GLUT_WINDOW_Y:      return( winRect.top                  );
397         case GLUT_WINDOW_WIDTH:  return( winRect.right - winRect.left );
398         case GLUT_WINDOW_HEIGHT: return( winRect.bottom - winRect.top );
399         }
400     }
401     break;
402
403     case GLUT_DISPLAY_MODE_POSSIBLE:
404         /*
405          * Check if the current display mode is possible
406          */
407         return( fgSetupPixelFormat( fgStructure.Window, TRUE, PFD_MAIN_PLANE ) );
408
409     case GLUT_WINDOW_FORMAT_ID:
410         /*
411          * Return the pixel format of the current window
412          */
413         if( fgStructure.Window != NULL )
414             return( GetPixelFormat( fgStructure.Window->Window.Device ) );
415
416         /*
417          * If the current window does not exist, fail:
418          */
419         return( 0 );
420
421 #endif
422
423     /*
424      * The window structure queries
425      */
426     case GLUT_WINDOW_PARENT:
427         /*
428          * Return the ID number of current window's parent, if any
429          */
430         if( fgStructure.Window         == NULL ) return( 0 );
431         if( fgStructure.Window->Parent == NULL ) return( 0 );
432
433         return( fgStructure.Window->Parent->ID );
434
435     case GLUT_WINDOW_NUM_CHILDREN:
436         /*
437          * Return the number of children attached to the current window
438          */
439         if( fgStructure.Window == NULL )
440             return( 0 );
441
442         return( fgListLength( &fgStructure.Window->Children ) );
443
444     case GLUT_WINDOW_CURSOR:
445         /*
446          * Return the currently selected window cursor
447          */
448         if( fgStructure.Window == NULL )
449             return( 0 );
450
451         return( fgStructure.Window->State.Cursor );
452
453     case GLUT_MENU_NUM_ITEMS:
454         /*
455          * Return the number of menu entries in the current menu
456          */
457         if( fgStructure.Menu == NULL )
458             return( 0 );
459
460         return( fgListLength( &fgStructure.Menu->Entries ) );
461
462     case GLUT_ACTION_ON_WINDOW_CLOSE: return ( fgState.ActionOnWindowClose ) ;
463
464     default:
465         /*
466          * Just have it reported, so that we can see what needs to be implemented
467          */
468         fgWarning( "glutGet(): missing enum handle %i\n", eWhat );
469         break;
470     }
471
472     /*
473      * If nothing happens, then we are in deep trouble...
474      */
475     return( -1 );
476 }
477
478 /*
479  * Returns various device information.
480  */
481 int FGAPIENTRY glutDeviceGet( GLenum eWhat )
482 {
483     freeglut_assert_ready;
484
485     /*
486      * See why are we bothered...
487      *
488      * WARNING: we are mostly lying in this function.
489      */
490     switch( eWhat )
491     {
492     case GLUT_HAS_KEYBOARD:
493         /*
494          * We always have a keyboard present on PC machines...
495          */
496         return( TRUE );
497
498 #if TARGET_HOST_UNIX_X11
499
500     case GLUT_HAS_MOUSE:
501         /*
502          * Hey, my Atari 65XE hasn't had a mouse!
503          */
504         return( TRUE );
505
506     case GLUT_NUM_MOUSE_BUTTONS:
507         /*
508          * Return the number of mouse buttons available. This is a big guess.
509          */
510         return( 3 );
511
512 #elif TARGET_HOST_WIN32
513
514     case GLUT_HAS_MOUSE:
515         /*
516          * The Windows can be booted without a mouse. 
517          * It would be nice to have this reported.
518          */
519         return( GetSystemMetrics( SM_MOUSEPRESENT ) );
520
521     case GLUT_NUM_MOUSE_BUTTONS:
522         /*
523          * We are much more fortunate under Win32 about this...
524          */
525         return( GetSystemMetrics( SM_CMOUSEBUTTONS ) );
526
527 #endif
528
529     case GLUT_JOYSTICK_POLL_RATE:
530     case GLUT_HAS_JOYSTICK:
531     case GLUT_JOYSTICK_BUTTONS:
532     case GLUT_JOYSTICK_AXES:
533         /*
534          * WARNING: THIS IS A BIG LIE!
535          */
536         return( 0 );
537
538     case GLUT_HAS_SPACEBALL:
539     case GLUT_HAS_DIAL_AND_BUTTON_BOX:
540     case GLUT_HAS_TABLET:
541         /*
542          * Sounds cool. And unuseful.
543          */
544         return( FALSE );
545
546     case GLUT_NUM_SPACEBALL_BUTTONS:
547     case GLUT_NUM_BUTTON_BOX_BUTTONS:
548     case GLUT_NUM_DIALS:
549     case GLUT_NUM_TABLET_BUTTONS:
550         /*
551          * Zero is not the answer. Zero is the question. Continuum is the answer.
552          */
553         return( 0 );
554
555     case GLUT_DEVICE_IGNORE_KEY_REPEAT:
556         /*
557          * Return what we think about the key auto repeat settings
558          */
559         return( fgState.IgnoreKeyRepeat );
560
561     case GLUT_DEVICE_KEY_REPEAT:
562         /*
563          * WARNING: THIS IS A BIG LIE!
564          */
565         return( GLUT_KEY_REPEAT_DEFAULT );
566
567     default:
568         /*
569          * Complain.
570          */
571         fgWarning( "glutDeviceGet(): missing enum handle %i\n", eWhat );
572         break;
573     }
574
575     /*
576      * And now -- the failure.
577      */
578     return( -1 );
579 }
580
581 /*
582  * This should return the current state of ALT, SHIFT and CTRL keys.
583  */
584 int FGAPIENTRY glutGetModifiers( void )
585 {
586     /*
587      * Fail if there is no current window or called outside an input callback
588      */
589     if( fgStructure.Window == NULL )
590         return( 0 );
591
592     if( fgStructure.Window->State.Modifiers == 0xffffffff )
593     {
594         fgWarning( "glutGetModifiers() called outside an input callback" );
595         return( 0 );
596     }
597
598     /*
599      * Return the current modifiers state otherwise
600      */
601     return( fgStructure.Window->State.Modifiers );
602 }
603
604 /*
605  * Return the state of the GLUT API overlay subsystem. A misery ;-)
606  */
607 int FGAPIENTRY glutLayerGet( GLenum eWhat )
608 {
609     freeglut_assert_ready;
610
611     /*
612      * This is easy as layers are not implemented ;-)
613      */
614     switch( eWhat )
615     {
616
617 #if TARGET_HOST_UNIX_X11
618
619     case GLUT_OVERLAY_POSSIBLE:
620         /*
621          * Nope, overlays are not possible.
622          */
623         return( FALSE );
624
625     case GLUT_LAYER_IN_USE:
626         /*
627          * The normal plane is always in use
628          */
629         return( GLUT_NORMAL );
630
631     case GLUT_HAS_OVERLAY:
632         /*
633          * No window is allowed to have an overlay
634          */
635         return( FALSE );
636
637     case GLUT_TRANSPARENT_INDEX:
638         /*
639          * Return just anything, which is always defined as zero
640          */
641         return( 0 );
642
643     case GLUT_NORMAL_DAMAGED:
644         /*
645          * Actually I do not know. Maybe.
646          */
647         return( FALSE );
648
649     case GLUT_OVERLAY_DAMAGED:
650         /*
651          * Return minus one to mark that no layer is in use
652          */
653         return( -1 );
654
655 #elif TARGET_HOST_WIN32
656
657     case GLUT_OVERLAY_POSSIBLE:
658         /*
659          * Check if an overlay display mode is possible
660          */
661         return( fgSetupPixelFormat( fgStructure.Window, TRUE, PFD_OVERLAY_PLANE ) );
662
663     case GLUT_LAYER_IN_USE:
664         /*
665          * The normal plane is always in use
666          */
667         return( GLUT_NORMAL );
668
669     case GLUT_HAS_OVERLAY:
670         /*
671          * No window is allowed to have an overlay
672          */
673         return( FALSE );
674
675     case GLUT_TRANSPARENT_INDEX:
676         /*
677          * Return just anything, which is always defined as zero
678          */
679         return( 0 );
680
681     case GLUT_NORMAL_DAMAGED:
682         /*
683          * Actually I do not know. Maybe.
684          */
685         return( FALSE );
686
687     case GLUT_OVERLAY_DAMAGED:
688         /*
689          * Return minus one to mark that no layer is in use
690          */
691         return( -1 );
692 #endif
693
694     default:
695         /*
696          * Complain to the user about the obvious bug
697          */
698         fgWarning( "glutLayerGet(): missing enum handle %i\n", eWhat );
699         break;
700     }
701
702     /*
703      * And fail. That's good. Programs do love failing.
704      */
705     return( -1 );
706 }
707
708 /*** END OF FILE ***/