Buildtools: Add "unpackssi" and "Build Customization Suite" [Palette Importer/Extractor] (bsuite), both by JonoF. I have rewritten bsuite to use command-line arguments rather than a 16-bit real mode DOS UI. Both programs have had all warnings fixed and whitespace corrected.

git-svn-id: https://svn.eduke32.com/eduke32@2493 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2012-03-18 08:48:32 +00:00
parent 0f7615daf7
commit 3503a42a9a
6 changed files with 685 additions and 3 deletions

View file

@ -174,9 +174,11 @@ OURCFLAGS+= $(BUILDCFLAGS)
UTILOBJS=$(OBJ)/kextract.$o $(OBJ)/kgroup.$o $(OBJ)/transpal.$o $(OBJ)/wad2art.$o $(OBJ)/wad2map.$o $(OBJ)/md2tool.$o \
$(OBJ)/generateicon.$o $(OBJ)/cacheinfo.$o $(OBJ)/enumdisplay.$o $(OBJ)/arttool.$o $(OBJ)/givedepth.$o $(OBJ)/mkpalette.$o \
$(OBJ)/unpackssi.$o $(OBJ)/bsuite.$o \
$(OBJ)/compat.$o $(OBJ)/compat_tools.$o $(OBJ)/pragmas.$o $(OBJ)/kplib.$o $(OBJ)/cache1d.$o
UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2art$(EXESUFFIX) wad2map$(EXESUFFIX) md2tool$(EXESUFFIX) \
generateicon$(EXESUFFIX) cacheinfo$(EXESUFFIX) arttool$(EXESUFFIX) givedepth$(EXESUFFIX) mkpalette$(EXESUFFIX)
generateicon$(EXESUFFIX) cacheinfo$(EXESUFFIX) arttool$(EXESUFFIX) givedepth$(EXESUFFIX) mkpalette$(EXESUFFIX) \
unpackssi$(EXESUFFIX) bsuite$(EXESUFFIX)
# all: $(OBJ)/$(ENGINELIB) $(OBJ)/$(EDITORLIB)
utils: start $(UTILS) finish
@ -242,6 +244,12 @@ givedepth$(EXESUFFIX): $(OBJ)/givedepth.$o $(UTILADDOBJS)
mkpalette$(EXESUFFIX): $(OBJ)/mkpalette.$o $(UTILADDOBJS)
$(ONESTEP_STATUS)
if $(CC) -o $@ $^ $(UTILLIBS); then $(ONESTEP_OK); fi
unpackssi$(EXESUFFIX): $(OBJ)/unpackssi.$o $(UTILADDOBJS)
$(ONESTEP_STATUS)
if $(CC) -o $@ $^ $(UTILLIBS); then $(ONESTEP_OK); fi
bsuite$(EXESUFFIX): $(OBJ)/bsuite.$o $(UTILADDOBJS)
$(ONESTEP_STATUS)
if $(CC) -o $@ $^ $(UTILLIBS); then $(ONESTEP_OK); fi
# DEPENDENCIES
include Makefile.deps

View file

@ -51,3 +51,5 @@ $(OBJ)/enumdisplay.$o: $(SRC)/misc/enumdisplay.c
$(OBJ)/arttool.$o: $(SRC)/util/arttool.cc
$(OBJ)/givedepth.$o: $(SRC)/util/givedepth.c
$(OBJ)/mkpalette.$o: $(SRC)/util/mkpalette.c
$(OBJ)/unpackssi.$o: $(SRC)/util/unpackssi.c
$(OBJ)/bsuite.$o: $(SRC)/util/bsuite.c

View file

