You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

secTypes.cxx 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved.
  2. *
  3. * This is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This software is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this software; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  16. * USA.
  17. */
  18. #include <string.h>
  19. #ifdef _WIN32
  20. #define strcasecmp _stricmp
  21. #endif
  22. #include <rfb/secTypes.h>
  23. #include <rfb/util.h>
  24. int rfb::secTypeNum(const char* name)
  25. {
  26. if (strcasecmp(name, "None") == 0) return secTypeNone;
  27. if (strcasecmp(name, "VncAuth") == 0) return secTypeVncAuth;
  28. if (strcasecmp(name, "Tight") == 0) return secTypeTight;
  29. if (strcasecmp(name, "RA2") == 0) return secTypeRA2;
  30. if (strcasecmp(name, "RA2ne") == 0) return secTypeRA2ne;
  31. return secTypeInvalid;
  32. }
  33. const char* rfb::secTypeName(int num)
  34. {
  35. switch (num) {
  36. case secTypeNone: return "None";
  37. case secTypeVncAuth: return "VncAuth";
  38. case secTypeTight: return "Tight";
  39. case secTypeRA2: return "RA2";
  40. case secTypeRA2ne: return "RA2ne";
  41. default: return "[unknown secType]";
  42. }
  43. }
  44. bool rfb::secTypeEncrypts(int num)
  45. {
  46. switch (num) {
  47. case secTypeRA2: return true;
  48. default: return false;
  49. }
  50. }
  51. std::list<int> rfb::parseSecTypes(const char* types_)
  52. {
  53. std::list<int> result;
  54. CharArray types(strDup(types_)), type;
  55. while (types.buf) {
  56. strSplit(types.buf, ',', &type.buf, &types.buf);
  57. int typeNum = secTypeNum(type.buf);
  58. if (typeNum != secTypeInvalid)
  59. result.push_back(typeNum);
  60. }
  61. return result;
  62. }