Clients.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*******************************************************************************
  2. * Copyright (c) 2009, 2022 IBM Corp.
  3. *
  4. * All rights reserved. This program and the accompanying materials
  5. * are made available under the terms of the Eclipse Public License v2.0
  6. * and Eclipse Distribution License v1.0 which accompany this distribution.
  7. *
  8. * The Eclipse Public License is available at
  9. * https://www.eclipse.org/legal/epl-2.0/
  10. * and the Eclipse Distribution License is available at
  11. * http://www.eclipse.org/org/documents/edl-v10.php.
  12. *
  13. * Contributors:
  14. * Ian Craggs - initial API and implementation and/or initial documentation
  15. * Ian Craggs - add SSL support
  16. *******************************************************************************/
  17. /**
  18. * @file
  19. * \brief functions which apply to client structures
  20. * */
  21. #include "Clients.h"
  22. #include <string.h>
  23. #include <stdio.h>
  24. /**
  25. * List callback function for comparing clients by clientid
  26. * @param a first integer value
  27. * @param b second integer value
  28. * @return boolean indicating whether a and b are equal
  29. */
  30. int clientIDCompare(void* a, void* b)
  31. {
  32. Clients* client = (Clients*)a;
  33. /*printf("comparing clientdIDs %s with %s\n", client->clientID, (char*)b);*/
  34. return strcmp(client->clientID, (char*)b) == 0;
  35. }
  36. /**
  37. * List callback function for comparing clients by socket
  38. * @param a first integer value
  39. * @param b second integer value
  40. * @return boolean indicating whether a and b are equal
  41. */
  42. int clientSocketCompare(void* a, void* b)
  43. {
  44. Clients* client = (Clients*)a;
  45. /*printf("comparing %d with %d\n", (char*)a, (char*)b); */
  46. return client->net.socket == *(SOCKET*)b;
  47. }