home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / fonts / server / os / access.c next >
Encoding:
C/C++ Source or Header  |  1993-07-21  |  2.9 KB  |  101 lines

  1. /* $XConsortium: access.c,v 1.6 92/06/01 17:07:58 gildea Exp $ */
  2. /*
  3.  * Copyright 1990, 1991 Network Computing Devices;
  4.  * Portions Copyright 1987 by Digital Equipment Corporation and the
  5.  * Massachusetts Institute of Technology
  6.  *
  7.  * Permission to use, copy, modify, distribute, and sell this software and
  8.  * its documentation for any purpose is hereby granted without fee, provided
  9.  * that the above copyright notice appear in all copies and that both that
  10.  * copyright notice and this permission notice appear in supporting
  11.  * documentation, and that the names of Network Computing Devices, Digital or
  12.  * M.I.T. not be used in advertising or publicity pertaining to distribution
  13.  * of the software without specific, written prior permission.
  14.  *
  15.  * NETWORK COMPUTING DEVICES, DIGITAL AND M.I.T. DISCLAIM ALL WARRANTIES WITH
  16.  * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  17.  * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES,
  18.  * DIGITAL OR M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  19.  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  20.  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  21.  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
  22.  * THIS SOFTWARE.
  23.  */
  24.  
  25. #include        <sys/param.h>
  26. #include    <sys/types.h>
  27. #include    <sys/socket.h>
  28. #include    <netdb.h>
  29. #include    <netinet/in.h>
  30. #include    "clientstr.h"
  31. #include    "misc.h"
  32. #include    "site.h"
  33. #include    "accstr.h"
  34. #include    "osdep.h"
  35.  
  36. long        MaxClients = DEFAULT_CLIENT_LIMIT;
  37.  
  38. void
  39. AccessSetConnectionLimit(num)
  40.     int         num;
  41. {
  42.     num++;    /* take serverClient into account */
  43.     if (num > MAXSOCKS) {
  44.     ErrorF("Client limit of %d too high; using default of %d\n",
  45.            num, DEFAULT_CLIENT_LIMIT);
  46.     return;
  47.     }
  48.     MaxClients = num;
  49. }
  50.  
  51. /*
  52.  * XXX
  53.  *
  54.  * needs massive amounts of OS-dependent work (big surprise)
  55.  */
  56. int
  57. GetHostAddress(addr)
  58.     HostAddress *addr;
  59. {
  60.     char        hname[64];
  61.     struct hostent *hp;
  62.  
  63.     addr->addr_len = sizeof(struct in_addr);
  64.     addr->address = (pointer) fsalloc(addr->addr_len);
  65.     if (!addr->address)
  66.     return FSBadAlloc;
  67.     addr->type = HOST_AF_INET;
  68.     gethostname(hname, sizeof(hname));
  69.     hp = gethostbyname(hname);
  70.     if (hp) {
  71.     bcopy((char *) hp->h_addr, (char *) addr->address, addr->addr_len);
  72.     } else {
  73.     fsfree((char *) addr->address);
  74.     return FSBadName;
  75.     }
  76.     return FSSuccess;
  77. }
  78.  
  79. /* ARGSUSED */
  80. int
  81. CheckClientAuthorization(client, client_auth, accept, index, size, auth_data)
  82.     ClientPtr   client;
  83.     AuthPtr     client_auth;
  84.     int        *accept;
  85.     int        *index;
  86.     int        *size;
  87.     char      **auth_data;
  88. {
  89.     OsCommPtr    oc;
  90.  
  91.     /* now that it's connected, zero the connect time
  92.        so it doesn't get killed */
  93.     oc = (OsCommPtr)client->osPrivate;
  94.     oc->conn_time = 0;
  95.  
  96.     *size = 0;
  97.     *accept = AuthSuccess;
  98.     *index = 0;            /* we support no authorization protocols */
  99.     return FSSuccess;
  100. }
  101.