wmprint.c File Reference

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include "machine.h"
#include "Messages.h"
#include "Warnings.h"
#include "Errors.h"
#include "setgetSCIpath.h"
#include "sciprint.h"

Include dependency graph for wmprint.c:

Go to the source code of this file.

Functions

static int Sed __PARAMS ((int, char *, FILE *, char *, char *, char *, char *, char *, char *))
static void readOneLine __PARAMS ((char *buff, int *stop, FILE *fd))
static void ConvertName __PARAMS ((char *filein, char *fileout))
int ScilabPsToEps (char orientation, char *filein, char *fileout)
static void ConvertName (char *filein, char *fileout)
static int Sed (int flag, file, FILE *fileo, strin1, strout1, strin2, strout2, strin3, strout3)
static void readOneLine (buff, int *stop, FILE *fd)

Variables

static char entete [256]


Function Documentation

static void ConvertName __PARAMS ( (char *filein, char *fileout)   )  [static]

static void readOneLine __PARAMS ( (char *buff, int *stop, FILE *fd  )  [static]

static int Sed __PARAMS ( (int, char *, FILE *, char *, char *, char *, char *, char *, char *)   )  [static]

static void ConvertName ( char *  filein,
char *  fileout 
) [static]

Definition at line 95 of file wmprint.c.

References p, and strchr().

Referenced by ScilabPsToEps().

00097 {
00098   char *p = filein, *p1;
00099   p1 = strchr (p, '/');
00100   while (p1 != 0)
00101     {
00102       p = p1 + 1;
00103       p1 = strchr (p, '/');
00104     }
00105   p = strchr (p, '.');
00106   if (p != 0)
00107     {
00108       *p = '\0';
00109       sprintf (fileout, "%s.eps", filein);
00110       *p = '.';
00111     }
00112   else
00113     sprintf (fileout, "%s.eps", filein);
00115 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void readOneLine ( buff  ,
int stop,
FILE *  fd 
) [static]

Definition at line 177 of file wmprint.c.

References i.

Referenced by Sed().

00181 {
00182   int i, c;
00183   for (i = 0; (c = getc (fd)) != '\n' && c != EOF; i++)
00184     buff[i] = c;
00185   buff[i] = '\n';
00186   buff[i + 1] = '\0';
00187   if (c == EOF)
00188     {
00189       *stop = 1;
00190     }
00191 }

Here is the caller 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:

static int Sed ( int  flag,
file  ,
FILE *  fileo,
strin1  ,
strout1  ,
strin2  ,
strout2  ,
strin3  ,
strout3   
) [static]

Definition at line 123 of file wmprint.c.

References fd, MSG_ERROR52, readOneLine(), and sciprint().

Referenced by main(), ScilabPsToEps(), and ScilabPsToTeX().

00128 {
00129   FILE *fd;
00130   fd = fopen (file, "r");
00131   if (fd != 0)
00132     {
00133       int stop = 0;
00134       while (stop != 1)
00135         {
00136           char buff[512];
00137           readOneLine (buff, &stop, fd);
00138           if (flag == 1)
00139             {
00140               if (strncmp (buff, "%!PS-Adobe-2.0 EPSF-2.0",
00141                            strlen ("%!PS-Adobe-2.0 EPSF-2.0")) == 0)
00142                 {
00143                   fclose (fd);
00144                   return (1);
00145                 }
00146             }
00147           if (strin1 != (char *) 0 && strncmp (buff, strin1, strlen (strin1)) == 0)
00148             fprintf (fileo, "%s\n", strout1);
00149           else
00150             {
00151               if (strin2 != (char *) 0 && strncmp (buff, strin2, strlen (strin2)) == 0)
00152                 fprintf (fileo, "%s\n", strout2);
00153               else
00154                 {
00155                   if (strin3 != (char *) 0 && strncmp (buff, strin3, strlen (strin3)) == 0)
00156                     fprintf (fileo, "%s\n", strout3);
00157                   else
00158                     fprintf (fileo, "%s", buff);
00159                 }
00160             }
00161         }
00162       fclose (fd);
00163     }
00164   else
00165     {
00166       sciprint (MSG_ERROR52, file);
00167       return (2);
00168     }
00169   return (0);
00170 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

char entete[256] [static]

Definition at line 25 of file wmprint.c.

Referenced by main().


Generated on Sun Mar 4 15:59:40 2007 for Scilab [trunk] by  doxygen 1.5.1