~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/editres/editresP.h

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*
 
3
 * $Xorg: editresP.h,v 1.4 2001/02/09 02:05:29 xorgcvs Exp $
 
4
 *
 
5
Copyright 1989, 1998  The Open Group
 
6
 
 
7
Permission to use, copy, modify, distribute, and sell this software and its
 
8
documentation for any purpose is hereby granted without fee, provided that
 
9
the above copyright notice appear in all copies and that both that
 
10
copyright notice and this permission notice appear in supporting
 
11
documentation.
 
12
 
 
13
The above copyright notice and this permission notice shall be included in
 
14
all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
Except as contained in this notice, the name of The Open Group shall not be
 
24
used in advertising or otherwise to promote the sale, use or other dealings
 
25
in this Software without prior written authorization from The Open Group.
 
26
 *
 
27
 * Author:  Chris D. Peterson, MIT X Consortium
 
28
 */
 
29
/* $XFree86: xc/programs/editres/editresP.h,v 1.7 2001/12/14 20:00:42 dawes Exp $ */
 
30
 
 
31
#include <X11/Xmu/EditresP.h>
 
32
#include <X11/Xresource.h>
 
33
 
 
34
#define DEBUG
 
35
 
 
36
#ifdef DEBUG
 
37
#  define CLIENT_TIME_OUT 60000 /* wait sixty seconds for the client. */
 
38
#else
 
39
#  define CLIENT_TIME_OUT 5000  /* wait five seconds for the client. */
 
40
#endif /* DEBUG */
 
41
 
 
42
#define PROTOCOL_VERSION_ONE_POINT_ONE  5 /* version 1.1 */
 
43
#define ONE_POINT_ONE_STRING "1.1"
 
44
#define PROTOCOL_VERSION_ONE_POINT_ZERO 4 /* version 1.0 */
 
45
#define ONE_POINT_ZERO_STRING "1.0" ONE_POINT_ONE_STRING 
 
46
 
 
47
#define CURRENT_PROTOCOL_VERSION PROTOCOL_VERSION_ONE_POINT_ONE 
 
48
#define CURRENT_PROTOCOL_VERSION_STRING ONE_POINT_ONE_STRING
 
49
 
 
50
#define FLASH_TIME  1000        /* Default flash time in microseconds */
 
51
#define NUM_FLASHES 3           /* Default number of flashes. */
 
52
 
 
53
#define NO_IDENT 0              /* an ident that will match nothing. */
 
54
 
 
55
#define NUM_INC 10              /* amount to increment allocators. */
 
56
 
 
57
#define ANY_RADIO_DATA ("the any widget")
 
58
#define RESOURCE_BOX ("resourceBox")
 
59
 
 
60
 
 
61
/*
 
62
 * Retrieving ResType and Boolean is the same as retrieving a Card8 except
 
63
 * possibly for signedness.
 
64
 */
 
65
 
 
66
#define _XEditResGetBoolean(_s, _r) _XEditResGet8((_s), (unsigned char *)(_r))
 
67
#define _XEditResGetResType _XEditResGet8
 
68
 
 
69
/*
 
70
 * Contexts to use with the X Context Manager.
 
71
 */
 
72
 
 
73
#define NODE_INFO ((XContext) 42)
 
74
 
 
75
/*
 
76
 * Error codes for X Server errors. 
 
77
 */
 
78
 
 
79
#define NO_ERROR 0
 
80
#define NO_WINDOW 1
 
81
 
 
82
typedef enum {LocalSendWidgetTree, LocalSetValues, LocalFindChild, 
 
83
              LocalFlashWidget, LocalGetGeometry, LocalGetResources,
 
84
              LocalGetValues} ResCommand;
 
85
 
 
86
typedef enum {ClassLabel, NameLabel, IDLabel, WindowLabel,
 
87
              ToggleLabel} LabelTypes;
 
88
typedef enum {SelectWidget, SelectAll, SelectNone, SelectInvert, SelectParent, 
 
89
              SelectChildren,  SelectDescendants, SelectAncestors} SelectTypes;
 
90
 
 
91
typedef struct _NameInfo {
 
92
    struct _NameInfo * next;    /* Next element in the linked list. */
 
93
    Widget sep_leader;          /* The separator toggle group leader. */
 
94
    Widget name_leader;         /* The name toggle group leader. */
 
95
} NameInfo;
 
