Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for client.c




Patch for systems which lack the gethostname(3) library call.
You might want to remove the prototypes for some function calls.
I've stopped using sunos.h, osf.h and sgi.h since I mean it's a
waste of resources to include those files in all the c files.

Kjetil

diff -cr crossfire-0.90.2-patched/client/client.c crossfire-0.90.2/client/client.c
*** crossfire-0.90.2-patched/client/client.c	Thu Mar 10 13:44:16 1994
--- crossfire-0.90.2/client/client.c	Fri Mar 11 20:18:26 1994
***************
*** 41,46 ****
--- 41,49 ----
  #include <X11/Xlib.h>
  #include <pwd.h>
  #ifdef linux
+ #if defined(__sgi) && defined(SVR4)
+ #include <sys/systeminfo.h>
+ #endif
  # include <stdlib.h>
  # include <malloc.h>
  #endif
***************
*** 53,58 ****
--- 56,92 ----
  # endif
  #endif
  
+ #if defined(__osf__) && !defined(__alpha)
+ unsigned short htons(unsigned short);
+ int socket(int, int, int);
+ int gethostname(char *, int);
+ int connect(int, struct sockaddr *, int);
+ #endif
+ #if defined(__sun__) && !defined(SVR4)
+ int socket(int, int, int);
+ int connect(int, struct sockaddr *, int);
+ int gethostname(char *, int);
+ int fprintf(FILE *, char *, ...);
+ int sscanf(char *, char *, ...);
+ void perror(char *);
+ void fflush(FILE *);
+ int system(char *);
+ int fclose(FILE *);
+ int fputs(char *, FILE *);
+ #endif
+ 
+ #ifndef NAME_MAX
+ # ifdef _POSIX_NAME_MAX
+ #  define	NAME_MAX	pathconf("/dev/null", _POSIX_NAME_MAX)
+ # else
+ #  ifdef MAXHOSTNAMELEN
+ #   define	NAME_MAX	MAXHOSTNAMELEN
+ #  else
+ #   define	NAME_MAX	256
+ #  endif
+ # endif
+ #endif
+ 
  #include <global.h> /* Sad to include the whole thing, only need libproto.h */
  #include <version.h>
  
***************
*** 178,188 ****
      {
        char localhostname[65+6];
  
!       if (gethostname(localhostname, 65))
!       {
  	fprintf(stderr, "Can't get local hostname.\n");
  	perror("gethostname ");
        }
        sprintf(localdispname, "%s%s", localhostname, dispname);
        dispname = localdispname;
      }
--- 212,228 ----
      {
        char localhostname[65+6];
  
! #ifdef SVR4
!       if (sysinfo(SI_HOSTNAME, localhostname, NAME_MAX) <0) {
! 	fprintf(stderr, "Can't get local hostname.\n");
! 	perror("%s: SI_HOSTNAME");
!       }
! #else   /* Assume BSD */
!       if (gethostname(localhostname, NAME_MAX) < 0) {
  	fprintf(stderr, "Can't get local hostname.\n");
  	perror("gethostname ");
        }
+ #endif  /* SVR4 */
        sprintf(localdispname, "%s%s", localhostname, dispname);
        dispname = localdispname;
      }