t606 to ..
Pavel Machek
pavel na elf.ucw.cz
Úterý Červen 23 23:14:28 CEST 1998
Ahoj!
> hledam neco co by prevadelo T602 DOsovske dokumenty do HTML.
> nevite o necem? mam pocit, ze t6022html nekdo
> delal (Honza Hubicka?), ale nikde to nemuhu najit.
Do html nevim, ale do textu to umim: Jestli z toho udelas (nebo
kdokoliv jiny) konvertor do html, budu rad. Jestli to nekdo chce dat
nekam na ftp, budu taky rad.
Pavel
PS: A hele, to znamena ze jsem mel linux uz 2 roky zpatky... To ten
cas leti...
/* Output from p2c, the Pascal-to-C translator */
/* From input file "6022txt.p" */
/* Convert T-602 File To ASCII
(c) 1992 MJSoft System Software
Martin Mares <mj na atrey.karlin.mff.cuni.cz>
1996 Converted to C to make it working under linux
Pavel Machek <machek na atrey.karlin.mff.cuni.cz>
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
typedef unsigned char Char;
typedef int boolean;
typedef enum {
Normal, Elite, Condensed
} Fnt;
typedef struct CoR {
Char name[3];
void (*proc)( void );
} CoR;
static FILE *i, *o;
static Char s[256];
static long f;
static Char com[3];
static Char Last;
unsigned char c;
static Fnt Font;
static boolean Bold, Underlined, High, Wide, Italic, Big, Upper, Lower;
static Char Tabs[256];
static long PgNr, LineSpacing, PageL, LM, RM, TM, BM;
static Char Header[256], Footer[256];
static boolean PgStat;
static void SetFont(Fnt x) { Font = x; }
static void SwitchStyle(boolean *y) { *y = !*y; }
static long GetNr( void )
{
long x, y;
y = (sscanf(s, "%ld", &x) == 0);
return x;
}
static void SetStyle( void ) { }
static void C_W()
{
printf("Warning! Command %s is not supported.\n", com);
}
static void C_M()
{
printf("Warning! Mail merge commands ignored!\n");
}
static void onechar( char c ) { putc( c, o ); }
static void Ignore( void ) { }
static void PageBreak( void ) { onechar( '\f' ); }
static void LeftMargin( void ) { LM = GetNr(); }
static void RightMargin( void ) { RM = GetNr(); }
static void PageLength( void ) { PageL = GetNr(); }
static void SetTabs( void ) { strcpy(Tabs, s); }
static void TopMargin( void ) { TM = GetNr(); }
static void BottMargin( void ) { BM = GetNr(); }
static void SetHeader( void ) { strcpy(Header, s); }
static void SetFooter( void ) { strcpy(Footer, s); }
static void SetLine( void ) { LineSpacing = GetNr(); }
static void SetPnr( void ) { PgNr = GetNr(); }
static void OmitPage( void ) { PgStat = 0; }
static void YesPage( void ) { PgStat = 1; }
#define Cmds 26
int main( int argc, char *argv[] )
{
static CoR Cmd[Cmds] = {
{ "CT", Ignore },
{ "LM", LeftMargin },
{ "RM", RightMargin },
{ "PL", PageLength },
{ "TB", SetTabs },
{ "MT", TopMargin },
{ "MB", BottMargin },
{ "PO", Ignore },
{ "PN", SetPnr },
{ "OP", OmitPage },
{ "LH", SetLine },
{ "HE", SetHeader },
{ "FO", SetFooter },
{ "PA", PageBreak },
{ "PG", YesPage },
{ "PC", C_W },
{ "HM", C_W },
{ "FM", C_W },
{ "CP", C_W },
{ "KP", C_W },
{ "IX", C_W },
{ "PI", C_W },
{ "DF", C_M },
{ "NT", C_M },
{ "SV", C_M },
{ "DV", C_M }
};
Font = Normal; Bold = 0; High = 0; Wide = 0; Italic = 0; Underlined = 0; Big = 0;
Upper = 0; Lower = 0;
printf("602 to TeXT - 1992 MJSoft System Software\n");
if (argc<3)
{
printf( "Usage: 6022txt <from> <to>\n" );
return 10;
}
i = fopen( argv[1], "r" );
if (!i) { printf( "Can not open %s for reading.", argv[1] ); return 9; }
o = fopen( argv[2], "w" );
if (!i) { printf( "Can not open %s for writing.", argv[2] ); return 8; }
Last = '\n';
while (Last != '\032')
{
fread(&c, 1, 1, i);
if (Last == '\n' && (c == '.' || c == '@'))
{ /* A command */
SetStyle();
if (!fgets(s, 256, i))
return 0;
{
char *t;
if ((t = strchr(s, '\n')))
*t = 0;
}
sprintf(com, "%c%c", toupper(s[0]), toupper(s[1]));
for (f = 1; f <= Cmds; f++)
{
if (!strcmp(Cmd[f - 1].name, com))
{
(Cmd[f - 1].proc) ();
goto _Lwen;
}
}
printf("Warning! Unrecognised command %s\n", com);
_Lwen:
c = '\n';
}
else
{
if (c >= ' ')
{
SetStyle();
if (c == 0x8D) /* onechar( 0x0d ); */;
else onechar( c );
}
else
{
switch (c) {
case '\001': SetFont(Elite); break;
case '\002': SwitchStyle(&Bold); break;
case '\003': SetFont(Condensed); break;
case '\004': SwitchStyle(&Italic); break;
case '\017': SwitchStyle(&Wide); break;
case '\020': SwitchStyle(&High); break;
case '\023': SwitchStyle(&Underlined); break;
case '\024': SwitchStyle(&Upper); break;
case '\026': SwitchStyle(&Lower); break;
case '\035': SwitchStyle(&Big); break;
case '\015': break;
case '\n': onechar( c ); printf( "." ); break;
default: printf("Warning! Unknown character: <%12d>\n", c); break;
}
}
}
Last = c;
}
return 0;
}
/* End. */
--
I'm really pavel na atrey.karlin.mff.cuni.cz. Pavel
Look at http://atrey.karlin.mff.cuni.cz/~pavel/ ;-).
Další informace o konferenci Linux