ReactOS 0.4.15-dev-7704-gc07eb9f
log2lines.c File Reference
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "util.h"
#include "version.h"
#include "compat.h"
#include "options.h"
#include "image.h"
#include "cache.h"
#include "log2lines.h"
#include "help.h"
#include "cmd.h"
#include "match.h"
Include dependency graph for log2lines.c:

Go to the source code of this file.

Functions

static void clearLastLine (void)
 
static void log_file (FILE *outFile, char *fileName, int line)
 
static void logSource (FILE *outFile)
 
static void reportSource (FILE *outFile)
 
static void report (FILE *outFile)
 
static int print_offset (void *data, size_t offset, char *toString)
 
static int process_data (const void *FileData, size_t offset, char *toString)
 
static int process_file (const char *file_name, size_t offset, char *toString)
 
static int translate_file (const char *cpath, size_t offset, char *toString)
 
static void translate_char (int c, FILE *outFile)
 
static charremove_mark (char *Line)
 
static void translate_line (FILE *outFile, char *Line, char *path, char *LineOut)
 
static int translate_files (FILE *inFile, FILE *outFile)
 
int main (int argc, const char **argv)
 

Variables

static FILEdbgIn = NULL
 
static FILEdbgOut = NULL
 
static FILEconIn = NULL
 
static FILEconOut = NULL
 
static const charkdbg_prompt = KDBG_PROMPT
 
static const charkdbg_cont = KDBG_CONT
 
LIST sources
 
LINEINFO lastLine
 
FILElogFile = NULL
 
LIST cache
 
SUMM summ
 

Function Documentation

◆ clearLastLine()

static void clearLastLine ( void  )
static

Definition at line 40 of file log2lines.c.

41{
42 memset(&lastLine, 0, sizeof(LINEINFO));
43}
LINEINFO lastLine
Definition: log2lines.c:33
#define memset(x, y, z)
Definition: compat.h:39

Referenced by main(), and report().

◆ log_file()

static void log_file ( FILE outFile,
char fileName,
int  line 
)
static

Definition at line 46 of file log2lines.c.

47{
48 int i = 0, min = 0, max = 0;
49 char s[LINESIZE];
50 FILE *src;
51
53 strcat(s, fileName);
54
56 if ((src = fopen(s, "r")))
57 {
59 min = (min < 0) ? 0 : min;
60 while (i < max && fgets(s, LINESIZE, src))
61 {
62 if (i >= min)
63 {
64 if (i == line)
65 log(outFile, "| ----\n");
66 log(outFile, "| %4.4d %s", i + 1, s);
67 }
68 i++;
69 }
70 fclose(src);
71 if ( i < min )
72 log(outFile, "| S--- source has only %d lines! (check source/revision)\n", i);
73 }
74 else
75 l2l_dbg(1, "Can't open: %s (check " SOURCES_ENV ")\n", s);
76}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define LINESIZE
Definition: chargen.c:18
GLdouble s
Definition: gl.h:2039
GLenum src
Definition: glext.h:6340
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
#define min(a, b)
Definition: monoChain.cc:55
#define SOURCES_ENV
Definition: config.h:9
char opt_SourcesPath[LINESIZE]
Definition: options.c:45
int opt_SrcPlus
Definition: options.c:35
int opt_Source
Definition: options.c:34
#define l2l_dbg(level,...)
Definition: util.h:35
#define log(outFile, fmt,...)
Definition: util.h:15
Definition: parser.c:49
#define max(a, b)
Definition: svc.c:63

◆ logSource()

static void logSource ( FILE outFile)
static

Definition at line 79 of file log2lines.c.

80{
82 if (lastLine.nr2)
83 {
84 log(outFile, "| ---- [%u] ----\n", lastLine.nr2);
86 }
87}
UNICODE_STRING log_file
Definition: btrfs.c:89
char file2[LINESIZE]
Definition: log2lines.h:18
char file1[LINESIZE]
Definition: log2lines.h:15

Referenced by reportSource().

◆ main()

