ReactOS  0.4.15-dev-4917-g934e521
fc.h
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS FC Command
3  * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE: Comparing files
5  * COPYRIGHT: Copyright 2021 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6  */
7 #pragma once
8 #include <stdlib.h>
9 #include <string.h>
10 #include <ctype.h>
11 #ifdef __REACTOS__
12  #include <windef.h>
13  #include <winbase.h>
14  #include <winuser.h>
15  #include <winnls.h>
16 #else
17  #include <windows.h>
18 #endif
19 #include <wine/list.h>
20 #include "resource.h"
21 
22 // See also: https://stackoverflow.com/questions/33125766/compare-files-with-a-cmd
23 typedef enum FCRET // return code of FC command
24 {
29  FCRET_NO_MORE_DATA = 3 // (extension)
30 } FCRET;
31 
32 typedef struct NODE_W
33 {
34  struct list entry;
36  LPWSTR pszComp; // compressed
39 } NODE_W;
40 typedef struct NODE_A
41 {
42  struct list entry;
44  LPSTR pszComp; // compressed
47 } NODE_A;
48 
49 #define FLAG_A (1 << 0) // abbreviation
50 #define FLAG_B (1 << 1) // binary
51 #define FLAG_C (1 << 2) // ignore cases
52 #define FLAG_L (1 << 3) // ASCII mode
53 #define FLAG_LBn (1 << 4) // line buffers
54 #define FLAG_N (1 << 5) // show line numbers
55 #define FLAG_OFFLINE (1 << 6) // ???
56 #define FLAG_T (1 << 7) // prevent fc from converting tabs to spaces
57 #define FLAG_U (1 << 8) // Unicode
58 #define FLAG_W (1 << 9) // compress white space
59 #define FLAG_nnnn (1 << 10) // ???
60 #define FLAG_HELP (1 << 11) // show usage
61 
62 typedef struct FILECOMPARE
63 {
64  DWORD dwFlags; // FLAG_...
65  INT n; // # of line buffers
66  INT nnnn; // retry count before resynch
68  struct list list[2];
69 } FILECOMPARE;
70 
71 // text.h
73  HANDLE *phMapping0, const LARGE_INTEGER *pcb0,
74  HANDLE *phMapping1, const LARGE_INTEGER *pcb1);
76  HANDLE *phMapping0, const LARGE_INTEGER *pcb0,
77  HANDLE *phMapping1, const LARGE_INTEGER *pcb1);
78 // fc.c
79 VOID PrintLineW(const FILECOMPARE *pFC, DWORD lineno, LPCWSTR psz);
80 VOID PrintLineA(const FILECOMPARE *pFC, DWORD lineno, LPCSTR psz);
85 FCRET Different(LPCWSTR file0, LPCWSTR file1);
86 FCRET LongerThan(LPCWSTR file0, LPCWSTR file1);
92 
93 #ifdef _WIN64
94  #define MAX_VIEW_SIZE (256 * 1024 * 1024) // 256 MB
95 #else
96  #define MAX_VIEW_SIZE (64 * 1024 * 1024) // 64 MB
97 #endif
Definition: fc.h:32
INT nnnn
Definition: fc.h:66
LPWSTR pszLine
Definition: fc.h:35
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
VOID PrintEndOfDiff(VOID)
Definition: fc.c:93
Definition: fc.h:62
VOID PrintDots(VOID)
Definition: fc.c:98
LPSTR pszComp
Definition: fc.h:44
FCRET Different(LPCWSTR file0, LPCWSTR file1)
Definition: fc.c:52
FCRET TextCompareA(FILECOMPARE *pFC, HANDLE *phMapping0, const LARGE_INTEGER *pcb0, HANDLE *phMapping1, const LARGE_INTEGER *pcb1)
FCRET
Definition: fc.h:23
char * LPSTR
Definition: xmlstorage.h:182
HANDLE DoOpenFileForInput(LPCWSTR file)
Definition: fc.c:118
int32_t INT
Definition: typedefs.h:58
VOID PrintCaption(LPCWSTR file)
Definition: fc.c:88
Definition: fc.h:40
DWORD dwFlags
Definition: fc.h:64
struct NODE_A NODE_A
VOID PrintLineW(const FILECOMPARE *pFC, DWORD lineno, LPCWSTR psz)
Definition: fc.c:103
struct list entry
Definition: fc.h:34
LPSTR pszLine
Definition: fc.h:43
FCRET NoDifference(VOID)
Definition: fc.c:46
const char * LPCSTR
Definition: xmlstorage.h:183
DWORD lineno
Definition: fc.h:45
DWORD hash
Definition: fc.h:38
LPWSTR pszComp
Definition: fc.h:36
VOID PrintLineA(const FILECOMPARE *pFC, DWORD lineno, LPCSTR psz)
Definition: fc.c:110
DWORD hash
Definition: fc.h:46
FCRET InvalidSwitch(VOID)
Definition: fc.c:76
unsigned long DWORD
Definition: ntddk_ex.h:95
FCRET OutOfMemory(VOID)
Definition: fc.c:64
FCRET ResyncFailed(VOID)
Definition: fc.c:82
Definition: _list.h:228
INT n
Definition: fc.h:65
FCRET TextCompareW(FILECOMPARE *pFC, HANDLE *phMapping0, const LARGE_INTEGER *pcb0, HANDLE *phMapping1, const LARGE_INTEGER *pcb1)
struct NODE_W NODE_W
struct FILECOMPARE FILECOMPARE
FCRET LongerThan(LPCWSTR file0, LPCWSTR file1)
Definition: fc.c:58
DWORD lineno
Definition: fc.h:37
struct list entry
Definition: fc.h:42
FCRET CannotRead(LPCWSTR file)
Definition: fc.c:70
WCHAR * LPWSTR
Definition: xmlstorage.h:184
Definition: fci.c:126