fix naming
This commit is contained in:
44
kpack_c.c
44
kpack_c.c
@@ -7,23 +7,15 @@
|
||||
#include <getopt.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/*
|
||||
TODO
|
||||
|
||||
Usage:
|
||||
kpack [--nologo / -n] [--kernel / -k] [--unpack / -u] <infile> [<outfile>]
|
||||
|
||||
*/
|
||||
|
||||
static const char* str_usage = "Usage: %s [--nologo / -n] [--kernel / -k] [--unpack / -u] <infile> [<outfile>]\n";
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool nologo = false;
|
||||
bool kernel = false;
|
||||
bool unpack = false;
|
||||
char *infile = NULL;
|
||||
char *outfile = NULL;
|
||||
bool flag_nologo = false;
|
||||
bool flag_kernel = false;
|
||||
bool flag_unpack = false;
|
||||
char *infile_name = NULL;
|
||||
char *outfile_name = NULL;
|
||||
int opt;
|
||||
static struct option long_options[] = {
|
||||
{"nologo", no_argument, NULL, 'n'},
|
||||
@@ -34,13 +26,13 @@ int main(int argc, char *argv[])
|
||||
while ((opt = getopt_long(argc, argv, "nku", long_options, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
nologo = true;
|
||||
flag_nologo = true;
|
||||
break;
|
||||
case 'k':
|
||||
kernel = true;
|
||||
flag_kernel = true;
|
||||
break;
|
||||
case 'u':
|
||||
unpack = true;
|
||||
flag_unpack = true;
|
||||
break;
|
||||
default: // '?'
|
||||
fprintf(stderr, str_usage, argv[0]);
|
||||
@@ -53,11 +45,11 @@ int main(int argc, char *argv[])
|
||||
printf(str_usage, argv[0]);
|
||||
return 1;
|
||||
}
|
||||
infile = argv[optind];
|
||||
infile_name = argv[optind];
|
||||
|
||||
// Optional outfile
|
||||
if (optind + 1 < argc) {
|
||||
outfile = argv[optind + 1];
|
||||
outfile_name = argv[optind + 1];
|
||||
optind++;
|
||||
}
|
||||
|
||||
@@ -69,19 +61,19 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// for debug: print parsed options and args
|
||||
printf("nologo: %s\n", nologo ? "true" : "false");
|
||||
printf("kernel: %s\n", kernel ? "true" : "false");
|
||||
printf("unpack: %s\n", unpack ? "true" : "false");
|
||||
printf("infile: %s\n", infile);
|
||||
printf("outfile: %s\n", outfile ? outfile : "Not specified");
|
||||
printf("nologo: %s\n", flag_nologo ? "true" : "false");
|
||||
printf("kernel: %s\n", flag_kernel ? "true" : "false");
|
||||
printf("unpack: %s\n", flag_unpack ? "true" : "false");
|
||||
printf("infile: %s\n", infile_name);
|
||||
printf("outfile: %s\n", outfile_name ? outfile_name : "Not specified");
|
||||
printf("\n");
|
||||
|
||||
if (!nologo) {
|
||||
if (!flag_nologo) {
|
||||
printf("KPackC - Kolibri Packer in C\nUses LZMA v4.32 compression library\n\n");
|
||||
}
|
||||
|
||||
struct stat64 statbuf;
|
||||
int res_stat = stat64(infile, &statbuf);
|
||||
int res_stat = stat64(infile_name, &statbuf);
|
||||
if (res_stat == -1) {
|
||||
printf("Error: cannot load input file\n");
|
||||
return 1;
|
||||
@@ -95,7 +87,7 @@ int main(int argc, char *argv[])
|
||||
unsigned infile_size = (unsigned int)statbuf.st_size;
|
||||
printf("infile_size = %u\n", infile_size);
|
||||
|
||||
FILE *infile_handle = fopen(infile, "rb");
|
||||
FILE *infile_handle = fopen(infile_name, "rb");
|
||||
if (!infile_handle) {
|
||||
printf("Error: cannot load input file\n");
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user