Enable export via driver/xinit/xend
[scilab.git] / scilab / modules / graphic_export / sci_gateway / c / gw_graphic_export.c
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2008 - INRIA - Allan CORNET
4  * Copyright (C) 2008 - INRIA - Jean-Baptiste SILVY
5  *
6  *
7  * This file must be used under the terms of the CeCILL.
8  * This source file is licensed as described in the file COPYING, which
9  * you should have received as part of this distribution.  The terms
10  * are also available at
11  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
12  *
13  */
14
15 #include <string.h>
16 #include "gw_graphic_export.h"
17 #include "api_scilab.h"
18 #include "MALLOC.h"
19 #include "scilabmode.h"
20 #include "callFunctionFromGateway.h"
21 #include "localization.h"
22 #include "Scierror.h"
23 #include "BOOL.h"
24 #include "loadOnUseClassPath.h"
25 /*--------------------------------------------------------------------------*/
26 static BOOL loadedDep = FALSE;
27 static BOOL loadedDepVectorialExport = FALSE;
28 /*--------------------------------------------------------------------------*/
29 static gw_generic_table Tab[] =
30 {
31     {sci_xs2bmp, "xs2bmp"},
32     {sci_xs2gif, "xs2gif"},
33     {sci_xs2jpg, "xs2jpg"},
34     {sci_xs2png, "xs2png"},
35     {sci_xs2ppm, "xs2ppm"},
36     {sci_xs2eps, "xs2eps"},
37     {sci_xs2pdf, "xs2pdf"},
38     {sci_xs2svg, "xs2svg"},
39     {sci_xs2ps, "xs2ps"},
40     {sci_driver, "driver"},
41     {sci_xinit, "xinit"},
42     {sci_xend, "xend"}
43 };
44 /*--------------------------------------------------------------------------*/
45 int gw_graphic_export(void)
46 {
47     Rhs = Max(0, Rhs);
48
49     if(pvApiCtx == NULL)
50     {
51         pvApiCtx = (StrCtx*)MALLOC(sizeof(StrCtx));
52     }
53
54     pvApiCtx->pstName = (char*)Tab[Fin-1].name;
55
56     if ( getScilabMode() != SCILAB_NWNI )
57     {
58         if (!loadedDep)
59         {
60             loadOnUseClassPath("graphics");
61             loadedDep=TRUE;
62         }
63         if (!loadedDepVectorialExport && (strcmp(Tab[Fin-1].name, "xs2eps")==0
64                                           || strcmp(Tab[Fin-1].name, "xs2pdf")==0
65                                           || strcmp(Tab[Fin-1].name, "xs2svg")==0
66                                           || strcmp(Tab[Fin-1].name, "xs2ps")==0))
67         {
68             loadOnUseClassPath("pdf_ps_eps_graphic_export");
69             loadedDepVectorialExport = TRUE;
70         }
71
72         callFunctionFromGateway(Tab, SIZE_CURRENT_GENERIC_TABLE(Tab));
73     }
74     else
75     {
76         Scierror(999,_("Scilab graphic module disabled -nogui or -nwni mode.\n"));
77     }
78     return 0;
79 }
80 /*--------------------------------------------------------------------------*/