1 /*
2 ** HivelyTracker !!!!11
3 */
4
5 #include <stdio.h>
6 #include <signal.h>
7
8 #include <exec/types.h>
9
10 #include <proto/intuition.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13
14 #include "replay.h"
15 #include "gui.h"
16 #include "about.h"
17
18 BOOL quitting = FALSE;
19
20 extern uint32 gui_sigs;
21 extern uint32 rp_sigs;
22 extern uint32 about_sigs;
23
24 extern struct List *rp_tunelist;
25
26 TEXT __attribute((used)) ver[] = "$VER: HivelyTracker 1.8 (7.5.2013)";
27
SetAmiUpdateENVVariable(TEXT * varname)28 void SetAmiUpdateENVVariable( TEXT *varname )
29 {
30 BPTR lock;
31 APTR oldwin;
32
33
34 if(( lock = IDOS->GetProgramDir() ))
35 {
36 TEXT progpath[2048];
37 TEXT varpath[1024] = "AppPaths";
38
39 if( IDOS->DevNameFromLock( lock, progpath, sizeof( progpath ), DN_FULLPATH ) )
40 {
41 oldwin = IDOS->SetProcWindow( (APTR)-1 );
42 IDOS->AddPart( varpath, varname, 1024 );
43 IDOS->SetVar( varpath, progpath, -1, GVF_GLOBAL_ONLY|GVF_SAVE_VAR );
44 IDOS->SetProcWindow( oldwin );
45 }
46 }
47 }
48
init(void)49 BOOL init( void )
50 {
51 SetAmiUpdateENVVariable( "HivelyTracker" );
52 gui_pre_init();
53 about_pre_init();
54 if( !rp_init() ) return FALSE;
55 if( !gui_init() ) return FALSE;
56 if( !about_init() ) return FALSE;
57 return TRUE;
58 }
59
shutdown(void)60 void shutdown( void )
61 {
62 about_shutdown();
63 gui_shutdown();
64 rp_shutdown();
65 }
66
main(void)67 int main( void )
68 {
69 signal( SIGINT, SIG_IGN );
70 if( init() )
71 {
72 uint32 gotsigs;
73
74 while( !quitting )
75 {
76 gotsigs = IExec->Wait( gui_sigs | rp_sigs | about_sigs | SIGBREAKF_CTRL_C );
77
78 if( gotsigs & rp_sigs )
79 {
80 rp_handler( gotsigs );
81 if( quitting ) break; // If rp_handler() says we need to quit, don't do anything else but just QUIT...
82 }
83
84 if( gotsigs & SIGBREAKF_CTRL_C )
85 {
86 signal( SIGINT, SIG_IGN );
87 quitting = TRUE;
88 }
89
90 if( gotsigs & about_sigs ) about_handler( gotsigs );
91
92 if( gotsigs & gui_sigs ) gui_handler( gotsigs );
93 }
94
95 rp_stop();
96 }
97 shutdown();
98 return 0;
99 }
100