home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
MM1
/
SOUNDUTILS
/
tracker.4.6.lzh
/
TRACKER4.6
/
Amiga
/
info.c
< prev
next >
Wrap
Text File
|
1994-11-24
|
2KB
|
95 lines
/* amiga/info.c
vi:ts=3 sw=3:
*/
/* $Id: info.c 1.1 1994/06/22 21:54:12 Espie Exp Espie $
* $Log: info.c $
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <proto/exec.h>
#include "defs.h"
#include "extern.h"
#include "amiga/amiga.h"
ID("$Id")
/***
***
*** Info window handling
***
***/
/* We chose the easy way: outputting everything in a console window
* on the fly. An interesting improvement would be to buffer everything
* and open the window with the right size afterwards
*/
struct handle
{
FILE *file;
int linecount;
int maxlength;
int currentlength;
};
#define H(h, field) ( ((struct handle *)h)->field )
void *begin_info(char *title)
{
struct handle *new;
char buffer[50];
new = malloc(sizeof(struct handle));
if (!new)
return 0;
sprintf(buffer, "CON:////%s/auto/close/wait", title);
new->file=fopen(buffer, "w");
if (!new->file)
{
free(new);
return 0;
}
new->linecount = 0;
new->maxlength = 0;
new->currentlength = 0;
return new;
}
void infos(void *handle, char *s)
{
if (handle)
{
fprintf( H(handle,file), s);
H(handle, currentlength) += strlen(s);
}
}
void info(void *handle, char *line)
{
infos(handle, line);
if (handle)
{
fputc('\n', H(handle, file));
if ( H(handle, currentlength) > H(handle, maxlength) )
H(handle, maxlength) = H(handle, currentlength);
H(handle, linecount)++;
}
}
void end_info(void *handle)
{
if (handle)
{
fclose(H(handle, file));
free(handle);
}
}