96
 
 
97
typedef struct _ResourceBoxInfo {
 
98
    Widget value_wid;           /* The string containing the value. */
 
99
    Widget res_label;           /* The label containing current resoruce. */
 
100
    Widget shell;               /* Shell widget containing resource box. */
 
101
    Widget norm_list;           /* The List widget for the normal list. */
 
102
    Widget cons_list;           /* The List widget for the 
 
103
                                   Constriaint Resources */
 
104
    NameInfo * name_info;       /* The info about the widgets for each
 
105
                                   name and class in the instance heirarchy. */
 
106
} ResourceBoxInfo;
 
107
    
 
108
typedef struct _WidgetResourceInfo {
 
109
    char * name, * class, *type; /* Name, Class and Type of each resource. */
 
110
} WidgetResourceInfo;
 
111
    
 
112
typedef struct _WidgetResources {
 
113
    int num_normal, num_constraint;
 
114
    WidgetResourceInfo *normal, *constraint;
 
115
    ResourceBoxInfo * res_box;
 
116
} WidgetResources;
 
117
 
 
118
typedef struct _WNode {
 
119
    char * name;
 
120
    char * class;
 
121
    unsigned long id, window;
 
122
    struct _WNode * parent;
 
123
    struct _WNode ** children;
 
124
    struct _TreeInfo * tree_info;
 
125
    Cardinal num_children, alloc_children;
 
126
    Widget widget;
 
127
    WidgetResources * resources;
 
128
} WNode;
 
129
 
 
130
/*
 
131
 * Information for the Select any widget, toggle buttons in the resource
 
132
 * boxes.
 
133
 */
 
134
 
 
135
typedef struct _AnyInfo {
 
136
    WNode * node;               /* A Pointer off to the node corrsponding to
 
137
                                   this resource box. */
 
138
    Widget left_dot, left_star; /* The dot and star widgets to our left. */
 
139
    Widget right_dot, right_star; /* The dot and star widgets to our right. */
 
140
    int left_count, *right_count; /* If count > 0 then desensitize the left or
 
141
                                    right dot and star widgets. */
 
142
} AnyInfo;
 
143
 
 
144
/*
 
145
 * Information about the client we are currently working with.
 
146
 */
 
147
 
 
148
typedef struct _CurrentClient {
 
149
    ResCommand command;         /* the command sent. */
 
150
    ResIdent ident;
 
151
    ProtocolStream stream;      /* protocol stream for this client. */
 
152
    XtIntervalId timeout;       /* timeout set in case he doesn't answer. */
 
153
    Window window;              /* window to communicate with. */
 
154
    Atom atom;                  /* Atom used to communicate with this client.*/
 
155
} CurrentClient;
 
156
 
 
157
/*
 
158
 * Information about a tree we can display.
 
159
 */
 
160
 
 
161
typedef struct _TreeInfo {
 
162
    Widget tree_widget;         /* The Tree widget that contains all nodes */
 
163
    WNode * top_node;           /* The top node in the tree. */
 
164
    WNode ** active_nodes;      /* The currently active nodes. */
 
165
    Cardinal num_nodes, alloc_nodes; /* number of active nodes, and space */
 
166
    Widget * flash_widgets;     /* list of widgets to flash on and off. */
 
167
    Cardinal num_flash_widgets, alloc_flash_widgets; /* number of flash wids.*/
 
168
} TreeInfo;
 
169
 
 
170
/*
 
171
 * Information specific to a give APPLICATION screen.
 
172
 */
 
173
 
 
174
typedef struct _ScreenData {
 
175
    Widget set_values_popup;    /* The SetValues popup. */
 
176
    Widget res_text;            /* SetValues resource text widget. */
 
177
    Widget val_text;            /* SetValues value text widget. */
 
178
    Widget info_label;          /* The information label. */
 
179
} ScreenData;
 
