#include <stdio.h>#include <string.h>Include dependency graph for Gensomex.c:

Go to the source code of this file.
Functions | |
| int | main (int argc, argv) |
Definition at line 8 of file Gensomex.c.
References file, fname, j, and NULL.
00010 { 00011 char nam1[256]; char fname[256]; char nam2[256]; 00012 char suffix; 00013 FILE *file,*filei1,*filei2; 00014 00015 /* ***********Open Xfilename2************* */ 00016 strcpy(fname,argv[2]); 00017 fname[strlen(fname)]= '\0'; 00021 if (NULL == (filei2=fopen(fname+1,"r"))) return 1; 00022 /* nam2 = the library name; nam1 (tmp) = nam2_gateway.c = name of C file */ 00023 fscanf(filei2,"%s",nam2); strcpy(nam1,nam2); 00024 strcat(nam1,"_gateway.c"); 00025 fclose(filei2); 00026 if (NULL == (file = fopen (nam1, "w"))) return 1; 00027 00028 /* ***********Open Xfilename1************* */ 00029 strcpy(fname,argv[1]); 00030 fname[strlen(fname)]= '\0'; 00033 /********* scilab_functions *************/ 00034 if (NULL == (filei1=fopen(fname+1,"r"))) return 1; 00035 00036 fprintf(file,"#include \"mex.h\"\n"); 00037 fprintf(file, " \n"); 00038 /* loop */ 00039 while (1) 00040 { 00041 int j; 00042 if ( fscanf(filei1,"%s",nam1) == EOF ) break; 00043 j= strlen(nam1); 00044 suffix=nam1[j-1]; 00045 while ( j != 0 && nam1[j] != '/' ) j--; 00046 nam1[j]= '\0'; 00047 if ((suffix=='c') | (suffix=='C')) fprintf(file, "extern Gatefunc mex_%s;\n",nam1); 00048 if ((suffix=='f') | (suffix=='F')) fprintf(file, "extern Gatefunc C2F(mex%s);\n",nam1); 00049 } 00050 /* end loop */ 00051 fprintf(file, " \n"); 00052 fclose(filei1); 00053 /* ***********Re-Open Xfilename1************* */ 00054 strcpy(fname,argv[1]); 00055 fname[strlen(fname)]= '\0'; 00058 /********* scilab_functions *************/ 00059 if (NULL == (filei1=fopen(fname+1,"r"))) return 1; 00060 00061 fprintf(file, "static GenericTable Tab[]={ \n"); 00062 /* loop */ 00063 while (1) 00064 { 00065 int j; 00066 if ( fscanf(filei1,"%s",nam1) == EOF ) break; 00067 j= strlen(nam1); 00068 suffix=nam1[j-1]; 00069 while ( j != 0 && nam1[j] != '/' ) j--; 00070 nam1[j]= '\0'; 00071 if ((suffix=='c') | (suffix=='C')) fprintf(file, "{mex_gateway, mex_%s,\"err msg\"},\n",nam1); 00072 if ((suffix=='f') | (suffix=='F')) fprintf(file, "{(Myinterfun)fortran_mex_gateway, C2F(mex%s),\"err msg\"},\n",nam1); 00073 } 00074 /* end loop */ 00075 fprintf(file, " }; \n"); 00076 fprintf(file, " \n"); 00077 /* fprintf(file, "int C2F(libmylib_gateway)() \n"); 00078 fprintf(file, "{ Rhs = Max(0, Rhs); \n"); 00079 fprintf(file,"(*(Tab[Fin-1].f))(Tab[Fin-1].name,Tab[Fin-1].F); \n"); 00080 fprintf(file," return 0; \n"); 00081 fprintf(file,"}\n"); 00082 fprintf(file, " \n"); */ 00083 fclose(filei1); 00084 00085 00086 00087 00088 00089 /* ends with Table of functions */ 00090 /* fprintf(file, "int C2F(\"./%s.so\",\"%s_gateway.o\",scilab_functions); \n",nam2,nam2); */ 00091 fclose (file) ; return 0; 00092 }
1.5.1