#include <varargs.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <stdio.h>#include "../../modules/core/includes/machine.h"#include "util.h"Include dependency graph for SEpsf.c:

Go to the source code of this file.
Defines | |
| #define | Min(x, y) (((x)<(y))?(x):(y)) |
| #define | PATH_MAX 1024 |
Functions | |
| char * | getenv () |
| static int | Sed (int, char *, FILE *, char *, char *, char *, char *, char *, char *) |
| int | ScilabPsToEps (char orientation, char *filein, char *fileout) |
| static void | dos2win32 (char *filename, char *filename1) |
| static void | ConvertName (char *filein, char *fileout) |
| static void | get_dims (char *file, int *w, int *h) |
| int | main (int argc, char *argv[]) |
| void | sciprint (va_alist) |
Variables | |
| char * | UsageStr [] |
| static char | file1 [PATH_MAX] |
| static char | file2 [PATH_MAX] |
| static char | entete [PATH_MAX] |
| static void ConvertName | ( | char * | filein, | |
| char * | fileout | |||
| ) | [static] |
Definition at line 249 of file SEpsf.c.
References p.
00250 { 00251 char *p=filein,*p1; 00252 p1= strrchr(p,'/'); /* last occurence of '/' */ 00253 p = strrchr(p,'.'); /* last occurence of '.' */ 00254 00255 if ( p != 0 ) 00256 { 00257 *p = '\0'; 00258 sprintf(fileout,"%s.eps",filein); 00259 *p = '.'; 00260 } 00261 else 00262 sprintf(fileout,"%s.eps",filein); 00264 }
| static void dos2win32 | ( | char * | filename, | |
| char * | filename1 | |||
| ) | [static] |
Definition at line 190 of file FigureToFile.c.
Referenced by main(), PrintPs(), and SavePs().
00191 { 00192 #ifdef CVT_PATH_BEG 00193 if (filename[1] == ':') 00194 { 00195 *filename1++ = '/'; 00196 *filename1++ = '/'; 00197 *filename1++ = *filename++; 00198 filename++; 00199 } 00200 #endif 00201 while (*filename != '\0') 00202 { 00203 *filename1++ = *filename++; 00204 if (*(filename1 - 1) == '\\') 00205 *(filename1 - 1) = '/'; 00206 } 00207 *filename1 = '\0'; 00208 }
Here is the caller graph for this function:

Definition at line 334 of file SEpsf.c.
References buflen, fd, malloc(), NULL, and read_one_line().
Referenced by ScilabPsToEps().
00335 { 00336 FILE *fd; 00337 static char scipos_w[] = "%scipos_w="; 00338 static char scipos_h[] = "%scipos_h="; 00339 static char stop_s[] = "% Dessin en bas a gauche"; 00340 00341 static char *buff = NULL; 00342 static int buflen = 512; 00343 if ( buff == NULL) 00344 { 00345 buff = malloc(buflen*sizeof(char)); 00346 if ( buff == NULL) 00347 { 00348 fprintf(stderr,"Running out of space \n"); 00349 exit(1); 00350 } 00351 } 00352 00353 fd=fopen(file,"r"); 00354 if (fd != 0) 00355 { 00356 int stop=0; 00357 while ( stop != 1) 00358 { 00359 read_one_line (&buff,&stop,fd,&buflen); 00360 if ( strncmp(buff,scipos_w,strlen(scipos_w))==0) 00361 { 00362 sscanf(buff+strlen(scipos_w),"%d",w); 00363 } 00364 if ( strncmp(buff,scipos_h,strlen(scipos_h))==0) 00365 { 00366 sscanf(buff+strlen(scipos_h),"%d",h); 00367 } 00368 if ( strncmp(buff,stop_s,strlen(stop_s))==0 ) 00369 break; 00370 } 00371 fclose(fd); 00372 } 00373 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* getenv | ( | ) |
Definition at line 41 of file SEpsf.c.
References dos2win32(), file1, file2, i, orientation, ScilabPsToEps(), and UsageStr.
00042 { 00043 char orientation='p'; 00044 if (argc >= 4 || argc <= 1) 00045 { int i=0; 00046 fprintf(stderr,"Usage : %s [-orientation] filename.ps \n",argv[0]); 00047 while (strcmp(UsageStr[i],"fin")!=0) 00048 fprintf(stderr,"%s",UsageStr[i]),i++; 00049 return(1); 00050 } 00051 switch ( argc ) 00052 { 00053 case 2: 00054 if ( strncmp( argv[1] ,"-p",2) == 0 || strncmp( argv[1] ,"-l",2) == 0) 00055 { 00056 fprintf(stderr,"filename argument missing\n"); 00057 exit(1); 00058 } 00059 orientation = 'p'; 00060 strcpy(file1,argv[1]); 00061 break; 00062 case 3: 00063 strcpy(file1,argv[2]); 00064 if ( strncmp( argv[1] ,"-p",2) == 0) 00065 orientation = 'p'; 00066 else if ( strncmp( argv[1] ,"-l",2) == 0) 00067 orientation = 'l'; 00068 else 00069 fprintf(stderr,"Invalid first argument %s\n",argv[1]); 00070 break; 00071 } 00073 dos2win32(file1,file2); 00075 ScilabPsToEps(orientation,file2,file1); 00076 return(0); 00077 }
Here is the call graph for this function:

| int ScilabPsToEps | ( | char | orientation, | |
| char * | filein, | |||
| char * | fileout | |||
| ) |
Definition at line 27 of file wmprint.c.
References ConvertName(), env, getSCIpath(), MSG_ERROR49, MSG_ERROR50, MSG_ERROR51, NULL, rep, sciprint(), and Sed().
00028 { 00029 int flag = 0, rep; 00030 FILE *fo; 00031 char *env; 00032 env = getSCIpath(); 00033 if (env == NULL) 00034 { 00035 sciprint (MSG_ERROR49); 00036 return (1); 00037 } 00038 sprintf (entete, "%s/tools/printer/NperiPos.ps", env); 00039 00040 ConvertName (filein, fileout); 00041 if (strcmp (fileout, filein) == 0) 00042 { 00043 flag = 1; 00044 strcat (fileout, ".temp"); 00045 } 00046 00047 if ((fo = fopen (fileout, "w")) == 0) 00048 { 00049 sciprint (MSG_ERROR50, fileout); 00050 return 1; 00051 } 00052 00053 fprintf (fo, "%%!PS-Adobe-2.0 EPSF-2.0\n"); 00054 if (orientation == 'p') 00055 fprintf (fo, "%%%%BoundingBox: 0 200 600 624\n"); 00056 else 00057 fprintf (fo, "%%%%BoundingBox: 0 0 600 780\n"); 00058 00059 Sed (0, entete, fo, "%!PS-ADOBE", "%%", (char *) 0, (char *) 0, (char *) 0, (char *) 0); 00060 00061 if (orientation == 'p') 00062 rep = Sed (1, filein, fo, "[0.5 10 div 0 0 0.5 10 div neg 0 2120 10 div] concat", 00063 "[0.5 5 div 0 0 0.5 5 div neg 0 3120 5 div] concat", 00064 (char *) 0, (char *) 0, (char *) 0, (char *) 0); 00065 else 00066 rep = Sed (1, filein, fo, "[0.5 10 div 0 0 0.5 10 div neg 0 2120 10 div] concat", 00067 "90 rotate 10 640 neg translate [0.5 5 div 0 0 0.5 5 div neg 0 3120 5 div] concat", 00068 (char *) 0, (char *) 0, (char *) 0, (char *) 0); 00069 fclose (fo); 00070 00071 if (rep >= 1) 00072 { 00073 if (rep == 1) 00074 sciprint (MSG_ERROR51); 00075 remove (fileout); 00076 return (0); 00077 } 00078 00079 if (flag == 1) 00080 { 00082 fo = fopen (filein, "w"); 00083 Sed (0, fileout, fo, (char *) 0, (char *) 0, (char *) 0, (char *) 0, (char *) 0, (char *) 0); 00084 fclose (fo); 00085 } 00086 else 00087 { 00088 remove (filein); 00089 } 00090 return (0); 00091 }
Here is the call graph for this function:

| void sciprint | ( | va_alist | ) |
Definition at line 272 of file SEpsf.c.
References buflen, fd, malloc(), NULL, read_one_line(), and sciprint().
00274 { 00275 FILE *fd; 00276 static char *buff = NULL; 00277 static int buflen = 512; 00278 if ( buff == NULL) 00279 { 00280 buff = malloc(buflen*sizeof(char)); 00281 if ( buff == NULL) 00282 { 00283 fprintf(stderr,"Running out of space \n"); 00284 exit(1); 00285 } 00286 } 00287 00288 fd=fopen(file,"r"); 00289 if (fd != 0) 00290 { int stop=0; 00291 while ( stop != 1) 00292 { 00293 00294 read_one_line (&buff,&stop,fd,&buflen); 00295 if ( flag == 1 ) 00296 { 00297 if ( strncmp(buff,"%!PS-Adobe-2.0 EPSF-2.0", 00298 strlen("%!PS-Adobe-2.0 EPSF-2.0"))== 0) 00299 { 00300 fclose(fd); 00301 return(1); 00302 } 00303 } 00304 if ( strin1 != (char *) 0 && strncmp(buff,strin1,strlen(strin1))==0) 00305 fprintf(fileo,"%s\n",strout1); 00306 else 00307 { 00308 if ( strin2 != (char *) 0 && strncmp(buff,strin2,strlen(strin2))==0) 00309 fprintf(fileo,"%s\n",strout2); 00310 else 00311 { 00312 if ( strin3 != (char *) 0 && strncmp(buff,strin3,strlen(strin3))==0) 00313 fprintf(fileo,"%s\n",strout3); 00314 else 00315 fprintf(fileo,"%s",buff); 00316 } 00317 } 00318 } 00319 fclose(fd); 00320 } 00321 else 00322 { 00323 sciprint("file %s not found \r\n",file); 00324 return(2); 00325 } 00326 return(0); 00327 }
Here is the call graph for this function:

char entete[PATH_MAX] [static] |
char file1[PATH_MAX] [static] |
| char* UsageStr[] |
1.5.1