ReactOS 0.4.16-dev-125-g798ea90
match.c
Go to the documentation of this file.
1/*
2 * ReactOS log2lines
3 * Written by Jan Roeloffzen
4 *
5 * - Custom match routines
6 */
7
8#include <string.h>
9
10#include "config.h"
11#include "log2lines.h"
12#include "match.h"
13
14// break pattern: show source+line
15static int match_break(FILE *outFile, char *Line, int processed)
16{
17 static int state = 0;
18
19 if ( processed ) return processed;
20 switch (state)
21 {
22 case 1:
23 state = 0;
24 break;
25 default:
26 state = 0;
27 }
28 return 1;
29}
30// "mod" command: update relocated addresses
31static int match_mod(FILE *outFile, char *Line, int processed)
32{
33 static int state = 0;
34 char Image[NAMESIZE];
35 UINT Base;
36 UINT Size;
37 PLIST_MEMBER plm;
38
39 int cnt;
40
41 if ( processed ) return processed;
42 if ( (cnt = sscanf(Line," Base Size %5s", Image)) == 1 )
43 {
44 l2l_dbg(1, "Module relocate list:\n");
45 state = 1;
46 return 0;
47 }
48 switch (state)
49 {
50 case 1:
51 if ( (cnt = sscanf(Line,"%x %x %20s", &Base, &Size, Image)) == 3 )
52 {
53 if (( plm = entry_lookup(&cache, Image) ))
54 {
55 plm->RelBase = Base;
56 plm->Size = Size;
57 l2l_dbg(1, "Relocated: %s %p -> %p\n", Image, (void*)plm->ImageBase, (void*)plm->RelBase);
58 }
59 return 0;
60 }
61 else
62 {
63 state = 0;
64 }
65 break;
66 default:
67 state = 0;
68 }
69 return 1;
70}
71
72int match_line(FILE *outFile, char *Line)
73{
74 int processed = 1;
75
76 if ( *Line == '\n' || *Line == '\0' )
77 return 1;
78 if ( strncmp(Line, KDBG_CONT, sizeof(KDBG_CONT)-1 ) == 0 )
79 return 1;
80
81 processed = match_mod(outFile, Line, processed);
83 /* more to be appended here:
84 * processed = match_xxx(outFile, Line, processed );
85 * ...
86 */
87
88 return (int)(Line[0]);
89}
90
91/* EOF */
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
static int state
Definition: maze.c:121
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
static int match_break(FILE *outFile, char *Line, int processed)
Definition: match.c:15
int match_line(FILE *outFile, char *Line)
Definition: match.c:72
static int match_mod(FILE *outFile, char *Line, int processed)
Definition: match.c:31
unsigned int UINT
Definition: ndis.h:50
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2451
#define KDBG_CONT
Definition: cmd.h:18
#define NAMESIZE
Definition: config.h:31
PLIST_MEMBER entry_lookup(PLIST list, char *name)
Definition: list.c:19
#define l2l_dbg(level,...)
Definition: util.h:35
Definition: ncftp.h:79
Definition: cache.c:49
size_t ImageBase
Definition: list.h:8
size_t Size
Definition: list.h:10
size_t RelBase
Definition: list.h:9
static int processed(const type_t *type)
Definition: typegen.c:2254
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533