00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include <stdio.h>
00042 #include <string.h>
00043 #include "mensagem.h"
00044 #include "memvirtu.h"
00045 #include "lowparam.h"
00046 #include "lowmacro.h"
00047 #include "lowsolid.h"
00048 #include "disdispl.h"
00049 #include "mancommd.h"
00050
00051 void MSD_execDisplayFile(void)
00052 {
00053 char rw;
00054 char name1[15];
00055
00056 for ( ; ; )
00057 {
00058 rw = optin();
00059 if ((rw == 'r') || (rw == 'w'))
00060 {
00061 if (1 == sscanf(restbuf, "%s", name1))
00062 {
00063 MSD_highDisplayFile(rw, name1);
00064 return;
00065 }
00066 }
00067 printf("%s: -rw arquivo\n", NAM_DisplayFile);
00068 if (!lineins("? "))
00069 {
00070 return;
00071 }
00072 }
00073 }
00074
00075 int MSD_highDisplayFile(char rw, char *fname)
00076 {
00077 switch (rw)
00078 {
00079 case 'r':
00080 return(MSD_lowDisplayReadFile(fname));
00081
00082 case 'w':
00083 return(MSD_lowDisplayWriteFile(fname));
00084 }
00085 return(FALSE);
00086 }
00087
00088 int MSD_lowDisplayReadFile(char *fname)
00089 {
00090 char namedsp[30];
00091
00092 if (dspfrptr)
00093 {
00094 fclose(dspfrptr);
00095 }
00096 if ((dspfrptr = fopen(fname, "r")) == (FILE *)NIL)
00097 {
00098 strcpy(namedsp, fname);
00099 strcat(namedsp, ".DSP");
00100 if ((dspfrptr = fopen(namedsp, "r")) == (FILE *)NIL)
00101 {
00102 fprintf(stderr, MEN_NaoAbriuArquivo,
00103 NAM_DisplayFile, fname);
00104 return(FALSE);
00105 }
00106 }
00107
00108 while (!feof(dspfrptr))
00109 {
00110 h_line();
00111 }
00112 fclose(dspfrptr);
00113 dspfrptr = (FILE *)NIL;
00114 return(TRUE);
00115 }
00116
00117 int MSD_lowDisplayWriteFile(char *fname)
00118 {
00119 char namedsp[30];
00120
00121 if (dspfwptr)
00122 {
00123 fclose(dspfwptr);
00124 }
00125
00126 if ((dspfwptr = fopen(fname, "w")) == (FILE *)NIL)
00127 {
00128 strcpy(namedsp, fname);
00129 strcat(namedsp, ".DSP");
00130 if ((dspfwptr = fopen(namedsp, "w")) == (FILE *)NIL)
00131 {
00132 fprintf(stderr, MEN_NaoAbriuArquivo,
00133 NAM_DisplayFile, fname);
00134 return(FALSE);
00135 }
00136 }
00137 return(TRUE);
00138 }