Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
auth_update crash
Dec 23, 2017, 10:15 pm
By Remcon
check_tumble
Dec 18, 2017, 7:21 pm
By Remcon
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Yahoo!, Exalead, DotBot

Members: 0
Guests: 9
Stats
Files
Topics
Posts
Members
Newest Member
478
3,708
19,242
612
Jacki72H
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » General Discussions » possible conversion?
Forum Rules | Mark all | Recent Posts

possible conversion?
< Newer Topic :: Older Topic > posted this a few places no help

Pages:<< prev 1 next >>
Post is unread #1 May 2, 2006, 2:10 am   Last edited May 2, 2006, 4:23 am by Samson
Go to the top of the page
Go to the bottom of the page

Slayer

GroupMembers
Posts12
JoinedMar 31, 2005

I downloaded a codebase recently and just trying to compile it... I've corrected all the easy warnings/errors but strike this one I can't really fix...

any help would be appreciated...

this is the code:
void lookup_address(DNS_LOOKUP *darg)
{
  struct hostent *from = 0;
  struct hostent ent;
  char buf[16384]; // enough ??
  int err;

  gethostbyaddr_r( darg->buf, sizeof(darg->buf), AF_INET, &ent, buf, 16384, &from, &err);
  if (from && from->h_name)
  {
    //free_string(darg->d->host);
    darg->d->host = str_dup(from->h_name);
  }
  darg->d->lookup_status++;
  free_string(darg->buf);
  darg->status = 0;
  pthread_exit(0);
}

I use gcc... under unix emulation...

I need to change gethostbyaddr_r() specifically or
rewrite the function so it is unix/posix compatiable?

I searched the web long and far etc and did manage to
post something like this insert infront which allowed
the file... handler.c to actually compile...

int gethostbyaddr_r(const char* addr, size_t length, int format, struct hostent* result, char *buf, size_t buflen, struct hostent **RESULT, int *h_errnop);

but of course, during linking, gethostbyaddr_r() was still undefined... guess I need the functions also in a library I link etc... probably completely wrong way to fix it but I just wanted to get it done to boot up the code...

here is the header of one file so you know what codebase we are dealing with...

I do apologise that it is not this projects real alley but
again help would be nice, thanks guys :)

/***************************************************************************
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik St�rfeldt, Tom Madsen, and Katja Nyboe. *
* *
* Merc Diku Mud improvements copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* *
* ROM 2.4 is copyright 1993-1995 Russ Taylor *
* ROM has been brought to you by the ROM consortium *
* Russ Taylor (rtaylor@pacinfo.com) *
* Gabrielle Taylor (gtaylor@pacinfo.com) *
* Brian Moore (rom@rom.efn.org) *
* ROT 2.0 is copyright 1996-1999 by Russ Walsh *
* DRM 1.0a is copyright 2000-2002 by Joshua Chance Blackwell *
***************************************************************************/
/***************************************************************************
* Shattered Dreams 0.3, 1.0, 2.0 and all future versions of this code *
* are copyright (c) 2004-2005 by Patrick M. Nielsen aka. Rhaelar. *
* *
* WARNING: This computer program is protected by copyright and *
* international treaties. Unauthorized reproduction or distribution *
* of this program, or any portion of it, may result in severe civil *
* and criminal penalties, and will be prosecuted to the maximum *
* extent possible under the law. *
* *
* Rhaelar - rhaelar@gmail.com *
***************************************************************************/
       
Post is unread #2 May 2, 2006, 4:24 am
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002


I use gcc... under unix emulation...


What kind of unix emulation are you referring to?

And could you paste in the compiler errors and such? Without those it's not going to be very clear to most people what is wrong here.
       
Post is unread #3 May 3, 2006, 12:26 am
Go to the top of the page
Go to the bottom of the page

Slayer

GroupMembers
Posts12
JoinedMar 31, 2005

gcc -c -m68060 -Werror -Wall -O0 -ggdb -DNOCRYPT -Dunix handler.c
handler.c: In function `lookup_address':
handler.c:4440: warning: implicit declaration of function `gethostbyaddr_r'
make: *** [handler.o] Error 1

gethostbyaddr_r isn't supported... using google might shine more
light on it...

I said unix emulation for lack of a better definition.

what I use is a smaller subset of NetBSD running under AmigaOS

