/*
** 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 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

/*
 * Author : Alexandre Parenteau <aubonbeurre@hotmail.com> --- December 1997
 */

/*
 * AppGlue.h --- glue code to access CVS services
 */

#ifndef APPGLUE_H
#define APPGLUE_H

#include <stdio.h>

class CCvsConsole
{
public:
	virtual long cvs_out(char *txt, long len) = 0L;
	virtual long cvs_err(char *txt, long len) = 0L;
};

#define errInternal -99
#define errThreadRunning -98

int testCVS(const char *path, int argc, char * const *argv);
	// checks if '-cvsgui' is supported
	// return the exit() error code.

int launchCVS(const char *path, int argc, char * const *argv,
	CCvsConsole * console = 0L);
	// return the exit() error code.
	// Optionally overides the default console.

class CvsArgs;
class UStr;

FILE *launchCVS(const char *dir, const CvsArgs & args, UStr & tmpFile, const char *prefix = 0L,
				const char *extension = 0L);
	// make a stream of the cvs output in a temporary file.

const char *launchCVS(const char *dir, const CvsArgs & args, const char *prefix = 0L,
					  const char *extension = 0L);
	// put the cvs output in a temp file (the temp file is automatically
	// removed when quitting)

// hooks for cvs
extern "C" {
	extern long glue_consoleout(char *txt, long len);
	extern long glue_consoleerr(char *txt, long len);
	extern long glue_consolein(char *txt, long len);
	extern const char *glue_getenv(char *name);
	extern void glue_exit(int code);
}

extern CCvsConsole *gConsole;
	// console is which the currebt cvs process write

#if defined(WIN32) || TARGET_RT_MAC_MACHO
	void WaitForCvs(void);
		// wait for the cvs thread to terminate
#else
#	define WaitForCvs()
#endif

#endif /* APPGLUE_H */
