105b261ecSmrg/************************************************************
205b261ecSmrg
36747b715SmrgAuthor: Eamon Walsh <ewalsh@tycho.nsa.gov>
405b261ecSmrg
505b261ecSmrgPermission to use, copy, modify, distribute, and sell this software and its
605b261ecSmrgdocumentation for any purpose is hereby granted without fee, provided that
705b261ecSmrgthis permission notice appear in supporting documentation.  This permission
805b261ecSmrgnotice shall be included in all copies or substantial portions of the
905b261ecSmrgSoftware.
1005b261ecSmrg
1105b261ecSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1205b261ecSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1305b261ecSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
1405b261ecSmrgAUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
1505b261ecSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1605b261ecSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1705b261ecSmrg
1805b261ecSmrg********************************************************/
1905b261ecSmrg
2005b261ecSmrg#ifndef _XACE_H
2105b261ecSmrg#define _XACE_H
2205b261ecSmrg
2305b261ecSmrg#ifdef XACE
2405b261ecSmrg
254642e01fSmrg#define XACE_MAJOR_VERSION		2
2605b261ecSmrg#define XACE_MINOR_VERSION		0
2705b261ecSmrg
284642e01fSmrg#include "pixmap.h"
294642e01fSmrg#include "region.h"
304642e01fSmrg#include "window.h"
314642e01fSmrg#include "property.h"
324642e01fSmrg#include "selection.h"
3305b261ecSmrg
344642e01fSmrg/* Default window background */
354642e01fSmrg#define XaceBackgroundNoneState(w) ((w)->forcedBG ? BackgroundPixel : None)
3605b261ecSmrg
3705b261ecSmrg/* security hooks */
3805b261ecSmrg/* Constants used to identify the available security hooks
3905b261ecSmrg */
4005b261ecSmrg#define XACE_CORE_DISPATCH		0
4105b261ecSmrg#define XACE_EXT_DISPATCH		1
4205b261ecSmrg#define XACE_RESOURCE_ACCESS		2
4305b261ecSmrg#define XACE_DEVICE_ACCESS		3
4405b261ecSmrg#define XACE_PROPERTY_ACCESS		4
454642e01fSmrg#define XACE_SEND_ACCESS		5
464642e01fSmrg#define XACE_RECEIVE_ACCESS		6
474642e01fSmrg#define XACE_CLIENT_ACCESS		7
4805b261ecSmrg#define XACE_EXT_ACCESS			8
494642e01fSmrg#define XACE_SERVER_ACCESS		9
504642e01fSmrg#define XACE_SELECTION_ACCESS		10
514642e01fSmrg#define XACE_SCREEN_ACCESS		11
524642e01fSmrg#define XACE_SCREENSAVER_ACCESS		12
534642e01fSmrg#define XACE_AUTH_AVAIL			13
544642e01fSmrg#define XACE_KEY_AVAIL			14
551b5d61b8Smrg#define XACE_NUM_HOOKS			15
5605b261ecSmrg
576747b715Smrgextern _X_EXPORT CallbackListPtr XaceHooks[XACE_NUM_HOOKS];
5805b261ecSmrg
5905b261ecSmrg/* Entry point for hook functions.  Called by Xserver.
606747b715Smrg * Required by libdbe and libextmod
6105b261ecSmrg */
6235c4bbdfSmrgextern _X_EXPORT int XaceHook(int /*hook */ ,
6335c4bbdfSmrg                              ...       /*appropriate args for hook */
6435c4bbdfSmrg    );
6535c4bbdfSmrg
6635c4bbdfSmrg/* determine whether any callbacks are present for the XACE hook */
6735c4bbdfSmrgextern _X_EXPORT int XaceHookIsSet(int hook);
6805b261ecSmrg
694642e01fSmrg/* Special-cased hook functions
704642e01fSmrg */
716747b715Smrgextern _X_EXPORT int XaceHookDispatch(ClientPtr ptr, int major);
721b5d61b8Smrg#define XaceHookDispatch(c, m) \
731b5d61b8Smrg    ((XaceHooks[XACE_EXT_DISPATCH] && (m) >= EXTENSION_BASE) ? \
741b5d61b8Smrg    XaceHookDispatch((c), (m)) : \
751b5d61b8Smrg    Success)
761b5d61b8Smrg
776747b715Smrgextern _X_EXPORT int XaceHookPropertyAccess(ClientPtr ptr, WindowPtr pWin,
7835c4bbdfSmrg                                            PropertyPtr *ppProp,
7935c4bbdfSmrg                                            Mask access_mode);
8035c4bbdfSmrgextern _X_EXPORT int XaceHookSelectionAccess(ClientPtr ptr, Selection ** ppSel,
8135c4bbdfSmrg                                             Mask access_mode);
824642e01fSmrg
8305b261ecSmrg/* Register a callback for a given hook.
8405b261ecSmrg */
8505b261ecSmrg#define XaceRegisterCallback(hook,callback,data) \
8605b261ecSmrg    AddCallback(XaceHooks+(hook), callback, data)
8705b261ecSmrg
8805b261ecSmrg/* Unregister an existing callback for a given hook.
8905b261ecSmrg */
9005b261ecSmrg#define XaceDeleteCallback(hook,callback,data) \
9105b261ecSmrg    DeleteCallback(XaceHooks+(hook), callback, data)
9205b261ecSmrg
936747b715Smrg/* XTrans wrappers for use by security modules
946747b715Smrg */
956747b715Smrgextern _X_EXPORT int XaceGetConnectionNumber(ClientPtr ptr);
966747b715Smrgextern _X_EXPORT int XaceIsLocal(ClientPtr ptr);
9705b261ecSmrg
9805b261ecSmrg/* From the original Security extension...
9905b261ecSmrg */
10005b261ecSmrg
10135c4bbdfSmrgextern _X_EXPORT void XaceCensorImage(ClientPtr client,
10235c4bbdfSmrg                                      RegionPtr pVisibleRegion,
10335c4bbdfSmrg                                      long widthBytesLine,
10435c4bbdfSmrg                                      DrawablePtr pDraw,
10535c4bbdfSmrg                                      int x, int y, int w, int h,
10635c4bbdfSmrg                                      unsigned int format, char *pBuf);
10705b261ecSmrg
10835c4bbdfSmrg#else                           /* XACE */
10905b261ecSmrg
1104642e01fSmrg/* Default window background */
1114642e01fSmrg#define XaceBackgroundNoneState(w)		None
1124642e01fSmrg
11305b261ecSmrg/* Define calls away when XACE is not being built. */
11405b261ecSmrg
11505b261ecSmrg#ifdef __GNUC__
1164642e01fSmrg#define XaceHook(args...) Success
11735c4bbdfSmrg#define XaceHookIsSet(args...) 0
1184642e01fSmrg#define XaceHookDispatch(args...) Success
1194642e01fSmrg#define XaceHookPropertyAccess(args...) Success
1204642e01fSmrg#define XaceHookSelectionAccess(args...) Success
12105b261ecSmrg#define XaceCensorImage(args...) { ; }
12205b261ecSmrg#else
1234642e01fSmrg#define XaceHook(...) Success
12435c4bbdfSmrg#define XaceHookIsSet(...) 0
1254642e01fSmrg#define XaceHookDispatch(...) Success
1264642e01fSmrg#define XaceHookPropertyAccess(...) Success
1274642e01fSmrg#define XaceHookSelectionAccess(...) Success
12805b261ecSmrg#define XaceCensorImage(...) { ; }
12905b261ecSmrg#endif
13005b261ecSmrg
13135c4bbdfSmrg#endif                          /* XACE */
13205b261ecSmrg
13335c4bbdfSmrg#endif                          /* _XACE_H */
134