void rfbProcessClientAuthType(rfbClientPtr cl)
{
  CARD32 auth_type;
  int n, i;
  AuthCapData **p;
  AuthCapData *c;

  /* Read authentication type selected by the client */
  n = ReadExact(cl, (char *)&auth_type, sizeof(auth_type));
  if (n <= 0) {
    if (n == 0)
      rfbLog("rfbProcessClientAuthType: client gone\n");
    else
      rfbLogPerror("rfbProcessClientAuthType: read");
    rfbCloseClient(cl);
    return;
  }
  auth_type = Swap32IfLE(auth_type);

  /* Make sure it was present in the list sent by the server */
  for (i = 0; i < cl->nAuthCaps; i++) {
    if (auth_type == cl->authCaps[i])
      break;
  }
  if (i >= cl->nAuthCaps) {
    rfbLog("rfbProcessClientAuthType: wrong authentication type requested\n");
    rfbCloseClient(cl);
    return;
  }

  for (p = authCaps; *p != NULL; p++) {
    c = *p;
    if (auth_type == c->authType) {
      cl->selectedAuthType = auth_type;
      c->startFunc(cl);
      return;
    }
  }

  rfbLog("rfbProcessClientAuthType: unknown authentication scheme\n");
  rfbCloseClient(cl);
}
void rfbProcessClientAuthType(rfbClientPtr cl)
{
  CARD32 auth_type;
  int n, i;
  AuthCapData **p;
  AuthCapData *c;

   
  n = ReadExact(cl, (char *)&auth_type, sizeof(auth_type));
  if (n <= 0) {
    if (n == 0)
      rfbLog("rfbProcessClientAuthType: client gone\n");
    else
      rfbLogPerror("rfbProcessClientAuthType: read");
    rfbCloseClient(cl);
    return;
  }
  auth_type = Swap32IfLE(auth_type);

   
  for (i = 0; i < cl->nAuthCaps; i++) {
    if (auth_type == cl->authCaps[i])
      break;
  }
  if (i >= cl->nAuthCaps) {
    rfbLog("rfbProcessClientAuthType: wrong authentication type requested\n");
    rfbCloseClient(cl);
    return;
  }

  for (p = authCaps; *p != NULL; p++) {
    c = *p;
    if (auth_type == c->authType) {
      cl->selectedAuthType = auth_type;
      c->startFunc(cl);
      return;
    }
  }

  rfbLog("rfbProcessClientAuthType: unknown authentication scheme\n");
  rfbCloseClient(cl);
}