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.

166 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. fc.hxx
  5. Abstract:
  6. This module contains the definition for the FC class, which
  7. implements the DOS5-compatible FC utility.
  8. Author:
  9. Ramon Juan San Andres (ramonsa) 01-May-1990
  10. Revision History:
  11. --*/
  12. #if !defined( _FC_ )
  13. #define _FC_
  14. #include "object.hxx"
  15. #include "program.hxx"
  16. #include "path.hxx"
  17. #include "wstring.hxx"
  18. extern "C" {
  19. #include <stdio.h>
  20. }
  21. //
  22. // Define DEBUG for debug support
  23. //
  24. // #define DEBUG
  25. //
  26. // Maximum file name size
  27. //
  28. #define MAXFNAME 80
  29. //
  30. // Maximum line size
  31. //
  32. #define MAXLINESIZE 128
  33. //
  34. // Exit codes
  35. //
  36. #define FAILURE -1
  37. #define SUCCESS 0x0
  38. #define FILES_ARE_DIFFERENT 0x1
  39. #define FILES_NOT_FOUND 0x2
  40. #define FILES_OFFLINE 0x4
  41. typedef struct lineType {
  42. INT line; // line number
  43. union {
  44. CHAR text[MAXLINESIZE]; // body of line
  45. WCHAR wtext[MAXLINESIZE]; // body of line
  46. };
  47. } LINETYPE, *PLINETYPE;
  48. DECLARE_CLASS( STREAM );
  49. DECLARE_CLASS( FC );
  50. class FC : public PROGRAM {
  51. public:
  52. DECLARE_CONSTRUCTOR( FC );
  53. NONVIRTUAL ~FC ();
  54. INT Fcmain ();
  55. BOOLEAN Initialize();
  56. BOOLEAN ParseArguments();
  57. INT BinaryCompare(PCWSTRING f1, PCWSTRING f2);
  58. BOOLEAN compare(int l1,int s1,int l2,int s2,int ct);
  59. INT LineCompare(PCWSTRING f1, PCWSTRING f2);
  60. INT RealLineCompare(PCWSTRING f1, PCWSTRING f2,
  61. PSTREAM Stream1, PSTREAM Stream2);
  62. int xfill(struct lineType *pl,PSTREAM Stream,int ct,int *plnum);
  63. int adjust(struct lineType *pl,int ml,int lt);
  64. void dump(struct lineType *pl,int start,int end);
  65. void pline(struct lineType *pl);
  66. INT ParseFileNames();
  67. INT comp(PCWSTRING, PCWSTRING);
  68. static char *strbscan (char *p, char *s);
  69. static char *strbskip (char *p, char *s);
  70. // static int fgetl(char *buf,int len, FILE *fh);
  71. static int extention (char *src, char *dst);
  72. static int filename (char *src, char *dst);
  73. private:
  74. int ctSync; /* number of lines required to sync */
  75. int cLine ; /* number of lines in internal buffs */
  76. BOOLEAN fUnicode; /* UNICODE text file compare */
  77. BOOLEAN fAbbrev ; /* abbreviated output */
  78. BOOLEAN fBinary ; /* binary comparison */
  79. BOOLEAN fLine ; /* line comparison */
  80. BOOLEAN fNumb ; /* display line numbers */
  81. BOOLEAN fCase ; /* case is significant */
  82. BOOLEAN fIgnore ; /* ignore spaces and blank lines */
  83. BOOLEAN fExpandTabs;
  84. BOOLEAN fSkipOffline; /* skip offline files */
  85. BOOLEAN fOfflineSkipped; /* if offline files were skipped */
  86. #ifdef DEBUG
  87. BOOLEAN fDebug ;
  88. #endif
  89. int (*funcRead) (char *buf,int len,FILE *fh); /* function to use to read lines */
  90. INT (*fCmp) (IN PSTR, IN PSTR); /* function to use to compare lines */
  91. INT (*fCmp_U) (IN PWSTR, IN PWSTR); /* function to use to compare lines */
  92. struct lineType *buffer1;
  93. struct lineType *buffer2;
  94. CHAR line[MAXLINESIZE]; /* single line buffer */
  95. CHAR **extBin;
  96. PATH _File1;
  97. PATH _File2;
  98. };
  99. INLINE
  100. char *FC::strbscan (char *p, char *s)
  101. {
  102. return p + strcspn(p,s);
  103. }
  104. INLINE
  105. char *FC::strbskip (char *p, char *s)
  106. {
  107. return p + strspn(p,s);
  108. }
  109. #endif //FC