2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
main.c
|
|
|
|
|
|
|
|
(c) 2003-2004 Daniel Campos Fernández <danielcampos@netcourrier.com>
|
|
|
|
|
|
|
|
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
|
2009-08-17 12:41:51 +02:00
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
2007-12-30 17:41:49 +01:00
|
|
|
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
|
2011-06-03 02:51:09 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
2011-12-31 03:39:20 +01:00
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
2011-12-31 03:39:20 +01:00
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#define MAX_DRIVER 8
|
|
|
|
#define __MAIN_C
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "CCompress.h"
|
|
|
|
#include "CUncompress.h"
|
|
|
|
#include "gb.compress.h"
|
|
|
|
|
|
|
|
#include "gb_common.h"
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GB_INTERFACE GB EXPORT;
|
|
|
|
|
|
|
|
static COMPRESS_DRIVER *_drivers[MAX_DRIVER];
|
|
|
|
static int _drivers_count = 0;
|
|
|
|
|
|
|
|
|
|
|
|
static void COMPRESS_Register(COMPRESS_DRIVER *driver)
|
|
|
|
{
|
|
|
|
if (_drivers_count >= MAX_DRIVER)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_drivers[_drivers_count] = driver;
|
|
|
|
_drivers_count++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
COMPRESS_DRIVER *COMPRESS_GetDriver(char *type)
|
|
|
|
{
|
|
|
|
int i;
|
2013-01-06 17:13:31 +01:00
|
|
|
char *comp;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2013-01-06 17:13:31 +01:00
|
|
|
if (!type || !*type)
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
|
|
|
GB.Error("Driver name missing");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-01-06 17:13:31 +01:00
|
|
|
comp = alloca(strlen(type) + 14);
|
|
|
|
|
|
|
|
strcpy(comp, "gb.compress.");
|
2008-02-19 00:07:24 +01:00
|
|
|
strcat(comp, type);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2012-05-08 17:32:33 +02:00
|
|
|
if (GB.Component.Load(comp))
|
2007-12-30 17:41:49 +01:00
|
|
|
{
|
|
|
|
GB.Error("Cannot find driver for : &1", type);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < _drivers_count; i++)
|
|
|
|
{
|
|
|
|
if (strcasecmp(_drivers[i]->name, type) == 0)
|
|
|
|
return _drivers[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *GB_COMPRESS_1[] EXPORT = {
|
|
|
|
|
|
|
|
(void *)1,
|
|
|
|
|
|
|
|
(void *)COMPRESS_Register,
|
|
|
|
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
GB_DESC *GB_CLASSES[] EXPORT =
|
|
|
|
{
|
|
|
|
CCompressDesc,
|
|
|
|
CUncompressDesc,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
int EXPORT GB_INIT(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EXPORT GB_EXIT()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|