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.

151 lines
2.8 KiB

  1. #include "config.h"
  2. #include <ctype.h>
  3. #include <io.h>
  4. #include <stdarg.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include "daedef.h"
  8. #include "fmp.h"
  9. #include "util.h"
  10. DeclAssertFile; /* Declare file name for assert macros */
  11. #define StringKey( sz ) {sizeof( sz )-1, sz}
  12. #ifdef DATABASE_FORMAT_CHANGE
  13. const KEY rgkeySTATIC[] = {
  14. StringKey( "" ), // 0
  15. StringKey( "T" ), // 1 TABLES
  16. StringKey( "I" ), // 2 INDEXES
  17. StringKey( "C" ), // 3 COLUMNS
  18. StringKey( "O" ), // 4 OWNED SPACE
  19. StringKey( "A" ), // 5 AVAILABLE SPACE
  20. StringKey( "R" ), // 6 ROOT
  21. StringKey( "D" ), // 7 DATABASES
  22. StringKey( "S" ), // 8 STATISTICS
  23. StringKey( "L" ), // 9 LONG DATA
  24. StringKey( "U" ), // 10 UNIQUE AUTO INCREMENT ID
  25. StringKey( "F" ) // 11 FREE SPACE COMPACTION STATISTICS
  26. };
  27. #else
  28. const KEY rgkeySTATIC[] = {
  29. StringKey( "" ), // 0
  30. StringKey( "TABLES" ), // 1
  31. StringKey( "INDEXES" ), // 2
  32. StringKey( "FIELDS" ), // 3
  33. StringKey( "OWNEXT" ), // 4
  34. StringKey( "AVAILEXT" ), // 5
  35. StringKey( "DATA" ), // 6
  36. StringKey( "DATABASES" ), // 7
  37. StringKey( "STATS" ), // 8
  38. StringKey( "LONG" ), // 9
  39. StringKey( "AUTOINC" ), // 10
  40. StringKey( "OLCSTATS" ) // 11
  41. };
  42. #endif
  43. ERR ErrCheckName( CHAR *szNewName, const CHAR *szName, INT cchName )
  44. {
  45. unsigned cch;
  46. cch = CchValidateName( szNewName, szName, cchName );
  47. if ( cch == 0 )
  48. return JET_errInvalidName;
  49. else
  50. szNewName[cch] = '\0';
  51. return JET_errSuccess;
  52. }
  53. INT CmpStKey( BYTE *stKey, const KEY *pkey )
  54. {
  55. INT s;
  56. INT sDiff;
  57. sDiff = *stKey - pkey->cb;
  58. s = memcmp( stKey + 1, pkey->pb, sDiff < 0 ? (INT)*stKey : pkey->cb );
  59. return s ? s : sDiff;
  60. }
  61. INT CmpPartialKeyKey( KEY *pkey1, KEY *pkey2 )
  62. {
  63. INT cmp;
  64. if ( FKeyNull( pkey1 ) || FKeyNull( pkey2 ) )
  65. {
  66. if ( FKeyNull( pkey1 ) && !FKeyNull( pkey2 ) )
  67. cmp = -1;
  68. else if ( !FKeyNull( pkey1 ) && FKeyNull( pkey2 ) )
  69. cmp = 1;
  70. else
  71. cmp = 0;
  72. }
  73. else
  74. {
  75. cmp = memcmp( pkey1->pb, pkey2->pb, pkey1->cb < pkey2->cb ? pkey1->cb : pkey2->cb );
  76. }
  77. return cmp;
  78. }
  79. #ifdef DEBUG
  80. CHAR *GetEnv2( CHAR *szEnvVar )
  81. {
  82. return getenv( szEnvVar );
  83. }
  84. BOOL fDBGPrintToStdOut = fFalse;
  85. void VARARG PrintF2(const CHAR * fmt, ...)
  86. {
  87. #ifndef WIN16
  88. va_list arg_ptr;
  89. va_start( arg_ptr, fmt );
  90. vprintf( fmt, arg_ptr );
  91. fflush( stdout );
  92. va_end( arg_ptr );
  93. #endif /* !WIN16 */
  94. }
  95. void VARARG FPrintF2(const CHAR * fmt, ...)
  96. {
  97. #ifndef WIN16
  98. FILE *f;
  99. va_list arg_ptr;
  100. va_start( arg_ptr, fmt );
  101. if ( fDBGPrintToStdOut )
  102. {
  103. vprintf( fmt, arg_ptr );
  104. fflush( stdout );
  105. }
  106. else
  107. {
  108. f = fopen( "jet.txt","a+");
  109. vfprintf( f, fmt, arg_ptr );
  110. fflush( f );
  111. fclose( f );
  112. }
  113. va_end( arg_ptr );
  114. #endif /* !WIN16 */
  115. }
  116. #endif /* DEBUG */
  117.