home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_18_1987_Transactor_Publishing.d64
/
seq_usr.c
< prev
next >
Wrap
Text File
|
2023-02-26
|
4KB
|
192 lines
/*program to convert Super c */
/*files to/from SEQ files */
/*converting filetypes */
/*and control codes */
/*#define POWER*/
#ifdef POWER
#include "stdio.h"
#define CLR '\223'
#else
#include "h:stdio.h"
#endif
char inname[25];
char outname[25];
int drivin;
int drivout;
#ifdef POWER
FILE inchan;
FILE outchan;
#else
file inchan;
file outchan;
#endif
main()
{SHIFT-+}
void fast();
int menu();
int choice;
int status=0;
char inbuff[255];
char outbuff[255];
while((choice=menu())!='0')
{SHIFT-+}
choice=(choice=='1')?1:2;
putchar(CLR);
#ifdef POWER
getchar();
#endif
namefile("Source ",inname);
drivin=drive("Source ");
namefile("Destination ",outname);
drivout=drive("Destination ");
modnames( choice );
#ifdef POWER
inchan=fopen(inname,"r");
outchan=fopen(outname,"w");
#else
inchan=open(drivin,2,inname);
outchan=open(drivout,3,outname);
#endif
putchar(CLR);
printf("\n\n\11\11\11\11WORKING!");
status=0;
while(!status) /* read a line and convert it */
{SHIFT-+}
fgets(inbuff, 254, inchan);
#ifdef POWER
status=feof(inchan);
#else
status=EOF;
#endif
convert(choice,inbuff,outbuff);
fputs(outbuff,outchan);
{SHIFT--}
close(inchan);
close(outchan);
{SHIFT--}
{SHIFT--}
modnames( choice ) /* modify filename for */
int choice; /*read/write usr/seq */
{SHIFT-+}
switch (choice)
{SHIFT-+}
case 1 :
strcat(inname, ",u,r");
strcat(outname, ",s,w");
break;
case 2 :
strcat(inname, ",s,r");
strcat(outname, ",u,w");
break;
{SHIFT--}
{SHIFT--}
namefile(filetype,name) /* input filename */
char *filetype;
char *name; /*pass pointer to filename */
{SHIFT-+}
printf("\n%sfile name: ",filetype);
gets(name,16);
/* Super C gets() fix*/
if (*(name+(strlen(name)-1))=='\n')
*(name+(strlen(name)-1))='\0';
{SHIFT--}
int drive(direction) /*input/output drive */
char *direction;
{SHIFT-+}
char key;
do
{SHIFT-+}
printf("\n%sdrive a, b, or h? ",direction);
key=getchar();
putchar (key);
{SHIFT--}
while((key!='a')&&(key!='b')&&(key!='h'));
return(key=='a')?8:(key=='b')?9:15;
{SHIFT--}
int menu()
{SHIFT-+}
int choice;
do
{SHIFT-+}
printf("%c\n",CLR);
printf(" 1. Super C to SEQuential\n");
printf(" 2. SEQuential to Super C\n\n");
printf(" 0. EXIT");
choice=getchar();
{SHIFT--}
while((choice!='0')&&(choice!='1')&&(choice!='2'));
return choice;
{SHIFT--}
convert(choice, inbuff, outbuff)
int choice;
char inbuff[];
char outbuff[];
{SHIFT-+}
static int linenum=0;
int inndex=0;
int outndex=0;
if(linenum==0)
switch(choice)
{SHIFT-+}
case 1:
inndex+=3;
linenum=1;
copybuff(inbuff, outbuff,inndex, outndex);
break;
case 2:
outbuff[0]=133;
outbuff[1]=129;
outbuff[2]=5;
outndex+=3;
linenum=1;
copybuff( inbuff, outbuff, inndex, outndex );
break;
{SHIFT--}
else
switch(choice)
{SHIFT-+}
case 1:
inndex++;
copybuff(inbuff, outbuff, inndex, outndex);
break;
case 2:
outbuff[0]=5;
outndex++;
copybuff(inbuff, outbuff, inndex, outndex);
break;
{SHIFT--}
{SHIFT--}
copybuff(inbuff, outbuff, inndex, outndex )
char inbuff[];
char outbuff[];
int inndex;
int outndex;
{SHIFT-+}
do
{SHIFT-+}
outbuff[ outndex ]=inbuff[ inndex ];
inndex++;
outndex++;
{SHIFT--}
while(inndex<=strlen(inbuff));
{SHIFT--}