#include <stdlib.h>#include <string.h>#include <ctype.h>#include <stdio.h>#include "util.h"Include dependency graph for Slatexpr2.c:

Go to the source code of this file.
Functions | |
| void | WriteTeX (char *filename, double wide, double height) |
| void | Sed (char *file, char *strin1, char *strout1, char *strin2, char *strout2, char *strin3, char *strout3, FILE *fdo) |
| void | ComputeSize (int num, int i, double *x, double *y, double *w, double *h, double *wt, double *ht) |
| int | main (int argc, char **argv) |
Variables | |
| char * | UsageStr [] |
| char | entete [160] |
Definition at line 154 of file Slatexpr2.c.
References buf, ComputeSize(), entete, env, fd, filename1, getenv(), h, i, NULL, SciEnv(), Sed(), UsageStr, w, WriteTeX(), x, and y.
00155 { 00156 char *env; 00157 char filename1[255]; 00158 double x,y,w,h,wt,ht; 00159 char buf[256]; 00160 int i ; 00161 FILE *fd; 00162 FILE *fdo; 00163 #if defined(freebsd) || defined(netbsd) 00164 fpsetmask(0); 00165 #endif 00166 #ifdef _MSC_VER 00167 SciEnv(); 00168 #endif 00169 if (argc !=4 ) { int i=0; 00170 while (strcmp(UsageStr[i],"fin")!=0) 00171 { 00172 fprintf(stderr,"%s",UsageStr[i]),i++; 00173 } 00174 exit(0); 00175 } 00176 sprintf(filename1,"%s.ps",argv[1]); 00177 fdo=fopen(filename1,"w"); 00178 if (fdo == 0 ) 00179 { 00180 fprintf (stderr," Can't Create Output file <%s> \n",filename1); 00181 exit(0); 00182 } 00183 env = getenv("SCI"); 00184 if (env == NULL) { 00185 fprintf(stderr,"Environment variable SCI must be defined\n"); 00186 exit(0); 00187 } 00188 sprintf(entete,"%s/tools/printer/NperiPos.ps",env); 00189 fd=fopen(entete,"r"); 00190 if (fd != 0) 00191 { int c; 00192 while ( (c=getc(fd)) != EOF) 00193 { 00194 putc((char) c,fdo); 00195 } 00196 fclose(fd); 00197 } 00198 else 00199 { 00200 fprintf(stderr,"file %s not found ",entete); 00201 return(1); 00202 } 00203 for ( i = 2 ; i < argc-1 ; i++) 00204 { 00205 ComputeSize(argc-2,i-1,&x,&y,&w,&h,&wt,&ht) ; 00206 sprintf(buf,"gsave [1 0 0 -1 0 0] concat %5.2f %5.2f %5.2f %5.2f DesPosi" 00207 ,x,y,w,h); 00208 Sed(argv[i],"[0.5 10 div 0 0 0.5 10 div neg 0 2120 10 div] concat", 00209 buf," showpage","grestore", 00210 " end saved restore","% end saved restore",fdo); 00211 } 00212 ComputeSize(argc-2,argc-2,&x,&y,&w,&h,&wt,&ht) ; 00213 sprintf(buf,"gsave [1 0 0 -1 0 0] concat %5.2f %5.2f %5.2f %5.2f DesPosi" 00214 ,x,y,w,h); 00215 Sed(argv[argc-1],"[0.5 10 div 0 0 0.5 10 div neg 0 2120 10 div] concat", 00216 buf, " showpage"," grestore ", 00217 " end saved restore"," end saved restore",fdo); 00218 fclose(fdo); 00220 WriteTeX(argv[1],wt,ht); 00221 return(0); 00222 }
Here is the call graph for this function:

| void Sed | ( | char * | file, | |
| char * | strin1, | |||
| char * | strout1, | |||
| char * | strin2, | |||
| char * | strout2, | |||
| char * | strin3, | |||
| char * | strout3, | |||
| FILE * | fdo | |||
| ) |
Definition at line 83 of file Slatexpr2.c.
References buflen, fd, malloc(), NULL, and read_one_line().
00084 { 00085 FILE *fd; 00086 00087 static char *buff = NULL; 00088 static int buflen = 512; 00089 if ( buff == NULL) 00090 { 00091 buff = malloc(buflen*sizeof(char)); 00092 if ( buff == NULL) 00093 { 00094 fprintf(stderr,"Running out of space \n"); 00095 exit(1); 00096 } 00097 } 00098 00099 fd=fopen(file,"r"); 00100 if (fd != 0) 00101 { int stop=0; 00102 while ( stop != 1) 00103 { 00104 read_one_line (&buff,&stop,fd,&buflen); 00105 if (strncmp(buff,strin1,strlen(strin1))==0) 00106 fprintf(fdo,"%s\n",strout1); 00107 else 00108 { 00109 if (strncmp(buff,strin2,strlen(strin2))==0) 00110 fprintf(fdo,"%s\n",strout2); 00111 else 00112 { 00113 if (strncmp(buff,strin3,strlen(strin3))==0) 00114 fprintf(fdo,"%s\n",strout3); 00115 else 00116 fprintf(fdo,"%s",buff); 00117 } 00118 } 00119 } 00120 fclose(fd); 00121 } 00122 else 00123 { 00124 fprintf(stderr,"file %s not found ",file); 00125 return; 00126 } 00127 }
Here is the call graph for this function:

| void WriteTeX | ( | char * | filename, | |
| double | wide, | |||
| double | height | |||
| ) |
Definition at line 39 of file Slatexpr2.c.
References filename1.
Referenced by main().
00040 { 00041 char filename1[255]; 00042 FILE *fdo; 00043 sprintf(filename1,"%s.tex",filename); 00044 fdo=fopen(filename1,"w"); 00045 if (fdo == 0 ) 00046 { 00047 fprintf (stderr," Can't Create Output file <%s> \n",filename1); 00048 exit(0); 00049 } 00050 00051 fprintf(fdo,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"); 00052 fprintf(fdo,"%% Usage: -To include a Figure with a caption, insert the TWO following lines\n"); 00053 fprintf(fdo,"%% in your Latex file:\n"); 00054 fprintf(fdo,"%% \\input{This_file_name} \n"); 00055 fprintf(fdo,"%% \\dessin{The_caption}{The_label}\n"); 00056 fprintf(fdo,"%% -To include just a picture, insert the lines \n"); 00057 fprintf(fdo,"%% between \\fbox{\\begin{picture}... and \\end{picture}} below \n"); 00058 fprintf(fdo,"%% \n"); 00059 fprintf(fdo,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"); 00060 00061 fprintf(fdo," \n"); 00062 00063 00064 fprintf(fdo,"\\long\\def\\Checksifdef#1#2#3{\n"); 00065 fprintf(fdo,"\\expandafter\\ifx\\csname #1\\endcsname\\relax#2\\else#3\\fi}\n"); 00066 fprintf(fdo,"\\Checksifdef{Figdir}{\\gdef\\Figdir{}}{}\n"); 00067 fprintf(fdo,"\\def\\dessin#1#2{\n"); 00068 fprintf(fdo,"\\begin{figure}\n\\begin{center}\n"); 00069 fprintf(fdo,"\\setlength{\\unitlength}{1cm}\n"); 00070 fprintf(fdo,"\\fbox{\\begin{picture}(%.2f,%.2f)\n",wide,height); 00071 fprintf(fdo,"\\special{psfile=\\Figdir %s.ps}\n", 00072 filename); 00073 fprintf(fdo,"\\end{picture}}\n"); 00074 fprintf(fdo,"\\end{center}\n\\caption{\\label{#2}#1}\n\\end{figure}}"); 00075 fclose(fdo); 00076 }
Here is the caller graph for this function:

| char entete[160] |
Definition at line 37 of file Slatexpr2.c.
| char* UsageStr[] |
Initial value:
{
"Usage : Blatexpr2 fileres file1 file2 \n",
"\tfile1, file2 : are 2 Postscript files produced by Scilab\n",
"\tfileres : a file name for the result \n",
"\tThis command will create fileres.ps and fileres.tex \n",
"fin"}
Definition at line 30 of file Slatexpr2.c.
1.5.1