Annotation of researchv9/X11/src/X.V11R1/lib/X/XInitExt.c, revision 1.1

1.1     ! root        1: #include "copyright.h"
        !             2: 
        !             3: /* $Header: XInitExt.c,v 11.13 87/08/28 13:35:22 toddb Exp $ */
        !             4: /* Copyright  Massachusetts Institute of Technology 1987 */
        !             5: 
        !             6: #include "Xlibint.h"
        !             7: #include <stdio.h>
        !             8: 
        !             9: extern _XUnknownWireEvent();
        !            10: extern _XUnknownNativeEvent();
        !            11: 
        !            12: /*
        !            13:  * This routine is used to link a extension in so it will be called
        !            14:  * at appropriate times.
        !            15:  */
        !            16: 
        !            17: XExtCodes *XInitExtension (dpy, name)
        !            18:        Display *dpy;
        !            19:        char *name;
        !            20: {
        !            21:        XExtCodes codes;        /* temp. place for extension information. */
        !            22:        register _XExtension *ext;/* need a place to build it all */
        !            23:        if (!XQueryExtension(dpy, name, 
        !            24:                &codes.major_opcode, &codes.first_event,
        !            25:                &codes.first_error)) return (NULL);
        !            26: 
        !            27:        LockDisplay (dpy);
        !            28:        ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension));
        !            29:        codes.extension = dpy->ext_number++;
        !            30:        ext->codes = codes;
        !            31:        
        !            32:        /* chain it onto the display list */
        !            33:        ext->next = dpy->ext_procs;
        !            34:        dpy->ext_procs = ext;
        !            35:        UnlockDisplay (dpy);
        !            36: 
        !            37:        return (&ext->codes);           /* tell him which extension */
        !            38: }
        !            39: 
        !            40: static _XExtension *XLookupExtension (dpy, extension)
        !            41:        register Display *dpy;  /* display */
        !            42:        register int extension; /* extension number */
        !            43: {
        !            44:        register _XExtension *ext = dpy->ext_procs;
        !            45:        while (ext != NULL) {
        !            46:                if (ext->codes.extension == extension) return (ext);
        !            47:                ext = ext->next;
        !            48:        }
        !            49:        return (NULL);
        !            50: }
        !            51: 
        !            52: /*
        !            53:  * Routines to hang procs on the extension structure.
        !            54:  */
        !            55: int (*XESetCreateGC(dpy, extension, proc))()
        !            56:        Display *dpy;           /* display */
        !            57:        int extension;          /* extension number */
        !            58:        int (*proc)();          /* routine to call when GC created */
        !            59: {
        !            60:        register _XExtension *e;        /* for lookup of extension */
        !            61:        register int (*oldproc)();
        !            62:        if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
        !            63: 
        !            64:        oldproc = e->create_GC;
        !            65:        e->create_GC = proc;
        !            66: 
        !            67:        return (oldproc);
        !            68: }
        !            69: int (*XESetCopyGC(dpy, extension, proc))()
        !            70:        Display *dpy;           /* display */
        !            71:        int extension;          /* extension number */
        !            72:        int (*proc)();          /* routine to call when GC copied */
        !            73: {
        !            74:        register _XExtension *e;        /* for lookup of extension */
        !            75:        register int (*oldproc)();
        !            76:        if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
        !            77: 
        !            78:        oldproc = e->copy_GC;
        !            79:        e->copy_GC = proc;
        !            80: 
        !            81:        return (oldproc);
        !            82: }
        !            83: int (*XESetFlushGC(dpy, extension, proc))()
        !            84:        Display *dpy;           /* display */
        !            85:        int extension;          /* extension number */
        !            86:        int (*proc)();          /* routine to call when GC copied */
        !            87: {
        !            88:        register _XExtension *e;        /* for lookup of extension */
        !            89:        register int (*oldproc)();
        !            90:        if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
        !            91: 
        !            92:        oldproc = e->flush_GC;
        !            93:        e->flush_GC = proc;
        !            94: 
        !            95:        return (oldproc);
        !            96: }
        !            97: 
        !            98: int (*XESetFreeGC(dpy, extension, proc))()
        !            99:        Display *dpy;           /* display */
        !           100:        int extension;          /* extension number */
        !           101:        int (*proc)();          /* routine to call when GC freed */
        !           102: {
        !           103:        register _XExtension *e;        /* for lookup of extension */
        !           104:        register int (*oldproc)();
        !           105:        if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
        !           106: 
        !           107:        oldproc = e->free_GC;
        !           108:        e->free_GC = proc;
        !           109: 
        !           110:        return (oldproc);
        !           111: }
        !           112: 
        !           113: int (*XESetCreateFont(dpy, extension, proc))()
        !           114:        Display *dpy;           /* display */
        !           115:        int extension;          /* extension number */
        !           116:        int (*proc)();          /* routine to call when font created */
        !           117: {
        !           118:        register _XExtension *e;        /* for lookup of extension */
        !           119:        register int (*oldproc)();
        !           120:        if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
        !           121: 
        !           122:        oldproc = e->create_Font;
        !           123:        e->create_Font = proc;
        !           124: 
        !           125:        return (oldproc);
        !           126: }
        !           127: 
        !           128: int (*XESetFreeFont(dpy, extension, proc))()
        !           129:        Display *dpy;           /* display */
        !           130:        int extension;          /* extension number */
        !           131:        int (*proc)();          /* routine to call when font freed */
        !           132: {
        !           133:        register _XExtension *e;        /* for lookup of extension */
        !           134:        register int (*oldproc)();
        !           135:        if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
        !           136: 
        !           137:        oldproc = e->free_Font;
        !           138:        e->free_Font = proc;
        !           139: 
        !           140:        return (oldproc);
        !           141: }
        !           142: 
        !           143: int (*XESetCloseDisplay(dpy, extension, proc))()
        !           144:        Display *dpy;           /* display */
        !           145:        int extension;          /* extension number */
        !           146:        int (*proc)();          /* routine to call when display closed */
        !           147: {
        !           148:        register _XExtension *e;        /* for lookup of extension */
        !           149:        register int (*oldproc)();
        !           150:        if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
        !           151: 
        !           152:        oldproc = e->close_display;
        !           153:        e->close_display = proc;
        !           154: 
        !           155:        return (oldproc);
        !           156: }
        !           157: int (*XESetWireToEvent(dpy, event_number, proc))()
        !           158:        Display *dpy;           /* display */
        !           159:        int (*proc)();          /* routine to call when converting event */
        !           160:        int event_number;       /* event routine to replace */
        !           161: {
        !           162:        register int (*oldproc)();
        !           163:        if (proc == NULL) proc = _XUnknownWireEvent;
        !           164:        LockDisplay (dpy);
        !           165:        oldproc = dpy->event_vec[event_number];
        !           166:        dpy->event_vec[event_number] = proc;
        !           167:        UnlockDisplay (dpy);
        !           168: 
        !           169:        return (oldproc);
        !           170: }
        !           171: int (*XESetEventToWire(dpy, event_number, proc))()
        !           172:        Display *dpy;           /* display */
        !           173:        int (*proc)();          /* routine to call when converting event */
        !           174:        int event_number;       /* event routine to replace */
        !           175: {
        !           176:        register int (*oldproc)();
        !           177:        if (proc == NULL) proc = _XUnknownNativeEvent;
        !           178:        LockDisplay (dpy);
        !           179:        oldproc = dpy->wire_vec[event_number];
        !           180:        dpy->wire_vec[event_number] = proc;
        !           181:        return (oldproc);
        !           182: }
        !           183: int (*XESetError(dpy, extension, proc))()
        !           184:        Display *dpy;           /* display */
        !           185:        int extension;          /* extension number */
        !           186:        int (*proc)();          /* routine to call when X error happens */
        !           187: {
        !           188:        register _XExtension *e;        /* for lookup of extension */
        !           189:        register int (*oldproc)();
        !           190:        if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
        !           191: 
        !           192:        oldproc = e->error;
        !           193:        e->error = proc;
        !           194: 
        !           195:        return (oldproc);
        !           196: }
        !           197: int (*XESetErrorString(dpy, extension, proc))()
        !           198:        Display *dpy;           /* display */
        !           199:        int extension;          /* extension number */
        !           200:        int (*proc)();          /* routine to call when I/O error happens */
        !           201: {
        !           202:        register _XExtension *e;        /* for lookup of extension */
        !           203:        register int (*oldproc)();
        !           204:        if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
        !           205: 
        !           206:        oldproc = e->error_string;
        !           207:        e->error_string = proc;
        !           208: 
        !           209:        return (oldproc);
        !           210: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.