ReactOS 0.4.16-dev-297-gc569aee
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
23typedef enum FCRET // return code of FC command
24{
29 FCRET_NO_MORE_DATA = 3 // (extension)
31
32typedef struct NODE_W
33{
34 struct list entry;
36 LPWSTR pszComp; // compressed
40typedef struct NODE_A
41{
42 struct list entry;
44 LPSTR pszComp; // compressed
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
62typedef 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];
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
79VOID PrintLineW(const FILECOMPARE *pFC, DWORD lineno, LPCWSTR psz);
80VOID PrintLineA(const FILECOMPARE *pFC, DWORD lineno, LPCSTR psz);
85FCRET Different(LPCWSTR file0, LPCWSTR file1);
86FCRET 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: list.h:37
VOID PrintCaption(LPCWSTR file)
Definition: fc.c:88
FCRET NoDifference(VOID)
Definition: fc.c:46
FCRET TextCompareW(FILECOMPARE *pFC, HANDLE *phMapping0, const LARGE_INTEGER *pcb0, HANDLE *phMapping1, const LARGE_INTEGER *pcb1)
FCRET
Definition: fc.h:24
@ FCRET_IDENTICAL
Definition: fc.h:26
@ FCRET_INVALID
Definition: fc.h:25
@ FCRET_NO_MORE_DATA
Definition: fc.h:29
@ FCRET_CANT_FIND
Definition: fc.h:28
@ FCRET_DIFFERENT
Definition: fc.h:27
VOID PrintDots(VOID)
Definition: fc.c:98
HANDLE DoOpenFileForInput(LPCWSTR file)
Definition: fc.c:118
VOID PrintLineA(const FILECOMPARE *pFC, DWORD lineno, LPCSTR psz)
Definition: fc.c:110
VOID PrintLineW(const FILECOMPARE *pFC, DWORD lineno, LPCWSTR psz)
Definition: fc.c:103
VOID PrintEndOfDiff(VOID)
Definition: fc.c:93
FCRET Different(LPCWSTR file0, LPCWSTR file1)
Definition: fc.c:52
FCRET CannotRead(LPCWSTR file)
Definition: fc.c:70
FCRET LongerThan(LPCWSTR file0, LPCWSTR file1)
Definition: fc.c:58
FCRET ResyncFailed(VOID)
Definition: fc.c:82
FCRET InvalidSwitch(VOID)
Definition: fc.c:76
FCRET TextCompareA(FILECOMPARE *pFC, HANDLE *phMapping0, const LARGE_INTEGER *pcb0, HANDLE *phMapping1, const LARGE_INTEGER *pcb1)
unsigned long DWORD
Definition: ntddk_ex.h:95
@ OutOfMemory
Definition: gdiplustypes.h:29
Definition: fc.h:63
DWORD dwFlags
Definition: fc.h:64
INT nnnn
Definition: fc.h:66
INT n
Definition: fc.h:65
Definition: fc.h:41
struct list entry
Definition: fc.h:42
DWORD lineno
Definition: fc.h:45
DWORD hash
Definition: fc.h:46
LPSTR pszLine
Definition: fc.h:43
LPSTR pszComp
Definition: fc.h:44
Definition: fc.h:33
LPWSTR pszLine
Definition: fc.h:35
LPWSTR pszComp
Definition: fc.h:36
DWORD lineno
Definition: fc.h:37
DWORD hash
Definition: fc.h:38
struct list entry
Definition: fc.h:34
Definition: fci.c:127
int32_t INT
Definition: typedefs.h:58
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185