home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fonts 1
/
freshfonts1.bin
/
programs
/
amiga
/
pastex
/
src
/
specialhost
/
specialhost.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-30
|
22KB
|
818 lines
/* specialhost.c */
/**************************************************************/
/* */
/* Bitte alle Aenderungen im Programm deutlich */
/* markieren und mir zusenden. Ich werde dann */
/* versuchen immer eine einheitliche Version */
/* zusammenzubasteln. */
/* 30.07.90 (c) Georg Hessmann */
/* */
/* Bug's und Anregungen bitte an: */
/* hessmann@unipas.fmi.uni-passau.de */
/* oder an: */
/* Georg Hessmann */
/* Oberer Markt 7 */
/* 8712 Volkach */
/* Germany */
/* */
/* */
/* Program zur Auswertung der special Strings von TeX */
/* wird von "ShowDVI" und "DVIprint" verwendet. */
/* Das Programm muss im Hintergrund laufen noch bevor */
/* die anderen Programme gestartet werden. */
/* Die ist nur ein Beispiel, das die Arbeitsweise */
/* dokumentieren soll. */
/* */
/* Das bisherige Format des special Kommandos: */
/* \special{ifffile=name */
/* hoffset=fxx */
/* voffset=fxx */
/* hsize=fxx */
/* vsize=fxx } */
/* wobei f eine real-Zahl ist und xx eine Einheit wie */
/* in den anderen Programmen definiert. */
/* */
/* Das Programm benoetigt die "iff.library"! */
/* */
/* Version: */
/* */
/* -- 0.70 30.07.90 (hes) Georg Hessmann */
/* -- 0.71 16.11.90 Verbesserungen von 'flextr.c' */
/* (MiL) Michael Illgner */
/* -- 0.80 23.01.91 Verarbeitung von Farben! */
/* (MiL) Michael Illgner */
/* -- 0.81 04.04.91 Neue Skalierungsroutinen, */
/* `flextr.c' jetzt überflüssig */
/* Olaf `Olsen' Barthel */
/* -- 0.86 17.04.91 `flextr.c' wieder drin :) */
/* (hes) */
/* -- 0.90 30.05.91 Einbau von Pull-Down Menues */
/* Einbau eines Config-Files */
/* Auswahl Blitter on/off */
/* Groessenbegrenzung bei Blitter */
/* Invert-Routine */
/* (hes) */
/* -- 0.91 05.07.91 Zwei 'enforcer' hits behoben. */
/* GADGIMAGE-Gadgets eingefuehrt. */
/* PubScreen Support eingefuehrt. */
/* (hes) */
/* -- 0.92 10.07.91 Kleine Probleme im Zusammenspiel*/
/* Gadgets-Menues behoben. */
/* (hes) */
/* -- 0.93 11.07.91 Probleme im TPIC Teil behoben. */
/* Dazu werden nun float Zahlen als*/
/* Strings uebergeben, damit es */
/* keine Probleme FFP - IEEE gibt. */
/* Enforcer Hit in pline beseitigt.*/
/* CTRL-E veranlasst SpecialHost */
/* dazu, vom PubScr zu verschwinden*/
/* (hes) */
/* -- 0.94 30.07.91 Kleiner Bug in work_w_message */
/* behoben. */
/* (hes) */
/* */
/**************************************************************/
static char ver[] = "$VER: SpecialHost "VERSION" Copyright © 1990/91 Georg Heßmann. All Right Reserved. (last compiled: "__DATE__", "__TIME__")";
#define DOSNAMESIZE 150
#ifndef ZERO
# define ZERO 0L
#endif
#ifdef LATTICE
long _stack = 5120;
char * _procname = "SpecialHost";
long _priority = 0;
long _BackGroundIO = 1;
extern BPTR _Backstdout;
#endif
/* global variable */
static struct special_map spmap;
static char bitfilename[DOSNAMESIZE];
struct MsgPort *special_port = NULL;
IFFFILE ifffile = NULL;
struct BitMap *bmap = NULL;
short use_blitter = TRUE;
short invert_bmap = FALSE;
short is_os2 = FALSE;
short ECS_chips = FALSE;
UBYTE IFFColors[64];
UBYTE HAMColors[16][16][16];
WORD ColorTab[64];
extern struct Library *IFFBase; /* defined in specialwin.c */
extern struct GfxBase *GfxBase;
extern struct IntuitionBase *IntuitionBase;
static char *TPICstr[] = {
"no command",
"PN", "PA", "FP", "IP", "DA", "DT", "SP", "SP",
"AR", "IA", "SH", "SH", "SW", "BK", "TX", "overflow"
};
/* local funktions */
static void free_bmap (struct BitMap **bmap);
static int MyCompareDates (struct DateStamp *date1,
struct DateStamp *date2);
static int test_date (char *iffile, char *bitfile, long *ssum);
static void write_bmap (char *name,
struct BitMap *bmap,
long ssum,
long width, long height);
static int get_iff_size (char *name,
long *width,
long *height);
static struct BitMap *load_iff_picture (struct parse_result *res,
long *width,
long *height,
short to_chip);
static struct BitMap *work_with_message (struct special_msg *message,
int draw_modus, int base_dpi);
static int scale_bmap (struct special_map *map,
struct BitMap **old_bmap,
struct parse_result *res,
int base_dpi,
short to_chip);
void close_port_bitm(void)
{
if (special_port != NULL) {
DeletePort(special_port);
}
free_bmap(&bmap);
}
static void free_bmap(struct BitMap **bmap)
{
int i;
struct BitMap *map = (*bmap);
if (map != NULL)
{
for (i=0; i<map->Depth; i++)
{
if (map->Planes[i] != NULL)
{
FreeMem(map->Planes[i],map->BytesPerRow*map->Rows);
map->Planes[i] = NULL;
}
}
free(map);
*bmap = NULL;
}
}
static int MyCompareDates(struct DateStamp *date1, struct DateStamp *date2)
{
int ret = 1;
if (memcmp(date1,date2,sizeof(struct DateStamp)) == 0) {
ret = 0;
}
else {
if (date1->ds_Days > date2->ds_Days) {
ret = -1;
}
else {
if (date1->ds_Days == date2->ds_Days) {
if (date1->ds_Minute > date2->ds_Minute) {
ret = -1;
}
else {
if (date1->ds_Minute == date2->ds_Minute && date1->ds_Tick > date2->ds_Tick) {
ret = -1;
}
}
}
}
}
return ret;
}
static int test_date(char *iffile, char *bitfile, long *ssum)
{
struct FileLock *lock_iff, *lock_bit;
struct FileInfoBlock *fib_iff, *fib_bit;
int ret = FALSE;
FILE *file;
long buffer;
fib_iff = (struct FileInfoBlock *)malloc((unsigned)sizeof(struct FileInfoBlock));
fib_bit = (struct FileInfoBlock *)malloc((unsigned)sizeof(struct FileInfoBlock));
lock_iff = (struct FileLock *)Lock(iffile, ACCESS_READ);
lock_bit = (struct FileLock *)Lock(bitfile, ACCESS_READ);
if (fib_iff != NULL && fib_iff != NULL && lock_iff != NULL && lock_bit != NULL) {
if (Examine((BPTR)lock_iff,fib_iff)!=0 && Examine((BPTR)lock_iff,fib_iff)!=0) {
ret = (MyCompareDates(&(fib_bit->fib_Date), &(fib_iff->fib_Date)) > 0);
}
}
if (lock_iff) UnLock((BPTR)lock_iff);
if (lock_bit) UnLock((BPTR)lock_bit);
if (fib_iff) free(fib_iff);
if (fib_bit) free(fib_bit);
if (ret) {
if ((file = fopen(bitfile,"r")) != NULL) {
if (fread((char *)&buffer,4,1,file) == 1) {
if (buffer != MAGIC_WORD) {
ret = FALSE;
pline(" wrong magic word in file %s!",bitfile);
}
else {
if (fread((char *)&buffer,4,1,file) != 1) {
ret = FALSE;
}
else {
*ssum = buffer;
}
}
}
fclose(file);
}
}
return ret;
}
static void write_bmap(char *name, struct BitMap *bmap, long ssum, long width, long height)
{
FILE *bmap_file;
long buffer;
int i;
/* File Format: 4Bytes - magic word "SPEC" */
/* 4Bytes - sum of \special-string */
/* 4Bytes - length of rows in bits */
/* 4Bytes - number of rows */
/* rows */
/* length of one row is word (16Bit) aligned!! */
if ((bmap_file = fopen(name,"w")) == NULL) {
pline("Can't write to bitmap-file (%s)!",name);
return;
}
buffer = (long)MAGIC_WORD;
fwrite((char *)&buffer,4,1,bmap_file);
buffer = ssum;
fwrite((char *)&buffer,4,1,bmap_file);
buffer = width;
fwrite((char *)&buffer,4,1,bmap_file);
buffer = height;
fwrite((char *)&buffer,4,1,bmap_file);
for (i=0; i<bmap->Rows; i++) {
fwrite(bmap->Planes[0]+(i*bmap->BytesPerRow),1,bmap->BytesPerRow,bmap_file);
}
fclose(bmap_file);
}
static int get_iff_size(char *name, long *width, long *height)
{
struct BitMapHeader *bmhd;
if (IFFBase == NULL) {
if(!(IFFBase = OpenLibrary(IFFNAME,IFFVERSION))) {
pline("Copy the iff.library (Ver: %ld) to your LIBS: directory!",IFFVERSION);
return FALSE;
}
}
if(!(ifffile=OpenIFF(name))) {
pline("Error opening iff-file \"%s\"!",name);
return FALSE;
}
if(!(bm