/***********************************************
 *  info.c                                 
 *                                            
 *  Copyright 2001 Eric Kratzer.              
 *  Includes Xaudio software Copyright (C)
 *           1996-2000 Xaudio Corporation
 *           All Rights Reserved.              
 *
 *  This file is part of imp3sh.
 *                                            
 *  imp3sh is free software; you can distribute
 *  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.
 *
 *  imp3sh 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 recieved a copy of the GNU
 *  General Public License along with imp3sh; if
 *  not, write to the Free Software Foundation,
 *  Inc., 59 Temple Place, Suite 330, Boston MA
 *  02111-1307 USA
 ************************************************/

/************************************
 *          Include Files           *
 ************************************/

#include "imp3sh.h"

/************************************
 *       External References        *
 ************************************/

extern CommandDef com[];

extern DCharBuf *args;

/************************************
 *     Help and info Functions      *
 ************************************/

void /* user */ print_gpl()
{
    add_outbuffer("********************************************");
    add_outbuffer("imp3sh is free software; you can distribute");
    add_outbuffer("it and/or modify it under the terms of the");
    add_outbuffer("GNU General Public License as published by");
    add_outbuffer("the Free Software Foundation; either version");
    add_outbuffer("2 of the License, or (at your option) any");
    add_outbuffer("later version.");
    add_outbuffer(" ");
    add_outbuffer("imp3sh is distributed in the hope that");
    add_outbuffer("it will be useful, but WITHOUT ANY WARRANTY;");
    add_outbuffer("without even the implied warranty of");
    add_outbuffer("MERCHANTABILITY or FITNESS FOR A PARTICULAR");
    add_outbuffer("PURPOSE. See the GNU General Public License");
    add_outbuffer("for more details.");
    add_outbuffer(" ");
    add_outbuffer("You should have recieved a copy of the GNU");
    add_outbuffer("General Public License along with imp3sh; if");
    add_outbuffer("not, write to the Free Software Foundation,");
    add_outbuffer("Inc., 59 Temple Place, Suite 330, Boston MA");
    add_outbuffer("02111-1307 USA");
    add_outbuffer("********************************************");

    flush_outbuffer();
}

void /* user */ print_info()
{
    show_user("*****************************************************");
    show_user("%s %s", NAME, VERSION);
#ifdef OGG_MODULE
    show_user("Interactive MP3/Ogg-Vorbis file and URL player with");
    show_user("limited shell functionality\n");
#else
    show_user("Interactive MP3 file/URL player with limited shell");
    show_user("functionality.\n");
#endif
    show_user("Copyrights (C) %s Eric Kratzer.", DATE);
    show_user("Includes Xaudio software Copyright (C) 1996-2000");
    show_user("         Xaudio Corporation All Rights Reserved.\n");
    show_user("This program comes with ABSOLUTELY NO WARRANTY and");
    show_user("is free software---you are welcome to redistribute it");
    show_user("under certain conditions; type \"%s\" for details.",
	      com[PRINT_GPL].name);
    show_user("\nReport bugs/comments to: kman_can@yahoo.com");
    show_user("*****************************************************");
}

void print_key_help()
{
    add_outbuffer("Next song-------------> Page-Up");
    add_outbuffer("Last song-------------> Page-Down");
    add_outbuffer("Fast-forward----------> Home");
    add_outbuffer("Rewind----------------> End");
    add_outbuffer("Play------------------> F1");
    add_outbuffer("Pause-----------------> F2");
    add_outbuffer("Resume----------------> F3");
    add_outbuffer("Stop------------------> F4");
    add_outbuffer("Increase master vol---> F5");
    add_outbuffer("Decrease master vol---> F6");
    add_outbuffer("Increase pcm vol------> F7");
    add_outbuffer("Decrease pcm vol------> F8");
    add_outbuffer("Pan balance left------> F9");
    add_outbuffer("Pan balance right-----> F10");
    add_outbuffer("Print status----------> F11");
    add_outbuffer("Print list status-----> F12");
}

void print_cmnd_help(int index)
{
    if (index >= 0 && index < NUM_COMM)
	show_user(DEBUG_MSG " %s", com[index].help);
}

void /* user */ print_help()
{
    char *name;
    int i, len;

    name = g_dbuf(args, 1);
    len = get_strlen(name);

    if (len && strcmp(name, "keys") == 0) {
	print_key_help();
	flush_outbuffer();
	return;
    }

    for (i = 0; i < NUM_COMM; i++) {
	if (len && grep_against_args(1, com[i].help) == FALSE)
	    continue;

	add_outbuffer("%s", com[i].help);

	/* seperate comm groups for readability */
	if (!len && (i == EXIT_DECODER      || i == REPORT_STATE ||
		     i == EDIT_LIST         || i == TOGGLE_READ_TAGS ||
		     i == LOAD_LIST         || i == LOAD_ALL_LISTS ||
		     i == RESIZE_QUEUE      || i == SET_MODE_SRANDOM ||
		     i == SET_PREF_F        || i == DJ_MODE ||
		     i == SET_STAMP_TIML    || i == ADD_PLAYER ||
		     i == DISABLE_EQ        || i == REMOVE_EVENT ||
		     i == REMOVE_ALIAS      || i == SEND_JOB_2BG ||
		     i == CHANGE_DIR        || i == SET_LEARN_WEIGHTS ||
		     i == PRINT_LIST_STATUS || i == PRINT_STYLES))
	    add_outbuffer(" ");
    }

    if (!len) {
	add_outbuffer(" ");
	print_key_help();
    }

    flush_outbuffer();
}
