source: rtems-testing/covoar/app_common.cc @ e7bb58a

4.11
Last change on this file since e7bb58a was e7bb58a, checked in by Jennifer Averett <Jennifer.Averett@…>, on May 25, 2010 at 7:14:48 PM

2010-05-25 Jennifer Averett <Jennifer.Averett@…>

  • DesiredSymbols?.cc, Explanations.cc, ObjdumpProcessor?.cc, TraceReaderLogQEMU.cc, app_common.cc, app_common.h: Added a inputBuffer to app_common and modified all fgets calls to use this buffer. This will allow for a size increase if necessary.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  $Id$
3 */
4
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h>
8#include <sys/stat.h>
9#include <sys/types.h>
10#include <unistd.h>
11
12#include "app_common.h"
13#include "DesiredSymbols.h"
14#include "Explanations.h"
15
16/* hack so this can compile on the RH7 RTEMS 4.5 host */
17#if (__GNUC__ <= 2)
18#define STAT stat
19#define OPEN fopen
20#else
21#define STAT stat64
22#define OPEN fopen64
23#endif
24
25/*
26 *  Global variables for the program
27 */
28Coverage::Explanations*     AllExplanations     = NULL;
29Coverage::ObjdumpProcessor* objdumpProcessor    = NULL;
30Coverage::DesiredSymbols*   SymbolsToAnalyze    = NULL;
31bool                        Verbose             = false;
32const char*                 outputDirectory     = ".";
33bool                        BranchInfoAvailable = false;
34Target::TargetBase*         TargetInfo          = NULL;
35const char*                 dynamicLibrary      = NULL;
36const char*                 projectName         = NULL;
37char                        inputBuffer[MAX_LINE_LENGTH];
38
39
40bool FileIsNewer(
41  const char *f1,
42  const char *f2
43)
44{
45  struct STAT buf1, buf2;
46
47   if (STAT( f2, &buf2 ) == -1)
48    return true;
49 
50  if (STAT( f1, &buf1 ) == -1)
51    exit (1);
52
53  if (buf1.st_mtime > buf2.st_mtime)
54    return true;
55
56  return false;
57}
58
59bool FileIsReadable( const char *f1 )
60{
61  struct STAT buf1;
62
63  if (STAT( f1, &buf1 ) == -1)
64    return false;
65
66  if (buf1.st_size == 0)
67    return false;
68
69  // XXX check permission ??
70  return true;
71}
72
73bool ReadUntilFound( FILE *file, const char *line )
74{
75  char discardBuff[100];
76  size_t  len = strlen( line );
77
78  do { 
79    if ( !fgets( discardBuff, 99, file ) )
80      return false;
81
82    if ( strncmp( discardBuff, line, len ) == 0 ) 
83      return true; 
84  } while (1);
85}
86
Note: See TracBrowser for help on using the repository browser.