summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/ibm/common/ibmUtils.c
blob: f7bfe1aa21ab16bda4cc07be7f141606278a8fd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/*
 * $XConsortium: ibmUtils.c,v 1.4 93/09/05 15:39:53 rws Exp $
 *
 * Copyright IBM Corporation 1987,1988,1989,1990,1991
 *
 * All Rights Reserved
 *
 * License to use, copy, modify, and distribute this software and its
 * documentation for any purpose and without fee is hereby granted,
 * provided that the above copyright notice appear in all copies and that
 * both that copyright notice and this permission notice appear in
 * supporting documentation, and that the name of IBM not be
 * used in advertising or publicity pertaining to distribution of the
 * software without specific, written prior permission.
 *
 * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND 
 * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
 * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 *
*/

#include "X.h"
#include "cursorstr.h"
#include "miscstruct.h"
#include "scrnintstr.h"

#include "ibmScreen.h"
#include "OSio.h"
#include "ibmTrace.h"

#ifdef TRACE_X
int	ibmTrace ;
int	ibmTraceSync ;
#endif

int ibmQuietFlag = 0 ;

void
ibmInfoMsg( str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 )
char *str ;
{
if ( !ibmQuietFlag )
	(void) ErrorF( str, arg1, arg2, arg3, arg4, arg5,
		       arg6, arg7, arg8, arg9 ) ;
return ;
}


/***==================================================================***/

void
ddxGiveUp()
{

    TRACE(("ddxGiveUp()"));

#ifdef OS_CapsLockFeedback
    OS_CapsLockFeedback(0);	
#endif

    OS_GiveUp();

    return;
}

/*
 * abort the server when someone calls through a bogus pointer, which
 * was usually initialized by the structure assignment method (xxxData.c)
 */

void
ibmAbort()
{
extern void abort() ;

	ErrorF(
   "ibmAbort: invalid call though function pointer\n... FATAL exiting...\n" ) ;
	abort() ;
	/*NOTREACHED*/
}

/***==================================================================***/

void
AbortDDX()
{
    TRACE(("AbortDDX()"));

#ifdef OS_CapsLockFeedback
    OS_CapsLockFeedback(0) ;
#endif

    OS_Abort();
    return;
}

ddxUseMsg()
{
int	i;

    TRACE(("ddxUseMsg()\n"));
#ifdef AIXV3
    AIXUseMsg();
#else
    ErrorF("    -D string	color database file \n");
    ErrorF("    -c #		key-click volume (0-100)\n");
    ErrorF("Recognized screens are:\n");
    ErrorF("    -all		opens all attached, supported screens\n");
    for (i=0;(ibmPossibleScreens[i]!=NULL);i++) {
	ErrorF("    %s\n",ibmPossibleScreens[i]->ibm_ScreenFlag);
    }
    ErrorF("Other device dependent options are:\n");
    ErrorF("    -bs		turn on backing store for windows that request it\n");
    ErrorF("    -D <file>	specify color database file\n");
#if defined(IBM_GSL)
    ErrorF("    -dd <dev>	specify a default display for GSL\n");
#endif /* defined(IBM_GSL) */
#ifdef IBM_SPECIAL_MALLOC
    ErrorF("    -malloc #	set malloc check level (0-5)\n");
#endif
    ErrorF("    -n :num		specify connection number (0-255)\n");
    ErrorF("    -nobs		always deny backing store\n");
    ErrorF("    -nohdwr		use generic functions where applicable\n");
    ErrorF("    -pckeys		swap CAPS LOCK and CTRL (for touch typists)\n");
#ifdef IBM_SPECIAL_MALLOC
    ErrorF("    -plumber string	dump malloc arena to named file\n");
#endif
    ErrorF("    -quiet		do not print informational messages\n");
    ErrorF("    -rtkeys		use CAPS LOCK and CTRL as labelled\n");
    ErrorF("    -T		disable CTRL-ALT_BACKSPACE key sequence\n");
#ifdef TRACE_X
    ErrorF("    -trace		trace execution of IBM specific functions\n");
#endif
    ErrorF("    -verbose	print informational messages\n");
    ErrorF("    -wrap		wrap mouse in both dimensions\n");
    ErrorF("    -wrapx		wrap mouse in X only\n");
    ErrorF("    -wrapy		wrap mouse in Y only\n");
    ErrorF("See Xibm(1) for a more complete description\n");
#endif
}

/***==================================================================***/

#ifdef IBM_SPECIAL_MALLOC
#include <stdio.h>
#include <signal.h>

int	ibmShouldDumpArena= 0;
static	char	*ibmArenaFile= 0;

static
ibmMarkDumpArena(sig)
    int sig;
{

    (void) OsSignal( SIGUSR1, ibmMarkDumpArena ) ;
    ibmShouldDumpArena= 1;

    return 0;
}

ibmDumpArena(sig)
    int sig;
{
FILE  *mfil;
static	char	fileName[100];
static	int	dumpNum= 0;

   (void) OsSignal( SIGUSR2, ibmDumpArena ) ;
   (void) sprintf(fileName,ibmArenaFile,dumpNum++);

   mfil= fopen(fileName,"a");
   if (!mfil) {
	ErrorF("Couldn't open %s to dump arena, ignored\n",fileName);
	return 0 ;
   }
   else {
	ErrorF("Dumping malloc arena to %s\n",fileName);
	plumber(mfil);
	(void) fflush(mfil);
	(void) fclose(mfil);
   }
   ibmShouldDumpArena= 0;
   return 1 ;
}

ibmNoteHit(sig)
    int sig;
{
static int old= 4;

   ErrorF("received SIGTERM\n");
   old= SetMallocCheckLevel(old);
   return 1 ;
}

int
ibmSetupPlumber( name )
register char *name ;
{
extern exit() ;

    ibmInfoMsg( "Setting up plumber to dump to %s\n", name ) ;
    (void) unlink( ibmArenaFile = name ) ;
    (void) OsSignal( SIGUSR1, ibmMarkDumpArena ) ;
    (void) OsSignal( SIGUSR2, ibmDumpArena ) ;
    (void) OsSignal( SIGTERM, ibmNoteHit ) ;
    return 1 ;
}

#endif /* IBM_SPECIAL_MALLOC */