r105: This commit was manufactured by cvs2svn to create tag
[cinelerra_cv/mob.git] / hvirtual / cinelerra / main.C
blobef3c978a6a5deb3edb5fe3dff06e1c057b8d55dc
1 #include "arraylist.h"
2 #include "builddate.h"
3 #include "filexml.h"
4 #include "filesystem.h"
5 #include "loadfile.inc"
6 #include "mainmenu.h"
7 #include "mwindow.h"
8 #include "mwindowgui.h"
9 #include "pluginserver.h"
10 #include "preferences.h"
11 #include "renderfarmclient.h"
12 #include <stdlib.h>
13 #include <string.h>
15 #define PACKAGE "cinelerra"
16 #define LOCALEDIR "/usr/share/locale"
17 #include <libintl.h>
18 #define _(String) gettext(String)
19 #define gettext_noop(String) String
20 #define N_(String) gettext_noop (String)
22 enum
24         DO_GUI,
25         DO_DEAMON,
26         DO_BRENDER,
27         DO_USAGE
30 #include "thread.h"
32 int main(int argc, char *argv[])
34 // handle command line arguments first
35         srand(time(0));
36         ArrayList<char*> filenames;
37         FileSystem fs;
38         
39         int operation = DO_GUI;
40         int deamon_port = DEAMON_PORT;
41         char deamon_path[BCTEXTLEN];
43         setlocale (LC_ALL, "");
44         bindtextdomain (PACKAGE, LOCALEDIR);
45         textdomain (PACKAGE);
46         for(int i = 1; i < argc; i++)
47         {
48                 if(!strcmp(argv[i], "-h"))
49                 {                     // help
50                         operation = DO_USAGE;
51                 }
52                 else
53                 if(!strcmp(argv[i], "-d"))
54                 {
55                         operation = DO_DEAMON;
57                         if(argc > i + 1)
58                         {
59                                 if(atol(argv[i + 1]) > 0)
60                                         deamon_port = atol(argv[i + 1]);
61                         }
62                 }
63                 else
64                 if(!strcmp(argv[i], "-b"))
65                 {
66                         operation = DO_BRENDER;
67                         strcpy(deamon_path, argv[i + 1]);
68                 }
69                 else
70                 {
71                         char *new_filename;
72                         new_filename = new char[1024];
73                         strcpy(new_filename, argv[i]);
74             fs.complete_path(new_filename);
76                         filenames.append(new_filename);
77                 }
78         }
83         if(operation == DO_GUI || operation == DO_DEAMON || operation == DO_USAGE)
84         fprintf(stderr, 
85                 PROGRAM_NAME " " 
86                 VERSION " " 
87                 BUILDDATE 
88                 " (C)2003 Heroine Virtual Ltd.\n\n"
90 PROGRAM_NAME " is free software, covered by the GNU General Public License,\n"
91 "and you are welcome to change it and/or distribute copies of it under\n"
92 "certain conditions. There is absolutely no warranty for " PROGRAM_NAME ".\n");
98         switch(operation)
99         {
100                 case DO_USAGE:
101                         printf(_("\nUsage:\n"));
102                         printf(_("%s [-d] [port]\n"), argv[0]);
103                         printf(_("\n-d = Run in the background as renderfarm client.\n"));
104                         printf(_("port = Port for client to listen on. (400)\n\n\n"));
105                         exit(0);
106                         break;
108                 case DO_DEAMON:
109                 {
110                         int pid = fork();
111                         
112                         if(pid) exit(0);
114                         RenderFarmClient client(deamon_port, 0);
115                         client.main_loop();
116                         break;
117                 }
119 // Same thing without detachment
120                 case DO_BRENDER:
121                 {
122                         RenderFarmClient client(0, deamon_path);
123                         client.main_loop();
124                         break;
125                 }
127                 case DO_GUI:
128                 {
129                         MWindow mwindow;
130                         mwindow.create_objects(1, !filenames.total);
132 // load the initial files on seperate tracks
133                         if(filenames.total)
134                         {
135                                 mwindow.gui->lock_window();
136                                 mwindow.load_filenames(&filenames, LOAD_REPLACE);
137                                 if(filenames.total == 1) 
138                                         mwindow.gui->mainmenu->add_load(filenames.values[0]);
139                                 mwindow.gui->unlock_window();
140                         }
142 // run the program
143                         mwindow.start();
144 //                      mwindow.gui->run_window();
145                         mwindow.save_defaults();
146                         break;
147                 }
148         }
150         filenames.remove_all_objects();
151         return 0;