Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:26

0001 /*
0002 
0003 Copyright 1989, 1998  The Open Group
0004 
0005 Permission to use, copy, modify, distribute, and sell this software and its
0006 documentation for any purpose is hereby granted without fee, provided that
0007 the above copyright notice appear in all copies and that both that
0008 copyright notice and this permission notice appear in supporting
0009 documentation.
0010 
0011 The above copyright notice and this permission notice shall be included in
0012 all copies or substantial portions of the Software.
0013 
0014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
0017 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
0018 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0019 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0020 
0021 Except as contained in this notice, the name of The Open Group shall not be
0022 used in advertising or otherwise to promote the sale, use or other dealings
0023 in this Software without prior written authorization from The Open Group.
0024 
0025 */
0026 
0027 /*
0028  * Author:  Chris D. Peterson, MIT X Consortium
0029  */
0030 
0031 /************************************************************
0032 
0033         The Editres Protocol
0034 
0035 
0036   The Client message sent to the application is:
0037 
0038   ATOM = "ResEditor"        --- RES_EDITOR_NAME
0039 
0040   FORMAT = 32                   --- RES_EDIT_SEND_EVENT_FORMAT
0041 
0042   l[0] = timestamp
0043   l[1] = command atom name
0044   l[2] = ident of command
0045   l[3] = protocol version number to use
0046 
0047 
0048 
0049   The binary protocol has the following format:
0050 
0051     Card8:      8-bit unsigned integer
0052     Card16:     16-bit unsigned integer
0053     Card32:     32-bit unsigned integer
0054     Int16:      16-bit signed integer
0055     Window:     32-bit value
0056     Widget:     32-bit value
0057     String8:        ListOfCard8
0058 
0059     [a][b][c] represent an exclusive list of choices.
0060 
0061     All widgets are passed as a list of widgets, containing the
0062     full instance heirarchy of this widget.  The hierarchy is ordered
0063     from parent to child.  Thus the first element of each list is
0064     the root of the widget tree (this makes verifying that the widget
0065     still exists, MUCH faster).
0066 
0067     ListOfFoo comprises a list of things in the following format:
0068 
0069     number:         Card16
0070     <number> things:    ????
0071 
0072   This is a synchronous protocol, every request MUST be followed by a
0073   reply.
0074 
0075   Request:
0076 
0077     Serial Number:  Card8
0078     Op Code:    Card8 - { SendWidgetTree = 0,
0079                   SetValues = 1,
0080                   GetResources = 2,
0081                   GetGeometry = 3,
0082                   FindChild = 4,
0083                   GetValues = 5 }
0084     Length:     Card32
0085     Data:
0086 
0087    Reply:
0088 
0089     Serial Number:  Card8
0090     Type:       Card8 - { Formatted = 0,
0091                               Unformatted = 1,
0092                   ProtocolMismatch = 2
0093                 }
0094     Length:     Card32
0095 
0096 
0097    Byte Order:
0098 
0099     All Fields are MSB -> LSB
0100 
0101     Data:
0102 
0103         Formatted:
0104 
0105             The data contains the reply information for the request as
0106         specified below if the reply type is "Formatted".  The return
0107         values for the other reply types are shown below.
0108 
0109         Unformatted:
0110 
0111         Message:    String8
0112 
0113     ProtocolMismatch:
0114 
0115         RequestedVersion:       Card8
0116 
0117 ------------------------------------------------------------
0118 
0119    SendWidgetTree:
0120 
0121     --->
0122 
0123     Number of Entries:  Card16
0124     Entry:
0125         widget:     ListOfWidgets
0126         name:       String8
0127         class:      String8
0128         window:     Card32
0129             toolkit:        String8
0130 
0131         SendWidgetTree returns the toolkit type, and a fully specified list
0132         of widgets for each widget in the tree.  This is enough information
0133         to completely reconstruct the entire widget hierarchy.
0134 
0135     The window return value contains the Xid of the window currently
0136     used by this widget.  If the widget is unrealized then 0 is returned,
0137     and if widget is a non-windowed object a value of 2 is returned.
0138 
0139    SetValues:
0140 
0141     name:   String8
0142     type:   String8
0143     value:  String8
0144     Number of Entries:  Card16
0145     Entry:
0146         widget:     ListOfWidgets
0147 
0148     --->
0149 
0150     Number of Entries:  Card16
0151     Entry:
0152         widget:     ListOfWidgets
0153         message:    String8
0154 
0155     SetValues will allow the same resource to be set on a number of
0156     widgets.  This function will return an error message if the SetValues
0157     request caused an Xt error.
0158 
0159   GetValues:
0160 
0161         names:                ListOfString8
0162         widget:               Widget
0163 
0164         --->
0165     novalues:             ListOfCard16
0166     values:               ListOfString8
0167 
0168         GetValues will allow a number of resource values to be read
0169         on a particular widget.  The request specifies the names of
0170     the resources wanted and the widget id these resources are
0171     from.  The reply returns a list of indices from the requests
0172     name list of resources for which a value can not be returned.
0173     It also returns a list of returned values, in the order of the
0174         requests names list, skipping those indices present in novalues.
0175 
0176    GetResources:
0177 
0178     Number of Entries:  Card16
0179     Entry
0180         widget:     ListOfWidgets:
0181 
0182     ---->
0183 
0184     Number of Entries:  Card16
0185     Entry
0186         Widget:         ListOfWidgets:
0187         Error:          Bool
0188 
0189         [ Message:      String 8 ]
0190         [ Number of Resources:  Card16
0191         Resource:
0192             Kind:   {normal, constraint}
0193             Name:   String8
0194             Class:  String8
0195             Type:   String8 ]
0196 
0197     GetResources retrieves the kind, name, class, and type for every
0198     widget passed to it.  If an error occurred with the resource fetch
0199     Error will be set to True for the given widget and a message
0200     is returned rather than the resource info.
0201 
0202   GetGeometry:
0203 
0204     Number of Entries:  Card16
0205     Entry
0206         Widget:     ListOfWidgets:
0207 
0208     ---->
0209 
0210     Number of Entries:  Card16
0211     Entry
0212         Widget:         ListOfWidgets:
0213         Error:          Bool
0214 
0215         [ message:      String 8 ]
0216         [ mapped:       Boolean
0217           X:        Int16
0218           Y:        Int16
0219           Width:    Card16
0220               Height:   Card16
0221           BorderWidth:  Card16 ]
0222 
0223     GetGeometry retrieves the mapping state, x, y, width, height
0224     and border width for each widget specified.  If an error occurred
0225     with the geometry fetch "Error" will be set to True for the given
0226     widget and a message is returned rather than the geometry info.
0227     X an Y correspond to the root coordinates of the upper left corner
0228     of the widget (outside the window border).
0229 
0230   FindChild:
0231 
0232     Widget:     ListOfWidgets
0233     X:      Int16
0234     Y:      Int16
0235 
0236     --->
0237 
0238     Widget:     ListOfWidgets
0239 
0240     FindChild returns a descendent of the widget specified that
0241     is at the root coordinates specified.
0242 
0243     NOTE:
0244 
0245     The returned widget is undefined if the point is contained in
0246     two or more mapped widgets, or in two overlapping Rect objs.
0247 
0248   GetValues:
0249 
0250         names:                ListOfString8
0251         widget:               Widget
0252 
0253         --->
0254 
0255     values:               ListOfString8
0256 
0257         GetValues will allow a number of resource values to be read
0258         on a particular widget.  Currently only InterViews 3.0.1 Styles
0259     and their attributes are supported.  In addition, the current
0260     user interface  only supports the return of 1 resource.  The ability
0261     to specify and return multiple resources is defined for future editres
0262     interfaces where some or all of a widgets resource values are returned
0263     and displayed at once.
0264 
0265 
0266 ************************************************************/
0267 
0268 #include <X11/Intrinsic.h>
0269 #include <X11/Xfuncproto.h>
0270 
0271 #define XER_NBBY 8      /* number of bits in a byte */
0272 #define BYTE_MASK 255
0273 
0274 #define HEADER_SIZE 6
0275 
0276 #define EDITRES_IS_OBJECT 2
0277 #define EDITRES_IS_UNREALIZED 0
0278 
0279 /*
0280  * Format for atoms
0281  */
0282 #define EDITRES_FORMAT             8
0283 #define EDITRES_SEND_EVENT_FORMAT 32
0284 
0285 /*
0286  * Atoms
0287  */
0288 #define EDITRES_NAME         "Editres"
0289 #define EDITRES_COMMAND_ATOM "EditresCommand"
0290 #define EDITRES_COMM_ATOM    "EditresComm"
0291 #define EDITRES_CLIENT_VALUE "EditresClientVal"
0292 #define EDITRES_PROTOCOL_ATOM "EditresProtocol"
0293 
0294 typedef enum {
0295   SendWidgetTree = 0,
0296            SetValues      = 1,
0297            GetResources   = 2,
0298            GetGeometry    = 3,
0299            FindChild      = 4,
0300            GetValues      = 5
0301 } EditresCommand;
0302 
0303 typedef enum {
0304   NormalResource     = 0,
0305   ConstraintResource = 1
0306 } ResourceType;
0307 
0308 /*
0309  * The type of a resource identifier
0310  */
0311 typedef unsigned char ResIdent;
0312 
0313 typedef enum {
0314   PartialSuccess   = 0,
0315   Failure      = 1,
0316   ProtocolMismatch = 2
0317 } EditResError;
0318 
0319 typedef struct _WidgetInfo {
0320     unsigned short num_widgets;
0321   unsigned long *ids;
0322     Widget real_widget;
0323 } WidgetInfo;
0324 
0325 typedef struct _ProtocolStream {
0326     unsigned long size, alloc;
0327     unsigned char *real_top, *top, *current;
0328 } ProtocolStream;
0329 
0330 /************************************************************
0331  * Function definitions for reading and writing protocol requests
0332  ************************************************************/
0333 _XFUNCPROTOBEGIN
0334 
0335 void _XEditResPutString8
0336 (
0337  ProtocolStream     *stream,
0338  _Xconst char       *str
0339  );
0340 
0341 void _XEditResPut8
0342 (
0343  ProtocolStream     *stream,
0344  unsigned int       value
0345  );
0346 
0347 void _XEditResPut16
0348 (
0349  ProtocolStream     *stream,
0350  unsigned int       value
0351  );
0352 
0353 void _XEditResPut32
0354 (
0355  ProtocolStream     *stream,
0356  unsigned long      value
0357  );
0358 
0359 void _XEditResPutWidgetInfo
0360 (
0361  ProtocolStream     *stream,
0362  WidgetInfo     *info
0363  );
0364 
0365 void _XEditResResetStream
0366 (
0367  ProtocolStream     *stream
0368  );
0369 
0370 Bool _XEditResGet8
0371 (
0372  ProtocolStream     *stream,
0373  unsigned char      *value
0374  );
0375 
0376 Bool _XEditResGet16
0377 (
0378  ProtocolStream     *stream,
0379  unsigned short     *value
0380  );
0381 
0382 Bool _XEditResGetSigned16
0383 (
0384  ProtocolStream     *stream,
0385  short          *value
0386  );
0387 
0388 Bool _XEditResGet32
0389 (
0390  ProtocolStream     *stream,
0391  unsigned long      *value
0392  );
0393 
0394 Bool _XEditResGetString8
0395 (
0396  ProtocolStream     *stream,
0397  char           **str
0398  );
0399 
0400 Bool _XEditResGetWidgetInfo
0401 (
0402  ProtocolStream     *stream,
0403  WidgetInfo     *info
0404  );
0405 
0406 _XFUNCPROTOEND