what I am looking for is a substitute for gethostbyaddr_r ?

can't I replace it with gethostbyaddr (after deleting some of
the arguements?) perhaps or rewrite the above function so it
returns something viable for unix/posix
       
Post is unread #4 May 3, 2006, 5:07 am
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

#include <netdb.h>
#include <sys/socket.h>

Might try adding one or both of those to your handler.c file near the top. An implicit delcaration doesn't mean the function is not supported, just that the compiler didn't see a definition for what it means.

In order to replace the function your code wants with the normal gethostbyaddr, you'd need to remove all of the threading support you code is relying on for DNS lookups. That's generally beyond my knowledge of some of the more obscure Rom derivatives. Removing it would also require specific knowledge of the codebase you're using and might be something to take up with the authors.
       
Post is unread #5 May 4, 2006, 12:42 am
Go to the top of the page
Go to the bottom of the page

Slayer

GroupMembers
Posts12
JoinedMar 31, 2005

ah, sorry, I just assumed you'd understand that gethostbyaddr_r isn't in any of the headers... before I look elsewhere I always check that the source isn't missing a header include...

I have them all joined together in one file for searching purposes... I know I could use grep etc but it's good to see surrounding information at times...

I checked the headers you suggest, the prior has gethostbyaddr but not gethostbyaddr_r and sys/socket doesn't have either...

seems a shame I'm going to have to just hack this some way when everything else comes together nicely...

I really hate that when I compile codebases...

thanks Samson for all your help
       
Post is unread #6 May 4, 2006, 4:57 am   Last edited May 4, 2006, 4:59 am by Noplex
Go to the top of the page
Go to the bottom of the page

Noplex
Apprentice
GroupMembers
Posts62
JoinedAug 30, 2005

"gethostbyaddr_r" seems to be a wrapper function. Grep through the source files and see if you simply need to add an prototype declaration
       
Post is unread #7 May 4, 2006, 5:39 am
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

gethostbyaddr_r is the thread safe way to call gethostbyaddr when you need to do DNS lookups in a multi-threaded app. My experience with this has always been that it just sucks to deal with for a mud codebase. Going multi-threaded always seems to be a disaster when done in muds :)

Best long-term solution would be to remove the multi-threading support entirely and go with some other method for doing DNS lookups if those are really desireable.
       
Post is unread #8 May 5, 2006, 12:26 am
Go to the top of the page
Go to the bottom of the page

Slayer

GroupMembers
Posts12
JoinedMar 31, 2005

prototype?

I'm not a programmer :)

as I said above, I did insert this

int gethostbyaddr_r(const char* addr, size_t length, int format, struct hostent* result, char *buf, size_t buflen, struct hostent **RESULT, int *h_errnop);

prior to the function being called in handler.c (the only time it
is ever used btw) and handler.o was created with no errors... it was
upon linking it complained once again about gethostbyaddr_r being
undefined...

I don't normally touch codebases which have pthread etc but this
codebase looked interesting so I installed the pthread particulars

just looking at the function, could we rewrite it simply to return
something fesible like a failed DNS or would that render the codebase
unbootable?

lets hardcode one? heh...

anyway, thanks again for your help...
       
Post is unread #9 May 5, 2006, 3:29 am
Go to the top of the page
Go to the bottom of the page

Slayer

GroupMembers
Posts12
JoinedMar 31, 2005

welp, after some thought I realised perhaps you mean __P kind of thing done some searching, came up with a few of these, this combo (not // out) seemed to compile handler.c but again upon linking, undefined get<.>_r
I guess we need a library? or?

extern int gethostbyaddr_r __P ((__const char *__addr, int __len, int __type, struct hostent *__result_buf, char *__buf, size_t __buflen, struct hostent **__result, int *__h_errnop));
//extern int gethostbyname_r __P ((__const char *__name, struct hostent *__result_buf, char *__buf, size_t __buflen, struct hostent **__result, int *__h_errnop));

struct hostent *gethostbyname_r(const char *name, struct hostent *result, char *buffer, int buflen, int *h_errnop);

//int gethostbyaddr_r(const char* addr, size_t length, int format, struct hostent* result, char *buf, size_t buflen, struct hostent **RESULT, int *h_errnop);

these lines were placed directly infront of the function being called
       
Pages:<< prev 1 next >>