better way to do dll (windows_tools module)
[scilab.git] / scilab / modules / windows_tools / src / c / scilab_windows / ConvertSlash.c
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2008 - INRIA - Allan CORNET
4  * 
5  * This file must be used under the terms of the CeCILL.
6  * This source file is licensed as described in the file COPYING, which
7  * you should have received as part of this distribution.  The terms
8  * are also available at    
9  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10  *
11  */
12 /*--------------------------------------------------------------------------*/
13 #include <string.h>
14 #include "BOOL.h"
15 #include "dynlib_scilab_windows.h"
16 /*--------------------------------------------------------------------------*/
17 #define UNIX_SEPATATOR '/'
18 #define WINDOWS_SEPATATOR '\\'
19 /*--------------------------------------------------------------------------*/
20 static BOOL convertSlash(char *path_in,char *path_out,BOOL slashToAntislash);
21 /*--------------------------------------------------------------------------*/
22 SCILAB_WINDOWS_IMPEXP BOOL slashToAntislash(char *pathunix,char *pathwindows)
23 {
24         return convertSlash(pathunix,pathwindows,TRUE);
25 }
26 /*--------------------------------------------------------------------------*/
27 SCILAB_WINDOWS_IMPEXP BOOL AntislashToSlash(char *pathwindows,char *pathunix)
28 {
29         return convertSlash(pathwindows,pathunix,FALSE);
30 }
31 /*--------------------------------------------------------------------------*/
32 static BOOL convertSlash(char *path_in,char *path_out,BOOL slashToAntislash)
33 {
34         BOOL bOK = FALSE;
35         if ( (path_in) && (path_out) )
36         {
37                 int i=0;
38                 strcpy(path_out,path_in);
39                 for (i=0;i<(int)strlen(path_out);i++)
40                 {
41                         if ( slashToAntislash )
42                         {
43                                 if (path_in[i] == UNIX_SEPATATOR) 
44                                 {
45                                         path_out[i] = WINDOWS_SEPATATOR;
46                                         bOK = TRUE;
47                                 }
48                         }
49                         else
50                         {
51                                 if (path_in[i] == WINDOWS_SEPATATOR) 
52                                 {
53                                         path_out[i] = UNIX_SEPATATOR;
54                                         bOK = TRUE;
55                                 }
56                         }
57                 }
58         }
59         else bOK = FALSE;
60
61         return bOK;
62 }
63 /*--------------------------------------------------------------------------*/