mud++0.35/etc/
mud++0.35/etc/guilds/
mud++0.35/help/propert/
mud++0.35/mudC/
mud++0.35/player/
mud++0.35/src/interface/
mud++0.35/src/os/cygwin32/
mud++0.35/src/os/win32/
mud++0.35/src/os/win32/bcppbuilder/
mud++0.35/src/osaddon/
mud++0.35/src/util/
/*
....[@@@..[@@@..............[@.................. MUD++ is a written from
....[@..[@..[@..[@..[@..[@@@@@....[@......[@.... scratch multi-user swords and
....[@..[@..[@..[@..[@..[@..[@..[@@@@@..[@@@@@.. sorcery game written in C++.
....[@......[@..[@..[@..[@..[@....[@......[@.... This server is an ongoing
....[@......[@..[@@@@@..[@@@@@.................. development project.  All 
................................................ contributions are welcome. 
....Copyright(C).1995.Melvin.Smith.............. Enjoy. 
------------------------------------------------------------------------------
Melvin Smith (aka Fusion)         msmith@hom.net
MUD++ development mailing list    mudpp@van.ml.org
------------------------------------------------------------------------------
mudln.cpp
*/

#include "config.h"
#include "string.h"
#include "io.h"
#include "asmobjfile.h"


char String::_argbuf[ 1024 ];
char * String::_argptr;
char * String::_argnext;
StringRep * String::repEmpty = new StringRep("");


int main( int argc, char ** argv )
{
	int i;
	int imagecount = 0;
	char buf[BUF];
	AsmObjFile * aofin;
	AsmObjFile * aofout;
	InputFile * inf;
	OutputFile * outf;

	if ( argc < 3 )
	{
		Cout << "Usage: mudln imagefile objfile1 [objfile2 ...]" << endl;
		return 1;
	}

	char * imagename = argv[1];
	int count = argc-2;
	char ** names = &argv[2];

	sprintf( buf, "%s.%d.mo", imagename, imagecount );
	outf = new OutputFile( buf );
	if ( !outf )
	{
		Cout << "Cannot open " << buf << " for writing" <<endl;
		return 1;
	}
	aofout = new AsmObjFile();

	for ( i=0; i < count; i++ )
	{
		inf = new InputFile( names[i] );
		if ( !(*inf) )
		{
			Cout << "Cannot find " << names[i] << endl;
			delete inf;
			continue;
		}
		Cout << "Linking " << names[i] << endl;
		aofin = new AsmObjFile();
		aofin->readFrom(*inf);
		if ( !aofout->canLink(*aofin) )
		{
			aofout->writeTo(*outf);
			imagecount++;
			sprintf( buf, "%s.%d.mo", imagename, imagecount );
			delete outf;
			outf = new OutputFile( buf );
			if ( !(*outf) )
			{
				Cout << "Cannot open " << buf << " for writing" <<endl;
				return 1;
			}
			delete aofout;
			aofout = new AsmObjFile();
		}
		aofout->link(*aofin);
		delete aofin;
		delete inf;
	}

	aofout->writeTo( *outf );
	delete aofout;
	delete outf;
	return 0;


}