|
root / base / usr / src / lib / libtermcap
libtermcap Plain Text 323 lines 8.9 KB
  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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
#

include		../Makefile.lib

HDRS =		termcap.h
HDRDIR=		common
# Hammerhead: amd64-only
SUBDIRS = $(MACH64)

# Install XPG4v2 header variants so that libtermcap can be used to
# filter over libcurses(3xcurses).
XHDRS =		termcap.h
XROOTHDRDIR=	$(ROOT)/usr/xpg4/include
XROOTHDRS=	$(XHDRS:%=$(XROOTHDRDIR)/%)

all :		TARGET= all
clean :	TARGET= clean
clobber :	TARGET= clobber
install :	TARGET= install

.KEEP_STATE:

all clean clobber install: $(SUBDIRS)

install_h: $(ROOTHDRS) $(XROOTHDRS)

check: $(CHECKHDRS)

$(SUBDIRS): FRC
	@cd $@; pwd; $(MAKE) $(TARGET)

$(XROOTHDRDIR)/%: $(HDRDIR)/x%
	$(INS.rename)

FRC:

include ../Makefile.targ
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
#

LIBRARY =	libtermcap.a
VERS =		.1

# Hammerhead: Define stub objects so GNU ld can resolve termcap symbols
# at link time.  The FILTER mechanism ensures runtime calls go to libcurses.so.1.
OBJECTS =	libtermcap_stubs.o
SRCDIR =	../common

# install this library in the root filesystem
include ../../Makefile.rootfs

COMPATLINKS +=	usr/ccs/lib/libtermcap.so
# Hammerhead: flattened layout — no amd64 subdir
COMPATLINKS64 += usr/ccs/lib/libtermcap.so

# Hammerhead: use : not := (dmake vs GNU Make target-specific variable syntax)
$(ROOT)/usr/ccs/lib/libtermcap.so : COMPATLINKTARGET=../../../lib/libtermcap.so.1

DYNFLAGS +=	$(ZLOADFLTR)
DYNFLAGS +=	-F libcurses.so.1
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
#

# Hammerhead: Set OBJECTS before includes so PICS gets PIC flags
OBJECTS =	libtermcap_stubs.o

include		$(SRC)/lib/Makefile.filter.com
include		../Makefile.com
include		$(SRC)/lib/Makefile.lib.64

install:	$(ROOTLIBS64) $(ROOTLINKS64) $(ROOTCOMPATLINKS64)

include		$(SRC)/lib/Makefile.filter.targ
/*
 * Copyright 2026 Zygaena Project.
 *
 * Hammerhead: Stub implementations for libtermcap filter library.
 * GNU ld cannot populate .dynsym from mapfile FILTER directives alone,
 * so we provide stub definitions.  At runtime, the ELF FILTER mechanism
 * (-F libcurses.so.1) redirects all symbol lookups to libcurses.so.1;
 * these stubs are never called.
 *
 * See libmd5/common/md5_stubs.c for the same pattern.
 */

#pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"

#define	STUB(name)	int name() { return (0); }
#define	VSTUB(name)	void *name() { return ((void *)0); }

/* Functions */
STUB(tgetent)
STUB(tgetflag)
STUB(tgetnum)
VSTUB(tgetstr)
VSTUB(tgoto)
STUB(tputs)

/* Data symbols */
char *BC = 0;
char *UP = 0;
char PC = 0;
short ospeed = 0;
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source.  A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
#

#
# MAPFILE HEADER START
#
# WARNING:  STOP NOW.  DO NOT MODIFY THIS FILE.
# Object versioning must comply with the rules detailed in
#
#	usr/src/lib/README.mapfiles
#
# You should not be making modifications here until you've read the most current
# copy of that file. If you need help, contact a gatekeeper for guidance.
#
# MAPFILE HEADER END
#

$mapfile_version 2

#
# This is a mapfile that defines a filter for libcurses so that
# libraries such as libreadline can link with this and NOT force
# the choice of which curses library will be used.  The NODIRECT
# flag lets other libraries earlier in the link order provide the
# symbols below, in which case those will be used by all calls
# to these functions _instead_ of the libcurses ones.  Cool, eh?
#

