home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / ibm / AIX / AIXinit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-16  |  2.6 KB  |  103 lines

  1. /*
  2.  * $XConsortium: AIXinit.c,v 1.3 91/07/16 12:56:15 jap Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1988,1989,1990,1991
  5.  *
  6.  * All Rights Reserved
  7.  *
  8.  * License to use, copy, modify, and distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted,
  10.  * provided that the above copyright notice appear in all copies and that
  11.  * both that copyright notice and this permission notice appear in
  12.  * supporting documentation, and that the name of IBM not be
  13.  * used in advertising or publicity pertaining to distribution of the
  14.  * software without specific, written prior permission.
  15.  *
  16.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  17.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND 
  18.  * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
  19.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  20.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  21.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  22.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  23.  * SOFTWARE.
  24.  *
  25. */
  26.  
  27. #include <fcntl.h>
  28. #include <sys/hft.h>
  29.  
  30. #include "Xmd.h"
  31. #include "miscstruct.h"
  32. #include "scrnintstr.h"
  33. #include "cursor.h"
  34. #include "ibmScreen.h"
  35. #include "OSio.h"
  36. #include "hftQueue.h"
  37.  
  38. #include "ibmTrace.h"
  39.  
  40. void
  41. ibmMachineDependentInit()
  42. {
  43.     TRACE(("ibmMachineDependentInit()\n"));
  44.  
  45.     hftInitQueue(AIXDefaultDisplay,FALSE);
  46.     RemoveEnabledDevice(hftQFD);
  47.     return;
  48. }
  49.  
  50. /***==================================================================***/
  51.  
  52. #if !defined(FORCE_DISPLAY_NUMBER)
  53.  
  54. #if !defined(MAX_SERVER_NUM)
  55. #define MAX_SERVER_NUM 255
  56. #endif
  57.  
  58. #include <sys/socket.h>
  59. #include <sys/un.h>
  60. #include <netinet/in.h>
  61.  
  62. #include <errno.h>
  63. #include <sys/wait.h>
  64.  
  65. #include "Xproto.h"
  66.  
  67. int AIXTCPSocket= -1;
  68. static char dummy[20];
  69.  
  70. extern char *display ;
  71.  
  72. void
  73. AIXFindServerIndex()
  74. {
  75. struct sockaddr_in insock ;
  76. int sockNum, sockFD ;
  77.  
  78.     if ((sockFD = socket (AF_INET, SOCK_STREAM, 0)) < 0) {
  79.     Error("creating TCP socket (in FindATCPSocket)\n",NULL);
  80.     display= "0";
  81.     return;
  82.     }
  83.  
  84.     bzero( (char *)&insock, sizeof insock );
  85.     insock.sin_family = AF_INET;
  86.     insock.sin_addr.s_addr = htonl(INADDR_ANY);
  87.  
  88.     for ( sockNum = 0 ; sockNum < MAX_SERVER_NUM ; sockNum++ ) {
  89.     insock.sin_port = htons( X_TCP_PORT + sockNum ) ;
  90.     if ( bind( sockFD, (struct sockaddr *) &insock, sizeof insock ) ) {
  91.         if (errno!=EADDRINUSE) {
  92.         display= "0";
  93.         return;
  94.         }
  95.     }
  96.     else break;
  97.     }
  98.     AIXTCPSocket= sockFD;
  99.     (void) sprintf( display = dummy, "%d", sockNum ) ;
  100.     return;
  101. }
  102. #endif /* FORCE_DISPLAY_NUMBER */
  103.