amath  1.8.5
Simple command line calculator
main.cpp File Reference
#include "amath.h"
#include "amathc.h"
#include "system/program.h"
#include "system/program_stdc.h"
#include "system/program_amiga.h"
#include "system/program_haiku.h"
#include "system/program_test.h"
Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Variables

const char * vers = TXTDOSVERSION
 
class ProgramProgram = nullptr
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 100 of file main.cpp.

References FreeAllSafe(), Program::GetExitStatus(), Program::Initialize(), StandardProgram::StandardProgram(), and Program::Start().

101 {
102 #if defined(WITHTEST)
103  if (argc == 2 && StrIsEqual(argv[1], "--test"))
104  {
105  Program = new TestProgram(false);
106  }
107  else if (argc == 2 && StrIsEqual(argv[1], "--testz"))
108  {
109  Program = new TestProgram(true);
110  }
111  else
112 #endif
113  {
114 #if defined(AMIGA)
115  DosBase = (struct DosBase*)OpenLibrary(AMIGADOS_NAME, AMIGADOS_REV);
116  IntuitionBase = (struct IntuitionBase*)OpenLibrary(INTUITION_NAME, INTUITION_REV);
117  GfxBase = (struct GfxBase*)OpenLibrary(GRAPHICS_NAME, GRAPHICS_REV);
118  LocaleBase = (struct LocaleBase*)OpenLibrary(LOCALE_NAME, LOCALE_REV);
119  Program = new AmigaProgram();
120 #elif defined(HAIKU)
121  Program = new HaikuProgram();
122 #else
123  Program = new StandardProgram();
124 #endif
125  }
126 
127  Program->Initialize(argc, argv);
128  Program->Start();
129 
130  int exit = Program->GetExitStatus();
131 
132 #if defined(AMIGA)
133  if (DosBase != nullptr)
134  CloseLibrary((struct Library*)DosBase);
135 
136  if (LocaleBase != nullptr)
137  CloseLibrary((struct Library*)LocaleBase);
138 
139  if (GfxBase != nullptr)
140  CloseLibrary((struct Library*)GfxBase);
141 
142  if (IntuitionBase != nullptr)
143  CloseLibrary((struct Library*)IntuitionBase);
144 #endif
145 
146  delete Program;
147  FreeAllSafe();
148 
149  return exit;
150 }
Master control class.
Definition: program.h:55
Test control class.
Definition: program_test.h:44
void FreeAllSafe()
Deallocate all memory in the global memory list.
Definition: mem.c:217
virtual void Start()=0
virtual void Initialize(int argc, char **argv)=0
class Program * Program
Definition: main.cpp:40
bool StrIsEqual(const char *s1, const char *s2)
Compare two null terminated strings to each other.
Definition: strcmp.c:50
int GetExitStatus() const
Definition: program.cpp:133
Here is the call graph for this function:

Variable Documentation

◆ Program

Definition at line 40 of file main.cpp.

◆ vers

const char* vers = TXTDOSVERSION

Definition at line 38 of file main.cpp.