Update the changelog
[opencv] / apps / cvenv / main.cpp
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                        Intel License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 //   * Redistribution's of source code must retain the above copyright notice,
20 //     this list of conditions and the following disclaimer.
21 //
22 //   * Redistribution's in binary form must reproduce the above copyright notice,
23 //     this list of conditions and the following disclaimer in the documentation
24 //     and/or other materials provided with the distribution.
25 //
26 //   * The name of Intel Corporation may not be used to endorse or promote products
27 //     derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/
41
42 #include <stdio.h>
43 #include "stdlib.h"
44 #include "string.h"
45 #include "eic.h"
46 #include "stdClib/stdClib2eic.h" 
47 #include "preproc.h"
48 #include "filelist.h"
49 #include "initeic.h"
50 #include "func.h"
51
52 extern "C" void stdClib();
53 extern "C" int ScriptMode;
54
55 #undef malloc
56 #undef free
57
58 #define str(x)  #x
59 #define xstr(x) str(x)
60
61 #ifdef WIN32
62 int  main(int argc, char ** argv)
63 #else
64 int  main_seance( int argc, char** argv )
65 #endif
66 {
67     EiC_init_EiC();
68
69     ScriptMode = 1;
70
71     stdClib();
72
73     int  i;
74     char* _argv[3] = {0, 0, 0};
75     for( i = 0; i < argc - 2; i++ )
76         _argv[i] = argv[i + 2];
77
78     InitIO( _argv[0], _argv[1], _argv[2] );
79
80     dodefine("_EiC");
81     dodefine((char*)&(xstr(PLATFORM)[1]));
82
83     InitEiC();
84
85     char** headers;
86     int    hn;
87     char** header_path;
88     int    hnp;
89     char** libs;
90     int    ln;
91
92     char* path = GetPathFromModuleName( argv[0] );
93
94     char temp[1000];
95
96     /* find all headers & libs in plugin directory */
97     strcpy( temp, path );
98     GetFileList( temp, &headers, &hn, &header_path, &hnp, &libs, &ln );
99
100     /* include path */
101     for( i = 0; i < hnp; i++ )
102     {
103         strcat( strcpy( temp, ":-I " ), header_path[i] );
104         EiC_parseString( temp );
105         free( header_path[i] );
106     }
107     if( hnp )
108         free( header_path );
109     
110     /* including headers */
111     for( i = 0; i < hn; i++ )
112     {
113         strcat( strcat( strcpy( temp, "#include <" ), headers[i]), ">" );
114         EiC_parseString( temp );
115         free( headers[i] );
116     }
117     if( hn )
118         free( headers );
119
120     /* adding library */
121     for( i = 0; i < ln; i++ )
122     {
123         AddLibrary( libs[i] );
124         free( libs[i] );
125     }
126     if( ln )
127         free( libs );
128
129 #ifndef WIN32
130     strcpy( temp, getenv("HOME" ) );
131     strcat( temp, "/.cvenv/" );
132     GetFileList( temp, &headers, &hn, &header_path, &hnp, &libs, &ln );
133
134     /* include path */
135     for( i = 0; i < hnp; i++ )
136     {
137         strcat( strcpy( temp, ":-I " ), header_path[i] );
138         EiC_parseString( temp );
139         free( header_path[i] );
140     }
141     if( hnp )
142         free( header_path );
143     
144     /* including headers */
145     for( i = 0; i < hn; i++ )
146     {
147         strcat( strcat( strcpy( temp, "#include <" ), headers[i]), ">" );
148         EiC_parseString( temp );
149         free( headers[i] );
150     }
151     if( hn )
152         free( headers );
153
154     /* adding library */
155     for( i = 0; i < ln; i++ )
156     {
157         AddLibrary( libs[i] );
158         free( libs[i] );
159     }
160     if( ln )
161         free( libs );
162 #endif
163
164     EiC_startEiC(argc, argv);
165
166     free( path );
167
168     return 0;
169 }