int main ( int argc  ,
const char **  argv 
)

Definition at line 547 of file log2lines.c.

548{
549 int res = 0;
550 int optInit = 0;
551 int optCount = 0;
552
553 dbgIn = stdin;
554 conOut = stdout;
555 (void)conIn;
556 (void)dbgOut;
557
558 memset(&cache, 0, sizeof(LIST));
559 memset(&sources, 0, sizeof(LIST));
562
563 optInit = optionInit(argc, argv);
564 optCount = optionParse(argc, argv);
565
566 if (optCount < 0 || optInit < 0)
567 {
568 res = optCount;
569 goto cleanup;
570 }
571
572 argc -= optCount;
573
575 {
576 res = 3;
577 goto cleanup;
578 }
579
581 if (opt_exit)
582 {
583 res = 0;
584 goto cleanup;
585 }
586
587 read_cache();
588 l2l_dbg(4, "Cache read complete\n");
589
590 if (set_LogFile(&logFile))
591 {
592 res = 2;
593 goto cleanup;
594 }
595 l2l_dbg(4, "opt_logFile processed\n");
596
597 if (opt_Pipe)
598 {
599 l2l_dbg(3, "Command line: \"%s\"\n",opt_Pipe);
600
601 if (!(dbgIn = POPEN(opt_Pipe, "r")))
602 {
603 dbgIn = stdin; //restore
604 l2l_dbg(0, "Could not popen '%s' (%s)\n", opt_Pipe, strerror(errno));
605 free(opt_Pipe);
606 opt_Pipe = NULL;
607 }
608 }
609 l2l_dbg(4, "opt_Pipe processed\n");
610
611 if (argc > 1)
612 { // translate {<exefile> <offset>}
613 int i = 1;
614 const char *exefile = NULL;
615 const char *offset = NULL;
616 char Line[LINESIZE + 1];
617 char PathBuffer[LINESIZE + 1];
618 char LineOutBuffer[LINESIZE + 1];
619
620 // TODO: Re-use one translate_files(), instead of repeated translate_line().
621 while (i < argc)
622 {
623 offset = argv[optCount + i++];
624 if (isOffset(offset))
625 {
626 if (exefile)
627 {
628 l2l_dbg(2, "translating %s %s\n", exefile, offset);
629
630 snprintf(Line, LINESIZE, "<%s:%s>\n", exefile, offset);
631 translate_line(conOut, Line, PathBuffer, LineOutBuffer);
632 report(conOut);
633 }
634 else
635 {
636 l2l_dbg(0, "<exefile> expected\n");
637 res = 3;
638 break;
639 }
640 }
641 else
642 {
643 // Not an offset so must be an exefile:
644 exefile = offset;
645 }
646 }
647 }
648 else
649 { // translate logging from stdin
651 }
652
653 if (logFile)
655
656 if (opt_Pipe)
657 PCLOSE(dbgIn);
658
659cleanup:
660 // See optionInit().
661 if (opt_Pipe)
662 {
663 free(opt_Pipe);
664 opt_Pipe = NULL;
665 }
666
669
670 return res;
671}
static int argc
Definition: ServiceArgs.c:12
static UINT check_directory(MSIPACKAGE *package, const WCHAR *dir, WCHAR **appValue)
Definition: appsearch.c:847
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
static void cleanup(void)
Definition: main.c:1335
GLuint res
Definition: glext.h:9613
GLsizei GLenum * sources
Definition: glext.h:7753
GLintptr offset
Definition: glext.h:5920
#define stdout
Definition: stdio.h:99
#define stdin
Definition: stdio.h:98
SUMM summ
Definition: log2lines.c:36
FILE * logFile
Definition: log2lines.c:34
static FILE * dbgIn
Definition: log2lines.c:25
static int translate_files(FILE *inFile, FILE *outFile)
Definition: log2lines.c:409
static void report(FILE *outFile)
Definition: log2lines.c:99
static void translate_line(FILE *outFile, char *Line, char *path, char *LineOut)
Definition: log2lines.c:321
static void clearLastLine(void)
Definition: log2lines.c:40
static FILE * dbgOut
Definition: log2lines.c:26
static FILE * conOut
Definition: log2lines.c:28
static FILE * conIn
Definition: log2lines.c:27
#define create_cache(iid)
Definition: domdoc.c:1230
const char * strerror(int err)
Definition: compat_str.c:23
#define argv
Definition: mplay32.c:18
#define errno
Definition: errno.h:18
int read_cache(void)
Definition: cache.c:157
#define PCLOSE
Definition: compat.h:26
#define POPEN
Definition: compat.h:25
void list_clear(PLIST list)
Definition: list.c:70
char * opt_Pipe
Definition: options.c:29
int optionParse(int argc, const char **argv)
Definition: options.c:112
int opt_force
Definition: options.c:23
int optionInit(int argc, const char **argv)
Definition: options.c:50
int opt_exit
Definition: options.c:24
int set_LogFile(FILE **plogFile)
Definition: util.c:19
int isOffset(const char *a)
Definition: util.c:154
Definition: ncftp.h:79
Definition: cache.c:49
void stat_clear(PSUMM psumm)
Definition: stat.c:41
#define snprintf
Definition: wintirpc.h:48

