#!/bin/sh #------------------------------------------------------------------------- # # Gen_fmgrtab.sh-- # shell script to generate fmgr.h and fmgrtab.c from pg_proc.h # # Copyright (c) 1994, Regents of the University of California # # # IDENTIFICATION # $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh,v 1.3 1996/07/22 21:55:40 scrappy Exp $ # # NOTES # Passes any -D options on to cpp prior to generating the list # of internal functions. These come from BKIOPTS. # #------------------------------------------------------------------------- # cpp is usually in one of these places... PATH=/usr/lib:/lib:/usr/ccs/lib:$PATH BKIOPTS='' if [ $? != 0 ] then echo `basename $0`: Bad option exit 1 fi # # Pass on any -D declarations, throwing away any other command # line switches. # for opt in $* do case $opt in -D) BKIOPTS="$BKIOPTS -D$2"; shift; shift;; -D*) BKIOPTS="$BKIOPTS $1";shift;; --) shift; break;; -*) shift;; esac done INFILE=$1 RAWFILE=fmgr.raw HFILE=fmgr.h TABCFILE=fmgrtab.c # # Generate the file containing raw pg_proc tuple data # (but only for "internal" language procedures...). # # Unlike genbki.sh, which can run through cpp last, we have to # deal with preprocessor statements first (before we sort the # function table by oid). # awk ' BEGIN { raw = 0; } /^DATA/ { print; next; } /^BKI_BEGIN/ { raw = 1; next; } /^BKI_END/ { raw = 0; next; } raw == 1 { print; next; }' $INFILE | \ sed -e 's/^.*OID[^=]*=[^0-9]*//' \ -e 's/(//g' \ -e 's/[ ]*).*$//' | \ awk ' /^#/ { print; next; } $4 == "11" { print; next; }' | \ cpp $BKIOPTS | \ egrep '^[0-9]' | \ sort -n > $RAWFILE # # Generate fmgr.h # cat > $HFILE <> $HFILE cat >> $HFILE < $TABCFILE < #else # if defined(PORTNAME_BSD44_derived) || \ defined(PORTNAME_bsdi) || \ defined(PORTNAME_bsdi_2_1) # include # define MAXINT INT_MAX # else # include /* for MAXINT */ # endif /* bsd descendents */ #endif /* WIN32 */ #include "utils/fmgrtab.h" FuNkYfMgRtAbStUfF awk '{ print "extern char *" $2 "();"; }' $RAWFILE >> $TABCFILE cat >> $TABCFILE <> $TABCFILE cat >> $TABCFILE < fmgr_builtins[i].proid) low = i + 1; else high = i - 1; } if (id == fmgr_builtins[i].proid) return(&fmgr_builtins[i]); return((FmgrCall *) NULL); } func_ptr fmgr_lookupByName(char *name) { int i; for (i=0;i