CvtCache.c

Go to the documentation of this file.
00001 /* $Xorg: CvtCache.c,v 1.5 2001/02/09 02:03:52 xorgcvs Exp $ */
00002 
00003 /*
00004  
00005 Copyright 1989, 1998  The Open Group
00006 
00007 Permission to use, copy, modify, distribute, and sell this software and its
00008 documentation for any purpose is hereby granted without fee, provided that
00009 the above copyright notice appear in all copies and that both that
00010 copyright notice and this permission notice appear in supporting
00011 documentation.
00012 
00013 The above copyright notice and this permission notice shall be included in
00014 all copies or substantial portions of the Software.
00015 
00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00019 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00020 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00021 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00022 
00023 Except as contained in this notice, the name of The Open Group shall not be
00024 used in advertising or otherwise to promote the sale, use or other dealings
00025 in this Software without prior written authorization from The Open Group.
00026 
00027 */
00028 /* $XFree86: xc/lib/Xmu/CvtCache.c,v 3.6 2001/08/23 00:03:21 dawes Exp $ */
00029 
00030 /* 
00031  * Author:  Jim Fulton, MIT X Consortium
00032  */
00033 
00034 #include <stdio.h>
00035 #include <X11/Xlib.h>
00036 #include <X11/Xos.h>
00037 #include <X11/Xmu/CvtCache.h>
00038 #include <stdlib.h>
00039 
00040 /*
00041  * Prototypes
00042  */
00043 static int _CloseDisplay(XmuDisplayQueue*, XmuDisplayQueueEntry*);
00044 static int _FreeCCDQ(XmuDisplayQueue*);
00045 static void _InitializeCvtCache(XmuCvtCache*);
00046 
00047 /*
00048  * Initialization
00049  */
00050 static XmuDisplayQueue *dq = NULL;
00051 
00052 
00053 /*
00054  * internal utility callbacks
00055  */
00056 
00057 static int
00058 _FreeCCDQ(XmuDisplayQueue *q)
00059 {
00060     XmuDQDestroy (dq, False);
00061     dq = NULL;
00062     return (0);
00063 }
00064 
00065 
00066 static int
00067 _CloseDisplay(XmuDisplayQueue *q, XmuDisplayQueueEntry *e)
00068 {
00069     XmuCvtCache *c;
00070 
00071     if (e && (c = (XmuCvtCache *)(e->data))) {
00072         _XmuStringToBitmapFreeCache (c);
00073         /* insert calls to free any cached memory */
00074 
00075     }
00076     return 0;
00077 }
00078 
00079 static void
00080 _InitializeCvtCache(register XmuCvtCache *c)
00081 {
00082     _XmuStringToBitmapInitCache (c);
00083     /* insert calls to init any cached memory */
00084 }
00085 
00086 
00087 /*
00088  * XmuCCLookupDisplay - return the cache entry for the indicated display;
00089  * initialize the cache if necessary
00090  */
00091 XmuCvtCache *
00092 _XmuCCLookupDisplay(Display *dpy)
00093 {
00094     XmuDisplayQueueEntry *e;
00095 
00096     /*
00097      * If no displays have been added before this, create the display queue.
00098      */
00099     if (!dq) {
00100         dq = XmuDQCreate (_CloseDisplay, _FreeCCDQ, NULL);
00101         if (!dq) return NULL;
00102     }
00103     
00104     /*
00105      * See if the display is already there
00106      */
00107     e = XmuDQLookupDisplay (dq, dpy);   /* see if it's there */
00108     if (!e) {                           /* else create it */
00109         XmuCvtCache *c = (XmuCvtCache *) malloc (sizeof (XmuCvtCache));
00110         if (!c) return NULL;
00111 
00112         /*
00113          * Add the display to the queue
00114          */
00115         e = XmuDQAddDisplay (dq, dpy, (XPointer) c);
00116         if (!e) {
00117             free ((char *) c);
00118             return NULL;
00119         }
00120 
00121         /*
00122          * initialize fields in cache
00123          */
00124         _InitializeCvtCache (c);
00125     }
00126 
00127     /*
00128      * got it
00129      */
00130     return (XmuCvtCache *)(e->data);
00131 }
00132 
00133 

Generated on Sun Mar 4 15:03:56 2007 for Scilab [trunk] by  doxygen 1.5.1