◆ print_offset()

static int print_offset ( void data,
size_t  offset,
char toString 
)
static

Definition at line 107 of file log2lines.c.

108{
111 PROSSYM_ENTRY e2 = NULL;
112 int bFileOffsetChanged = 0;
113 char fmt[LINESIZE];
114 char *Strings = (char *)data + RosSymHeader->StringsOffset;
115
116 fmt[0] = '\0';
118 if (opt_twice)
119 {
120 e2 = find_offset(data, offset - 1);
121
122 if (e == e2)
123 e2 = NULL;
124 else
125 summ.diff++;
126
127 if (opt_Twice && e2)
128 {
129 e = e2;
130 e2 = NULL;
131 /* replaced (transparantly), but updated stats */
132 }
133 }
134 if (e || e2)
135 {
136 strcpy(lastLine.file1, &Strings[e->FileOffset]);
137 strcpy(lastLine.func1, &Strings[e->FunctionOffset]);
138 lastLine.nr1 = e->SourceLine;
140 lastLine.valid = 1;
141 if (e2)
142 {
145 lastLine.nr2 = e2->SourceLine;
147 bFileOffsetChanged = e->FileOffset != e2->FileOffset;
148 if (e->FileOffset != e2->FileOffset || e->FunctionOffset != e2->FunctionOffset)
149 summ.majordiff++;
150
151 /*
152 * - "%.0s" displays nothing, but processes argument
153 * - bFileOffsetChanged implies always display 2nd SourceLine even if the same
154 * - also for FunctionOffset
155 */
156 strcat(fmt, "%s");
157 if (bFileOffsetChanged)
158 strcat(fmt, "[%s]");
159 else
160 strcat(fmt, "%.0s");
161
162 strcat(fmt, ":%u");
163 if (e->SourceLine != e2->SourceLine || bFileOffsetChanged)
164 strcat(fmt, "[%u]");
165 else
166 strcat(fmt, "%.0u");
167
168 strcat(fmt, " (%s");
169 if (e->FunctionOffset != e2->FunctionOffset || bFileOffsetChanged)
170 strcat(fmt, "[%s])");
171 else
172 strcat(fmt, "%.0s)");
173
174 if (toString)
175 { // put in toString if provided
176 snprintf(toString, LINESIZE, fmt,
177 &Strings[e->FileOffset],
178 &Strings[e2->FileOffset],
179 (unsigned int)e->SourceLine,
180 (unsigned int)e2->SourceLine,
181 &Strings[e->FunctionOffset],
182 &Strings[e2->FunctionOffset]);
183 }
184 else
185 {
186 strcat(fmt, "\n");
187 printf(fmt,
188 &Strings[e->FileOffset],
189 &Strings[e2->FileOffset],
190 (unsigned int)e->SourceLine,
191 (unsigned int)e2->SourceLine,
192 &Strings[e->FunctionOffset],
193 &Strings[e2->FunctionOffset]);
194 }
195 }
196 else
197 {
198 if (toString)
199 { // put in toString if provided
200 snprintf(toString, LINESIZE, "%s:%u (%s)",
201 &Strings[e->FileOffset],
202 (unsigned int)e->SourceLine,
203 &Strings[e->FunctionOffset]);
204 }
205 else
206 {
207 printf("%s:%u (%s)\n",
208 &Strings[e->FileOffset],
209 (unsigned int)e->SourceLine,
210 &Strings[e->FunctionOffset]);
211 }
212 }
213 return 0;
214 }
215 return 1;
216}
static const WCHAR Strings[]
Definition: reg.c:35
#define printf
Definition: freeldr.h:94
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define e
Definition: ke_i.h:82
struct _SYMBOLFILE_HEADER * PSYMBOLFILE_HEADER
#define SVN_PREFIX
Definition: config.h:12
PROSSYM_ENTRY find_offset(void *data, size_t offset)
Definition: image.c:39
PLIST_MEMBER sources_entry_create(PLIST list, char *path, char *prefix)
Definition: list.c:173
int opt_twice
Definition: options.c:36
int opt_Twice
Definition: options.c:37
Definition: rossym.h:26
ULONG SourceLine
Definition: rossym.h:30
ULONG FileOffset
Definition: rossym.h:29
ULONG FunctionOffset
Definition: rossym.h:28
ULONG StringsOffset
Definition: rsym.h:34
Definition: dsound.c:943
char func1[NAMESIZE]
Definition: log2lines.h:16
char func2[NAMESIZE]
Definition: log2lines.h:19
int majordiff
Definition: stat.h:19
int diff
Definition: stat.h:18

