Attached is what I have accomplished so far, in my effort to construct a program that will produce a list of function prototypes for the Linux GCC LIBC headers.
It is not complete, but it's a good start.
Here is my preface to the program:
' h2incz.bas [Copyright (C) 2012, sarbayo]
' using: Bxbasic v20.3.1 -- Win32 executable
'
' The original h2inc program is designed to translate GCC C header files
' into ".inc" include files, more or less usable by Masm and other
' assemblers.
' This program functions similar to h2inc, with a number of exception.
'
' Presently, the primary goal of this program is to extract the #define
' and extern statements and produce clean and uncluttered variable
' definitions and function prototypes and not to attempt to parse the
' conditional #if statements, typically found in header files.
'
' As stated, conditional statements are ignored, entirely.
' Instead, each line is parsed and tested for a valid and understandable
' variable definition that can be translated into an assembly language
' equate statement.
'
' How to run this program:
' ========================
' 1) First, by default, this program is designed to read the contents of a
' text file, (named header.txt), in the working directory, which contains
' a list of the header file names to be translated.
' The header.txt file must be formated in a specific way.
' The first line of the file must contain the number of headers to be
' processed. The second and subsequent lines must contain the names of the
' header files, without the ".h" extension and must appear between quotes,
' like so:
' __________
' |10
' |"a.out"
' |"aio"
' |"alloca"
' |"ar"
' |"argp"
' |"argz"
' |...etc
'
'
' 2) Copies of the headers to be translated must be placed in a sub-
' directory of the current working directory, named "Linux-Headers".
' As an example, assume the working directory is named h2incz somewhere on
' the current drive: i.e.:
' c:\..\h2incz
'
' the files required to reside in the working directory would be:
' bxbasic.exe,
' h2incz.bas and
' headers.txt.
'
' 3) Next, create a subdirectory named: "Linux-Headers"
' c:\..\h2incz\Linux-Headers
'
' Store copies of the gcc headers to be processed into that subdirectory.
'
' 4) Create a second subdirectory and name it: "Linux-Inc".
' This is where the translated files will be stored.
' c:\..\h2incz\Linux-Inc
'
' 5) To run, from the command-line, type:
' bxbasic h2incz
'
'
' Anywhere from 1 to 100 (or more) header files may be processed this way.
'
' The resulting output files will be usable, but, not in their entirety in
' the outputted format. Many items, will be commented-out, with the
' exception of function prototypes. Includes, defines and possibly other
' things will be commented-out. Since the main objective of this program
' is to provide usable function prototypes, that is where the main focus of
' the output files will be placed.
'
' Those items which are commented-out can be un-commented and tested
' individually. The reason for this is that many define statements are
' subject to conditional statements and in some cases do not apply in a
' given context.
'
' It should be understood, (by the user), that GCC (as do most C compilers)
' uses a preprocessor to read, parse and interpret the C header files. This
' small program is in no way a preprecessor and falls far short of
' interpreting the meaning and context of the statements contained in the
' header files. This simple program simply strips-out and dumps what
' information may be useful to the Assembly Language programmer.
'
' **NOTE:
' The prototypes and equate statements generated are purely theoretical.
' Most of the files generated by this program are untested. There are just
' too many header files contained in the GCC LIBC to be able to test them
' all in the time I have available.
' Should you find errors (and I am sure there will be several), in the
' output files, please let me know, so that I can make corrections to the
' program.
' Thanks, Steve.
'