@ -117,7 +117,7 @@ CFLAGS=$(CFLAGS) /DRENDERTYPE$(RENDERTYPE)=1 /W2
$(CC) /c $(CFLAGS) /Fo$@ $<
# TARGETS
UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2art$(EXESUFFIX) wad2map$(EXESUFFIX) md2tool$(EXESUFFIX) generateicon$(EXESUFFIX) cacheinfo$(EXESUFFIX) arttool$(EXESUFFIX) givedepth$(EXESUFFIX) mkpalette$(EXESUFFIX)
UTILS=kextract$(EXESUFFIX) kgroup$(EXESUFFIX) transpal$(EXESUFFIX) wad2art$(EXESUFFIX) wad2map$(EXESUFFIX) md2tool$(EXESUFFIX) generateicon$(EXESUFFIX) cacheinfo$(EXESUFFIX) arttool$(EXESUFFIX) givedepth$(EXESUFFIX) mkpalette$(EXESUFFIX) unpackssi$(EXESUFFIX) bsuite$(EXESUFFIX)
all: $(OBJ)\$(ENGINELIB) $(OBJ)\$(EDITORLIB);
utils: $(UTILS) ;
@ -175,12 +175,20 @@ mkpalette$(EXESUFFIX): $(OBJ)\mkpalette.$o $(OBJ)\nedmalloc.$o
$(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** $(LIBS)
$(MT) -manifest $@.manifest -outputresource:$@
unpackssi$(EXESUFFIX): $(OBJ)\unpackssi.$o $(OBJ)\nedmalloc.$o
$(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** $(LIBS)
$(MT) -manifest $@.manifest -outputresource:$@
bsuite$(EXESUFFIX): $(OBJ)\bsuite.$o $(OBJ)\nedmalloc.$o
$(LINK) /OUT:$@ /SUBSYSTEM:CONSOLE $(flags_link) /MAP $** $(LIBS)
$(MT) -manifest $@.manifest -outputresource:$@
# DEPENDENCIES
!include Makefile.deps
# PHONIES
clean:
-del /Q $(ENGINEOBJS) $(EDITOROBJS) $(OBJ)\kextract.$o $(OBJ)\kgroup.$o $(OBJ)\transpal.$o $(OBJ)\wad2art.$o $(OBJ)\wad2map.$o $(OBJ)\md2tool.$o $(OBJ)\generateicon.$o $(OBJ)\cacheinfo.$o $(OBJ)\arttool.$o $(OBJ)\givedepth.$o $(OBJ)\mkpalette.$o $(OBJ)\compat.$o $(OBJ)\compat_tools.$o $(OBJ)\pragmas.$o $(OBJ)\kplib.$o $(OBJ)\cache1d.$o $(OBJ)\nedmalloc.$o
-del /Q $(ENGINEOBJS) $(EDITOROBJS) $(OBJ)\kextract.$o $(OBJ)\kgroup.$o $(OBJ)\transpal.$o $(OBJ)\wad2art.$o $(OBJ)\wad2map.$o $(OBJ)\md2tool.$o $(OBJ)\generateicon.$o $(OBJ)\cacheinfo.$o $(OBJ)\arttool.$o $(OBJ)\givedepth.$o $(OBJ)\mkpalette.$o $(OBJ)\unpackssi.$o $(OBJ)\bsuite.$o $(OBJ)\compat.$o $(OBJ)\compat_tools.$o $(OBJ)\pragmas.$o $(OBJ)\kplib.$o $(OBJ)\cache1d.$o $(OBJ)\nedmalloc.$o
veryclean: clean
-del /Q $(OBJ)\$(ENGINELIB) $(OBJ)\$(EDITORLIB) $(UTILS) *.map *.manifest *.pdb

View file

@ -478,6 +478,8 @@ static inline uint16_t system_15bit_rand(void) { return ((uint16_t)rand())&0x7ff
# define Bfread fread
# define Bfwrite fwrite
# define Bfprintf fprintf
# define Bfscanf fscanf
# define Bfseek fseek
# define Bstrcpy strcpy
# define Bstrncpy strncpy
# define Bstrcmp strcmp

View file

@ -0,0 +1,469 @@
/*
Build Game Customization Suite
Copyright (c) 1999, 2004 Jonathon Fowler
15 September 2004
This is the source code to BCS. It was written in Borland Turbo C++ for DOS
and [was] a 16bit real-mode DOS application. I'm releasing the code because
I have no reason to keep it a secret. Some folks might find it interesting.
BTW, you can use this code for any purpose you want.
Jonathon Fowler
jf@jonof.id.au
http://www.jonof.id.au/
*/
/*
NOTE: This program does not fall under BUILDLIC.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "compat.h"
const char APP_NAME[] = "Build Game Customization Suite v0.2-EDuke32";
const char APP_CPRT[] = "Copyright (c) 1999, 2004 Jonathon Fowler";
int bsExtractD3DPalette(int, const char*);
int bsUpdateD3DPalette(int, const char*);
int bsExtractPalette(const char*);
int bsUpdatePalette(const char*);
const char *MainMenuStrings[] = {
"Options:",
"Extract Duke Nukem 3D-specific Palettes",
"Update Duke Nukem 3D-specific Palettes",
"Extract Build Game Palette",
"Update Build Game Palette"
};
const char *D3DMenuStrings[] = {
"Sub-Option: Duke Nukem 3D-specific Palettes:",
"Water Palette",
"Night-Vision Palette",
"Title Screen Palette",
"3D Realms Logo Palette",
"Episode 1 Ending Animation Palette"
};
const char *pal_deffn[] = {
"GAME.PAL",
"D3DWATER.PAL",
"D3DNVIS.PAL",
"D3DTITLE.PAL",
"D3D3DR.PAL",
"D3DEP1.PAL"
};
int main(const int32_t argc, const char **argv)
{
int opt = 0, d3dpal = 0, k = 0;
int16_t i = 1;
char *filename = NULL; // This is only a pointer. Do not strcpy to it.
char *c = NULL;
Bprintf("%s\n%s\n\n", APP_NAME, APP_CPRT);
if (argc > 1)
{
opt = Bstrtol(argv[i++],NULL,10);
if ((opt == 1 || opt == 2) && i < argc) // Duke-specific palettes
d3dpal = Bstrtol(argv[i++],NULL,10);
while (i < argc)
{
c = (char *)argv[i];
if ((*c == '-')
#ifdef _WIN32
|| (*c == '/')
#endif
)
{
++c;
if (!Bstrcasecmp(c,"f"))
{
if (argc > i+1)
filename = (char *)argv[++i];
++i;
continue;
}
}
++i;
}
}
if (opt < 1 || opt > 4 || (opt < 3 && (d3dpal < 1 || d3dpal > 5)))
{
Bprintf("usage: %s <option> <sub-option(s)> [-f filename]\n",argv[0]);
Bprintf("If a filename is not specified, internal defaults will be used.\n");
Bprintf("\n");
for (k = 0; k < 5; ++k)
{
if (k > 0)
Bprintf("%d - ",k);
Bprintf("%s\n",MainMenuStrings[k]);
}
Bprintf("\n");
for (k = 0; k < 6; ++k)
{
if (k > 0)
Bprintf("%d - ",k);
Bprintf("%s\n",D3DMenuStrings[k]);
}
Bprintf("\n");
/*
Bprintf( "This program is, well, I guess freeware. Questions, suggestions,\n"
"comments and bug reports are welcome at jf@jonof.id.au. Visit\n"
"my website at http://www.jonof.id.au/ for more information\n"
"on this program and others that I may happen to write.\n\n");
*/
}
else
{
if (filename == NULL)
switch (opt)
{
case 1: // Duke-specific palettes
case 2:
filename = (char*)pal_deffn[d3dpal];
break;
case 3: // game palette
case 4:
filename = (char*)pal_deffn[0];
break;
}
switch (opt)
{
case 1: // extract Duke-specific palettes
bsExtractD3DPalette(d3dpal-1, filename);
break;
case 2: // update Duke-specific palettes
bsUpdateD3DPalette(d3dpal-1, filename);
break;
case 3: // extract game palette
bsExtractPalette(filename);
break;
case 4: // update game palette
bsUpdatePalette(filename);
break;
}
}
return 0;
}
const int pal_offsets[5] = {6426, 7194, 7962, 8730, 9498};
#define PAL_LEN 768
/////////////////////////////////////////////////
//
// Extract and update functions
int bsExtractD3DPalette(int palnum, const char *outfn)
{
BFILE *lookup, *out;
char cb[3];
int lp;
Bprintf("Using: %s\n",outfn);
lookup = Bfopen("LOOKUP.DAT", "rb");
if (lookup == NULL)
{
// could not open LOOKUP.DAT
Bprintf("Error opening LOOKUP.DAT!\n"
"Make sure that the file is in the current\n"
"directory, then try again.\n\n");
return 1;
}
// create output file
out = Bfopen(outfn, "w+t");
if (out == NULL)
{
Bfclose(lookup);
Bprintf("Error creating output file!\n"
"The file may be open by another program\n"
"or is read-only, or the disk may be read-only.\n\n");
return 1;
}
// write out the palette data in PSP format
// find palette data
Bfseek(lookup, pal_offsets[palnum], SEEK_SET);
// write out a Paint Shop Pro palette file
Bfprintf(out, "JASC-PAL\n0100\n256\n");
for (lp=0; lp < 256; lp++)
{
cb[0] = Bfgetc(lookup) * 4;
cb[1] = Bfgetc(lookup) * 4;
cb[2] = Bfgetc(lookup) * 4;
Bfprintf(out, "%d %d %d\n", cb[0], cb[1], cb[2]);
}
// close files
Bfclose(out);
Bfclose(lookup);
Bprintf("Palette dumped successfully!\n\n");
return 0;
}
int bsUpdateD3DPalette(int palnum, const char *palfn)
{
BFILE *lookup, *pal;
char cb[3], work[64];
int lp;
Bprintf("Using: %s\n",palfn);
lookup = Bfopen("LOOKUP.DAT", "r+b");
if (lookup == NULL)
{
// could not open LOOKUP.DAT
Bprintf("Error opening LOOKUP.DAT!\n"
"The file may be open by another program\n"
"or is read-only, or the disk may be read-only.\n\n");
return 1;
}
// open source file
pal = Bfopen(palfn, "rt");
if (pal == NULL)
{
Bfclose(lookup);
Bprintf("Error opening palette file!\n"
"Make sure that the file exists.\n\n");
return 1;
}
// read the palette data and write it to LOOKUP.DAT
Bfgets(work, 64, pal);
if (strncmp(work, "JASC-PAL", 8))
{
Bfclose(pal); Bfclose(lookup);
Bprintf("Error validating palette file!\n"
"This palette file appears to be in a format\n"
"other than Paint Shop Pro format. This program\n"
"works only with Paint Shop Pro palette files.\n\n");
return 1;
}
Bfgets(work, 64, pal);
if (strncmp(work, "0100", 4))
{
Bfclose(pal); Bfclose(lookup);
Bprintf("Error validating palette file!\n"
"This palette file appears to be in a version\n"
"other than 0100. This program works only with\n"
"Paint Shop Pro palettes of version 0100.\n\n");
return 1;
}
Bfgets(work, 64, pal);
if (strncmp(work, "256", 3))
{
Bfclose(pal); Bfclose(lookup);
Bprintf("Error validating palette file!\n"
"This palette file appears to be for a palette\n"
"size other than 256 colours. This program works\n"
"only with Paint Shop Pro palettes of 256 colours.\n\n");
return 1;
}
// find palette data
Bfseek(lookup, pal_offsets[palnum], SEEK_SET);
// write out new palette info
for (lp=0; lp < 256; lp++)
{
Bfscanf(pal, "%c %c %c\n", &cb[0], &cb[1], &cb[2]);
Bfputc(cb[0] / 4, lookup);
Bfputc(cb[1] / 4, lookup);
Bfputc(cb[2] / 4, lookup);
}
// close files
Bfclose(pal);
Bfclose(lookup);
Bprintf("Palette updated successfully!\n\n");
return 0;
}
// Format of PALETTE.DAT files
//
// 256 bytes - palette
// 2 bytes - short: number of palette lookups
// n*256 bytes - shading lookup tables
// 256*256 bytes - translucency lookup array
int bsExtractPalette(const char *outfn)
{
BFILE *palette, *out;
char cb[3];
int lp;
Bprintf("Using: %s\n",outfn);
palette = Bfopen("PALETTE.DAT", "rb");
if (palette == NULL)
{
// could not open PALETTE.DAT
Bprintf("Error opening PALETTE.DAT!\n"
"Make sure that the file is in the current\n"
"directory, then try again.\n\n");
return 1;
}
// create output file
out = Bfopen(outfn, "w+t");
if (out == NULL)
{
Bfclose(palette);
Bprintf("Error creating output file!\n"
"The file may be open by another program\n"
"or is read-only, or the disk may be read-only.\n\n");
return 1;
}
// write out the palette data in PSP format
// write out a Paint Shop Pro palette file
Bfprintf(out, "JASC-PAL\n0100\n256\n");
for (lp=0; lp < 256; lp++)
{
cb[0] = Bfgetc(palette) * 4;
cb[1] = Bfgetc(palette) * 4;
cb[2] = Bfgetc(palette) * 4;
Bfprintf(out, "%d %d %d\n", cb[0], cb[1], cb[2]);
}
// close files
Bfclose(out);
Bfclose(palette);
Bprintf("Palette dumped successfully!\n\n");
return 0;
}
int bsUpdatePalette(const char *palfn)
{
BFILE *palette, *pal;
char cb[3], work[64];
int lp;
Bprintf("Using: %s\n",palfn);
palette = Bfopen("PALETTE.DAT", "w+b");
if (palette == NULL)
{
// could not open LOOKUP.DAT
Bprintf("Error opening PALETTE.DAT!\n"
"The file may be open by another program\n"
"or is read-only, or the disk may be read-only.\n\n");
return 1;
}
// open source file
pal = Bfopen(palfn, "rt");
if (pal == NULL)
{
Bfclose(palette);
Bprintf("Error opening palette file!\n"
"Make sure that the file exists.\n\n");
return 1;
}
// read the palette data and write it to PALETTE.DAT
Bfgets(work, 64, pal);
if (strncmp(work, "JASC-PAL", 8))
{
Bfclose(pal); Bfclose(palette);
Bprintf("Error validating palette file!\n"
"This palette file appears to be in a format\n"
"other than Paint Shop Pro format. This program\n"
"works only with Paint Shop Pro palette files.\n\n");
return 1;
}
Bfgets(work, 64, pal);
if (strncmp(work, "0100", 4))
{
Bfclose(pal); Bfclose(palette);
Bprintf("Error validating palette file!\n"
"This palette file appears to be in a version\n"
"other than 0100. This program works only with\n"
"Paint Shop Pro palettes of version 0100.\n\n");
return 1;
}
Bfgets(work, 64, pal);
if (strncmp(work, "256", 3))
{
Bfclose(pal); Bfclose(palette);
Bprintf("Error validating palette file!\n"
"This palette file appears to be for a palette\n"
"size other than 256 colours. This program works\n"
"only with Paint Shop Pro palettes of 256 colours.\n\n");
return 1;
}
// write out new palette info
for (lp=0; lp < 256; lp++)
{
Bfscanf(pal, "%c %c %c\n", &cb[0], &cb[1], &cb[2]);
// put the bytes into the basergb array as well
Bfputc(cb[0] / 4, palette);
Bfputc(cb[1] / 4, palette);
Bfputc(cb[2] / 4, palette);
}
// close files
Bfclose(pal);
Bfclose(palette);
Bprintf("Palette updated successfully!\n"
"Now run TRANSPAL.EXE to create the shading\n"
"and translucency tables for the palette.\n\n");
return 0;
}

View file

@ -0,0 +1,193 @@
/*
.SSI File Unpacker
Copyright (c) 2003 Jonathon Fowler
This is a small program to extract the files from the .SSI package format
which Sunstorm Interactive expansion packs for games like Duke Nukem 3D
are distributed in. It is unsupported but should errors arise, bug reports
are welcome.
Update: 12 June 2003
This updated version includes the ability to extract the SSI revision 2
format as used in Duke Carribean.
This program is distributed under the terms of the GNU General Public
License Version 2 which can be found in the included GNU.txt file.
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
Jonathon Fowler
jf@jonof.id.au
http://www.jonof.id.au/
*/
/*
NOTE: This program does not fall under BUILDLIC.
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
FILE *fp, *ofp;
long i,j=0;
long version;
long numfiles;
unsigned char numchars;
char title[33];
char description[3][71];
struct file {
char name[13];
long length;
} *filenames;
char runfile[13] = "<unknown>";
char buf[1024];
int mode=0, param;
puts("unpackssi - .SSI File Unpacker\n"
"Copyright (c) 2003 Jonathon Fowler\n"
"This software is distributed under the terms of the GNU General Public License.");
if (argc<2) {
puts("\nUsage: unpackssi [-l] <ssifile.ssi> [ssifile2.ssi ...]");
puts(" Unpacks the contents of an SSI file (like those which Sunstorm Interactive");
puts(" expansion packs for Duke Nukem 3D are distributed in) to the current");
puts(" directory. NOTE: Any files which already exist and have the same name as the");
puts(" files contained in the SSI file will be overwritten when extracting.");
puts("\nSwitches:");
puts(" -l List files (no extraction)\n");
return -1;
} else {
param = 1;
if (argv[1][0] == '-') {
param++;
switch (argv[1][1]) {
case 'l': mode = 1; break;
default: printf("Unrecognised switch: %c.\n", argv[1][1]); break;
}
}
}
while (param < argc) {
puts("");
fp = fopen(argv[param],"rb");
if (!fp) return -2;
fread(&version, 4, 1, fp);
if (version != 1 && version != 2) {
fclose(fp);
puts("Error: Unrecognized SSI version.");
return -1;
}
printf("File is SSI Version %ld\n", version);
fread(&numfiles, 4, 1, fp);
fread(&numchars, 1, 1, fp);
if (numchars > 32) numchars = 32;
fread(title, 32, 1, fp);
title[numchars] = 0;
if (version == 2) {
fread(&numchars, 1, 1, fp);
if (numchars > 12) numchars = 12;
fread(runfile, 12, 1, fp);
runfile[numchars] = 0;
}
for (i=0;i<3;i++) {
fread(&numchars, 1, 1, fp);
if (numchars > 70) numchars = 70;
fread(description[i], 70, 1, fp);
description[i][numchars] = 0;
}
filenames = (struct file *)malloc(sizeof(struct file) * numfiles);
if (!filenames) {
fclose(fp);
puts("Error: Failed allocating memory for file index.");
return -2;
}
for (i=0;i<numfiles;i++) {
fread(&numchars, 1, 1, fp);
if (numchars > 12) numchars = 12;
fread(filenames[i].name, 12, 1, fp);
filenames[i].name[numchars] = 0;
fread(&filenames[i].length, 4, 1, fp);
// seek past some stuff I can't seem to fully decipher at the moment
fseek(fp, 34+1+69, SEEK_CUR);
}
printf("File: %s\n"
"Package Title: %s\n"
"Description: %s\n"
" %s\n"
" %s\n"
"Run Filename: %s\n\n"
, argv[param], title, description[0], description[1], description[2], runfile);
if (mode == 1) {
j=0;
puts("File listing:");
}
for (i=0;i<numfiles;i++) {
if (mode == 0) {
ofp = fopen(filenames[i].name, "wb");
if (!ofp) {
printf("Error: Failed creating %s. Unpack operation cancelled.\n", filenames[i].name);
break;
}
printf("Unpacking %s (%ld bytes)...", filenames[i].name, filenames[i].length);
for (j=filenames[i].length; j>1024; j-=1024) {
fread(buf, 1024, 1, fp);
fwrite(buf, 1024, 1, ofp);
}
if (j) {
fread(buf, j, 1, fp);
fwrite(buf, j, 1, ofp);
}
fclose(ofp);
puts("done");
} else if (mode == 1) {
printf(" %-12s %ld bytes\n", filenames[i].name, filenames[i].length);
j += filenames[i].length;
}
}
if (mode == 1) {
puts("");
printf(" %ld files, %ld bytes\n", numfiles, j);
}
fclose(fp);
free(filenames);
param++;
}
return 0;
}