Referenced by process_data().

◆ process_data()

static int process_data ( const void FileData,
size_t  offset,
char toString 
)
static

Definition at line 219 of file log2lines.c.

220{
221 int res;
222
223 PIMAGE_SECTION_HEADER PERosSymSectionHeader = get_sectionheader((char *)FileData);
224 if (!PERosSymSectionHeader)
225 return 2;
226
227 res = print_offset((char *)FileData + PERosSymSectionHeader->PointerToRawData, offset, toString);
228 if (res)
229 {
230 if (toString)
231 sprintf(toString, "??:0");
232 else
233 printf("??:0");
234 l2l_dbg(1, "Offset not found: %x\n", (unsigned int)offset);
236 }
237
238 return res;
239}
static FILEDATA FileData[MAX_FDS]
Definition: fs.c:51
static int print_offset(void *data, size_t offset, char *toString)
Definition: log2lines.c:107
#define sprintf(buf, format,...)
Definition: sprintf.c:55
PIMAGE_SECTION_HEADER get_sectionheader(const void *FileData)
Definition: image.c:60
DWORD PointerToRawData
Definition: pedump.c:290
int offset_errors
Definition: stat.h:22

Referenced by process_file().

◆ process_file()

static int process_file ( const char file_name,
size_t  offset,
char toString 
)
static

Definition at line 242 of file log2lines.c.

243{
244 void *FileData;
245 size_t FileSize;
246 int res = 1;
247
249 if (!FileData)
250 {
251 l2l_dbg(0, "An error occured loading '%s'\n", file_name);
252 }
253 else
254 {
255 res = process_data(FileData, offset, toString);
256 free(FileData);
257 }
258 return res;
259}
static UINT load_file(MSIRECORD *row, LPVOID param)
Definition: action.c:1032
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
static int process_data(const void *FileData, size_t offset, char *toString)
Definition: log2lines.c:219
static LPCWSTR file_name
Definition: protocol.c:147

Referenced by translate_file().

◆ remove_mark()

static char * remove_mark ( char Line)
static

Definition at line 312 of file log2lines.c.

