EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
eve-tool.cpp File Reference
#include "eve-tool.h"
#include "Commands.h"
Include dependency graph for eve-tool.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 
void ProcessString (const char *str)
 Processes given string as command. More...
 
void ProcessString (const std::string &str)
 Processes given string as command. More...
 
void ProcessFile (FILE *file)
 Loads commands from given file. More...
 
void ProcessFile (const char *filename)
 Loads commands from given file. More...
 
void ProcessFile (const std::string &filename)
 Loads commands from given file. More...
 

Variables

const char *const CACHE_DIR = EVEMU_ROOT "/cache"
 
const char *const LOG_FILE = EVEMU_ROOT "/log/eve-tool.log"
 
const char *const LOG_SETTINGS_FILE = EVEMU_ROOT "/etc/log.ini"
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 34 of file eve-tool.cpp.

References load_log_settings(), LOG_FILE, log_open_logfile(), LOG_SETTINGS_FILE, ProcessFile(), and sLog.

35 {
36 #if defined( HAVE_CRTDBG_H ) && !defined( NDEBUG )
37  // Under Visual Studio setup memory leak detection
38  _CrtSetDbgFlag( _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ) );
39 #endif /* defined( HAVE_CRTDBG_H ) && !defined( NDEBUG ) */
40 
41  // Load server log settings ( will be removed )
43  sLog.Warning( "init", "Unable to read %s (this file is optional)", LOG_SETTINGS_FILE );
44  else
45  sLog.Success( "init", "Log settings loaded from %s", LOG_SETTINGS_FILE );
46 
47  if( !log_open_logfile( LOG_FILE ) )
48  sLog.Warning( "init", "Unable to open log file '%s', only logging to the screen now.", LOG_FILE );
49  else
50  sLog.Success( "init", "Opened log file %s", LOG_FILE );
51 
52  //skip first argument (launch path), we don't need it
53  --argc;
54  ++argv;
55 
56  for(; argc > 0; --argc, ++argv)
57  ProcessFile( *argv );
58 
59  ProcessFile( stdin );
60 
61  sLog.Log( "shutdown", "Exiting." );
62 
63  return 0;
64 }
bool load_log_settings(const char *filename)
Definition: logsys.cpp:168
bool log_open_logfile(const char *filename)
Definition: logsys.cpp:149
void ProcessFile(FILE *file)
Loads commands from given file.
Definition: eve-tool.cpp:76
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250
const char *const LOG_FILE
Definition: eve-tool.cpp:31
const char *const LOG_SETTINGS_FILE
Definition: eve-tool.cpp:32

Here is the call graph for this function:

void ProcessFile ( FILE *  file)

Loads commands from given file.

Parameters
[in]fileFile to load commands from.

Definition at line 76 of file eve-tool.cpp.

References ProcessString().

Referenced by LoadScript(), main(), and ProcessFile().

77 {
78  std::string cmd;
79 
80  while( true )
81  {
82  char input = fgetc( file );
83 
84  if( '\n' == input || EOF == input )
85  {
86  if( !cmd.empty() )
87  {
88  ProcessString( cmd );
89  cmd.clear();
90  }
91 
92  if( EOF == input )
93  break;
94  }
95  else
96  cmd += input;
97  }
98 }
void ProcessString(const char *str)
Processes given string as command.
Definition: eve-tool.cpp:66

Here is the call graph for this function:

Here is the caller graph for this function:

void ProcessFile ( const char *  filename)

Loads commands from given file.

Parameters
[in]filenameName of file to load commands from.

Definition at line 100 of file eve-tool.cpp.

References ProcessFile().

101 {
102  ProcessFile( std::string( filename ) );
103 }
void ProcessFile(FILE *file)
Loads commands from given file.
Definition: eve-tool.cpp:76

Here is the call graph for this function:

void ProcessFile ( const std::string &  filename)

Loads commands from given file.

Parameters
[in]filenameName of file to load commands from.

Definition at line 105 of file eve-tool.cpp.

References ProcessFile(), and sLog.

106 {
107  FILE* file = fopen( filename.c_str(), "r" );
108  if( NULL == file )
109  {
110  sLog.Error( "input", "Unable to open script '%s'.", filename.c_str() );
111  return;
112  }
113 
114  sLog.Log( "input", "Queuing commands from script '%s'.", filename.c_str() );
115  ProcessFile( file );
116 
117  if( feof( file ) )
118  sLog.Success( "input", "Load of script '%s' successfully completed.", filename.c_str() );
119  else
120  sLog.Error( "input", "Error occured while reading script '%s'.", filename.c_str() );
121 
122  fclose( file );
123 }
void ProcessFile(FILE *file)
Loads commands from given file.
Definition: eve-tool.cpp:76
#define sLog
Evaluates to a NewLog instance.
Definition: LogNew.h:250

Here is the call graph for this function:

void ProcessString ( const char *  str)

Processes given string as command.

Parameters
[in]strString to be processed.

Definition at line 66 of file eve-tool.cpp.

References ProcessCommand().

Referenced by ProcessFile(), and ProcessString().

67 {
68  ProcessCommand( Seperator( str ) );
69 }
Separates string to arguments.
Definition: Seperator.h:36
void ProcessCommand(const Seperator &cmd)
Processed given command.
Definition: Commands.cpp:82

Here is the call graph for this function:

Here is the caller graph for this function:

void ProcessString ( const std::string &  str)

Processes given string as command.

Parameters
[in]strString to be processed.

Definition at line 71 of file eve-tool.cpp.

References ProcessString().

72 {
73  ProcessString( str.c_str() );
74 }
void ProcessString(const char *str)
Processes given string as command.
Definition: eve-tool.cpp:66

Here is the call graph for this function:

Variable Documentation

const char* const CACHE_DIR = EVEMU_ROOT "/cache"

Cache directory to be used.

Definition at line 30 of file eve-tool.cpp.

const char* const LOG_FILE = EVEMU_ROOT "/log/eve-tool.log"

Log file to be used.

Definition at line 31 of file eve-tool.cpp.

Referenced by main().

const char* const LOG_SETTINGS_FILE = EVEMU_ROOT "/etc/log.ini"

Log settings file to be used.

Definition at line 32 of file eve-tool.cpp.

Referenced by main().