Hey fellas,

I'm posting the H2INC program I recently created in good ol' fat C++ for DOS. It doesn't really do wonders but it did save me from doing 70%-90% of the work involved in translating the TAPI.h constants and structs to assembler.


1. Excellent translation of constants. Perfectly translated all the constants in TAPI.h (after many hours of improving it).
2. Good translation of structures. It will handle everything except structs in structs and/or unions in structs. On the other hand, it can be completely messed up by any struct whose name starts with _ or __ so make the necessary editing ahead of time.
3. Completely ignores API protos (I created this proggie because I wanted to translate structs and constants).
4. Features good translation of compiler directives. I added this feature because TAPI structs differ among various versions of TAPI. You might find it useful too.

I've only used this proggie to translate TAPI.h, so I don't know if it will work equally well when translating other .h files. One thing is certain: you need to go through the output file and copy only those structs, constants and directives that are needed. This program doesn't filter out all those useless # directives that you generally encounter in the .h files. It's up to you to look and determine what's gold and what's garbage .

You might ask why I didn't make this perfect. I'll tell you that I was only interested in translating one file. I could do it manually or I could build a program. I chose to build a program because I realized I could do this in less time than the time needed to manually edit the file. However, when the program started to do most of the work I had to stop and ask myself if I should further improve it or if I should simply do the work manually. To make the proggie perfect would have taken much more time than to edit the file, so I stopped improving the proggie and I manually edited the rest.

In addition to the time advantage, I also realized that the search and replace approach that I had taken was not good enough. I was looking at these .h files like a human, and working with lines of text that ended in a line return. A better approach would have been to look at the files like a compiler and use aditional symbols such as ; { } to create lines. I could have also compacted the file by eliminating comments and reducing all spacing between "words" to the bare minimum of a single space. Nevertheless, my proggie worked with regular lines of text, so it could be fooled by weird, unconventional spacing that a C++ compiler could swallow with no problem.

Will I build a better compiler-like version? Maybe, but only when I finish all the projects I want to finish :tongue: . Until then, you can use this proggie for anything you want with no restrictions whatsoever :alright: .


P.S. Spare my life valiant crusaders! :rolleyes: :tongue: :alright:
Posted on 2002-03-23 12:56:37 by Lysic
Hi, Lysic!

Your program seems to me very pretty. I am not sure that this record was written properly (a little piece from Mapi.inc):
typedef struct
ULONG ulReserved COMMENT % Reserved, must be zero. %
ULONG cbTag COMMENT % Size (in bytes) of %
LPBYTE lpTag COMMENT % X.400 OID for this attachment type %
ULONG cbEncoding COMMENT % Size (in bytes) of %
LPBYTE lpEncoding COMMENT % X.400 OID for this attachment's encoding %
} MapiFileTagExt, FAR *lpMapiFileTagExt
but program is very useful.

Regards, Mike
Posted on 2002-03-25 06:17:27 by Mike

There are way too many things that I can point to... which are not going great at all.

All this proggie wants to do is save you some editing. If you analyze its output closely and u get where it goes wrong with files, you might be able to get even more out of it by doing particular edits on the input file. But it's never gonna be perfect. It wasn't meant to be.


Posted on 2002-03-25 15:31:33 by Lysic
Just looked at your output more closely, and i noticed that the structs were not translated.

What probably happened is that the proggie didn't recognize the end of a structure in the file, somewhere above the structure you posted. As a reult, the rest of the structs were no longer translated. Find the structure that messed it up, and do the necessary edits on the input, .h file. It might be that the structure has one or more _ in front of its name. Remove them. There might also be other causes, which I haven't found yet. If you have a c++ compiler, look in the code for the debugging loop and read the comments i have made about it. Use that debugging loop to get at the problem by analyzing what's happening in real time.
Posted on 2002-03-25 15:37:01 by Lysic
Thank you Lysic!
Lvp now was downloaded and program have been seen. I work with BC ++ 5.02; it compile all normally (only exe has become slightly more) but I need a time to understand algorithm. I never wrote before any parser because I am network administrator so my problems differ from text processing. But this problem is very interesting for me as programmer; may be I'll find out some free time...

Regards, Mike
Posted on 2002-03-26 09:29:14 by Mike

Thanks Lysic it is a real time saver for me. I have used it to convert TAPI.
Posted on 2003-05-09 03:22:27 by shiny