313{
314 if (Line[1] == ' ' && Line[2] == '<')
315 if (Line[0] == '*' || Line[0] == '?')
316 return Line + 2;
317 return Line;
318}

Referenced by translate_line().

◆ report()

static void report ( FILE outFile)
static

Definition at line 99 of file log2lines.c.

100{
101 reportSource(outFile);
103}
static void reportSource(FILE *outFile)
Definition: log2lines.c:90

Referenced by main(), and translate_files().

◆ reportSource()

static void reportSource ( FILE outFile)
static

Definition at line 90 of file log2lines.c.

91{
92 if (!opt_Source)
93 return;
94 if (lastLine.valid)
95 logSource(outFile);
96}
static void logSource(FILE *outFile)
Definition: log2lines.c:79

Referenced by report().

◆ translate_char()

static void translate_char ( int  c,
FILE outFile 
)
static

Definition at line 304 of file log2lines.c.

305{
306 fputc(c, outFile);
307 if (logFile)
308 fputc(c, logFile);
309}
const GLubyte * c
Definition: glext.h:8905
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)

Referenced by translate_files().

◆ translate_file()

static int translate_file ( const char cpath,
size_t  offset,
char toString 
)
static

Definition at line 262 of file log2lines.c.

263{
264 size_t base = 0;
265 LIST_MEMBER *pentry = NULL;
266 int res = 0;
267 char *path, *dpath;
268
269 dpath = path = convert_path(cpath);
270 if (!path)
271 return 1;
272
273 // The path could be absolute:
274 if (get_ImageBase(path, &base))
275 {
276 pentry = entry_lookup(&cache, path);
277 if (pentry)
278 {
279 path = pentry->path;
280 base = pentry->ImageBase;
281 if (base == INVALID_BASE)
282 {
283 l2l_dbg(1, "No, or invalid base address: %s\n", path);
284 res = 2;
285 }
286 }
287 else
288 {
289 l2l_dbg(1, "Not found in cache: %s\n", path);
290 res = 3;
291 }
292 }
293
294 if (!res)
295 {
296 res = process_file(path, offset, toString);
297 }
298
299 free(dpath);
300 return res;
301}
static int process_file(const char *file_name, size_t offset, char *toString)
Definition: log2lines.c:242
char * convert_path(char *origpath)
Definition: rcopy.c:11
#define INVALID_BASE
Definition: config.h:5
int get_ImageBase(char *fname, size_t *ImageBase)
Definition: image.c:102
PLIST_MEMBER entry_lookup(PLIST list, char *name)
Definition: list.c:19
size_t ImageBase
Definition: list.h:8
char * path
Definition: list.h:7

Referenced by translate_line().

◆ translate_files()

static int translate_files ( FILE inFile,
FILE outFile 
)
static

Definition at line 409 of file log2lines.c.

