home *** CD-ROM | disk | FTP | other *** search
- # -*- C -*- --- well, not actually...
- # $Id: config_var.awk,v 1.7 1993/11/06 23:51:22 ppessi Exp puhuri $
- #
- # Copyright © 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
- # Helsinki University of Technology, Finland.
- # All rights reserved.
- #
- # Created : Wed Apr 28 21:09:22 1993 puhuri
- # Last modified: Thu Nov 4 07:33:09 1993 ppessi
- #
- # $Log: config_var.awk,v $
- # Revision 1.7 1993/11/06 23:51:22 ppessi
- # Added `global' definitions, allowing to export second level strings.
- #
- # Revision 1.6 1993/06/04 11:16:15 jraja
- # Fixes for first public release.
- #
- # Revision 1.5 1993/05/04 13:44:00 ppessi
- # Fixed Aliasing, removed level 0 \begin{description} \end{description}
- #
- # Revision 1.4 93/05/03 13:46:42 13:46:42 puhuri (Markus Peuhkuri)
- # Modified to use \Alias(es) command.
- #
- # Revision 1.3 93/04/29 22:05:16 22:05:16 puhuri (Markus Peuhkuri)
- # Now gawk supouse substitute FILENAME
- #
- # Revision 1.2 93/04/29 08:55:05 08:55:05 puhuri (Markus Peuhkuri)
- # Changed field seperator to ; surrounded by zero or more spaces or tabs.
- #
- # Revision 1.1 93/04/28 21:55:56 21:55:56 ppessi (Pekka Pessi)
- # Initial revision
- #
-
- BEGIN {
- FS="[\t ]*;[\t ]*";
- level=1;
- tab="";
- vars="";
- var2="";
- GFN = "kern/variables.src (" FILENAME ")";
- TEXTARGET=0;CTARGET=0;TEXITARGET=0
- if (TARGETTI == "TEX") {
- TEXTARGET = 1;
- startcomment = "% -*- LaTeX -*-";
- comment = "%";
- endcomment = "%";
- }else if (TARGETTI == "TEXINFO") {
- level = 0;
- TEXITARGET = 1;
- startcomment = "@c -*- Texinfo -*-";
- comment = "@c ";
- endcomment = "@c ";
- } else if (TARGETTI == "C") {
- CTARGET = 1;
- startcomment = "/* -*- C -*-";
- comment = " *";
- endcomment = " */";
- } else printf "Unknown target format '%s'\n",TARGETTI > "/dev/stderr"
- print startcomment;
- printf "%s This file is automatically generated from %s\n", comment, GFN;
- print comment;
- printf "%s Do not change this file\n", comment;
- print endcomment;
- if (CTARGET) {
- print "";
- print "\#include <sys/param.h>";
- print "\#include <sys/socket.h>";
- print "\#include <netinet/in.h>";
- print "\#include <kern/amiga_includes.h>";
- print "\#include <kern/amiga_config.h>";
- print "";
- }
- }
-
- # skip comments and empty lines
- /^#/ { next }
- /^ *$/ { next }
- # Collect global variables
- /^global/ {
- gsub("^global ", "");
- globals = globals "\n" $0;
- next;
- }
- # Change _ to \_ in TeX
- TEXTARGET && /_/ { gsub("_","\\_") }
- # Generate indentation, add environment parenthesis
- level != $2 && TEXTARGET {
- if (level < $2)
- for(i=level; i < $2; i++) {
- tab = sprintf("%"2*i"s", "");
- print tab "\\begin{description}";
- }
- else
- for(i=level; i > $2; i--) {
- tab = sprintf("% "2*i "s", "");
- print tab "\\end{description}";
- }
- level = $2;
- tab = sprintf("%" 2*level "s", "");
- print "";
- }
- TEXTARGET {
- n = split($1,temp,"=");
- printf "%s\\item[\\code{%s}] %s\n",tab,temp[n],$3;
- if(n>1) {
- printf tab " \\Alias%s{%s",(n>2)?"es":"",temp[1];
- for(i=2;i<n;i++)
- printf "{\\rm ,} %s",temp[i];
- print "}";
- }
- print "";
- if ($2 == 1) {
- # Skip C declarations
- getline dummy;
- getline dummy;
- }
- }
- #
- # TEXINFO
- #
- $2 == 2 && TEXITARGET {
- if (level == 1)
- print "@table @code";
- n = split($1,temp,"=");print "level=" $2, n > "/dev/stderr"
- printf "@item %s\n",temp[n];
- for(i=1;i<n;i++) {
- printf "@itemx %s\n",temp[i];
- }
- gsub("\\\\n","\n",$3) # replace with newlines
- print $3;print "";
- level = $2;
- print "";
- }
- $2 == 1 && TEXITARGET {
- if (level == 2)
- print "@end table";
- if (level != 0)
- print "@end deffn\n";
- n = split($1,temp,"="); print "level=" $2, n > "/dev/stderr"
- printf "@deffn {AREXX Variable} %s\n",temp[n];
- for(i=1;i<n;i++) {
- printf "@deffnx {AREXX Variable} %s\n",temp[i];
- }
- gsub("\\\\n","\n",$3) # replace with newlines
- print $3;print "";
- level = $2;
- print "";
-
- if ($2 == 1) {
- # Skip C declarations
- getline dummy;
- getline dummy;
- }
- }
- ($2 != 1 && $2 != 2) && TEXITARGET {
- print FILENAME ":" FNR ": Invalid level: " $2 > "/dev/stderr"
- }
- #
- # Make a C file
- #
- CTARGET {
- n = split($1, temp, "=");
- if ($2 == 1) {
- if (length(var2) > 0) {
- printf "/* %s */\n#define KW_%s \\\n \"", varcom, curvar;
- n2 = split(var2, t2, ",");
- cnt = 0;
- for (i = 1; i < n2; i++) {
- if ((cnt + length(t2[i])) > 60) {
- printf "\" \\\n \"";
- cnt=0;
- }
- cnt += length(t2[i]);
- printf "%s,",t2[i];
- }
- if (length(t2[n2]) + cnt > 60)
- printf "\" \\\n \"";
- printf "%s\"\n\n", t2[n2];
- }
- curvar=temp[n];
- varcom=$3;
- if (length(vars) > 0) {
- vars=vars "," $1;
- } else {
- vars=$1;
- }
- var2 = "";
- # Get external vars
- getline extern;
- externs = externs "\n" extern;
- # get variables line
- getline varline;
- if (length(varlines) > 0) {
- varlines = varlines ",\n" varline;
- } else {
- varlines = varline;
- }
- } else {
- if(length(var2) == 0) {
- var2=$1;
- } else {
- var2 = var2 "," $1;
- }
- }
- }
-
- END {
- if (TEXTARGET) {
- for(i = level; i > 1; i--)
- print "\\end{description}";
- } else if(TEXITARGET) {
- if (level == 2)
- print "@end table";
- if (level != 0)
- print "@end deffn\n";
- } else if(CTARGET) {
- if (length(var2) > 0) {
- printf "/* %s */\n#define KW_%s \\\n \"", varcom, curvar;
- n2 = split(var2, t2, ",");
- cnt = 0;
- for(i=1;i<n2;i++) {
- if((cnt+length(t2[i]))>60) {
- printf "\" \\\n \"";
- cnt=0;
- }
- cnt += length(t2[i]);
- printf "%s,",t2[i];
- }
- if (length(t2[n2])+cnt> 60) printf "\" \\\n \"";
- printf "%s\"\n\n", t2[n2];
- }
-
- if (length(vars) > 0) {
- printf "/* %s */\nSTRPTR KW_%s =\n \"", "Level 1 variables", "VARS";
- n2 = split(vars, t2, ","); cnt=0;
- for(i=1; i<n2; i++) {
- if(cnt + length(t2[i]) > 60) {
- printf "\"\n \"";
- cnt=0;
- }
- cnt+=length(t2[i]);
- printf "%s,",t2[i];
- }
- printf "%s\";\n\n", t2[n2];
- }
- if (length(externs)) {
- print "/* extern declarations */";
- print externs;
- print;
- }
- if (length(globals)) {
- printf "/* Global variables */";
- print globals;
- print;
- }
- if (length(varlines)) {
- print "struct cfg_variable variables[] = {";
- print varlines;
- print "};";
- }
- }
- }
-