DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T r

⟦60cca1ed0⟧ TextFile

    Length: 1622 (0x656)
    Types: TextFile
    Names: »read.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/General/Wanderer/read.c« 

TextFile

#include "wand_head.h"

extern int edit_mode;
extern char *edit_screen;
extern char screen[NOOFROWS][ROWLEN+1];

int rscreen(num,maxmoves)
int *maxmoves, num;
{
int  y;
FILE *fp;
char name[50];
char (*row_ptr)[ROWLEN+1] = screen;
if(!edit_mode)
    sprintf(name,"%s/screen.%d",SCREENPATH,num);
else
    {
    if(!edit_screen)
        sprintf(name,"./screen");
    else
	sprintf(name,"%s",edit_screen);
    }
fp = fopen(name,"r");
if(fp == NULL)
    {
    if(edit_mode)
	printf("\nCannot find file %s.\n\n",name);
    else
        printf("\nFile for screen %d unavailable.\n\n",num) ;
    }
else
    {
    for(y = 0;y<NOOFROWS;y++)
        {
        fgets((*row_ptr++),ROWLEN + 1,fp);
	fgetc(fp);                         /* remove newline char*/
	};
    if(fscanf(fp,"%*s\n%d",maxmoves) != 1)
	*maxmoves=0;
    fclose(fp);
    };
return (fp == NULL);
}

int wscreen(num,maxmoves)
int maxmoves, num;
{
int  y,x;
FILE *fp;
char name[50];
char (*row_ptr)[ROWLEN+1] = screen;
if(!edit_screen)
    sprintf(name,"./screen");
else
    sprintf(name,"%s",edit_screen);
fp = fopen(name,"w");
if(fp == NULL)
    {
    sprintf(name,"/tmp/screen.%d",getpid());
    fp = fopen(name,"w");
    move(21,0);
    addstr("Written file is ");
    addstr(name);
    refresh();
    }
if(fp == NULL)
    printf("\nFile for screen cannot be written.\n\n") ;
else
    {
    for(y = 0;y<NOOFROWS;y++)
        {
	for(x = 0;x<ROWLEN;x++)
	    fputc(row_ptr[y][x],fp);
	fputc('\n',fp);
	};
    for(x = 0; x<ROWLEN;x++)
	fputc('#',fp);
    fputc('\n',fp);
    if(maxmoves != 0)
	fprintf(fp,"%d\n",maxmoves);
    fclose(fp);
    };
return (fp == NULL);
}