00001 #include <stdio.h>
00002 #include <string.h>
00003
00004
00005
00006
00007
00008 int main(argc,argv)
00009 int argc;char *argv[];
00010 {
00011 char nam1[256]; char fname[256]; char nam2[256];
00012 char suffix;
00013 FILE *file,*filei1,*filei2;
00014
00015
00016 strcpy(fname,argv[2]);
00017 fname[strlen(fname)]= '\0';
00021 if (NULL == (filei2=fopen(fname+1,"r"))) return 1;
00022
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
00029 strcpy(fname,argv[1]);
00030 fname[strlen(fname)]= '\0';
00033
00034 if (NULL == (filei1=fopen(fname+1,"r"))) return 1;
00035
00036 fprintf(file,"#include \"mex.h\"\n");
00037 fprintf(file, " \n");
00038
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
00051 fprintf(file, " \n");
00052 fclose(filei1);
00053
00054 strcpy(fname,argv[1]);
00055 fname[strlen(fname)]= '\0';
00058
00059 if (NULL == (filei1=fopen(fname+1,"r"))) return 1;
00060
00061 fprintf(file, "static GenericTable Tab[]={ \n");
00062
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
00075 fprintf(file, " }; \n");
00076 fprintf(file, " \n");
00077
00078
00079
00080
00081
00082
00083 fclose(filei1);
00084
00085
00086
00087
00088
00089
00090
00091 fclose (file) ; return 0;
00092 }
00093