Leaked source code of windows server 2003
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.

111 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1994-1999 Microsoft Corporation
  3. Module Name :
  4. strfrn.h
  5. Abstract:
  6. String Functions
  7. Author:
  8. Aaron Lee (aaronl)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #ifndef _STRVALID_H
  14. #define _STRVALID_H
  15. #define IS_FLAG_SET(dw, flag) ((((dw) & (flag)) != 0) ? TRUE : FALSE)
  16. #define FLAG_IS_NOT_SET(dw, flag) ((((dw) & (flag)) == 0) ? TRUE : FALSE)
  17. #define SET_FLAG(dw, flag) dw |= (flag)
  18. // FAILURE values are 32 bit values layed out as follows:
  19. //
  20. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  21. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  22. // +-+-------+---------------------+-------------------------------+
  23. // |S|0000000|General | Code |
  24. // +-+-------+---------------------+-------------------------------+
  25. //
  26. // where
  27. // S - Severity - indicates success/fail
  28. // 0 - Success, 1 - Fail (COERROR)
  29. // 0 - NOT USED AT ALL
  30. // General - is the General error code area
  31. // Code - is the error code
  32. typedef long FILERESULT;
  33. // success or error
  34. #define SEVERITY_SUCCESS 0
  35. #define SEVERITY_ERROR 1
  36. // Construct a code
  37. #define MAKE_FILERESULT(sev,fac,code) \
  38. ((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
  39. // Allowed:
  40. // These need to be allow rather than "not allow" flags,
  41. // the reason is that the caller must specifically specify
  42. // what they expect. Whereas if we changed the function
  43. // to check for more stuff, we won't break code which specially
  44. // says what they want....
  45. #define CHKPATH_ALLOW_RELATIVE_PATH 0x00000001
  46. #define CHKPATH_ALLOW_DEVICE_PATH 0x00000002
  47. #define CHKPATH_ALLOW_UNC_PATH 0x00000004
  48. #define CHKPATH_ALLOW_UNC_SERVERNAME_ONLY 0x00000008
  49. #define CHKPATH_ALLOW_UNC_SERVERSHARE_ONLY 0x00000010
  50. #define CHKPATH_ALLOW_MAX 0x0000001F
  51. // Charset:
  52. #define CHKPATH_CHARSET_GENERAL 0x00000001
  53. #define CHKPATH_CHARSET_GENERAL_NO_COMMA 0x00000002
  54. #define CHKPATH_CHARSET_GENERAL_ALLOW_QUESTION 0x00000004
  55. #define CHKPATH_CHARSET_MAX 0x00000007
  56. // Returned failures:
  57. // E_INVALIDARG if a bad parameter was sent
  58. #define CHKPATH_FAIL_INVALID_LENGTH 0x00100000
  59. #define CHKPATH_FAIL_INVALID_EMPTY 0x80100101
  60. #define CHKPATH_FAIL_INVALID_TOO_LONG 0x80100102
  61. //
  62. #define CHKPATH_FAIL_INVALID_CHARSET 0x00200000
  63. #define CHKPATH_FAIL_INVALID_CHARSET_GENERAL 0x80200201
  64. #define CHKPATH_FAIL_INVALID_CHARSET_FOR_DIR 0x80200202
  65. #define CHKPATH_FAIL_INVALID_CHARSET_FOR_FILE 0x80200203
  66. #define CHKPATH_FAIL_INVALID_CHARSET_FOR_UNC 0x80200204
  67. //
  68. #define CHKPATH_FAIL_INVALID_PARTS 0x00400000
  69. #define CHKPATH_FAIL_INVALID_BAD_DRIVE_PART 0x80400301
  70. #define CHKPATH_FAIL_INVALID_BAD_DIR_PART 0x80400302
  71. #define CHKPATH_FAIL_INVALID_BAD_FILE_PART 0x80400303
  72. #define CHKPATH_FAIL_INVALID_BAD_UNC_PART 0x80400304
  73. #define CHKPATH_FAIL_INVALID_BAD_PATH 0x80400305
  74. //
  75. #define CHKPATH_FAIL_NOT_ALLOWED 0x00800000
  76. #define CHKPATH_FAIL_NOT_ALLOWED_FILE_PATH 0x80800401
  77. #define CHKPATH_FAIL_NOT_ALLOWED_DIR_PATH 0x80800402
  78. #define CHKPATH_FAIL_NOT_ALLOWED_RELATIVE_PATH 0x80800403
  79. #define CHKPATH_FAIL_NOT_ALLOWED_DEVICE_PATH 0x80800404
  80. #define CHKPATH_FAIL_NOT_ALLOWED_UNC_PATH 0x80800405
  81. #define CHKPATH_FAIL_NOT_ALLOWED_UNC_SERVERNAME 0x80800406
  82. #define CHKPATH_FAIL_NOT_ALLOWED_UNC_SERVERSHARE 0x80800407
  83. #define CHKPATH_FAIL_NOT_ALLOWED_DIR_NOT_EXIST 0x80800408
  84. // commas are valid dir/filenames
  85. //
  86. #define CHKPATH_INVALID_CHARSET_GENERAL _T("|<>/*?\t\r\n")
  87. #define CHKPATH_INVALID_CHARSET_COMMA _T(",")
  88. #define CHKPATH_INVALID_CHARSET_QUESTION _T("?")
  89. #define CHKPATH_WANT_FILE 1
  90. #define CHKPATH_WANT_DIR 2
  91. FILERESULT COMDLL MyValidatePath(LPCTSTR path,BOOL bLocal,INT iPathTypeWanted,DWORD dwAllowedFlags,DWORD dwCharSetFlags);
  92. #endif // _STRVALID_H