/*
    NewsCoaster
    Copyright (C) 1999-2002 Mark Harman

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    NewsCoaster Homepage :
        http://newscoaster.tripod.com/

    Mailing List to hear about announcements of new releases etc at:
        http://groups.yahoo.com/group/newscoaster-announce/
*/

//#include <clib/amigaguide_protos.h>
//#include <clib/asl_protos.h>
//#include <clib/dos_protos.h>
#include <proto/amigaguide.h>
#include <proto/asl.h>
#include <proto/dos.h>

#include <stdio.h>
#include <string.h>

#include "vector.h"
#include "general.h"

/* Opens the AmigaGuide documentation at a specific node and line.
 */
BOOL ShowGuide(STRPTR node,LONG line) {
	struct NewAmigaGuide nag = {NULL};
	AMIGAGUIDECONTEXT handle;
	nag.nag_Name = "PROGDIR:NewsCoaster.Guide";
	nag.nag_Node = node;
	nag.nag_Line = line;
	if( handle = OpenAmigaGuide(&nag,NULL)) {
		CloseAmigaGuide(handle);
		return TRUE;
	}
	else
		return FALSE;
}

/* Opens an ASL requester.
 */
BOOL LoadASL(STRPTR filename,STRPTR title,STRPTR ifile,STRPTR pattern,BOOL folders) {
	static char current_dir[300] = "";
	BOOL ok=FALSE;
	struct FileRequester * freq=NULL;
	if(freq = (struct FileRequester *)AllocAslRequest(ASL_FileRequest,NULL)) {
		if(AslRequestTags(freq,
								ASLFR_TitleText,			title,
								ASLFR_Window,				0,
								ASLFR_Flags1,				FRF_DOPATTERNS,
								ASLFR_InitialFile,		ifile,
								ASLFR_InitialDrawer,		current_dir,
								ASLFR_InitialPattern,	pattern,
								ASLFR_DrawersOnly,		folders,
								/*ASLFR_UserData,			app,
								ASLFR_IntuiMsgFunc,		&IntuiMsgHook,*/
								TAG_DONE)) {
			strcpy(current_dir,freq->rf_Dir);
			
			strcpy(filename,freq->rf_Dir);
			if(AddPart(filename,freq->rf_File,MAXFILENAME))
				ok=TRUE;
		}
		FreeAslRequest(freq);
	}
	return ok;
}
