/*
 * backend.h
 * 
 * Copyright (C) 2006-2007  Josef Kufner <jk@myserver.cz>
 * 
 * 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.
 *
 */
#ifndef JK_BACKEND_H
#define JK_BACKEND_H

#include <glib.h>
#include "message.h"

typedef struct {
	char msg_src;
	GPid pid;
	gint fd_in, fd_out, fd_err;
	GIOChannel *ch_in, *ch_out, *ch_err;

	/* message parser data */
	MESSAGE *msg;

	/* misc */
	int log_enabled;
} BACKEND;

extern BACKEND *backend_network;
extern BACKEND *backend_game;

BACKEND *backend_spawn(char msg_src, const char *dir, char *argv[], int log_enabled);
void backend_kill(BACKEND *backend);
void backend_cleanup(BACKEND *backend);
int backend_send(BACKEND *backend, const char *str);

#endif