180
 
 
181
typedef struct _AppResources {
 
182
    Boolean debug;              /* Is debugging on? */
 
183
    int num_flashes, flash_time; /* Number and duration of flashes. */
 
184
    Pixel flash_color;          /* Color of flash window. */
 
185
    char * save_resources_file; /* File to save the resources into. */
 
186
 
 
187
    /* Private state */
 
188
    Boolean allocated_save_resources_file;
 
189
} AppResources;
 
190
 
 
191
/*
 
192
 * Information needed to apply the resource string to all widgets.
 
193
 */
 
194
 
 
195
typedef struct _ApplyResourcesInfo {
 
196
    char * name, *class;        /* name and class  of this resource. */
 
197
    unsigned short count;
 
198
    ProtocolStream * stream;
 
199
    XrmDatabase database;
 
200
} ApplyResourcesInfo;
 
201
    
 
202
/*
 
203
 * Information needed to get a resource string from a widget.
 
204
 */
 
205
 
 
206
typedef struct _ObtainResourcesInfo {
 
207
    char * name, *class;        /* name and class  of this resource. */
 
208
    unsigned short count;
 
209
    ProtocolStream * stream;
 
210
    XrmDatabase database;
 
211
} ObtainResourcesInfo;
 
212
 
 
213
/************************************************************
 
214
 *
 
215
 * The Event Structures.
 
216
 *
 
217
 ************************************************************/
 
218
 
 
219
typedef struct _AnyEvent {
 
220
    EditresCommand type;
 
221
} AnyEvent;
 
222
 
 
223
typedef struct _WidgetTreeInfo {
 
224
    WidgetInfo widgets;
 
225
    char * name;
 
226
    char * class;
 
227
    unsigned long window;
 
228
} WidgetTreeInfo;
 
229
 
 
230
typedef struct _SendWidgetTreeEvent {
 
231
    EditresCommand type;
 
232
    char * toolkit;
 
233
    unsigned short num_entries;
 
234
    WidgetTreeInfo * info;
 
235
} SendWidgetTreeEvent;
 
236
 
 
237
typedef struct _SetValuesInfo {
 
238
    WidgetInfo widgets;
 
239
    char * message;
 
240
} SetValuesInfo;
 
241
    
 
242
typedef struct _SetValuesEvent {
 
243
    EditresCommand type;
 
244
    unsigned short num_entries;
 
245
    SetValuesInfo * info;
 
246
} SetValuesEvent;
 
247
 
 
248
typedef struct _GetValuesInfo {
 
249
    WidgetInfo widgets;
 
250
    char * value;
 
251
} GetValuesInfo;
 
252
    
 
253
typedef struct _GetValuesEvent {
 
254
    EditresCommand type;
 
255
    unsigned short num_entries;
 
256
    GetValuesInfo * info;
 
257
} GetValuesEvent;
 
258
 
 
259
typedef struct _ResourceInfo {
 
260
    ResourceType res_type;
 
261
    char * name, *class, *type;
 
262
} ResourceInfo;
 
263
 
 
264
typedef struct _GetResourcesInfo {
 
265
    WidgetInfo widgets;
 
266
    Boolean error;
 
267
    char * message;
 
268
    unsigned short num_resources;
 
269
    ResourceInfo * res_info;
 
270
} GetResourcesInfo;
 
271
 
 
272
typedef struct _GetResourcesEvent {
 
273
    EditresCommand type;
 
274
    unsigned short num_entries;
 
275
    GetResourcesInfo * info;
 
276
} GetResourcesEvent;
 
277
 
 
278
typedef struct _GetGeomInfo {
 
279
    EditresCommand type;
 
280
    WidgetInfo widgets;
 
281
    Boolean error;
 
282
    char * message;
 
283
    Boolean visable;
 
284
    short x, y;
 
285
    unsigned short width, height, border_width;
 
286
} GetGeomInfo;
 
287
 
 
288
typedef struct _GetGeomEvent {
 
289
    EditresCommand type;
 
290
    unsigned short num_entries;
 
291
    GetGeomInfo * info;
 
292
} GetGeomEvent;
 
293
 
 
294
typedef struct _FindChildEvent {
 
295
    EditresCommand type;
 
296
    WidgetInfo widgets;
 
297
} FindChildEvent;
 
