Cobol Chaining in C (Was Re: strings & function addresses)

Mike Albaugh albaugh at dms.UUCP
Thu Nov 1 05:40:49 AEST 1990


>From article <1990Oct26.211532.27626 at unislc.uucp>, by ttobler at unislc.uucp (Trent Tobler):
> From article <3785 at wb3ffv.ampr.org>, by wmark at wb3ffv.ampr.org (Mark Winsor):
>> 
>>   I need to write a C front end for a cobol application. The cobol programs
>> will return a string that is the name of the next program to call which is
>> representing a C function. I need a way to associate that string with the 
>> function address, anybody have any ideas? Please don't suggest I rewrite the
>> application in C, time doesn't allow that option.
>> 
> 
> I'm not sure I understand the question, but as I understand it, you require
> a 'C' function to be associated with a string?  If you can get that to a 
> 'C' string, you can use either an array or linked list of structures with
> a string and a function pointer.  Here is an examples, using arrays...

	Not to pick on Trent, and lord knows I am _not_ a COBOL guru, but
I believe that this and the other similar responses miss the _intent_
of Mark's question. COBOL provides a standard way to "call" a function
(which may be in another "module", or whatever their term) by name, sort
or like exec*() in *nix, but with the syntax and semantics defined in
the language, and with perhaps more guarantees. An implementation may or
may not provide this feature, but if they do, they have to support specific
semantics. I am not at all sure that *nix can provide this function at all,
or that Mark is trying to do it on *nix, but if so he should ask on the
unix groups, where variants of this question regularly come up in regard
to dynamic loading of libraries and LISP implementations. The answer is
typically "There is no portable way" (even portable across unices), but
you can usually grub around in the symbol table if you know your a.out
format and your binaries have not been stripped. In any case:

1) This is almost certainly an OS, rather than C question.
2) It is a whole lot of pain, and non-portable
3) Mark may not even be on unix, but there _may_ be an os-specific hack.

	Oh, yeah, the sub-set problem of when you have an exhaustive list
of all possible function names is amenable to munging the various relevant
files and then using the techniques discussed in this thread so far, but
it can lead to huge binaries :-) Of course, he said "next program to call",
so some lessons on exec* _may_ do the trick, but that's still more of
an OS than C question.

					Mike

| Mike Albaugh (albaugh at dms.UUCP || {...decwrl!pyramid!}weitek!dms!albaugh)
| Atari Games Corp (Arcade Games, no relation to the makers of the ST)
| 675 Sycamore Dr. Milpitas, CA 95035		voice: (408)434-1709
| The opinions expressed are my own (Boy, are they ever)



More information about the Comp.lang.c mailing list