os.h revision 4202a189
105b261ecSmrg/*********************************************************** 205b261ecSmrg 305b261ecSmrgCopyright 1987, 1998 The Open Group 405b261ecSmrg 505b261ecSmrgPermission to use, copy, modify, distribute, and sell this software and its 605b261ecSmrgdocumentation for any purpose is hereby granted without fee, provided that 705b261ecSmrgthe above copyright notice appear in all copies and that both that 805b261ecSmrgcopyright notice and this permission notice appear in supporting 905b261ecSmrgdocumentation. 1005b261ecSmrg 1105b261ecSmrgThe above copyright notice and this permission notice shall be included in 1205b261ecSmrgall copies or substantial portions of the Software. 1305b261ecSmrg 1405b261ecSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1505b261ecSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1605b261ecSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1705b261ecSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 1805b261ecSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 1905b261ecSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2005b261ecSmrg 2105b261ecSmrgExcept as contained in this notice, the name of The Open Group shall not be 2205b261ecSmrgused in advertising or otherwise to promote the sale, use or other dealings 2305b261ecSmrgin this Software without prior written authorization from The Open Group. 2405b261ecSmrg 2505b261ecSmrg 2605b261ecSmrgCopyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. 2705b261ecSmrg 2805b261ecSmrg All Rights Reserved 2905b261ecSmrg 3005b261ecSmrgPermission to use, copy, modify, and distribute this software and its 3105b261ecSmrgdocumentation for any purpose and without fee is hereby granted, 3205b261ecSmrgprovided that the above copyright notice appear in all copies and that 3305b261ecSmrgboth that copyright notice and this permission notice appear in 3405b261ecSmrgsupporting documentation, and that the name of Digital not be 3505b261ecSmrgused in advertising or publicity pertaining to distribution of the 3605b261ecSmrgsoftware without specific, written prior permission. 3705b261ecSmrg 3805b261ecSmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 3905b261ecSmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 4005b261ecSmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 4105b261ecSmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 4205b261ecSmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 4305b261ecSmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 4405b261ecSmrgSOFTWARE. 4505b261ecSmrg 4605b261ecSmrg******************************************************************/ 4705b261ecSmrg 4805b261ecSmrg 4905b261ecSmrg#ifndef OS_H 5005b261ecSmrg#define OS_H 5105b261ecSmrg 5205b261ecSmrg#include "misc.h" 5305b261ecSmrg#include <stdarg.h> 5405b261ecSmrg 5505b261ecSmrg#define SCREEN_SAVER_ON 0 5605b261ecSmrg#define SCREEN_SAVER_OFF 1 5705b261ecSmrg#define SCREEN_SAVER_FORCER 2 5805b261ecSmrg#define SCREEN_SAVER_CYCLE 3 5905b261ecSmrg 6005b261ecSmrg#ifndef MAX_REQUEST_SIZE 6105b261ecSmrg#define MAX_REQUEST_SIZE 65535 6205b261ecSmrg#endif 6305b261ecSmrg#ifndef MAX_BIG_REQUEST_SIZE 6405b261ecSmrg#define MAX_BIG_REQUEST_SIZE 4194303 6505b261ecSmrg#endif 6605b261ecSmrg 6705b261ecSmrgtypedef struct _FontPathRec *FontPathPtr; 6805b261ecSmrgtypedef struct _NewClientRec *NewClientPtr; 6905b261ecSmrg 7005b261ecSmrg#ifndef xalloc 7105b261ecSmrg#define xnfalloc(size) XNFalloc((unsigned long)(size)) 7205b261ecSmrg#define xnfcalloc(_num, _size) XNFcalloc((unsigned long)(_num)*(unsigned long)(_size)) 7305b261ecSmrg#define xnfrealloc(ptr, size) XNFrealloc((pointer)(ptr), (unsigned long)(size)) 7405b261ecSmrg 7505b261ecSmrg#define xalloc(size) Xalloc((unsigned long)(size)) 7605b261ecSmrg#define xcalloc(_num, _size) Xcalloc((unsigned long)(_num)*(unsigned long)(_size)) 7705b261ecSmrg#define xrealloc(ptr, size) Xrealloc((pointer)(ptr), (unsigned long)(size)) 7805b261ecSmrg#define xfree(ptr) Xfree((pointer)(ptr)) 7905b261ecSmrg#define xstrdup(s) Xstrdup(s) 8005b261ecSmrg#define xnfstrdup(s) XNFstrdup(s) 8105b261ecSmrg#endif 8205b261ecSmrg 8305b261ecSmrg#include <stdio.h> 8405b261ecSmrg#include <stdarg.h> 85de0a7c19Smacallan#include <string.h> 86de0a7c19Smacallan#include <strings.h> 87de0a7c19Smacallan 8805b261ecSmrg 894202a189Smrg#ifdef DDXBEFORERESET 904202a189Smrgextern void ddxBeforeReset (void); 9105b261ecSmrg#endif 9205b261ecSmrg 934202a189Smrg#ifdef DDXOSVERRORF 944202a189Smrgextern _X_EXPORT void (*OsVendorVErrorFProc)(const char *, va_list args); 954202a189Smrg#endif 9605b261ecSmrg 974202a189Smrgextern _X_EXPORT int WaitForSomething( 9805b261ecSmrg int* /*pClientsReady*/ 9905b261ecSmrg); 10005b261ecSmrg 1014202a189Smrgextern _X_EXPORT int ReadRequestFromClient(ClientPtr /*client*/); 10205b261ecSmrg 1034202a189Smrgextern _X_EXPORT Bool InsertFakeRequest( 10405b261ecSmrg ClientPtr /*client*/, 10505b261ecSmrg char* /*data*/, 10605b261ecSmrg int /*count*/); 10705b261ecSmrg 1084202a189Smrgextern _X_EXPORT void ResetCurrentRequest(ClientPtr /*client*/); 10905b261ecSmrg 1104202a189Smrgextern _X_EXPORT void FlushAllOutput(void); 11105b261ecSmrg 1124202a189Smrgextern _X_EXPORT void FlushIfCriticalOutputPending(void); 11305b261ecSmrg 1144202a189Smrgextern _X_EXPORT void SetCriticalOutputPending(void); 11505b261ecSmrg 1164202a189Smrgextern _X_EXPORT int WriteToClient(ClientPtr /*who*/, int /*count*/, const void* /*buf*/); 11705b261ecSmrg 1184202a189Smrgextern _X_EXPORT void ResetOsBuffers(void); 11905b261ecSmrg 1204202a189Smrgextern _X_EXPORT void InitConnectionLimits(void); 12105b261ecSmrg 1224202a189Smrgextern _X_EXPORT void NotifyParentProcess(void); 123637ac9abSmrg 1244202a189Smrgextern _X_EXPORT void CreateWellKnownSockets(void); 12505b261ecSmrg 1264202a189Smrgextern _X_EXPORT void ResetWellKnownSockets(void); 12705b261ecSmrg 1284202a189Smrgextern _X_EXPORT void CloseWellKnownConnections(void); 12905b261ecSmrg 1304202a189Smrgextern _X_EXPORT XID AuthorizationIDOfClient(ClientPtr /*client*/); 13105b261ecSmrg 1324202a189Smrgextern _X_EXPORT char *ClientAuthorized( 13305b261ecSmrg ClientPtr /*client*/, 13405b261ecSmrg unsigned int /*proto_n*/, 13505b261ecSmrg char* /*auth_proto*/, 13605b261ecSmrg unsigned int /*string_n*/, 13705b261ecSmrg char* /*auth_string*/); 13805b261ecSmrg 1394202a189Smrgextern _X_EXPORT Bool EstablishNewConnections( 14005b261ecSmrg ClientPtr /*clientUnused*/, 14105b261ecSmrg pointer /*closure*/); 14205b261ecSmrg 1434202a189Smrgextern _X_EXPORT void CheckConnections(void); 14405b261ecSmrg 1454202a189Smrgextern _X_EXPORT void CloseDownConnection(ClientPtr /*client*/); 14605b261ecSmrg 1474202a189Smrgextern _X_EXPORT void AddGeneralSocket(int /*fd*/); 14805b261ecSmrg 1494202a189Smrgextern _X_EXPORT void RemoveGeneralSocket(int /*fd*/); 15005b261ecSmrg 1514202a189Smrgextern _X_EXPORT void AddEnabledDevice(int /*fd*/); 15205b261ecSmrg 1534202a189Smrgextern _X_EXPORT void RemoveEnabledDevice(int /*fd*/); 15405b261ecSmrg 1554202a189Smrgextern _X_EXPORT int OnlyListenToOneClient(ClientPtr /*client*/); 15605b261ecSmrg 1574202a189Smrgextern _X_EXPORT void ListenToAllClients(void); 15805b261ecSmrg 1594202a189Smrgextern _X_EXPORT void IgnoreClient(ClientPtr /*client*/); 16005b261ecSmrg 1614202a189Smrgextern _X_EXPORT void AttendClient(ClientPtr /*client*/); 16205b261ecSmrg 1634202a189Smrgextern _X_EXPORT void MakeClientGrabImpervious(ClientPtr /*client*/); 16405b261ecSmrg 1654202a189Smrgextern _X_EXPORT void MakeClientGrabPervious(ClientPtr /*client*/); 16605b261ecSmrg 167637ac9abSmrg#ifdef XQUARTZ 168637ac9abSmrgextern void ListenOnOpenFD(int /* fd */, int /* noxauth */); 169637ac9abSmrg#endif 17005b261ecSmrg 1714202a189Smrgextern _X_EXPORT CARD32 GetTimeInMillis(void); 17205b261ecSmrg 1734202a189Smrgextern _X_EXPORT void AdjustWaitForDelay( 17405b261ecSmrg pointer /*waitTime*/, 17505b261ecSmrg unsigned long /*newdelay*/); 17605b261ecSmrg 17705b261ecSmrgtypedef struct _OsTimerRec *OsTimerPtr; 17805b261ecSmrg 17905b261ecSmrgtypedef CARD32 (*OsTimerCallback)( 18005b261ecSmrg OsTimerPtr /* timer */, 18105b261ecSmrg CARD32 /* time */, 18205b261ecSmrg pointer /* arg */); 18305b261ecSmrg 1844202a189Smrgextern _X_EXPORT void TimerInit(void); 18505b261ecSmrg 1864202a189Smrgextern _X_EXPORT Bool TimerForce(OsTimerPtr /* timer */); 18705b261ecSmrg 18805b261ecSmrg#define TimerAbsolute (1<<0) 18905b261ecSmrg#define TimerForceOld (1<<1) 19005b261ecSmrg 1914202a189Smrgextern _X_EXPORT OsTimerPtr TimerSet( 19205b261ecSmrg OsTimerPtr /* timer */, 19305b261ecSmrg int /* flags */, 19405b261ecSmrg CARD32 /* millis */, 19505b261ecSmrg OsTimerCallback /* func */, 19605b261ecSmrg pointer /* arg */); 19705b261ecSmrg 1984202a189Smrgextern _X_EXPORT void TimerCheck(void); 1994202a189Smrgextern _X_EXPORT void TimerCancel(OsTimerPtr /* pTimer */); 2004202a189Smrgextern _X_EXPORT void TimerFree(OsTimerPtr /* pTimer */); 20105b261ecSmrg 2024202a189Smrgextern _X_EXPORT void SetScreenSaverTimer(void); 2034202a189Smrgextern _X_EXPORT void FreeScreenSaverTimer(void); 20405b261ecSmrg 2054202a189Smrgextern _X_EXPORT void AutoResetServer(int /*sig*/); 20605b261ecSmrg 2074202a189Smrgextern _X_EXPORT void GiveUp(int /*sig*/); 20805b261ecSmrg 2094202a189Smrgextern _X_EXPORT void UseMsg(void); 21005b261ecSmrg 2114202a189Smrgextern _X_EXPORT void ProcessCommandLine(int /*argc*/, char* /*argv*/[]); 21205b261ecSmrg 2134202a189Smrgextern _X_EXPORT int set_font_authorizations( 21405b261ecSmrg char ** /* authorizations */, 21505b261ecSmrg int * /*authlen */, 21605b261ecSmrg pointer /* client */); 21705b261ecSmrg 21805b261ecSmrg#ifndef _HAVE_XALLOC_DECLS 21905b261ecSmrg#define _HAVE_XALLOC_DECLS 2204202a189Smrg 2214202a189Smrg/* 2224202a189Smrg * Use malloc(3) instead. 2234202a189Smrg */ 2244202a189Smrgextern _X_EXPORT void *Xalloc(unsigned long /*amount*/) _X_DEPRECATED; 2254202a189Smrg/* 2264202a189Smrg * Use calloc(3) instead 2274202a189Smrg */ 2284202a189Smrgextern _X_EXPORT void *Xcalloc(unsigned long /*amount*/) _X_DEPRECATED; 2294202a189Smrg/* 2304202a189Smrg * Use realloc(3) instead 2314202a189Smrg */ 2324202a189Smrgextern _X_EXPORT void *Xrealloc(void * /*ptr*/, unsigned long /*amount*/) 2334202a189Smrg _X_DEPRECATED; 2344202a189Smrg/* 2354202a189Smrg * Use free(3) instead 2364202a189Smrg */ 2374202a189Smrgextern _X_EXPORT void Xfree(void * /*ptr*/) _X_DEPRECATED; 2384202a189Smrg 23905b261ecSmrg#endif 24005b261ecSmrg 2414202a189Smrg/* 2424202a189Smrg * This function malloc(3)s buffer, terminating the server if there is not 2434202a189Smrg * enough memory. 2444202a189Smrg */ 2454202a189Smrgextern _X_EXPORT void *XNFalloc(unsigned long /*amount*/); 2464202a189Smrg/* 2474202a189Smrg * This function calloc(3)s buffer, terminating the server if there is not 2484202a189Smrg * enough memory. 2494202a189Smrg */ 2504202a189Smrgextern _X_EXPORT void *XNFcalloc(unsigned long /*amount*/); 2514202a189Smrg/* 2524202a189Smrg * This function realloc(3)s passed buffer, terminating the server if there is 2534202a189Smrg * not enough memory. 2544202a189Smrg */ 2554202a189Smrgextern _X_EXPORT void *XNFrealloc(void * /*ptr*/, unsigned long /*amount*/); 25605b261ecSmrg 2574202a189Smrg/* 2584202a189Smrg * This function strdup(3)s passed string. The only difference from the library 2594202a189Smrg * function that it is safe to pass NULL, as NULL will be returned. 2604202a189Smrg */ 2614202a189Smrgextern _X_EXPORT char *Xstrdup(const char *s); 26205b261ecSmrg 2634202a189Smrg/* 2644202a189Smrg * This function strdup(3)s passed string, terminating the server if there is 2654202a189Smrg * not enough memory. If NULL is passed to this function, NULL is returned. 2664202a189Smrg */ 2674202a189Smrgextern _X_EXPORT char *XNFstrdup(const char *s); 26805b261ecSmrg 2694202a189Smrgextern _X_EXPORT char *Xprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2); 2704202a189Smrgextern _X_EXPORT char *Xvprintf(const char *fmt, va_list va); 2714202a189Smrgextern _X_EXPORT char *XNFprintf(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2); 2724202a189Smrgextern _X_EXPORT char *XNFvprintf(const char *fmt, va_list va); 27305b261ecSmrg 2744202a189Smrgtypedef void (*OsSigHandlerPtr)(int /* sig */); 2754202a189Smrgtypedef int (*OsSigWrapperPtr)(int /* sig */); 27605b261ecSmrg 2774202a189Smrgextern _X_EXPORT OsSigHandlerPtr OsSignal(int /* sig */, OsSigHandlerPtr /* handler */); 2784202a189Smrgextern _X_EXPORT OsSigWrapperPtr OsRegisterSigWrapper(OsSigWrapperPtr newWrap); 27905b261ecSmrg 2804202a189Smrgextern _X_EXPORT int auditTrailLevel; 2814202a189Smrg 2824202a189Smrgextern _X_EXPORT void LockServer(void); 2834202a189Smrgextern _X_EXPORT void UnlockServer(void); 2844202a189Smrg 2854202a189Smrgextern _X_EXPORT int OsLookupColor( 28605b261ecSmrg int /*screen*/, 28705b261ecSmrg char * /*name*/, 28805b261ecSmrg unsigned /*len*/, 28905b261ecSmrg unsigned short * /*pred*/, 29005b261ecSmrg unsigned short * /*pgreen*/, 29105b261ecSmrg unsigned short * /*pblue*/); 29205b261ecSmrg 2934202a189Smrgextern _X_EXPORT void OsInit(void); 29405b261ecSmrg 2954202a189Smrgextern _X_EXPORT void OsCleanup(Bool); 29605b261ecSmrg 2974202a189Smrgextern _X_EXPORT void OsVendorFatalError(void); 29805b261ecSmrg 2994202a189Smrgextern _X_EXPORT void OsVendorInit(void); 30005b261ecSmrg 3014202a189Smrgextern _X_EXPORT void OsBlockSignals (void); 30205b261ecSmrg 3034202a189Smrgextern _X_EXPORT void OsReleaseSignals (void); 3044202a189Smrg 3054202a189Smrgextern _X_EXPORT void OsAbort (void) _X_NORETURN; 30605b261ecSmrg 30705b261ecSmrg#if !defined(WIN32) 3084202a189Smrgextern _X_EXPORT int System(char *); 3094202a189Smrgextern _X_EXPORT pointer Popen(char *, char *); 3104202a189Smrgextern _X_EXPORT int Pclose(pointer); 3114202a189Smrgextern _X_EXPORT pointer Fopen(char *, char *); 3124202a189Smrgextern _X_EXPORT int Fclose(pointer); 31305b261ecSmrg#else 31405b261ecSmrg#define System(a) system(a) 31505b261ecSmrg#define Popen(a,b) popen(a,b) 31605b261ecSmrg#define Pclose(a) pclose(a) 31705b261ecSmrg#define Fopen(a,b) fopen(a,b) 31805b261ecSmrg#define Fclose(a) fclose(a) 31905b261ecSmrg#endif 32005b261ecSmrg 3214202a189Smrgextern _X_EXPORT void CheckUserParameters(int argc, char **argv, char **envp); 3224202a189Smrgextern _X_EXPORT void CheckUserAuthorization(void); 32305b261ecSmrg 3244202a189Smrgextern _X_EXPORT int AddHost( 32505b261ecSmrg ClientPtr /*client*/, 32605b261ecSmrg int /*family*/, 32705b261ecSmrg unsigned /*length*/, 3284202a189Smrg const void */*pAddr*/); 32905b261ecSmrg 3304202a189Smrgextern _X_EXPORT Bool ForEachHostInFamily ( 33105b261ecSmrg int /*family*/, 33205b261ecSmrg Bool (* /*func*/ )( 33305b261ecSmrg unsigned char * /* addr */, 33405b261ecSmrg short /* len */, 33505b261ecSmrg pointer /* closure */), 33605b261ecSmrg pointer /*closure*/); 33705b261ecSmrg 3384202a189Smrgextern _X_EXPORT int RemoveHost( 33905b261ecSmrg ClientPtr /*client*/, 34005b261ecSmrg int /*family*/, 34105b261ecSmrg unsigned /*length*/, 34205b261ecSmrg pointer /*pAddr*/); 34305b261ecSmrg 3444202a189Smrgextern _X_EXPORT int GetHosts( 34505b261ecSmrg pointer * /*data*/, 34605b261ecSmrg int * /*pnHosts*/, 34705b261ecSmrg int * /*pLen*/, 34805b261ecSmrg BOOL * /*pEnabled*/); 34905b261ecSmrg 35005b261ecSmrgtypedef struct sockaddr * sockaddrPtr; 35105b261ecSmrg 3524202a189Smrgextern _X_EXPORT int InvalidHost(sockaddrPtr /*saddr*/, int /*len*/, ClientPtr client); 35305b261ecSmrg 3544202a189Smrgextern _X_EXPORT int LocalClient(ClientPtr /* client */); 35505b261ecSmrg 3564202a189Smrgextern _X_EXPORT int LocalClientCred(ClientPtr, int *, int *); 35705b261ecSmrg 358637ac9abSmrg#define LCC_UID_SET (1 << 0) 359637ac9abSmrg#define LCC_GID_SET (1 << 1) 360637ac9abSmrg#define LCC_PID_SET (1 << 2) 361637ac9abSmrg#define LCC_ZID_SET (1 << 3) 362637ac9abSmrg 363637ac9abSmrgtypedef struct { 364637ac9abSmrg int fieldsSet; /* Bit mask of fields set */ 365637ac9abSmrg int euid; /* Effective uid */ 366637ac9abSmrg int egid; /* Primary effective group id */ 367637ac9abSmrg int nSuppGids; /* Number of supplementary group ids */ 368637ac9abSmrg int *pSuppGids; /* Array of supplementary group ids */ 369637ac9abSmrg int pid; /* Process id */ 370637ac9abSmrg int zoneid; /* Only set on Solaris 10 & later */ 371637ac9abSmrg} LocalClientCredRec; 372637ac9abSmrg 3734202a189Smrgextern _X_EXPORT int GetLocalClientCreds(ClientPtr, LocalClientCredRec **); 3744202a189Smrgextern _X_EXPORT void FreeLocalClientCreds(LocalClientCredRec *); 375637ac9abSmrg 3764202a189Smrgextern _X_EXPORT int ChangeAccessControl(ClientPtr /*client*/, int /*fEnabled*/); 37705b261ecSmrg 3784202a189Smrgextern _X_EXPORT int GetAccessControl(void); 37905b261ecSmrg 38005b261ecSmrg 3814202a189Smrgextern _X_EXPORT void AddLocalHosts(void); 38205b261ecSmrg 3834202a189Smrgextern _X_EXPORT void ResetHosts(char *display); 38405b261ecSmrg 3854202a189Smrgextern _X_EXPORT void EnableLocalHost(void); 38605b261ecSmrg 3874202a189Smrgextern _X_EXPORT void DisableLocalHost(void); 38805b261ecSmrg 3894202a189Smrgextern _X_EXPORT void AccessUsingXdmcp(void); 39005b261ecSmrg 3914202a189Smrgextern _X_EXPORT void DefineSelf(int /*fd*/); 39205b261ecSmrg 3934202a189Smrg#if XDMCP 3944202a189Smrgextern _X_EXPORT void AugmentSelf(pointer /*from*/, int /*len*/); 39505b261ecSmrg 3964202a189Smrgextern _X_EXPORT void RegisterAuthorizations(void); 3974202a189Smrg#endif 39805b261ecSmrg 3994202a189Smrgextern _X_EXPORT void InitAuthorization(char * /*filename*/); 40005b261ecSmrg 4014202a189Smrg/* extern int LoadAuthorization(void); */ 40205b261ecSmrg 4034202a189Smrgextern _X_EXPORT int AuthorizationFromID ( 40405b261ecSmrg XID id, 40505b261ecSmrg unsigned short *name_lenp, 40605b261ecSmrg char **namep, 40705b261ecSmrg unsigned short *data_lenp, 40805b261ecSmrg char **datap); 40905b261ecSmrg 4104202a189Smrgextern _X_EXPORT XID CheckAuthorization( 41105b261ecSmrg unsigned int /*namelength*/, 4124202a189Smrg const char * /*name*/, 41305b261ecSmrg unsigned int /*datalength*/, 4144202a189Smrg const char * /*data*/, 41505b261ecSmrg ClientPtr /*client*/, 41605b261ecSmrg char ** /*reason*/ 41705b261ecSmrg); 41805b261ecSmrg 4194202a189Smrgextern _X_EXPORT void ResetAuthorization(void); 42005b261ecSmrg 4214202a189Smrgextern _X_EXPORT int RemoveAuthorization ( 42205b261ecSmrg unsigned short name_length, 4234202a189Smrg const char *name, 42405b261ecSmrg unsigned short data_length, 4254202a189Smrg const char *data); 42605b261ecSmrg 4274202a189Smrgextern _X_EXPORT int AddAuthorization( 42805b261ecSmrg unsigned int /*name_length*/, 4294202a189Smrg const char * /*name*/, 43005b261ecSmrg unsigned int /*data_length*/, 43105b261ecSmrg char * /*data*/); 43205b261ecSmrg 4334202a189Smrg#ifdef XCSECURITY 4344202a189Smrgextern _X_EXPORT XID GenerateAuthorization( 43505b261ecSmrg unsigned int /* name_length */, 4364202a189Smrg const char * /* name */, 43705b261ecSmrg unsigned int /* data_length */, 4384202a189Smrg const char * /* data */, 43905b261ecSmrg unsigned int * /* data_length_return */, 44005b261ecSmrg char ** /* data_return */); 4414202a189Smrg#endif 44205b261ecSmrg 4434202a189Smrgextern _X_EXPORT int ddxProcessArgument(int /*argc*/, char * /*argv*/ [], int /*i*/); 44405b261ecSmrg 4454202a189Smrgextern _X_EXPORT void ddxUseMsg(void); 44605b261ecSmrg 44705b261ecSmrg/* int ReqLen(xReq *req, ClientPtr client) 44805b261ecSmrg * Given a pointer to a *complete* request, return its length in bytes. 44905b261ecSmrg * Note that if the request is a big request (as defined in the Big 45005b261ecSmrg * Requests extension), the macro lies by returning 4 less than the 45105b261ecSmrg * length that it actually occupies in the request buffer. This is so you 45205b261ecSmrg * can blindly compare the length with the various sz_<request> constants 45305b261ecSmrg * in Xproto.h without having to know/care about big requests. 45405b261ecSmrg */ 45505b261ecSmrg#define ReqLen(_pxReq, _client) \ 45605b261ecSmrg ((_pxReq->length ? \ 45705b261ecSmrg (_client->swapped ? lswaps(_pxReq->length) : _pxReq->length) \ 45805b261ecSmrg : ((_client->swapped ? \ 45905b261ecSmrg lswapl(((CARD32*)_pxReq)[1]) : ((CARD32*)_pxReq)[1])-1) \ 46005b261ecSmrg ) << 2) 46105b261ecSmrg 46205b261ecSmrg/* otherReqTypePtr CastxReq(xReq *req, otherReqTypePtr) 46305b261ecSmrg * Cast the given request to one of type otherReqTypePtr to access 46405b261ecSmrg * fields beyond the length field. 46505b261ecSmrg */ 46605b261ecSmrg#define CastxReq(_pxReq, otherReqTypePtr) \ 46705b261ecSmrg (_pxReq->length ? (otherReqTypePtr)_pxReq \ 46805b261ecSmrg : (otherReqTypePtr)(((CARD32*)_pxReq)+1)) 46905b261ecSmrg 47005b261ecSmrg/* stuff for ReplyCallback */ 4714202a189Smrgextern _X_EXPORT CallbackListPtr ReplyCallback; 47205b261ecSmrgtypedef struct { 47305b261ecSmrg ClientPtr client; 474637ac9abSmrg const void *replyData; 47505b261ecSmrg unsigned long dataLenBytes; 47605b261ecSmrg unsigned long bytesRemaining; 47705b261ecSmrg Bool startOfReply; 47805b261ecSmrg} ReplyInfoRec; 47905b261ecSmrg 48005b261ecSmrg/* stuff for FlushCallback */ 4814202a189Smrgextern _X_EXPORT CallbackListPtr FlushCallback; 48205b261ecSmrg 4834202a189Smrgextern _X_EXPORT void AbortDDX(void); 4844202a189Smrgextern _X_EXPORT void ddxGiveUp(void); 4854202a189Smrgextern _X_EXPORT int TimeSinceLastInputEvent(void); 48605b261ecSmrg 487637ac9abSmrg/* strcasecmp.c */ 488637ac9abSmrg#if NEED_STRCASECMP 489637ac9abSmrg#define strcasecmp xstrcasecmp 4904202a189Smrgextern _X_EXPORT int xstrcasecmp(const char *s1, const char *s2); 491637ac9abSmrg#endif 492637ac9abSmrg 493637ac9abSmrg#if NEED_STRNCASECMP 494637ac9abSmrg#define strncasecmp xstrncasecmp 4954202a189Smrgextern _X_EXPORT int xstrncasecmp(const char *s1, const char *s2, size_t n); 496637ac9abSmrg#endif 497637ac9abSmrg 498637ac9abSmrg#if NEED_STRCASESTR 499637ac9abSmrg#define strcasestr xstrcasestr 5004202a189Smrgextern _X_EXPORT char *xstrcasestr(const char *s, const char *find); 501637ac9abSmrg#endif 502637ac9abSmrg 503637ac9abSmrg#ifndef HAS_STRLCPY 5044202a189Smrgextern _X_EXPORT size_t strlcpy(char *dst, const char *src, size_t siz); 5054202a189Smrgextern _X_EXPORT size_t strlcat(char *dst, const char *src, size_t siz); 506637ac9abSmrg#endif 507637ac9abSmrg 50805b261ecSmrg/* Logging. */ 50905b261ecSmrgtypedef enum _LogParameter { 51005b261ecSmrg XLOG_FLUSH, 51105b261ecSmrg XLOG_SYNC, 51205b261ecSmrg XLOG_VERBOSITY, 51305b261ecSmrg XLOG_FILE_VERBOSITY 51405b261ecSmrg} LogParameter; 51505b261ecSmrg 51605b261ecSmrg/* Flags for log messages. */ 51705b261ecSmrgtypedef enum { 51805b261ecSmrg X_PROBED, /* Value was probed */ 51905b261ecSmrg X_CONFIG, /* Value was given in the config file */ 52005b261ecSmrg X_DEFAULT, /* Value is a default */ 52105b261ecSmrg X_CMDLINE, /* Value was given on the command line */ 52205b261ecSmrg X_NOTICE, /* Notice */ 52305b261ecSmrg X_ERROR, /* Error message */ 52405b261ecSmrg X_WARNING, /* Warning message */ 52505b261ecSmrg X_INFO, /* Informational message */ 52605b261ecSmrg X_NONE, /* No prefix */ 52705b261ecSmrg X_NOT_IMPLEMENTED, /* Not implemented */ 52805b261ecSmrg X_UNKNOWN = -1 /* unknown -- this must always be last */ 52905b261ecSmrg} MessageType; 53005b261ecSmrg 5314202a189Smrgextern _X_EXPORT const char *LogInit(const char *fname, const char *backup); 5324202a189Smrgextern _X_EXPORT void LogClose(void); 5334202a189Smrgextern _X_EXPORT Bool LogSetParameter(LogParameter param, int value); 5344202a189Smrgextern _X_EXPORT void LogVWrite(int verb, const char *f, va_list args); 5354202a189Smrgextern _X_EXPORT void LogWrite(int verb, const char *f, ...) _X_ATTRIBUTE_PRINTF(2,3); 5364202a189Smrgextern _X_EXPORT void LogVMessageVerb(MessageType type, int verb, const char *format, 53705b261ecSmrg va_list args); 5384202a189Smrgextern _X_EXPORT void LogMessageVerb(MessageType type, int verb, const char *format, 5394202a189Smrg ...) _X_ATTRIBUTE_PRINTF(3,4); 5404202a189Smrgextern _X_EXPORT void LogMessage(MessageType type, const char *format, ...) 5414202a189Smrg _X_ATTRIBUTE_PRINTF(2,3); 5424202a189Smrgextern _X_EXPORT void FreeAuditTimer(void); 5434202a189Smrgextern _X_EXPORT void AuditF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2); 5444202a189Smrgextern _X_EXPORT void VAuditF(const char *f, va_list args); 5454202a189Smrgextern _X_EXPORT void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN; 54605b261ecSmrg 54705b261ecSmrg#ifdef DEBUG 54805b261ecSmrg#define DebugF ErrorF 54905b261ecSmrg#else 550637ac9abSmrg#define DebugF(...) /* */ 55105b261ecSmrg#endif 55205b261ecSmrg 5534202a189Smrgextern _X_EXPORT void VErrorF(const char *f, va_list args); 5544202a189Smrgextern _X_EXPORT void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2); 5554202a189Smrgextern _X_EXPORT void Error(char *str); 5564202a189Smrgextern _X_EXPORT void LogPrintMarkers(void); 55705b261ecSmrg 5584202a189Smrgextern _X_EXPORT void xorg_backtrace(void); 559637ac9abSmrg 56005b261ecSmrg#endif /* OS_H */ 561