298
 
 
299
typedef union _Event {
 
300
    AnyEvent any_event;
 
301
    SendWidgetTreeEvent send_widget_tree_event;
 
302
    SetValuesEvent set_values_event;
 
303
    GetResourcesEvent get_resources_event;
 
304
    GetGeomEvent get_geom_event;
 
305
    FindChildEvent find_child_event;
 
306
    GetValuesEvent get_values_event;
 
307
} Event;
 
308
    
 
309
/*
 
310
 * number of application resource labels.
 
311
 */
 
312
 
 
313
#define NUM_RES_LABELS 37
 
314
 
 
315
/*
 
316
 * Global variables. 
 
317
 */
 
318
 
 
319
#ifndef THIS_IS_MAIN
 
320
    extern int global_effective_protocol_version;
 
321
    extern char* global_effective_toolkit;
 
322
    extern int global_error_code;
 
323
    extern unsigned long global_serial_num;
 
324
    extern int (*global_old_error_handler)(Display *, XErrorEvent *);
 
325
    extern Boolean global_resource_box_up;
 
326
 
 
327
    extern TreeInfo *global_tree_info;
 
328
    extern CurrentClient global_client;
 
329
    extern ScreenData global_screen_data;
 
330
    extern Widget global_tree_parent;
 
331
    extern Widget global_paned; /* named after toolkit */
 
332
    extern Widget global_toplevel;
 
333
    extern AppResources global_resources;
 
334
 
 
335
    extern String res_labels[NUM_RES_LABELS];
 
336
#endif
 
337
 
 
338
/*
 
339
 * Macros.
 
340
 */
 
341
 
 
342
#define streq(a, b)        ( strcmp((a), (b)) == 0 )
 
343
 
 
344
/* number of entries in the command menu */
 
345
#define NUM_CM_ENTRIES 8
 
346
/* offset into CM entries for setting insensitive */
 
347
#define CM_OFFSET 1
 
348
/* number of CM entries to make insensitive */
 
349
#define CM_NUM 5
 
350
/* number of entries in the tree menu */
 
351
#define NUM_TM_ENTRIES 16
 
352
#define TM_OFFSET 0
 
353
#define TM_NUM 16
 
354
 
 
355
/*
 
356
 * Prototypes
 
357
 */
 
358
extern void ActivateResourceWidgets ( Widget w, XtPointer node_ptr, XtPointer junk );
 
359
extern void ActivateWidgetsAndSetResourceString ( Widget w, XtPointer node_ptr, XtPointer call_data );
 
360
extern void AddString ( char ** str, char *add );
 
361
extern void AddTreeNode ( Widget tree, WNode * top );
 
362
extern void AnyChosen ( Widget w, XtPointer any_info_ptr, XtPointer state_ptr );
 
363
extern void ApplyResource ( Widget w, XtPointer node_ptr, XtPointer junk );
 
364
extern void BuildVisualTree ( Widget tree_parent, Event * event );
 
365
extern void BuildWidgetTree ( Widget parent );
 
366
extern Boolean CheckDatabase ( XrmDatabase db, XrmQuarkList names, XrmQuarkList classes );
 
367
extern void CreateResourceBox ( WNode * node, char ** errors );
 
368
extern void CreateResourceBoxWidgets ( WNode * node, char **names, char **cons_names );
 
369
extern TreeInfo * CreateTree ( Event * event );
 
370
extern void DisplayChild ( Event * event );
 
371
extern void DumpTreeToFile ( Widget w, XtPointer junk, XtPointer garbage );
 
372
extern void ExecuteOverAllNodes ( WNode * top_node, void (*func)(WNode *, XtPointer), XtPointer data );
 
373
extern WNode * FindNode ( WNode *top_node, unsigned long * ids, Cardinal number );
 
374
extern void FindWidget ( Widget w, XtPointer client_data, XtPointer call_data );
 
375
extern WNode * FindWidgetFromWindow ( TreeInfo * tree_info, Window win );
 
376
extern void FlashActiveWidgets ( Widget w, XtPointer junk, XtPointer garbage );
 
377
extern void GetAllStrings ( char *in, char sep, char ***out, int * num );
 
378
extern Window GetClientWindow ( Widget w, int *x, int *y );
 
379
extern char * GetFailureMessage ( ProtocolStream * stream );
 
