# Porting an old UNIX application to FreeBSD 9.0 64bit



## lucky7456969 (Sep 10, 2012)

Hi,
I've got a piece of software that was written with curses in 1994.
At that time, I think curses has no function called "box".
My application defined a function called "box"
So that these symbols collided.
How would I "shadow" the curses' box function and make use of my own box function with the cc compiler?
Thanks
Jack


----------



## wblock@ (Sep 10, 2012)

Rename the custom box function, both where it's defined and where it's called from the application.


----------



## fluca1978 (Sep 10, 2012)

Assuming you need to use both old and current libraries in different installations, and that your code i written in C, you can use a pragma like _#ifdef_ to define your _box_ function if the library is old, and rename it to a new function if using the new libraries. But probably this is an extra effort that you don't need, and therefore simply renaming the function will give you a cleaner result.


----------



## lucky7456969 (Sep 11, 2012)

Hello guys,
Thanks for your responses.

Here I've an errors I am not quite sure how to resolve while preserving the original program behaviour.


I've got a prototype at the very beginning of my module

u_short htons();

the error is 
tcp.c:8: error: expected ')' before '?' token

What would I do to solve this problem since I don't have any '?' token written down on that line.


----------



## xibo (Sep 11, 2012)

The name htons(3) is already defined in netinet/in.h that you probably include to tcp.c.
The htons defined in the system header however is not a regular function but a macro instead, which uses the ?-Operator to decide whether a permutation of its' parameter is required or not.

To resolve this, rename the htons function and all calls to it.


----------



## lucky7456969 (Sep 11, 2012)

Thanks xibo,
I don't remember what I should rename it to as my memory worn out.
BTW: how do I locate where netinet/in.h is?
I try whereis in.h to no avail.


----------



## numpad5 (Sep 11, 2012)

The link he posted to the manpage on the function says its in standard library, so should just be in its folder in include.

He didn't suggest that you get rid of the h file though, he was saying rename it in your program, so you wouldn't have to touch the standard library files.

As a side note, have you tried just getting the older version of curses to compile and using LD_PRELOAD before the appname to run it?

Seems like that might be easier, if the old version compiles.


----------



## lucky7456969 (Sep 17, 2012)

I can't seem find a old version of curses.

https://www.google.com/search?q=cur...imvnsa&ei=r_JWUIDvNK-4iAeJ6oC4CQ&start=0&sa=N

Any public archives I can look?


----------

