Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
PopovEvgeniy committed Aug 18, 2019
1 parent 913f6d5 commit 6e2316d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 34 deletions.
65 changes: 36 additions & 29 deletions grpdecompiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ void show_progress(const unsigned long int start,const unsigned long int stop);
FILE *open_input_file(const char *name);
FILE *create_output_file(const char *name);
void data_dump(FILE *input,FILE *output,const size_t length);
void fast_data_dump(FILE *input,FILE *output,const size_t length);
void write_output_file(FILE *input,const char *name,const size_t length);
void check_memory(const void *memory);
char *get_string_memory(const size_t length);
Expand Down Expand Up @@ -42,10 +43,10 @@ void show_intro()
{
putchar('\n');
puts("GRP DECOMPILER");
puts("Version 2.0.4");
puts("Version 2.0.6");
puts("This program distributed under GNU GENERAL PUBLIC LICENSE");
puts("File extraction tools for GRP pseudo-archives by Popov Evgeniy Alekseyevich");
puts("2010-2018 years");
puts("2010-2019 years");
putchar('\n');
}

Expand All @@ -61,7 +62,7 @@ void show_start_message()

void show_end_message()
{
puts(" ");
putchar('\n');
puts("Work finish");
}

Expand All @@ -77,49 +78,55 @@ void show_progress(const unsigned long int start,const unsigned long int stop)

FILE *open_input_file(const char *name)
{
FILE *file;
file=fopen(name,"rb");
if (file==NULL)
FILE *target;
target=fopen(name,"rb");
if (target==NULL)
{
puts(" ");
puts("File operation error");
exit(2);
putchar('\n');
puts("Can't open input file");
exit(1);
}
return file;
return target;
}

FILE *create_output_file(const char *name)
{
FILE *file;
file=fopen(name,"wb");
if (file==NULL)
FILE *target;
target=fopen(name,"wb");
if (target==NULL)
{
puts(" ");
puts("File operation error");
putchar('\n');
puts("Can't create ouput file");
exit(2);
}
return file;
return target;
}

void data_dump(FILE *input,FILE *output,const size_t length)
{
unsigned char single_byte;
unsigned char data;
size_t index;
data=0;
for (index=0;index<length;++index)
{
fread(&data,sizeof(unsigned char),1,input);
fwrite(&data,sizeof(unsigned char),1,input);
}

}

void fast_data_dump(FILE *input,FILE *output,const size_t length)
{
unsigned char *buffer=NULL;
buffer=(unsigned char*)calloc(length,sizeof(unsigned char));
if (buffer==NULL)
{
for(index=0;index<length;++index)
{
fread(&single_byte,1,1,input);
fwrite(&single_byte,1,1,output);
}

data_dump(input,output,length);
}
else
{
fread(buffer,length,1,input);
fwrite(buffer,length,1,output);
fread(buffer,sizeof(unsigned char),length,input);
fwrite(buffer,sizeof(unsigned char),length,output);
free(buffer);
}

Expand All @@ -129,17 +136,17 @@ void write_output_file(FILE *input,const char *name,const size_t length)
{
FILE *output;
output=create_output_file(name);
data_dump(input,output,length);
fast_data_dump(input,output,length);
fclose(output);
}

void check_memory(const void *memory)
{
if(memory==NULL)
{
puts(" ");
putchar('\n');
puts("Can't allocate memory");
exit(1);
exit(3);
}

}
Expand Down Expand Up @@ -208,7 +215,7 @@ size_t check_format(FILE *input)
if(strncmp(target.information,"KenSilverman",12)!=0)
{
puts("Bad signature of GRP pseudo-archive!");
exit(3);
exit(4);
}
return (size_t)target.length;
}
Expand Down
12 changes: 7 additions & 5 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GRP DECOMPILER

Version 2.0.4.1
Version 2.0.6

File extraction tools for GRP pseudo-archives by Popov Evgeniy Alekseyevich

Expand All @@ -18,9 +18,10 @@ Always add directory separator(\ or /) at end of output path.
Exit codes

0 - Operation successfully complete.
1 - Can't allocate memory.
2 - File operation error.
3 - Invalid format.
1 - Can't open input file.
2 - Can't create output file.
3 - Can't allocate memory.
4 - Invalid format.

License

Expand Down Expand Up @@ -65,4 +66,5 @@ Version history
1.9.1 - 1.9.6 - Small changes.
1.9.8 - 2.0.1 - Small bug with output file names was fixed.
2.0.2 - 2.0.4 - Small changes.
2.0.4.1 - Makefile was updated.
2.0.4.1 - Makefile was updated.
2.0.5 - 2.0.6 - Small changes.

0 comments on commit 6e2316d

Please sign in to comment.