diff --git a/FileInputUtils.c b/FileInputUtils.c index aeb9af0..ca780aa 100644 --- a/FileInputUtils.c +++ b/FileInputUtils.c @@ -40,7 +40,7 @@ unsigned int get_file_size(char fname[]) } // open, read file, save content into string variable -void get_file_content(char fname[],char content[], unsigned int flen) +void get_file_content(char fname[],char content[]) { FILE *fp; fp = fopen(fname, "r"); diff --git a/vbs2exe.c b/vbs2exe.c index 8fc4a07..932fc85 100644 --- a/vbs2exe.c +++ b/vbs2exe.c @@ -11,49 +11,47 @@ int main(int argc, char *argv[]) instructions(); exit(1); } - else + + // check argv[1l length + if (strlen(argv[1]) > 20) { - // chech argv[1l length - if (strlen(argv[1]) > 20) - { - printf("Name must be 20 characters long max."); - exit(4); - } + printf("Name must be 20 characters long max."); + exit(4); + } - // get file name - strcpy(fname, argv[1]); + // get file name + strcpy(fname, argv[1]); - // add vbs extension if necessary - if (!check_vbs_extension(fname)) - { - strcat(fname, ".vbs"); - } + // add vbs extension if necessary + if (!check_vbs_extension(fname)) + { + strcat(fname, ".vbs"); + } - // check file existence - if (!file_exists(fname)) - { - printf("File not found."); - exit(2); - } + // check file existence + if (!file_exists(fname)) + { + printf("File not found."); + exit(2); + } - // count chars of file and malloc - flen = get_file_size(fname); - if (flen == 0) - { - printf("File is empty."); - exit(3); - } - - fcontent = (char *) malloc((flen + 1)* (sizeof(char *))); - // content of the file is into the string now - get_file_content(fname, fcontent, flen); + // count chars of file and malloc + flen = get_file_size(fname); + if (flen == 0) + { + printf("File is empty."); + exit(3); + } + + fcontent = (char *) malloc((flen + 1)* (sizeof(char *))); + // content of the file is into the string now + get_file_content(fname, fcontent); - // create the exe file - create_exe_file(fname, fcontent); + // create the exe file + create_exe_file(fname, fcontent); - // freedom - free(fcontent); - } + // freedom + free(fcontent); return 0; }