410{
411 char Line[LINESIZE + 1];
412 char path[LINESIZE + 1];
413 char LineOut[LINESIZE + 1];
414 int c;
415 unsigned char ch;
416 int i = 0;
417 const char *pc = kdbg_cont;
418 const char *p = kdbg_prompt;
419 const char *p_eos = p + sizeof(KDBG_PROMPT) - 1; //end of string pos
420
421 memset(Line, '\0', LINESIZE + 1);
422 if (opt_console)
423 {
424 while ((c = fgetc(inFile)) != EOF)
425 {
426 if (opt_quit)break;
427
428 ch = (unsigned char)c;
429 if (!opt_raw)
430 {
431 switch (ch)
432 {
433 case '\n':
434 if ( strncmp(Line, KDBG_DISCARD, sizeof(KDBG_DISCARD)-1) == 0 )
435 {
436 memset(Line, '\0', LINESIZE); // flushed
437 }
438 else
439 {
440 Line[1] = handle_escape_cmd(outFile, Line);
441 if (Line[1] != KDBG_ESC_CHAR)
442 {
443 if (p == p_eos)
444 {
445 // kdbg prompt, so already echoed char by char
446 memset(Line, '\0', LINESIZE);
447 translate_char(c, outFile);
448 }
449 else
450 {
451 if (match_line(outFile, Line))
452 {
453 translate_line(outFile, Line, path, LineOut);
454 translate_char(c, outFile);
455 report(outFile);
456 }
457 }
458 }
459 }
460 i = 0;
461 p = kdbg_prompt;
462 pc = kdbg_cont;
463 break;
464 case '<':
465 i = 0;
466 Line[i++] = ch;
467 break;
468 case '>':
469 if (ch == *p)
470 {
471 p = p_eos;
472 translate_line(outFile, Line, path, LineOut);
473 }
474
475 if (p != p_eos)
476 {
477 if (i < LINESIZE)
478 {
479 Line[i++] = ch;
480 translate_line(outFile, Line, path, LineOut);
481 }
482 else
483 {
484 translate_line(outFile, Line, path, LineOut);
485 translate_char(c, outFile);
486 }
487 }
488 else
489 translate_char(c, outFile);
490 i = 0;
491 break;
492 default:
493 if (ch == *p)p++;
494 if (ch == *pc)pc++;
495 if (i < LINESIZE)
496 {
497 Line[i++] = ch;
498 if (p == p_eos)
499 {
500 translate_char(c, outFile);
501 }
502 else if (!*pc)
503 {
504 translate_line(outFile, Line, path, LineOut);
505 i = 0;
506 }
507 }
508 else
509 {
510 translate_line(outFile, Line, path, LineOut);
511 translate_char(c, outFile);
512 i = 0;
513 }
514 }
515 }
516 else
517 translate_char(c, outFile);
518 }
519 }
520 else
521 { // Line by line, slightly faster but less interactive
522 while (fgets(Line, LINESIZE, inFile) != NULL)
523 {
524 if (opt_quit)break;
525
526 if (!opt_raw)
527 {
528 translate_line(outFile, Line, path, LineOut);
529 report(outFile);
530 }
531 else
532 log(outFile, "%s", Line);
533 }
534 }
535
536 if (opt_stats)
537 {
538 stat_print(outFile, &summ);
539 if (logFile)
541 }
542 return 0;
543}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
unsigned char
Definition: typeof.h:29
GLfloat GLfloat p
Definition: glext.h:8902
_Check_return_opt_ _CRTIMP int __cdecl fgetc(_Inout_ FILE *_File)
#define EOF
Definition: stdio.h:24
#define c
Definition: ke_i.h:80
int match_line(FILE *outFile, char *Line)
Definition: match.c:72
static const char * kdbg_prompt
Definition: log2lines.c:29
static void translate_char(int c, FILE *outFile)
Definition: log2lines.c:304
static const char * kdbg_cont
Definition: log2lines.c:30
char handle_escape_cmd(FILE *outFile, char *Line)
Definition: cmd.c:138
#define KDBG_DISCARD
Definition: cmd.h:19
#define KDBG_PROMPT
Definition: cmd.h:17
#define KDBG_ESC_CHAR
Definition: cmd.h:13
int opt_raw
Definition: options.c:32
int opt_quit
Definition: options.c:30
int opt_console
Definition: options.c:26
int opt_stats
Definition: options.c:33
void stat_print(FILE *outFile, PSUMM psumm)
Definition: stat.c:17

Referenced by main().

◆ translate_line()

static void translate_line ( FILE outFile,
char Line,
char path,
char LineOut 
)
static

Definition at line 321 of file log2lines.c.

