xref: /openbsd/lib/libcurses/tty/MKexpanded.sh (revision 09467b48)
1#! /bin/sh
2# $OpenBSD: MKexpanded.sh,v 1.4 2010/01/12 23:22:07 nicm Exp $
3##############################################################################
4# Copyright (c) 1998-2000,2005 Free Software Foundation, Inc.                #
5#                                                                            #
6# Permission is hereby granted, free of charge, to any person obtaining a    #
7# copy of this software and associated documentation files (the "Software"), #
8# to deal in the Software without restriction, including without limitation  #
9# the rights to use, copy, modify, merge, publish, distribute, distribute    #
10# with modifications, sublicense, and/or sell copies of the Software, and to #
11# permit persons to whom the Software is furnished to do so, subject to the  #
12# following conditions:                                                      #
13#                                                                            #
14# The above copyright notice and this permission notice shall be included in #
15# all copies or substantial portions of the Software.                        #
16#                                                                            #
17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   #
19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    #
20# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      #
21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    #
22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER        #
23# DEALINGS IN THE SOFTWARE.                                                  #
24#                                                                            #
25# Except as contained in this notice, the name(s) of the above copyright     #
26# holders shall not be used in advertising or otherwise to promote the sale, #
27# use or other dealings in this Software without prior written               #
28# authorization.                                                             #
29##############################################################################
30#
31# Author: Thomas E. Dickey <dickey@clark.net> 1997
32#
33# $Id: MKexpanded.sh,v 1.4 2010/01/12 23:22:07 nicm Exp $
34#
35# Script to generate 'expanded.c', a dummy source that contains functions
36# corresponding to complex macros used in this library.  By making functions,
37# we simplify analysis and debugging.
38
39if test $# != 0; then
40preprocessor="$1"
41else
42preprocessor="cc -E"
43fi
44shift
45if test $# != 0 ; then
46	preprocessor="$preprocessor $*"
47else
48	preprocessor="$preprocessor -DHAVE_CONFIG_H -I. -I../include"
49fi
50
51TMP=gen$$.c
52trap "rm -f $TMP" 0 1 2 5 15
53
54cat <<EOF
55/* generated by MKexpanded.sh */
56#include <curses.priv.h>
57#include <term.h>
58#if NCURSES_EXPANDED
59EOF
60
61cat >$TMP <<EOF
62#include <ncurses_cfg.h>
63#undef NCURSES_EXPANDED /* this probably is set in ncurses_cfg.h */
64#include <curses.priv.h>
65/* these are names we'd like to see */
66#undef ALL_BUT_COLOR
67#undef PAIR_NUMBER
68#undef TRUE
69#undef FALSE
70/* this is a marker */
71IGNORE
72NCURSES_EXPORT(void) _nc_toggle_attr_on (attr_t *S, attr_t at)
73{
74	toggle_attr_on(*S,at);
75}
76NCURSES_EXPORT(void) _nc_toggle_attr_off (attr_t *S, attr_t at) 
77{
78	toggle_attr_off(*S,at);
79}
80NCURSES_EXPORT(int) _nc_DelCharCost (int count)
81{
82	return DelCharCost(count);
83}
84NCURSES_EXPORT(int) _nc_InsCharCost (int count)
85{
86	return InsCharCost(count);
87}
88NCURSES_EXPORT(void) _nc_UpdateAttrs (NCURSES_CH_T c)
89{
90	UpdateAttrs(c);
91}
92EOF
93
94$preprocessor $TMP 2>/dev/null | sed -e '1,/^IGNORE$/d'
95
96cat <<EOF
97#else /* ! NCURSES_EXPANDED */
98NCURSES_EXPORT(void) _nc_expanded (void) { }
99#endif /* NCURSES_EXPANDED */
100EOF
101