Category : Graphic Animations - Lots of older FLI's
Archive   : UN-GL100.ZIP
Filename : RE-GL.C

 
Output of file : RE-GL.C contained in archive : UN-GL100.ZIP
/* re-gl.c
*
* 9/29/92 A quick and dirty program to recombine the
* component parts of a .GL file.
*
*/
#include
#include
#include
#include /* filelength() */

struct FN_type {
long pos; /* offset in the output file */
char name[14]; /* original filename */
long length; /* file length */
struct FN_type *next;
};
typedef struct FN_type FN;

/* str_max_cpy()
*
* 9/6/90
* Copies at most 'max' chars from 'src' to 'dest'. Appends NUL to end.
* NOTE: 'dest' must have room for 'max'+1 characters!
*/
void str_max_cpy( char *dest, char *src, int max )
{
while (max-- && *src)
*(dest++) = *(src++);
*dest = (char)0;
}

void strlower( char *src )
{
for ( ; *src != '\0'; src++ ) {
if (isupper( *src ))
*src = tolower( *src );
}
}

/* filesize()
*
* 9/29/92
*
* Returns filesize of unopened file, or -1L on error.
*/
long filesize( char *filename )
{
FILE *file;
long len;

if ((file = fopen( filename, "rb" )) == NULL) {
return -1L;
}
len = filelength( fileno( file ) );
fclose( file );
return len;
}

int filecat( FILE *outfile, char *infilename )
{
int towrite;
char buffer[512];
FILE *infile;

if ((infile = fopen( infilename, "rb" )) == NULL) {
fprintf( stderr, "\nCannot open file '%s'.\n", infilename );
return 1;
}
while ((towrite = fread( buffer, sizeof( char ), sizeof( buffer ), infile)) > 0) {
fwrite( buffer, sizeof( char ), towrite, outfile );
}
fclose( infile );
return 0;
}

int main( int argc, char **argv)
{
int i = 1;
FILE *outfile;
char *outname = "1.gl";
long pos;
int headerlength;
FN *list, **fnp, *fn;
int nfiles;
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
char buf[_MAX_PATH];

if (argc == 1) {
fprintf( stderr, "re-gl Copyright 1992 by George Dinwiddie\n"
" Version 1.00 Distribute freely.\n"
" USAGE: re-gl \n"
" Recombines files into a GRASP (.gl) file.\n"
" Output is placed in file named \"1.gl\"\n" );
return 1;
}
list = NULL;
fnp = &list;
for (argv++; *argv; argv++) {
if (((*fnp) = (FN *)malloc( sizeof( FN ))) == NULL) {
fprintf( stderr, "\nOut of memory.\n" );
return -1;
}
printf( "Input file '%s'. \r", *argv );
memset( (*fnp)->name, '\0', sizeof( (*fnp)->name ));
str_max_cpy( (*fnp)->name, *argv, sizeof( (*fnp)->name ));
strlower( (*fnp)->name );
(*fnp)->length = filesize( *argv );
if ((*fnp)->length < 0L) {
fprintf( stderr, "\nInvalid length of file '%s'.\n", *argv );
return -1;
}
(*fnp)->next = NULL;
fnp = &(*fnp)->next;
}
pos = 0L;
nfiles = 0;
for (fn = list; fn != NULL; fn=fn->next) {
nfiles++;
fn->pos = pos;
pos += fn->length + sizeof( long );
}
printf( "Output file '%s'. \r", outname );
if ((outfile = fopen( outname, "wb" )) == NULL) {
fprintf( stderr, "\nCannot open file '%s'.\n", outname );
return -1;
}
headerlength = (nfiles+1)*(sizeof(fn->name)-1 + sizeof(fn->length));
fwrite( &headerlength, sizeof( headerlength ), 1, outfile );
for (fn = list; fn != NULL; fn=fn->next) {
fn->pos = fn->pos + headerlength + sizeof( int );
fwrite( &fn->pos, sizeof( fn->pos ), 1, outfile );
_splitpath( fn->name, NULL, NULL, fname, ext );
_makepath( buf, "", "", fname, ext );
fwrite( buf, sizeof(fn->name)-1, 1, outfile );
}
fwrite( "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof( char ), sizeof( fn->length ) + sizeof(fn->name)-1, outfile );
for (fn = list; fn != NULL; fn=fn->next) {
printf( "Adding file '%s'. \r", fn->name );
fwrite( &fn->length, sizeof( fn->length ), 1, outfile );
if (filecat( outfile, fn->name )) {
fprintf( stderr, "\nError copying file '%s'.\n", fn->name );
return -1;
}
}
fclose( outfile );
return 0;
}


  3 Responses to “Category : Graphic Animations - Lots of older FLI's
Archive   : UN-GL100.ZIP
Filename : RE-GL.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/