322{
323 unsigned int offset;
324 int cnt, res;
325 char *sep, *tail, *mark, *s;
326 unsigned char ch;
327
328 if (!*Line)
329 return;
330
331 res = 1;
332 mark = "";
333 s = remove_mark(Line);
334 if (opt_undo)
335 {
336 /* Strip all lines added by this tool: */
337 char buf[NAMESIZE];
338 if (sscanf(s, "| %s", buf) == 1)
339 if (buf[0] == '0' || strcmp(buf, "----") == 0 || strcmp(buf, "L2L-") == 0 || strcmp(buf, "S---") == 0 || strcmp(buf, "R---") == 0 || atoi(buf))
340 res = 0;
341 }
342
343 sep = strchr(s, ':');
344 if (sep)
345 {
346 *sep = ' ';
347 cnt = sscanf(s, "<%s %x%c", path, &offset, &ch);
348 if (opt_undo)
349 {
350 if (cnt == 3 && ch == ' ')
351 {
352 tail = strchr(s, '>');
353 tail = tail ? tail - 1 : tail;
354 if (tail && tail[0] == ')' && tail[1] == '>')
355 {
356 res = 0;
357 tail += 2;
358 mark = opt_mark ? "* " : "";
359 if (opt_redo && !(res = translate_file(path, offset, LineOut)))
360 {
361 log(outFile, "%s<%s:%x (%s)>%s", mark, path, offset, LineOut, tail);
362 summ.redo++;
363 }
364 else
365 {
366 log(outFile, "%s<%s:%x>%s", mark, path, offset, tail);
367 summ.undo++;
368 }
369 }
370 else
371 {
372 mark = opt_Mark ? "? " : "";
373 summ.skipped++;
374 }
375 summ.total++;
376 }
377 }
378
379 if (!opt_undo || opt_redo)
380 {
381 if (cnt == 3 && ch == '>')
382 {
383 tail = strchr(s, '>') + 1;
384 if (!(res = translate_file(path, offset, LineOut)))
385 {
386 mark = opt_mark ? "* " : "";
387 log(outFile, "%s<%s:%x (%s)>%s", mark, path, offset, LineOut, tail);
389 }
390 else
391 {
392 mark = opt_Mark ? "? " : "";
393 summ.skipped++;
394 }
395 summ.total++;
396 }
397 }
398 }
399 if (res)
400 {
401 if (sep)
402 *sep = ':'; // restore because not translated
403 log(outFile, "%s%s", mark, s);
404 }
405 memset(Line, '\0', LINESIZE); // flushed
406}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
char * strchr(const char *String, int ch)
Definition: utclib.c:501
struct outqueuenode * tail
Definition: adnsresfilter.c:66
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
static int translate_file(const char *cpath, size_t offset, char *toString)
Definition: log2lines.c:262
static char * remove_mark(char *Line)
Definition: log2lines.c:312
#define NAMESIZE
Definition: config.h:31
int opt_undo
Definition: options.c:38
int opt_redo
Definition: options.c:39
int opt_mark
Definition: options.c:27
int opt_Mark
Definition: options.c:28
int translated
Definition: stat.h:14
int undo
Definition: stat.h:15
int skipped
Definition: stat.h:17
int total
Definition: stat.h:23
int redo
Definition: stat.h:16

Referenced by main(), and translate_files().

Variable Documentation

◆ cache

Definition at line 35 of file log2lines.c.

◆ conIn

FILE* conIn = NULL
static

Definition at line 27 of file log2lines.c.

Referenced by main().

◆ conOut

FILE* conOut = NULL
static

Definition at line 28 of file log2lines.c.

Referenced by main().

◆ dbgIn

FILE* dbgIn = NULL
static

Definition at line 25 of file log2lines.c.

Referenced by main().

◆ dbgOut

FILE* dbgOut = NULL
static

Definition at line 26 of file log2lines.c.

Referenced by main().

◆ kdbg_cont

const char* kdbg_cont = KDBG_CONT
static

Definition at line 30 of file log2lines.c.

Referenced by translate_files().

◆ kdbg_prompt

const char* kdbg_prompt = KDBG_PROMPT
static

Definition at line 29 of file log2lines.c.

Referenced by translate_files().

◆ lastLine

LINEINFO lastLine

Definition at line 33 of file log2lines.c.

Referenced by clearLastLine(), logSource(), print_offset(), and reportSource().

◆ logFile

FILE* logFile = NULL

Definition at line 34 of file log2lines.c.

Referenced by main(), translate_char(), and translate_files().

◆ sources

Definition at line 32 of file log2lines.c.

◆ summ