1 /*----------------------------------------------------------------------------
2 --
3 --  Module:           xtmEditAclUx
4 --
5 --  Project:          Xdiary
6 --  System:           xtm - X Desktop Calendar
7 --    Subsystem:      <>
8 --    Function block: <>
9 --
10 --  Description:
11 --    Edit the ACL list for a calendar in a UNIX file system.
12 --
13 --  Filename:         xtmEditAclUx.c
14 --
15 --  Authors:          Roger Larsson, Ulrika Bornetun
16 --  Creation date:    1992-10-30
17 --
18 --
19 --  (C) Copyright Ulrika Bornetun, Roger Larsson (1995)
20 --      All rights reserved
21 --
22 --  Permission to use, copy, modify, and distribute this software and its
23 --  documentation for any purpose and without fee is hereby granted,
24 --  provided that the above copyright notice appear in all copies. Ulrika
25 --  Bornetun and Roger Larsson make no representations about the usability
26 --  of this software for any purpose. It is provided "as is" without express
27 --  or implied warranty.
28 ----------------------------------------------------------------------------*/
29 
30 /* SCCS module identifier. */
31 static char SCCSID[] = "@(#) Module: xtmEditAclUx.c, Version: 1.1, Date: 95/02/18 15:52:13";
32 
33 
34 /*----------------------------------------------------------------------------
35 --  Include files
36 ----------------------------------------------------------------------------*/
37 
38 #include <sys/types.h>
39 #include <grp.h>
40 #include <pwd.h>
41 #include <string.h>
42 #include <stdlib.h>
43 #include <stdio.h>
44 #include <sys/types.h>
45 #include <sys/stat.h>
46 
47 #include <X11/Intrinsic.h>
48 #include <X11/Shell.h>
49 
50 #include <Xm/Protocols.h>
51 
52 #include <Xm/Xm.h>
53 #include <Xm/List.h>
54 #include <Xm/RowColumn.h>
55 #include <Xm/Text.h>
56 #include <Xm/ToggleB.h>
57 
58 #include "System.h"
59 #include "LstLinked.h"
60 #include "Message.h"
61 
62 #include "msgXdiary.h"
63 #include "xtmGlobal.h"
64 #include "xtmAccBase.h"
65 #include "xtmHelp.h"
66 #include "xitError.h"
67 #include "xitInfo.h"
68 #include "xitTools.h"
69 #include "xtmEditAclUx.h"
70 
71 
72 /*----------------------------------------------------------------------------
73 --  Macro definitions
74 ----------------------------------------------------------------------------*/
75 
76 /* The number of ACLs we can handle. */
77 #define MAX_ACLS         200
78 
79 
80 /* Local widgets in the window. */
81 #define aclLi            dataLocalW[  0 ]
82 #define actionRc         dataLocalW[  1 ]
83 #define calLa            dataLocalW[  2 ]
84 #define flagMsgTb        dataLocalW[  3 ]
85 #define flagRc           dataLocalW[  4 ]
86 #define flagReadTb       dataLocalW[  5 ]
87 #define flagWriteTb      dataLocalW[  6 ]
88 #define groupLa          dataLocalW[  7 ]
89 #define groupTx          dataLocalW[  8 ]
90 #define placeLa          dataLocalW[  9 ]
91 #define placeRc          dataLocalW[ 10 ]
92 #define placeTx          dataLocalW[ 11 ]
93 #define userLa           dataLocalW[ 12 ]
94 #define userTx           dataLocalW[ 13 ]
95 
96 
97 /*----------------------------------------------------------------------------
98 --  Type declarations
99 ----------------------------------------------------------------------------*/
100 
101 /* Record describing one instance of the ACL window. */
102 typedef struct {
103 
104   /* Has any fields changed? */
105   Boolean  field_changed;
106 
107   /* Has any ACLs changed? */
108   Boolean  acl_changed;
109 
110   /* Location of the calendar to edit. */
111   char  cal_location[ XTM_GL_MAX_LOCATION + 1 ];
112 
113   /* Name of the calendar to edit. */
114   char  cal_name[ XTM_GL_MAX_CAL_NAME + 1 ];
115 
116   /* ACL window. */
117   Widget  aclW;
118 
119   /* Info reference. */
120   XIT_IN_HANDLE  info_handle;
121 
122   /* Customization data. */
123   XTM_GL_CUSTOM_DATA_REF  custom_data_ref;
124 
125   /* Callback and user data to inform our creator of specific actions. */
126   XTM_AU_ACTION_CB  actionCB;
127   void              *user_data;
128 
129 } ACL_REC, *ACL_REC_REF;
130 
131 
132 /*----------------------------------------------------------------------------
133 --  Global definitions
134 ----------------------------------------------------------------------------*/
135 
136 /* Name of module. */
137 static char  *module_name = "xtmEditAclUnix";
138 
139 /* IDs for the help windows. */
140 static char  *acl_window_id = "EditAclUnix";
141 
142 
143 /*----------------------------------------------------------------------------
144 --  Function prototypes
145 ----------------------------------------------------------------------------*/
146 
147 static void
148   accessListCB( Widget                widget,
149                 ACL_REC_REF           acl_ref,
150                 XmListCallbackStruct  *call_data );
151 
152 static void
153   addCB( Widget       widget,
154          ACL_REC_REF  acl_ref,
155          XtPointer    call_data );
156 
157 static void
158   cancelCB( Widget       widget,
159             ACL_REC_REF  acl_ref,
160             XtPointer    call_data );
161 
162 static void
163   closeCB( Widget       widget,
164            ACL_REC_REF  acl_ref,
165            XtPointer    call_data );
166 
167 static Widget
168   createAclWindow( ACL_REC_REF  acl_ref,
169                    Widget       parent );
170 
171 static void
172   deleteCB( Widget       widget,
173             ACL_REC_REF  acl_ref,
174             XtPointer    call_data );
175 
176 static void
177   destroyCB( Widget       widget,
178              ACL_REC_REF  acl_ref,
179              XtPointer    call_data );
180 
181 static void
182   fieldChangedCB( Widget       widget,
183                   ACL_REC_REF  acl_ref,
184                   XtPointer    call_data );
185 
186 static void
187   helpCB( Widget       widget,
188           ACL_REC_REF  acl_ref,
189           XtPointer    call_data );
190 
191 static void
192   okCB( Widget       widget,
193         ACL_REC_REF  acl_ref,
194         XtPointer    call_data );
195 
196 static void
197   saveAccessInfo( ACL_REC_REF  acl_ref );
198 
199 static void
200   saveAndCloseCB( Widget       widget,
201                   ACL_REC_REF  acl_ref,
202                   XtPointer    call_data );
203 
204 static void
205   setAccessData( ACL_REC_REF  acl_ref );
206 
207 static void
208   setAccessItem( ACL_REC_REF  acl_ref,
209                  int          position,
210                  char         *user,
211                  char         *group,
212                  int          flags );
213 
214 static void
215   setAction( ACL_REC_REF  acl_ref,
216              Boolean      add_active,
217              Boolean      delete_active );
218 
219 static void
220   setEmptyItem( ACL_REC_REF  acl_ref );
221 
222 
223 
224 /*----------------------------------------------------------------------------
225 --  Functions
226 ----------------------------------------------------------------------------*/
227 
228 XTM_AU_HANDLE
xtmAuInitialize(XTM_GL_CUSTOM_DATA_REF custom_data_ref,XIT_IN_HANDLE info_handle,Widget parent,XTM_AU_ACTION_CB actionCB,void * user_data)229   xtmAuInitialize( XTM_GL_CUSTOM_DATA_REF  custom_data_ref,
230                    XIT_IN_HANDLE           info_handle,
231                    Widget                  parent,
232                    XTM_AU_ACTION_CB        actionCB,
233                    void                    *user_data )
234 {
235 
236   /* Variables. */
237   ACL_REC_REF  acl_ref;
238 
239 
240   /* Code. */
241 
242   /* Create and initialize our private data. */
243   acl_ref = SysNew( ACL_REC );
244   if( acl_ref == NULL )
245     return( NULL );
246 
247   acl_ref -> custom_data_ref = custom_data_ref;
248   acl_ref -> info_handle     = info_handle;
249   acl_ref -> field_changed   = False;
250   acl_ref -> actionCB        = actionCB;
251   acl_ref -> user_data       = user_data;
252   acl_ref -> aclW            = NULL;
253 
254 
255   /* Create the base window. */
256   acl_ref -> aclW = createAclWindow( acl_ref, parent );
257   if( acl_ref -> aclW == NULL ) {
258     SysFree( acl_ref );
259 
260     return( NULL );
261   }
262 
263 
264   return( (XTM_AU_HANDLE) acl_ref );
265 
266 } /* xtmAuInitialize */
267 
268 
269 /*----------------------------------------------------------------------*/
270 
271 void
xtmAuDestroy(XTM_AU_HANDLE acl_handle)272   xtmAuDestroy( XTM_AU_HANDLE  acl_handle )
273 {
274 
275   /* Variables. */
276   ACL_REC_REF  acl_ref;
277 
278 
279   /* Code. */
280 
281   if( acl_handle == NULL )
282     return;
283 
284   /* Our private data. */
285   acl_ref = (ACL_REC_REF) acl_handle;
286 
287   /* Get rid of all windows. */
288   if( acl_ref -> aclW != NULL )
289     XtDestroyWidget( acl_ref -> aclW );
290 
291 
292   return;
293 
294 } /* xtmAuDestroy */
295 
296 
297 /*----------------------------------------------------------------------*/
298 
299 void
xtmAuEditAcl(XTM_AU_HANDLE acl_handle,char * cal_name,char * cal_location)300   xtmAuEditAcl( XTM_AU_HANDLE  acl_handle,
301                 char           *cal_name,
302                 char           *cal_location )
303 {
304 
305   /* Variables. */
306   Arg          args[ 10 ];
307   Cardinal     n;
308   ACL_REC_REF  acl_ref;
309 
310 
311   /* Code. */
312 
313   /* Our private data. */
314   acl_ref = (ACL_REC_REF) acl_handle;
315 
316 
317   /* Save the name and location of the calendar. */
318   strncpy( acl_ref -> cal_name, cal_name, XTM_GL_MAX_CAL_NAME );
319   acl_ref -> cal_name[ XTM_GL_MAX_CAL_NAME ] = '\0';
320 
321   strncpy( acl_ref -> cal_location, cal_location, XTM_GL_MAX_LOCATION );
322   acl_ref -> cal_location[ XTM_GL_MAX_LOCATION ] = '\0';
323 
324 
325   /* Make sure the window is visible. */
326   XtManageChild( acl_ref -> aclW );
327 
328 
329   /* Make sure our children don't spoil our size. */
330   n = 0;
331   XtSetArg( args[ n ], XmNallowShellResize, False ); n++;
332   XtSetValues( XtParent( acl_ref -> aclW ), args, n );
333 
334 
335   /* Set the window data. */
336   setAccessData( acl_ref );
337 
338   acl_ref -> acl_changed = False;
339 
340 
341   return;
342 
343 } /* xtmAuEditAcl */
344 
345 
346 /*----------------------------------------------------------------------*/
347 
348 static Widget
createAclWindow(ACL_REC_REF acl_ref,Widget parent)349   createAclWindow( ACL_REC_REF  acl_ref,
350                    Widget       parent )
351 {
352 
353   /* Variables. */
354   int       index;
355   Arg       args[ 10 ];
356   Cardinal  n;
357   Widget    actionBu[ 2 ];
358   Widget    aclFd;
359   Widget    dataLocalW[ 14 ];
360   Widget    workFo;
361 
362   static XIT_PUSH_STRUCT access_action_def[] = {
363     { "AddPb",     "", "", True, NULL },
364     { "DeletePb",  "", "", True, NULL },
365   };
366 
367   static XIT_TEXT_STRUCT text_buffer[] = {
368     { "UserTx",  NULL, 1, True },
369     { "GroupTx", NULL, 1, True },
370     { "PlaceTx", NULL, 1, True },
371   };
372 
373   static XIT_ACTION_AREA_ITEM  action_buttons[] = {
374     { "",   okCB,     NULL },
375     { NULL, NULL,     NULL },
376     { "",   cancelCB, NULL },
377     { NULL, NULL,     NULL },
378     { "",   helpCB,   NULL },
379   };
380 
381 
382   /* Code. */
383 
384   action_buttons[ 0 ].label = msgGetText( MXDI_OK_BUTTON );
385   action_buttons[ 0 ].data  = acl_ref;
386   action_buttons[ 2 ].label = msgGetText( MXDI_CANCEL_BUTTON );
387   action_buttons[ 2 ].data  = acl_ref;
388   action_buttons[ 4 ].label = msgGetText( MXDI_HELP_BUTTON );
389   action_buttons[ 4 ].data  = acl_ref;
390 
391   access_action_def[ 0 ].title = msgGetText( MXDI_ADD_CHANGE_ITEM );
392   access_action_def[ 1 ].title = msgGetText( MXDI_DELETE_ITEM );
393 
394 
395   /* Create a form dialog with buttons. */
396   aclFd = xitCreateFormDialog( parent, "AclFd",
397                                1, 0,
398                                action_buttons,
399                                XtNumber( action_buttons ) );
400 
401   XtAddCallback( aclFd, XmNdestroyCallback,
402                  (XtCallbackProc) destroyCB, (XtPointer) acl_ref );
403 
404   /* We want to know when this window is closed. */
405   {
406     Atom  wm_delete_window;
407 
408     wm_delete_window = XmInternAtom( XtDisplay( aclFd ),
409                                      "WM_DELETE_WINDOW", False );
410 
411     XmAddWMProtocols( XtParent( aclFd ), &wm_delete_window, 1 );
412     XmAddWMProtocolCallback( XtParent( aclFd ), wm_delete_window,
413                              (XtCallbackProc) cancelCB, (XtPointer) acl_ref );
414   } /* block */
415 
416   n = 0;
417   XtSetArg( args[ n ], XmNtitle, msgGetText( MXDI_UNIX_ACCESS_TITLE ) ); n++;
418   XtSetValues( XtParent( aclFd ), args, n );
419 
420 
421   /* Form to hold the information. */
422   workFo = XtNameToWidget( aclFd, "AclFdFo" );
423 
424 
425   /* The calendar we are editing. */
426   calLa = xitCreateLabel( workFo, "CalLa", "", -1 );
427 
428 
429   /* List with access information. */
430   n = 0;
431   XtSetArg( args[ n ], XmNlistSizePolicy,         XmCONSTANT ); n++;
432   XtSetArg( args[ n ], XmNscrollBarDisplayPolicy, XmSTATIC ); n++;
433   XtSetArg( args[ n ], XmNselectionPolicy,        XmSINGLE_SELECT ); n++;
434   XtSetArg( args[ n ], XmNlistMarginHeight,       5 ); n++;
435   XtSetArg( args[ n ], XmNlistMarginWidth,        5 ); n++;
436   aclLi = XmCreateScrolledList( workFo, "AclLi", args, n );
437 
438   XtAddCallback( aclLi, XmNsingleSelectionCallback,
439                  (XtCallbackProc) accessListCB, (XtPointer) acl_ref );
440   XtAddCallback( aclLi, XmNdefaultActionCallback,
441                  (XtCallbackProc) accessListCB, (XtPointer) acl_ref );
442 
443 
444   /* User name. */
445   userLa = xitCreateLabel( workFo, "UserLa",
446                            msgGetText( MXDI_USER_LABEL ), -1 );
447 
448   userTx = xitCreateText( workFo, &text_buffer[ 0 ] );
449 
450   XtAddCallback( userTx, XmNvalueChangedCallback,
451                  (XtCallbackProc) fieldChangedCB, (XtPointer) acl_ref );
452 
453   /* Group name. */
454   groupLa = xitCreateLabel( workFo, "GroupLa",
455                             msgGetText( MXDI_GROUP_LABEL ), -1 );
456 
457   groupTx = xitCreateText( workFo, &text_buffer[ 1 ] );
458 
459   XtAddCallback( groupTx, XmNvalueChangedCallback,
460                  (XtCallbackProc) fieldChangedCB, (XtPointer) acl_ref );
461 
462 
463   /* Access flags. */
464   n = 0;
465   XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++;
466   flagRc = XmCreateRowColumn( workFo, "FlagRc", args, n );
467 
468   flagReadTb  = xitCreateToggleButton(
469                   flagRc, "FlagReadTb",
470                   msgGetText( MXDI_READ_LABEL ), False );
471 
472   flagWriteTb = xitCreateToggleButton(
473                   flagRc, "FlagWriteTb",
474                   msgGetText( MXDI_WRITE_LABEL ), False );
475 
476   flagMsgTb   = xitCreateToggleButton(
477                   flagRc, "FlagMsgTb",
478                   msgGetText( MXDI_MESSAGE_PRIV_LABEL ), False );
479 
480 
481   /* Add to place in list? */
482   n = 0;
483   XtSetArg( args[ n ], XmNorientation, XmHORIZONTAL ); n++;
484   placeRc = XmCreateRowColumn( workFo, "PlaceRc", args, n );
485 
486   placeLa = xitCreateLabel( placeRc, "PlaceLa",
487                             msgGetText( MXDI_ACL_POSITION ), -1 );
488 
489   placeTx = xitCreateTextCols( placeRc, &text_buffer[ 2 ], 5 );
490 
491   n = 0;
492   XtSetArg( args[ n ], XmNmaxLength, 5 );  n++;
493   XtSetValues( placeTx, args, n );
494 
495 
496   /* Action (add, delete and change). */
497   n = 0;
498   XtSetArg( args[ n ], XmNorientation,  XmHORIZONTAL ); n++;
499   XtSetArg( args[ n ], XmNspacing,      10 ); n++;
500   XtSetArg( args[ n ], XmNmarginHeight, 10 ); n++;
501   actionRc = XmCreateRowColumn( workFo, "ActionRc", args, n );
502 
503   for( index = 0; index < XtNumber( access_action_def ); index++ )
504     actionBu[ index ] = xitCreatePushButton( actionRc,
505                                              &access_action_def[ index ] );
506 
507   XtAddCallback( actionBu[ 0 ], XmNactivateCallback,
508                  (XtCallbackProc) addCB, (XtPointer) acl_ref );
509   XtAddCallback( actionBu[ 1 ], XmNactivateCallback,
510                  (XtCallbackProc) deleteCB, (XtPointer) acl_ref );
511 
512 
513   /* Place the various elements together. */
514   xitAttachWidget( calLa,
515                    XmATTACH_FORM, NULL, XmATTACH_FORM, NULL,
516                    XmATTACH_NONE, NULL, XmATTACH_NONE, NULL );
517   xitAttachWidget( XtParent( aclLi ),
518                    XmATTACH_WIDGET, calLa, XmATTACH_FORM, NULL,
519                    XmATTACH_NONE,   NULL,  XmATTACH_NONE, NULL );
520   xitAttachWidget( userLa,
521                    XmATTACH_WIDGET, XtParent( aclLi ), XmATTACH_FORM, NULL,
522                    XmATTACH_NONE,   NULL,              XmATTACH_NONE, NULL );
523   xitAttachWidget( userTx,
524                    XmATTACH_WIDGET, userLa, XmATTACH_FORM, NULL,
525                    XmATTACH_FORM,   NULL,   XmATTACH_NONE, NULL );
526   xitAttachWidget( groupLa,
527                    XmATTACH_WIDGET, userTx, XmATTACH_FORM, NULL,
528                    XmATTACH_NONE,   NULL,   XmATTACH_NONE, NULL );
529   xitAttachWidget( groupTx,
530                    XmATTACH_WIDGET, groupLa, XmATTACH_FORM, NULL,
531                    XmATTACH_FORM,   NULL,    XmATTACH_NONE, NULL );
532   xitAttachWidget( flagRc,
533                    XmATTACH_WIDGET, groupTx, XmATTACH_FORM, NULL,
534                    XmATTACH_NONE,   NULL,    XmATTACH_NONE, NULL );
535   xitAttachWidget( placeRc,
536                    XmATTACH_WIDGET, flagRc, XmATTACH_FORM, NULL,
537                    XmATTACH_NONE,   NULL,   XmATTACH_NONE, NULL );
538   xitAttachWidget( actionRc,
539                    XmATTACH_WIDGET, placeRc, XmATTACH_FORM, NULL,
540                    XmATTACH_NONE,   NULL,    XmATTACH_NONE, NULL );
541 
542   /* Make sure there is enough space between the children. */
543   n = 0;
544   XtSetArg( args[ n ], XmNtopOffset,    5 ); n++;
545   XtSetArg( args[ n ], XmNleftOffset,   5 ); n++;
546   XtSetArg( args[ n ], XmNrightOffset,  5 ); n++;
547   XtSetArg( args[ n ], XmNbottomOffset, 5 ); n++;
548   XtSetValues( calLa,             args, n );
549   XtSetValues( XtParent( aclLi ), args, n );
550   XtSetValues( userLa,            args, n );
551   XtSetValues( userTx,            args, n );
552   XtSetValues( groupLa,           args, n );
553   XtSetValues( groupTx,           args, n );
554   XtSetValues( flagRc,            args, n );
555   XtSetValues( placeRc,           args, n );
556   XtSetValues( actionRc,          args, n );
557 
558 
559   /* Manage the widgets. */
560   XtManageChildren( actionBu, XtNumber( actionBu ) );
561 
562   xitManageChildren( dataLocalW, XtNumber( dataLocalW ) );
563 
564   /* Set the size of the window. */
565   xitSetSizeFormDialog( aclFd, True );
566 
567 
568   /* Make the final attachments. */
569   xitAttachWidget( actionRc,
570                    XmATTACH_NONE, NULL, XmATTACH_FORM, NULL,
571                    XmATTACH_NONE, NULL, XmATTACH_FORM, NULL );
572   xitAttachWidget( placeRc,
573                    XmATTACH_NONE, NULL, XmATTACH_FORM,   NULL,
574                    XmATTACH_NONE, NULL, XmATTACH_WIDGET, actionRc );
575   xitAttachWidget( flagRc,
576                    XmATTACH_NONE, NULL, XmATTACH_FORM,   NULL,
577                    XmATTACH_NONE, NULL, XmATTACH_WIDGET, placeRc );
578   xitAttachWidget( groupTx,
579                    XmATTACH_NONE, NULL, XmATTACH_FORM,   NULL,
580                    XmATTACH_FORM, NULL, XmATTACH_WIDGET, flagRc );
581   xitAttachWidget( groupLa,
582                    XmATTACH_NONE, NULL, XmATTACH_FORM,   NULL,
583                    XmATTACH_NONE, NULL, XmATTACH_WIDGET, groupTx );
584   xitAttachWidget( userTx,
585                    XmATTACH_NONE, NULL, XmATTACH_FORM,   NULL,
586                    XmATTACH_FORM, NULL, XmATTACH_WIDGET, groupLa );
587   xitAttachWidget( userLa,
588                    XmATTACH_NONE, NULL, XmATTACH_FORM,   NULL,
589                    XmATTACH_NONE, NULL, XmATTACH_WIDGET, userTx );
590   xitAttachWidget( XtParent( aclLi ),
591                    XmATTACH_WIDGET, calLa, XmATTACH_FORM,   NULL,
592                    XmATTACH_FORM,   NULL,  XmATTACH_WIDGET, userLa );
593 
594 
595   return( aclFd );
596 
597 } /* createAclWindow */
598 
599 
600 /*----------------------------------------------------------------------*/
601 
602 static void
saveAccessInfo(ACL_REC_REF acl_ref)603   saveAccessInfo( ACL_REC_REF  acl_ref )
604 {
605 
606   /* Variables. */
607   int                 index;
608   int                 item_count;
609   Arg                 args[ 3 ];
610   Cardinal            n;
611   Widget              mainW;
612   Widget              tempW;
613   XmString            *items;
614   LST_DESC_TYPE       access_info;
615   LST_STATUS          lst_status;
616   XTM_AB_ACCESS_INFO  access;
617   XTM_AB_STATUS       ab_status;
618   struct group        *group_ref;
619   struct passwd       *password_ref;
620 
621 
622   /* Code. */
623 
624   mainW = XtNameToWidget( acl_ref -> aclW, "AclFdFo" );
625 
626 
627   /* Create an new access list. */
628   access_info = LstLinkNew( sizeof( XTM_AB_ACCESS_INFO ), NULL );
629 
630   /* Fetch information from the access list. */
631   tempW = XtNameToWidget( mainW, "AclLiSW.AclLi" );
632 
633   n = 0;
634   XtSetArg( args[ n ], XmNitemCount, &item_count ); n++;
635   XtSetArg( args[ n ], XmNitems,     &items ); n++;
636   XtGetValues( tempW, args, n );
637 
638   for( index = 0; index < item_count; index++ ) {
639 
640     int   dummy;
641     char  flags[ 30 ];
642     char  group[ 30 ];
643     char  user[ 30 ];
644     char  *buffer_ref;
645 
646     buffer_ref = xitStringGetString( *(items + index), CS );
647 
648     sscanf( buffer_ref, "%d %s (%[^)]) %s",
649             &dummy, user, group, flags );
650     SysFree( buffer_ref );
651 
652     /* User name to uid number? */
653     if( strcmp( user, "*" ) == 0 ) {
654       access.uid = -1;
655     } else {
656       password_ref = getpwnam( user );
657       access.uid = password_ref -> pw_uid;
658     }
659 
660     /* Group name to gid number? */
661     if( strcmp( group, "*" ) == 0 ) {
662       access.gid = -1;
663     } else {
664       group_ref = getgrnam( group );
665       access.gid = group_ref -> gr_gid;
666     }
667 
668     /* Check the flags. */
669     access.flags = 0;
670 
671     if( strchr( flags, 'r' ) != NULL )
672       flagSet( access.flags, XTM_AB_FLAG_READ );
673 
674     if( strchr( flags, 'w' ) != NULL )
675       flagSet( access.flags, XTM_AB_FLAG_WRITE );
676 
677     if( strchr( flags, 'm' ) != NULL )
678       flagSet( access.flags, XTM_AB_FLAG_MSG );
679 
680     /* Save the entry. */
681     lst_status = LstLinkInsertLast( access_info, &access );
682 
683   } /* loop */
684 
685   /* Save the access informatuon. */
686   ab_status = xtmAbSaveAccessInfo( acl_ref -> cal_location, access_info );
687 
688   /* Free access list. */
689   LstLinkClear( access_info );
690 
691 
692   return;
693 
694 } /* saveAccessInfo */
695 
696 
697 /*----------------------------------------------------------------------*/
698 
699 static void
setAccessData(ACL_REC_REF acl_ref)700   setAccessData( ACL_REC_REF  acl_ref )
701 {
702 
703   /* Variables. */
704   int                 index;
705   int                 index1;
706   char                buffer[ 100 ];
707   char                flags_buffer[ 20 ];
708   char                group[ 31 ];
709   char                user[ 31 ];
710   char                *char_ref;
711   Arg                 args[ 5 ];
712   Cardinal            n;
713   Widget              mainW;
714   Widget              tempW;
715   XmString            list_items[ MAX_ACLS ];
716   LST_DESC_TYPE       access_info;
717   LST_STATUS          lst_status;
718   XTM_AB_ACCESS_INFO  access;
719   struct group        *group_ref;
720   struct passwd       *password_ref;
721 
722 
723   /* Code. */
724 
725   mainW = XtNameToWidget( acl_ref -> aclW, "AclFdFo" );
726 
727 
728   /* Name of the calendar we are using. */
729   char_ref = (char *) SysMalloc( strlen( acl_ref -> cal_name ) +
730                                  strlen( acl_ref -> cal_location ) + 10 );
731 
732   sprintf( char_ref, "%s (%s)",
733            acl_ref -> cal_name, acl_ref -> cal_location );
734 
735   tempW = XtNameToWidget( mainW, "CalLa" );
736   xitStringSetLabel( tempW, char_ref );
737 
738   SysFree( char_ref );
739 
740 
741   /* All is empty. */
742   setEmptyItem( acl_ref );
743 
744 
745   /* Fetch the access information for this database. */
746   xtmAbGetAccessInfo( acl_ref -> cal_location, &access_info );
747 
748   /* Set access control info. */
749   if( LstLinkElements( access_info ) <= 0 )
750     return;
751 
752 
753   /* Build the access control list. */
754   index = 0;
755 
756   lst_status = LstLinkCurrentFirst( access_info );
757 
758   while( lst_status == LST_OK ) {
759 
760     lst_status = LstLinkGetCurrent( access_info, &access );
761 
762     /* Fetch user name. */
763     if( access.uid == -1 ) {
764       strcpy( user, "*" );
765 
766     } else {
767       password_ref = getpwuid( access.uid );
768       if( password_ref != NULL )
769 	strcpy( user, password_ref -> pw_name );
770       else
771 	strcpy( user, "-" );
772 
773     } /* if */
774 
775 
776     /* Fetch group name. */
777     if( access.gid == -1 ) {
778       strcpy( group, "*" );
779 
780     } else {
781       group_ref = getgrgid( access.gid );
782       if( group_ref != NULL )
783 	strcpy( group, group_ref -> gr_name );
784       else
785 	strcpy( group, "-" );
786 
787     } /* if */
788 
789 
790     /* Fetch the flags values. */
791     flags_buffer[ 0 ] = '\0';
792 
793     if( flagIsSet( access.flags, XTM_AB_FLAG_READ ) )
794       strcat( flags_buffer, "r" );
795     else
796       strcat( flags_buffer, "-" );
797 
798     if( flagIsSet( access.flags, XTM_AB_FLAG_WRITE ) )
799       strcat( flags_buffer, "w" );
800     else
801       strcat( flags_buffer, "-" );
802 
803     if( flagIsSet( access.flags, XTM_AB_FLAG_MSG ) )
804       strcat( flags_buffer, "m" );
805     else
806       strcat( flags_buffer, "-" );
807 
808     if( flagIsSet( access.flags, XTM_AB_FLAG_PRIV ) )
809       strcat( flags_buffer, "p" );
810     else
811       strcat( flags_buffer, "-" );
812 
813     sprintf( buffer, "%3d %s (%s) %s",
814 	     index + 1, user, group, flags_buffer );
815 
816     list_items[ index ] = XmStringCreate( buffer, CS );
817     index++;
818 
819     if( index >= MAX_ACLS )
820       break;
821 
822     /* Next entry. */
823     lst_status = LstLinkCurrentNext( access_info );
824 
825   } /* while */
826 
827 
828   tempW = XtNameToWidget( mainW, "AclLiSW.AclLi" );
829 
830   /* Assign the entries to the list. */
831   n = 0;
832   XtSetArg( args[ n ], XmNitems, list_items ); n++;
833   XtSetArg( args[ n ], XmNitemCount, index ); n++;
834   XtSetArg( args[ n ], XmNselectedItemCount, 0 ); n++;
835   XtSetValues( tempW, args, n );
836 
837   /* Free allocated memory. */
838   for( index1 = 0; index1 < index; index1++ )
839     XmStringFree( list_items[ index1 ] );
840 
841 
842   return;
843 
844 } /* setAccessData */
845 
846 
847 /*----------------------------------------------------------------------*/
848 
849 static void
setAccessItem(ACL_REC_REF acl_ref,int position,char * user,char * group,int flags)850   setAccessItem( ACL_REC_REF  acl_ref,
851                  int          position,
852                  char         *user,
853                  char         *group,
854                  int          flags )
855 {
856 
857   /* Variables. */
858   int        dummy;
859   int        found_position;
860   int        index;
861   int        index1;
862   int        item_count;
863   char       buffer[ 150 ];
864   char       flags_buffer[ 20 ];
865   char       read_group[ 30 ];
866   char       read_user[ 30 ];
867   char       *buffer_ref;
868   Arg        args[ 3 ];
869   Cardinal   n;
870   Widget     mainW;
871   Widget     listW;
872   XmString   *items;
873   XmString   list_items[ MAX_ACLS ];
874   XmString   xstr;
875 
876 
877   /* Code. */
878 
879   mainW = XtNameToWidget( acl_ref -> aclW, "AclFdFo" );
880 
881 
882   /* Fetch the flags values. */
883   flags_buffer[ 0 ] = '\0';
884 
885   if( flagIsSet( flags, XTM_AB_FLAG_READ ) )
886     strcat( flags_buffer, "r" );
887   else
888     strcat( flags_buffer, "-" );
889 
890   if( flagIsSet( flags, XTM_AB_FLAG_WRITE ) )
891     strcat( flags_buffer, "w" );
892   else
893     strcat( flags_buffer, "-" );
894 
895   if( flagIsSet( flags, XTM_AB_FLAG_MSG ) )
896     strcat( flags_buffer, "m" );
897   else
898     strcat( flags_buffer, "-" );
899 
900   if( flagIsSet( flags, XTM_AB_FLAG_PRIV ) )
901     strcat( flags_buffer, "p" );
902   else
903     strcat( flags_buffer, "-" );
904 
905   /* Line to add to list. */
906   sprintf( buffer, "%3d %s (%s) %s",
907            1, user, group, flags_buffer );
908 
909   xstr = XmStringCreate( buffer, CS );
910 
911 
912   /* Check if we have this user/group combination? */
913   listW = XtNameToWidget( mainW, "AclLiSW.AclLi" );
914 
915   n = 0;
916   XtSetArg( args[ n ], XmNitemCount, &item_count ); n++;
917   XtSetArg( args[ n ], XmNitems,     &items ); n++;
918   XtGetValues( listW, args, n );
919 
920   found_position = 0;
921 
922   for( index = 0; index < item_count; index++ ) {
923 
924     buffer_ref = xitStringGetString( *(items + index), CS );
925 
926     sscanf( buffer_ref, "%d %s (%[^)])",
927             &dummy, read_user, read_group );
928 
929     if( strcmp( user,  read_user )  == 0 &&
930         strcmp( group, read_group ) == 0 )
931       found_position = index + 1;
932 
933     SysFree( buffer_ref );
934 
935   } /* loop */
936 
937   /* Does the entry already exist? */
938   if( found_position > 0 ) {
939     XmListDeletePos( listW, found_position );
940     item_count--;
941     if( found_position <= position )
942       position--;
943   }
944 
945   if( position > item_count + 1 )
946     position = item_count + 1;
947 
948   /* Store at the new location. */
949   XmListAddItem( listW, xstr, position );
950 
951   XmStringFree( xstr );
952 
953 
954   /* Fetch the items again and re-number. */
955   n = 0;
956   XtSetArg( args[ n ], XmNitemCount, &item_count ); n++;
957   XtSetArg( args[ n ], XmNitems,     &items ); n++;
958   XtGetValues( listW, args, n );
959 
960   for( index = 0; index < item_count; index++ ) {
961 
962     buffer_ref = xitStringGetString( *(items + index), CS );
963 
964     sscanf( buffer_ref, "%d %s (%[^)]) %s",
965             &dummy, user, group, flags_buffer );
966     SysFree( buffer_ref );
967 
968     sprintf( buffer, "%3d %s (%s) %s",
969 	     index + 1, user, group, flags_buffer );
970 
971     list_items[ index ] = XmStringCreate( buffer, CS );
972     if( index >= MAX_ACLS )
973       break;
974 
975   } /* loop */
976 
977 
978   /* Assign the entries to the list. */
979   n = 0;
980   XtSetArg( args[ n ], XmNitems, list_items ); n++;
981   XtSetArg( args[ n ], XmNitemCount, index ); n++;
982   XtSetArg( args[ n ], XmNselectedItemCount, 0 ); n++;
983   XtSetValues( listW, args, n );
984 
985   /* Free allocated memory. */
986   for( index1 = 0; index1 < index; index1++ )
987     XmStringFree( list_items[ index1 ] );
988 
989 
990   /* Set position. */
991   if( position > 1 )
992     position--;
993 
994   XmListSetPos( listW, position );
995   XmListDeselectAllItems( listW );
996 
997 
998   return;
999 
1000 } /* setAccessItem */
1001 
1002 
1003 /*----------------------------------------------------------------------*/
1004 
1005 static void
setAction(ACL_REC_REF acl_ref,Boolean add_active,Boolean delete_active)1006   setAction( ACL_REC_REF  acl_ref,
1007              Boolean      add_active,
1008              Boolean      delete_active )
1009 {
1010 
1011   /* Variables. */
1012   Widget  mainW;
1013   Widget  tempW;
1014 
1015 
1016   /* Code. */
1017 
1018   mainW = XtNameToWidget( acl_ref -> aclW, "AclFdFo" );
1019 
1020   tempW = XtNameToWidget( mainW, "ActionRc.AddPb" );
1021   XtSetSensitive( tempW, add_active );
1022 
1023   tempW = XtNameToWidget( mainW, "ActionRc.DeletePb" );
1024   XtSetSensitive( tempW, delete_active );
1025 
1026 
1027   return;
1028 
1029 } /* setAction */
1030 
1031 
1032 /*----------------------------------------------------------------------*/
1033 
1034 static void
setEmptyItem(ACL_REC_REF acl_ref)1035   setEmptyItem( ACL_REC_REF  acl_ref )
1036 {
1037 
1038   /* Variables. */
1039   Widget  mainW;
1040   Widget  tempW;
1041 
1042 
1043   /* Code. */
1044 
1045   mainW = XtNameToWidget( acl_ref -> aclW, "AclFdFo" );
1046 
1047   /* Empty the user, group and position field. */
1048   tempW = XtNameToWidget( mainW, "UserTx" );
1049   XmTextSetString( tempW, "" );
1050 
1051   tempW = XtNameToWidget( mainW, "GroupTx" );
1052   XmTextSetString( tempW, "" );
1053 
1054   tempW = XtNameToWidget( mainW, "PlaceRc.PlaceTx" );
1055   XmTextSetString( tempW, "" );
1056 
1057 
1058   /* Set the flag values. */
1059   tempW = XtNameToWidget( mainW, "FlagRc.FlagReadTb" );
1060   XmToggleButtonSetState( tempW, False, False );
1061 
1062   tempW = XtNameToWidget( mainW, "FlagRc.FlagWriteTb" );
1063   XmToggleButtonSetState( tempW, False, False );
1064 
1065   tempW = XtNameToWidget( mainW, "FlagRc.FlagMsgTb" );
1066   XmToggleButtonSetState( tempW, False, False );
1067 
1068 
1069   /* No items selected. */
1070   setAction( acl_ref, True, False );
1071 
1072   tempW = XtNameToWidget( mainW, "AclLiSW.AclLi" );
1073   XmListDeselectAllItems( tempW );
1074 
1075   acl_ref -> field_changed = False;
1076 
1077 
1078   return;
1079 
1080 } /* setEmptyItem */
1081 
1082 
1083 /*----------------------------------------------------------------------*/
1084 
1085 static void
accessListCB(Widget widget,ACL_REC_REF acl_ref,XmListCallbackStruct * call_data)1086   accessListCB( Widget                widget,
1087                 ACL_REC_REF           acl_ref,
1088                 XmListCallbackStruct  *call_data )
1089 {
1090 
1091   /* Variables. */
1092   int          position;
1093   char         flags[ 20 ];
1094   char         group[ 30 ];
1095   char         user[ 30 ];
1096   char         buffer[ 50 ];
1097   char         *buffer_ref;
1098   Widget       mainW;
1099   Widget       tempW;
1100 
1101 
1102   /* Code. */
1103 
1104   mainW = XtNameToWidget( acl_ref -> aclW, "AclFdFo" );
1105 
1106 
1107   /* Fetch the selected name/directory line. */
1108   buffer_ref = xitStringGetString( call_data -> item, CS );
1109 
1110   flags[ 0 ] = '\0';
1111 
1112   sscanf( buffer_ref, "%d %s (%[^)]) %s",
1113           &position, user, group, flags );
1114 
1115 
1116   /* Set user and group. */
1117   tempW = XtNameToWidget( mainW, "UserTx" );
1118   XmTextSetString( tempW, user );
1119 
1120   tempW = XtNameToWidget( mainW, "GroupTx" );
1121   XmTextSetString( tempW, group );
1122 
1123   tempW = XtNameToWidget( mainW, "PlaceRc.PlaceTx" );
1124   sprintf( buffer, "%d", position );
1125   XmTextSetString( tempW, buffer );
1126 
1127 
1128   /* Set flags. */
1129   tempW = XtNameToWidget( mainW, "FlagRc.FlagReadTb" );
1130   if( strchr( flags, 'r' ) != NULL )
1131     XmToggleButtonSetState( tempW, True, False );
1132   else
1133     XmToggleButtonSetState( tempW, False, False );
1134 
1135 
1136   tempW = XtNameToWidget( mainW, "FlagRc.FlagWriteTb" );
1137   if( strchr( flags, 'w' ) != NULL )
1138     XmToggleButtonSetState( tempW, True, False );
1139   else
1140     XmToggleButtonSetState( tempW, False, False );
1141 
1142 
1143   tempW = XtNameToWidget( mainW, "FlagRc.FlagMsgTb" );
1144   if( strchr( flags, 'm' ) != NULL )
1145     XmToggleButtonSetState( tempW, True, False );
1146   else
1147     XmToggleButtonSetState( tempW, False, False );
1148 
1149   SysFree( buffer_ref );
1150 
1151 
1152   setAction( acl_ref, True, True );
1153 
1154   acl_ref -> field_changed = False;
1155 
1156 
1157   return;
1158 
1159 } /* accessListCB */
1160 
1161 
1162 /*----------------------------------------------------------------------*/
1163 
1164 static void
addCB(Widget widget,ACL_REC_REF acl_ref,XtPointer call_data)1165   addCB( Widget       widget,
1166          ACL_REC_REF  acl_ref,
1167          XtPointer    call_data )
1168 {
1169 
1170   /* Variables. */
1171   int            flags;
1172   int            items;
1173   int            position;
1174   char           group[ 31 ];
1175   char           user[ 31 ];
1176   char           *buffer_ref;
1177   Widget         mainW;
1178   Widget         tempW;
1179   struct group   *group_ref;
1180   struct passwd  *password_ref;
1181 
1182 
1183 
1184   /* Code. */
1185 
1186   mainW = XtNameToWidget( acl_ref -> aclW, "AclFdFo" );
1187 
1188 
1189   /* Fetch the user name. */
1190   tempW = XtNameToWidget( mainW, "UserTx" );
1191 
1192   buffer_ref = xitStringGetText( tempW );
1193 
1194   items = sscanf( buffer_ref, "%30s", user );
1195   SysFree( buffer_ref );
1196 
1197   if( items != 1 )
1198     return;
1199 
1200   /* Check the user name. */
1201   if( strcmp( user, "*" ) != 0 ) {
1202     password_ref = getpwnam( user );
1203 
1204     if( password_ref == NULL ) {
1205       xitErMessage( acl_ref -> aclW, XIT_ER_ERROR,
1206                     module_name, "addCB",
1207                     msgGetText( MXDI_NO_VALID_USERNAME ) );
1208       return;
1209     }
1210   }
1211 
1212 
1213   /* Fetch the group name. */
1214   tempW = XtNameToWidget( mainW, "GroupTx" );
1215 
1216   buffer_ref = xitStringGetText( tempW );
1217 
1218   items = sscanf( buffer_ref, "%30s", group );
1219   SysFree( buffer_ref );
1220 
1221   if( items == EOF )
1222     strcpy( group, "*" );
1223   else if( items != 1 )
1224     return;
1225 
1226   /* Check the group name. */
1227   if( strcmp( group, "*" ) != 0 ) {
1228     group_ref = getgrnam( group );
1229 
1230     if( group_ref == NULL ) {
1231       xitErMessage( acl_ref -> aclW, XIT_ER_ERROR,
1232                     module_name, "addCB",
1233                     msgGetText( MXDI_NO_VALID_GROUPNAME ) );
1234       return;
1235     }
1236   }
1237 
1238 
1239   /* Fetch the position in the list. */
1240   tempW = XtNameToWidget( mainW, "PlaceRc.PlaceTx" );
1241 
1242   buffer_ref = xitStringGetText( tempW );
1243   position   = 1;
1244   position   = atoi( buffer_ref );
1245 
1246   SysFree( buffer_ref );
1247 
1248   if( position <= 0 )
1249     position = 1;
1250 
1251 
1252   /* Fetch the access flags. */
1253   flags = 0;
1254 
1255   tempW = XtNameToWidget( mainW, "FlagRc.FlagReadTb" );
1256   if( XmToggleButtonGetState( tempW ) )
1257     flagSet( flags, XTM_AB_FLAG_READ );
1258 
1259   tempW = XtNameToWidget( mainW, "FlagRc.FlagWriteTb" );
1260   if( XmToggleButtonGetState( tempW ) )
1261     flagSet( flags, XTM_AB_FLAG_WRITE | XTM_AB_FLAG_READ );
1262 
1263   tempW = XtNameToWidget( mainW, "FlagRc.FlagMsgTb" );
1264   if( XmToggleButtonGetState( tempW ) )
1265     flagSet( flags, XTM_AB_FLAG_MSG );
1266 
1267   /* Any flags given? */
1268   if( flags == 0 ) {
1269     xitErMessage( acl_ref -> aclW, XIT_ER_ERROR,
1270                   module_name, "addCB",
1271                   msgGetText( MXDI_NO_ACCESS_FLAGS ) );
1272     return;
1273   }
1274 
1275   /* Set the new database. */
1276   setAccessItem( acl_ref, position, user, group, flags );
1277 
1278   /* All is empty. */
1279   setEmptyItem( acl_ref );
1280 
1281   acl_ref -> acl_changed = True;
1282 
1283 
1284   return;
1285 
1286 } /* addCB */
1287 
1288 
1289 /*----------------------------------------------------------------------*/
1290 
1291 static void
cancelCB(Widget widget,ACL_REC_REF acl_ref,XtPointer call_data)1292   cancelCB( Widget       widget,
1293             ACL_REC_REF  acl_ref,
1294             XtPointer    call_data )
1295 {
1296 
1297   /* Variables. */
1298   Widget  tempW;
1299 
1300 
1301   /* Code. */
1302 
1303   /* Any ACL changes? */
1304   if( acl_ref -> acl_changed ) {
1305     tempW = xitCreateQuestionDialog(
1306               acl_ref -> aclW, "InformationDialog",
1307 	      msgGetText( MXDI_QUESTION_MESSAGE_LABEL ),
1308               msgGetText( MXDI_ALL_CHANGES_LOST ),
1309               closeCB, acl_ref,
1310               NULL, NULL );
1311 
1312     return;
1313   }
1314 
1315   closeCB( widget, acl_ref, NULL );
1316 
1317 
1318   return;
1319 
1320 } /* cancelCB */
1321 
1322 
1323 /*----------------------------------------------------------------------*/
1324 
1325 static void
deleteCB(Widget widget,ACL_REC_REF acl_ref,XtPointer call_data)1326   deleteCB( Widget       widget,
1327             ACL_REC_REF  acl_ref,
1328             XtPointer    call_data )
1329 {
1330 
1331   /* Variables. */
1332   int       dummy;
1333   int       index;
1334   int       index1;
1335   int       item_count;
1336   char      buffer[ 150 ];
1337   char      flags_buffer[ 20 ];
1338   char      group[ 31 ];
1339   char      user[ 31 ];
1340   char      *buffer_ref;
1341   Arg       args[ 3 ];
1342   Cardinal  n;
1343   Widget    mainW;
1344   Widget    listW;
1345   Widget    tempW;
1346   XmString  *items;
1347   XmString  list_items[ MAX_ACLS ];
1348 
1349 
1350   /* Code. */
1351 
1352   mainW = XtNameToWidget( acl_ref -> aclW, "AclFdFo" );
1353 
1354 
1355   tempW = XtNameToWidget( mainW, "AclLiSW.AclLi" );
1356 
1357   /* Fetch selected item from the list. */
1358   n = 0;
1359   XtSetArg( args[ n ], XmNselectedItemCount, &item_count ); n++;
1360   XtSetArg( args[ n ], XmNselectedItems, &items ); n++;
1361   XtGetValues( tempW, args, n );
1362 
1363   if( item_count != 1 )
1364     return;
1365 
1366   /* Delete the selected short name/directory. */
1367   XmListDeleteItem( tempW, *items );
1368 
1369 
1370   /* Fetch the items again and re-number. */
1371   listW = XtNameToWidget( mainW, "AclLiSW.AclLi" );
1372 
1373   n = 0;
1374   XtSetArg( args[ n ], XmNitemCount, &item_count ); n++;
1375   XtSetArg( args[ n ], XmNitems,     &items ); n++;
1376   XtGetValues( listW, args, n );
1377 
1378   for( index = 0; index < item_count; index++ ) {
1379 
1380     buffer_ref = xitStringGetString( *(items + index), CS );
1381 
1382     sscanf( buffer_ref, "%d %s (%[^)]) %s",
1383             &dummy, user, group, flags_buffer );
1384     SysFree( buffer_ref );
1385 
1386     sprintf( buffer, "%3d %s (%s) %s",
1387 	     index + 1, user, group, flags_buffer );
1388 
1389     list_items[ index ] = XmStringCreate( buffer, CS );
1390     if( index >= MAX_ACLS )
1391       break;
1392 
1393   } /* loop */
1394 
1395 
1396   /* Assign the entries to the list. */
1397   n = 0;
1398   XtSetArg( args[ n ], XmNitems, list_items ); n++;
1399   XtSetArg( args[ n ], XmNitemCount, index ); n++;
1400   XtSetArg( args[ n ], XmNselectedItemCount, 0 ); n++;
1401   XtSetValues( listW, args, n );
1402 
1403   /* Free allocated memory. */
1404   for( index1 = 0; index1 < index; index1++ )
1405     XmStringFree( list_items[ index1 ] );
1406 
1407 
1408   /* All is empty. */
1409   setEmptyItem( acl_ref );
1410 
1411   acl_ref -> acl_changed = True;
1412 
1413 
1414   return;
1415 
1416 } /* deleteCB */
1417 
1418 
1419 /*----------------------------------------------------------------------*/
1420 
1421 static void
destroyCB(Widget widget,ACL_REC_REF acl_ref,XtPointer call_data)1422   destroyCB( Widget       widget,
1423              ACL_REC_REF  acl_ref,
1424              XtPointer    call_data )
1425 {
1426 
1427   /* Code. */
1428 
1429   /* Call callback function? */
1430   if( acl_ref -> actionCB != NULL )
1431     (* acl_ref -> actionCB )( XTM_AU_REASON_DESTROY, acl_ref -> user_data );
1432 
1433   /* Release the user data. */
1434   SysFree( acl_ref );
1435 
1436 
1437   return;
1438 
1439 } /* destroyCB */
1440 
1441 
1442 /*----------------------------------------------------------------------*/
1443 
1444 static void
closeCB(Widget widget,ACL_REC_REF acl_ref,XtPointer call_data)1445   closeCB( Widget       widget,
1446            ACL_REC_REF  acl_ref,
1447            XtPointer    call_data )
1448 {
1449 
1450   /* Code. */
1451 
1452   XtUnmanageChild( acl_ref -> aclW );
1453 
1454 
1455   return;
1456 
1457 } /* closeCB */
1458 
1459 
1460 /*----------------------------------------------------------------------*/
1461 
1462 static void
fieldChangedCB(Widget widget,ACL_REC_REF acl_ref,XtPointer call_data)1463   fieldChangedCB( Widget       widget,
1464                   ACL_REC_REF  acl_ref,
1465                   XtPointer    call_data )
1466 {
1467 
1468   /* Code. */
1469 
1470   acl_ref -> field_changed = True;
1471 
1472 
1473   return;
1474 
1475 } /* fieldChangedCB */
1476 
1477 
1478 /*----------------------------------------------------------------------*/
1479 
1480 static void
helpCB(Widget widget,ACL_REC_REF acl_ref,XtPointer call_data)1481   helpCB( Widget       widget,
1482           ACL_REC_REF  acl_ref,
1483           XtPointer    call_data )
1484 {
1485 
1486   /* Code. */
1487 
1488   xtmHlDisplayHelp( acl_ref -> info_handle, XTM_HL_WINDOW_INDEX,
1489                     acl_window_id, "" );
1490 
1491   return;
1492 
1493 } /* helpCB */
1494 
1495 
1496 /*----------------------------------------------------------------------*/
1497 
1498 static void
okCB(Widget widget,ACL_REC_REF acl_ref,XtPointer call_data)1499   okCB( Widget       widget,
1500         ACL_REC_REF  acl_ref,
1501         XtPointer    call_data )
1502 {
1503 
1504   /* Variables. */
1505   Widget   tempW;
1506 
1507 
1508   /* Code. */
1509 
1510   /* Warn the user that he/she might forget to add sometinhg. */
1511   if( acl_ref -> field_changed ) {
1512     tempW = xitCreateQuestionDialog(
1513               acl_ref -> aclW, "InformationDialog",
1514 	      msgGetText( MXDI_INFORMATION_LABEL ),
1515               msgGetText( MXDI_INFORMATION_NOT_SAVED ),
1516               saveAndCloseCB, acl_ref,
1517               NULL, NULL );
1518 
1519     return;
1520   }
1521 
1522   /* Save and close the window. */
1523   saveAndCloseCB( widget, acl_ref, call_data );
1524 
1525 
1526   return;
1527 
1528 } /* okCB */
1529 
1530 
1531 /*----------------------------------------------------------------------*/
1532 
1533 static void
saveAndCloseCB(Widget widget,ACL_REC_REF acl_ref,XtPointer call_data)1534   saveAndCloseCB( Widget       widget,
1535                   ACL_REC_REF  acl_ref,
1536                   XtPointer    call_data )
1537 {
1538 
1539   /* Code. */
1540 
1541   /* Save the access information. */
1542   saveAccessInfo( acl_ref );
1543 
1544 
1545   /* Call callback function? */
1546   if( acl_ref -> actionCB != NULL )
1547     (* acl_ref -> actionCB )( XTM_AU_REASON_OK, acl_ref -> user_data );
1548 
1549   XtUnmanageChild( acl_ref -> aclW );
1550 
1551 
1552   return;
1553 
1554 } /* saveAndCloseCB */
1555