380
extern void GetNamesAndClasses ( WNode * node, char *** names, char ***classes );
 
381
extern ResIdent GetNewIdent ( void );
 
382
extern void GetResourceList ( Widget w, XtPointer junk, XtPointer garbage );
 
383
extern char * GetResourceValueForSetValues ( WNode * node, unsigned short * size );
 
384
extern char * HandleFlashWidget ( Event * event );
 
385
extern char * HandleGetResources ( Event * event );
 
386
extern int HandleXErrors ( Display * display, XErrorEvent * error );
 
387
extern void InitSetValues ( Widget w, XtPointer client_data, XtPointer call_data );
 
388
extern void InsertWidgetFromNode ( ProtocolStream * stream, WNode * node );
 
389
extern void InternAtoms ( Display * dpy );
 
390
extern void LayoutTree ( Widget tree );
 
391
extern int main ( int argc, char **argv );
 
392
extern void ModifySVEntry ( Widget w, XEvent *event, String * params, Cardinal * num_params );
 
393
extern void PannerCallback ( Widget w, XtPointer closure, XtPointer report_ptr );
 
394
extern void PerformTreeToFileDump ( WNode * node, int num_tabs, FILE * fp );
 
395
extern void PopdownResBox ( Widget w, XtPointer shell_ptr, XtPointer junk );
 
396
extern void PopupCentered ( XEvent * event, Widget w, XtGrabKind mode );
 
397
extern void PopupSetValues ( Widget parent, XEvent * event );
 
398
extern void PortholeCallback ( Widget w, XtPointer panner_ptr, XtPointer report_ptr );
 
399
extern void PrepareToLayoutTree ( Widget tree );
 
400
extern void PrintNodes ( WNode * top );
 
401
extern char * PrintSetValuesError ( Event * event );
 
402
extern char * ProtocolFailure ( ProtocolStream * stream );
 
403
extern XrmQuarkList Quarkify ( char ** list, char * ptr );
 
404
extern void Quit ( Widget w, XtPointer client_data, XtPointer call_data );
 
405
extern void RebuildMenusAndLabel ( String toolkit );
 
406
extern void ResourceListCallback ( Widget list, XtPointer node_ptr, XtPointer junk );
 
407
extern void SaveResource ( Widget w, XtPointer res_box_ptr, XtPointer junk );
 
408
extern void SendTree ( Widget w, XtPointer value, XtPointer call_data );
 
409
extern void SetAndCenterTreeNode ( WNode * node );
 
410
extern void SetApplicationActions ( XtAppContext app_con );
 
411
extern void SetCommand ( Widget w, ResCommand command, char * msg );
 
412
extern void SetEntriesSensitive ( Widget *entries, int num, Boolean sensitive );
 
413
extern void SetFile ( Widget w, XtPointer junk, XtPointer garbage );
 
414
extern void SetMessage ( Widget w, char * str );
 
415
extern void SetResourceString ( Widget w, XtPointer node_ptr, XtPointer junk );
 
416
extern void TreeRelabel ( Widget w, XtPointer client_data, XtPointer call_data );
 
417
extern void TreeSelect ( Widget w, XtPointer client_data, XtPointer call_data );
 
418
extern void TreeToggle ( Widget w, XtPointer node_ptr, XtPointer state_ptr );
 
419
extern void _DumpTreeToFile ( Widget w, XtPointer tree_ptr, XtPointer filename );
 
420
extern void _FindWidget ( Widget w );
 
421
extern void _FlashActiveWidgets ( TreeInfo * tree_info );
 
422
extern void _PopdownFileDialog ( Widget w, XtPointer client_data, XtPointer junk );
 
423
extern void _PopupFileDialog ( Widget w, String str, String default_value, XtCallbackProc func, XtPointer data );
 
424
extern void _TreeActivateNode ( WNode * node, SelectTypes type );
 
425
extern void _TreeRelabel ( TreeInfo * tree_info, LabelTypes type );
 
426
extern void _TreeRelabelNode ( WNode * node, LabelTypes type, Boolean recurse );
 
427
extern void _TreeSelect ( TreeInfo * tree_info, SelectTypes type );
 
428
extern void _TreeSelectNode ( WNode * node, SelectTypes type, Boolean recurse );
 
429