/*		host.c

		Amiga host 

Maintenance Notes:
  25Aug87 - if dcp, set the condition code returned by dcpmain - Jal

*/

#include <stdio.h>
#include "host.h"

#include <ctype.h>
#include <setjmp.h>
#include <errno.h>

static char *curdir;
char * getcwd();
int chdir();
int	debuglevel;		/* debuginglevel */

jmp_buf	dcpexit;

main( argc, argv )
int	argc;
char *argv[];
{
	int returnCode = 0;

	/* Amiga specific prolog */

	loadenv();
	curdir = getcwd( NULL, 0 );

#ifdef CWDSPOOL
	chdir( spooldir );
#endif

	/* setup longjmp for error exit's */
	if ( setjmp( dcpexit ) == 0 ) {
#if MAIN == dcpmain
	returnCode = MAIN( argc, argv );
#else
		MAIN( argc, argv );
#endif
	}

	/* Amiga specific epilog */

	exitenv();
	chdir( curdir );
	exit( returnCode );

}


/* canonical name conversio routines

	inportpath	canonical -> host
	exportpath	host -> canonical

	host		your local pathname format
	canonical	unix style
*/

importpath( host, canon )
char * host;
char * canon;
{
	extern char *pubdir;

	*host = '\0';

	if ( *canon == '~' )
	  {
		if ( canon[1] == '/' )
		   strcpy( host, pubdir );
		else
		   {
			strcpy( host, home );
			strcat( host, "/" );
		   }
	  }

	strcat( host, canon );

        if ( *host == '/' )
	  *host = ':';

}

exportpath( canon, host )
char * host;
char * canon;
{
	strcpy( canon, host );
	if ( *canon == ':' )
	   *canon = '/';
}