SYMBOL_VERSION ILLUMOS_0.1 {
    global:

$if _ELF32
	BC		{ TYPE = COMMON; SIZE = 4; FLAGS = NODIRECT;
			  FILTER = libcurses.so.1; };
	UP		{ TYPE = COMMON; SIZE = 4; FLAGS = NODIRECT;
			  FILTER = libcurses.so.1; };
$endif
$if _ELF64
	BC		{ TYPE = COMMON; SIZE = 8; FLAGS = NODIRECT;
			  FILTER = libcurses.so.1; };
	UP		{ TYPE = COMMON; SIZE = 8; FLAGS = NODIRECT;
			  FILTER = libcurses.so.1; };
$endif
	PC		{ TYPE = COMMON; SIZE = 1; FLAGS = NODIRECT;
			  FILTER = libcurses.so.1; };
	ospeed		{ TYPE = COMMON; SIZE = 2; FLAGS = NODIRECT;
			  FILTER = libcurses.so.1; };

	tgetent		{ TYPE = FUNCTION; FLAGS = NODIRECT;
			  FILTER = libcurses.so.1; };
	tgetflag	{ TYPE = FUNCTION; FLAGS = NODIRECT;
			  FILTER = libcurses.so.1 };
	tgetnum		{ TYPE = FUNCTION; FLAGS = NODIRECT;
			  FILTER = libcurses.so.1 };
	tgetstr		{ TYPE = FUNCTION; FLAGS = NODIRECT;
			  FILTER = libcurses.so.1 };
	tgoto		{ TYPE = FUNCTION; FLAGS = NODIRECT;
			  FILTER = libcurses.so.1 };
	tputs		{ TYPE = FUNCTION; FLAGS = NODIRECT;
			  FILTER = libcurses.so.1 };
};
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 */

#ifndef	_TERMCAP_H_
#define	_TERMCAP_H_

/*
 * This declares the public functions exported by the
 * "filter" library: libtermcap.  That exports only
 * the traditional BSD-style functions and data.
 *
 * Note that the libtermcap filter library uses NODIRECT
 * linker bindings when filtering what libcurses exports
 * so that an application can link with an alternative
 * curses library providing the symbols below, and those
 * will be used instead of the ones in libcurses.
 */

#ifdef	__cplusplus
extern "C" {
#endif

extern char PC, *UP, *BC;
extern short ospeed;

/*
 * These are intentionally the same as term.h declares
 * so the compiler won't bark if you include that too.
 */
extern int tgetent(char *, char *);
extern int tgetflag(char *);
extern int tgetnum(char *);
extern char *tgetstr(char *, char **);
extern char *tgoto(char *, int, int);
extern int tputs(char *, int, int (*)(char));

#ifdef	__cplusplus
}
#endif

#endif	/* _TERMCAP_H_ */
/*
 * This file and its contents are supplied under the terms of the
 * Common Development and Distribution License ("CDDL"), version 1.0.
 * You may only use this file in accordance with the terms of version
 * 1.0 of the CDDL.
 *
 * A full copy of the text of the CDDL should have accompanied this
 * source.  A copy of the CDDL is also available via the Internet at
 * http://www.illumos.org/license/CDDL.
 */

/*
 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
 * Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
 */

#ifndef	_TERMCAP_H_
#define	_TERMCAP_H_

/*
 * This declares the public functions exported by the
 * "filter" library: libtermcap.  That exports only
 * the traditional BSD-style functions and data.
 *
 * Note that the libtermcap filter library uses NODIRECT
 * linker bindings when filtering what libcurses exports
 * so that an application can link with an alternative
 * curses library providing the symbols below, and those
 * will be used instead of the ones in libcurses.
 */

#ifdef	__cplusplus
extern "C" {
#endif

extern char PC, *UP, *BC;
extern short ospeed;

/*
 * These are intentionally the same as the XPG4v2 term.h
 * declares so the compiler won't bark if that is included
 * too.
 */
extern int tgetent(char *, const char *);
extern int tgetflag(char *);
extern int tgetnum(char *);
extern char *tgetstr(char *, char **);
extern char *tgoto(char *, int, int);
extern int tputs(const char *, int, int (*)(int));

#ifdef	__cplusplus
}
#endif

#endif	/* _TERMCAP_H_ */