Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenrgenstat.c
Go to the documentation of this file.
00001 /* 00002 * Generate a file with API status information from a list 00003 * of files in a directory. 00004 * Casper S. Hornstrup <chorns@users.sourceforge.net> 00005 */ 00006 00007 #include <stdio.h> 00008 #include <fcntl.h> 00009 #include <sys/stat.h> 00010 #include <stdlib.h> 00011 #include <string.h> 00012 00013 #ifdef WIN32 00014 #include <io.h> 00015 #include <dos.h> 00016 #include <windows.h> 00017 int __cdecl strcasecmp (const char * __sz1, const char * __sz2) 00018 {return _stricmp (__sz1, __sz2);} 00019 #else 00020 #if !defined(__FreeBSD__) && !defined(__APPLE__) 00021 #include <sys/io.h> 00022 #endif 00023 #include <errno.h> 00024 #include <sys/types.h> 00025 #include <dirent.h> 00026 #include <unistd.h> 00027 #endif 00028 #include <ctype.h> 00029 #ifndef WIN32 00030 #ifndef MAX_PATH 00031 #define MAX_PATH 260 00032 #endif 00033 #define DIR_SEPARATOR_CHAR '/' 00034 #define DIR_SEPARATOR_STRING "/" 00035 #else 00036 #define DIR_SEPARATOR_CHAR '\\' 00037 #define DIR_SEPARATOR_STRING "\\" 00038 #endif 00039 00040 #define TAG_UNKNOWN -1 00041 #define TAG_IMPLEMENTED 0 00042 #define TAG_UNIMPLEMENTED 1 00043 00044 typedef struct _API_INFO 00045 { 00046 struct _API_INFO *next; 00047 int tag_id; 00048 char name[100]; 00049 char filename[MAX_PATH]; 00050 } API_INFO, *PAPI_INFO; 00051 00052 00053 PAPI_INFO sort_linked_list(PAPI_INFO, 00054 unsigned, int (*)(PAPI_INFO, PAPI_INFO)); 00055 00056 00057 static FILE *in; 00058 static FILE *out; 00059 static FILE *file_handle = NULL; 00060 static char *file_buffer = NULL; 00061 static unsigned int file_size = 0; 00062 static unsigned int file_pointer = 0; 00063 static char tagname[200]; 00064 static PAPI_INFO api_info_list = NULL; 00065 00066 00067 static char* 00068 convert_path(char* origpath) 00069 { 00070 char* newpath; 00071 int i; 00072 00073 newpath = strdup(origpath); 00074 00075 i = 0; 00076 while (newpath[i] != 0) 00077 { 00078 #ifndef WIN32 00079 if (newpath[i] == '\\') 00080 { 00081 newpath[i] = '/'; 00082 } 00083 #else 00084 #ifdef WIN32 00085 if (newpath[i] == '/') 00086 { 00087 newpath[i] = '\\'; 00088 } 00089 #endif 00090 #endif 00091 i++; 00092 } 00093 return(newpath); 00094 } 00095 00096 static char* 00097 path_to_url(char* path) 00098 { 00099 int i; 00100 00101 i = 0; 00102 while (path[i] != 0) 00103 { 00104 if (path[i] == '\\') 00105 { 00106 path[i] = '/'; 00107 } 00108 i++; 00109 } 00110 return(path); 00111 } 00112 00113 static void 00114 write_line(char *line) 00115 { 00116 char buf[200]; 00117 00118 memset(buf, 0, sizeof(buf)); 00119 strcpy(buf, line); 00120 /* Terminate the line */ 00121 buf[strlen(buf)] = '\r'; 00122 buf[strlen(buf)] = '\n'; 00123 00124 (void)fwrite(&buf[0], 1, strlen(buf), out); 00125 } 00126 00127 00128 static void 00129 read_file(char *filename) 00130 { 00131 file_handle = fopen(filename, "rb"); 00132 if (file_handle == NULL) 00133 { 00134 printf("Can't open %s\n", filename); 00135 exit(1); 00136 } 00137 00138 // Get the size of the file 00139 fseek(file_handle, 0, SEEK_END); 00140 file_size = ftell(file_handle); 00141 00142 // Load it all into memory 00143 file_buffer = malloc(file_size); 00144 if (file_buffer == NULL) 00145 { 00146 fclose(file_handle); 00147 printf("Out of memory\n"); 00148 exit(1); 00149 } 00150 fseek(file_handle, 0, SEEK_SET); 00151 if (file_size > 0) 00152 { 00153 if (fread (file_buffer, 1, file_size, file_handle) < 1) 00154 { 00155 fclose(file_handle); 00156 printf("Read error in file %s\n", filename); 00157 exit(1); 00158 } 00159 } 00160 00161 file_pointer = 0; 00162 } 00163 00164 static void 00165 close_file() 00166 { 00167 free(file_buffer); 00168 file_buffer = NULL; 00169 fclose(file_handle); 00170 file_handle = NULL; 00171 file_pointer = 0; 00172 } 00173 00174 static int 00175 is_whitespace(char ch) 00176 { 00177 if (ch == ' ') 00178 { 00179 return 1; 00180 } 00181 if (ch == '\t') 00182 { 00183 return 1; 00184 } 00185 return 0; 00186 } 00187 00188 static int 00189 is_eol_char(char ch) 00190 { 00191 if (ch == '\r') 00192 { 00193 return 1; 00194 } 00195 if (ch == '\n') 00196 { 00197 return 1; 00198 } 00199 return 0; 00200 } 00201 00202 static int 00203 is_end_of_tag(char ch) 00204 { 00205 if ((ch >= 'a') && (ch <= 'z')) 00206 { 00207 return 0; 00208 } 00209 if ((ch >= 'A') && (ch <= 'Z')) 00210 { 00211 return 0; 00212 } 00213 if ((ch >= '0') && (ch <= '9')) 00214 { 00215 return 0; 00216 } 00217 if (ch == '_') 00218 { 00219 return 0; 00220 } 00221 return 1; 00222 } 00223 00224 static int 00225 is_end_of_name(char ch) 00226 { 00227 /* Currently the same as is_end_of_tag() */ 00228 return is_end_of_tag(ch); 00229 } 00230 00231 static int 00232 is_valid_file(char *filename) 00233 { 00234 char ext[MAX_PATH]; 00235 int i; 00236 00237 i = strlen(filename); 00238 while (i > 0 && filename[i] != '.') 00239 { 00240 i--; 00241 } 00242 if (i > 0) 00243 { 00244 memset(ext, 0, sizeof(ext)); 00245 strncpy(&ext[0], &filename[i], strlen(&filename[i])); 00246 00247 if ((strncmp(ext, ".c", 2) == 0) || (strncmp(ext, ".C", 2) == 0)) 00248 { 00249 return 1; 00250 } 00251 } 00252 return 0; 00253 } 00254 00255 static int 00256 get_tag_id(char *tag) 00257 { 00258 if (strcasecmp(tag, "implemented") == 0) 00259 { 00260 return TAG_IMPLEMENTED; 00261 } 00262 if (strcasecmp(tag, "unimplemented") == 0) 00263 { 00264 return TAG_UNIMPLEMENTED; 00265 } 00266 return TAG_UNKNOWN; 00267 } 00268 00269 static int 00270 skip_to_next_tag() 00271 { 00272 unsigned int start; 00273 int end_of_tag; 00274 int found_tag = 0; 00275 int tag_id; 00276 int len; 00277 00278 tagname[0] = 0; 00279 while ((file_pointer < file_size) && (!found_tag)) 00280 { 00281 if (file_buffer[file_pointer] == '@') 00282 { 00283 file_pointer++; 00284 start = file_pointer; 00285 end_of_tag = 0; 00286 while ((file_pointer < file_size) && (!end_of_tag)) 00287 { 00288 end_of_tag = is_end_of_tag(file_buffer[file_pointer]); 00289 file_pointer++; 00290 } 00291 len = file_pointer > start ? file_pointer - start - 1 : 0; 00292 strncpy(tagname, &file_buffer[start], len); 00293 tagname[len] = 0; 00294 00295 tag_id = get_tag_id(tagname); 00296 if (tag_id != TAG_UNKNOWN) 00297 { 00298 return tag_id; 00299 } 00300 } 00301 file_pointer++; 00302 } 00303 00304 return TAG_UNKNOWN; 00305 } 00306 00307 static void 00308 skip_line() 00309 { 00310 while ((file_pointer < file_size) && (!is_eol_char(file_buffer[file_pointer]))) 00311 { 00312 file_pointer++; 00313 } 00314 if ((file_pointer < file_size) && (file_buffer[file_pointer] == '\n')) 00315 { 00316 file_pointer++; 00317 } 00318 } 00319 00320 static void 00321 skip_comments() 00322 { 00323 while ((file_pointer < file_size)) 00324 { 00325 if (file_buffer[file_pointer] == '*') 00326 { 00327 if ((file_pointer + 1 < file_size)) 00328 { 00329 if (file_buffer[file_pointer + 1] == '/') 00330 { 00331 skip_line(); 00332 return; 00333 } 00334 } 00335 } 00336 file_pointer++; 00337 } 00338 } 00339 00340 static int 00341 get_previous_identifier(unsigned int end, char *name) 00342 { 00343 unsigned int my_file_pointer = end; 00344 int len; 00345 00346 name[0] = 0; 00347 00348 while ((my_file_pointer > 0) && (is_whitespace(file_buffer[my_file_pointer]) 00349 || is_eol_char(file_buffer[my_file_pointer]))) 00350 { 00351 my_file_pointer--; 00352 } 00353 00354 /* Skip any comments between function name and it's parameters */ 00355 if ((my_file_pointer > 0) && (file_buffer[my_file_pointer] == '/')) 00356 { 00357 if ((my_file_pointer > 0) && (file_buffer[my_file_pointer - 1] == '*')) 00358 { 00359 my_file_pointer--; 00360 while ((my_file_pointer > 0) && !((file_buffer[my_file_pointer] == '*') 00361 && (file_buffer[my_file_pointer - 1] == '/'))) 00362 { 00363 my_file_pointer--; 00364 } 00365 my_file_pointer -= 2; 00366 } 00367 } 00368 00369 /* Skip any remaining whitespace */ 00370 while ((my_file_pointer > 0) && (is_whitespace(file_buffer[my_file_pointer]))) 00371 { 00372 my_file_pointer--; 00373 } 00374 00375 end = my_file_pointer; 00376 while ((my_file_pointer > 0)) 00377 { 00378 if (is_end_of_name(file_buffer[my_file_pointer])) 00379 { 00380 len = end - my_file_pointer; 00381 strncpy(name, &file_buffer[my_file_pointer + 1], len); 00382 name[len] = 0; 00383 return 1; 00384 } 00385 my_file_pointer--; 00386 } 00387 00388 return 0; 00389 } 00390 00391 static int 00392 skip_to_next_name(char *name) 00393 { 00394 while ((file_pointer < file_size)) 00395 { 00396 if (file_buffer[file_pointer] == '(') 00397 { 00398 return get_previous_identifier(file_pointer - 1, name); 00399 } 00400 file_pointer++; 00401 } 00402 return 0; 00403 } 00404 00405 // Build a path and filename so it is of the format [module][directory][filename]. 00406 // Also convert all backslashes into forward slashes. 00407 static void 00408 get_filename(char *cvspath, char *filename, char *result) 00409 { 00410 strcpy(result, cvspath); 00411 strcat(result, filename); 00412 path_to_url(result); 00413 } 00414 00415 static void 00416 parse_file(char *fullname, char *cvspath, char *filename) 00417 { 00418 PAPI_INFO api_info; 00419 char prev[200]; 00420 char name[200]; 00421 int tag_id; 00422 00423 read_file(fullname); 00424 00425 prev[0] = 0; 00426 do 00427 { 00428 tag_id = skip_to_next_tag(); 00429 if (tag_id == TAG_UNKNOWN) 00430 { 00431 break; 00432 } 00433 00434 /* Skip rest of the comments between the tag and the function name */ 00435 skip_comments(); 00436 00437 if (skip_to_next_name(name)) 00438 { 00439 if (strlen(name) == 0) 00440 { 00441 printf("Warning: empty function name in file %s. Previous function name was %s.\n", 00442 fullname, prev); 00443 } 00444 api_info = malloc(sizeof(API_INFO)); 00445 if (api_info == NULL) 00446 { 00447 printf("Out of memory\n"); 00448 exit(1); 00449 } 00450 00451 api_info->tag_id = tag_id; 00452 strcpy(api_info->name, name); 00453 00454 get_filename(cvspath, filename, api_info->filename); 00455 00456 api_info->next = api_info_list; 00457 api_info_list = api_info; 00458 strcpy(prev, name); 00459 } 00460 } while (1); 00461 00462 close_file(); 00463 } 00464 00465 #ifdef WIN32 00466 00467 /* Win32 version */ 00468 static void 00469 process_directory (char *path, char *cvspath) 00470 { 00471 struct _finddata_t f; 00472 int findhandle; 00473 char searchbuf[MAX_PATH]; 00474 char buf[MAX_PATH]; 00475 char newcvspath[MAX_PATH]; 00476 00477 strcpy(searchbuf, path); 00478 strcat(searchbuf, "*.*"); 00479 00480 findhandle =_findfirst(searchbuf, &f); 00481 if (findhandle != -1) 00482 { 00483 do 00484 { 00485 if (f.attrib & _A_SUBDIR) 00486 { 00487 if (f.name[0] != '.') 00488 { 00489 strcpy(buf, path); 00490 strcat(buf, f.name); 00491 strcat(buf, DIR_SEPARATOR_STRING); 00492 00493 strcpy(newcvspath, cvspath); 00494 strcat(newcvspath, f.name); 00495 strcat(newcvspath, "/"); 00496 00497 process_directory(buf, newcvspath); 00498 } 00499 continue; 00500 } 00501 00502 strcpy(buf, path); 00503 strcat(buf, f.name); 00504 00505 /* Must be a .c file */ 00506 if (!is_valid_file(buf)) 00507 { 00508 continue; 00509 } 00510 00511 parse_file(buf, cvspath, f.name); 00512 } 00513 while (_findnext(findhandle, &f) == 0); 00514 _findclose(findhandle); 00515 } 00516 else 00517 { 00518 printf("Cannot open directory '%s'", path); 00519 exit(1); 00520 } 00521 } 00522 00523 #else 00524 00525 /* Linux version */ 00526 static void 00527 process_directory (char *path, char *cvspath) 00528 { 00529 DIR *dirp; 00530 struct dirent *entry; 00531 struct stat stbuf; 00532 char buf[MAX_PATH]; 00533 char newcvspath[MAX_PATH]; 00534 00535 #ifdef HAVE_D_TYPE 00536 dirp = opendir(path); 00537 if (dirp != NULL) 00538 { 00539 while ((entry = readdir(dirp)) != NULL) 00540 { 00541 if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) 00542 continue; // skip self and parent 00543 00544 if (entry->d_type == DT_REG) // normal file 00545 { 00546 // Check for an absolute path 00547 if (path[0] == DIR_SEPARATOR_CHAR) 00548 { 00549 strcpy(buf, path); 00550 strcat(buf, DIR_SEPARATOR_STRING); 00551 strcat(buf, entry->d_name); 00552 } 00553 else 00554 { 00555 if (!getcwd(buf, sizeof(buf))) 00556 { 00557 printf("Can't get CWD: %s\n", strerror(errno)); 00558 return; 00559 } 00560 strcat(buf, DIR_SEPARATOR_STRING); 00561 strcat(buf, path); 00562 strcat(buf, entry->d_name); 00563 } 00564 00565 if (stat(buf, &stbuf) == -1) 00566 { 00567 printf("Can't access '%s' (%s)\n", buf, strerror(errno)); 00568 return; 00569 } 00570 00571 if (S_ISDIR(stbuf.st_mode)) 00572 { 00573 strcpy(newcvspath, cvspath); 00574 strcat(newcvspath, f.name); 00575 strcat(newcvspath, "/"); 00576 00577 process_directory(buf, newcvspath); 00578 continue; 00579 } 00580 00581 /* Must be a .c file */ 00582 if (!is_valid_file(buf)) 00583 { 00584 continue; 00585 } 00586 00587 parse_file(buf, cvspath, entry->d_name); 00588 } 00589 } 00590 closedir(dirp); 00591 } 00592 else 00593 { 00594 printf("Can't open %s\n", path); 00595 exit(1); 00596 } 00597 00598 #else 00599 00600 dirp = opendir(path); 00601 if (dirp != NULL) 00602 { 00603 while ((entry = readdir(dirp)) != NULL) 00604 { 00605 if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) 00606 continue; // skip self and parent 00607 00608 // Check for an absolute path 00609 if (path[0] == DIR_SEPARATOR_CHAR) 00610 { 00611 strcpy(buf, path); 00612 strcat(buf, DIR_SEPARATOR_STRING); 00613 strcat(buf, entry->d_name); 00614 } 00615 else 00616 { 00617 if (!getcwd(buf, sizeof(buf))) 00618 { 00619 printf("Can't get CWD: %s\n", strerror(errno)); 00620 return; 00621 } 00622 strcat(buf, DIR_SEPARATOR_STRING); 00623 strcat(buf, path); 00624 strcat(buf, entry->d_name); 00625 } 00626 00627 if (stat(buf, &stbuf) == -1) 00628 { 00629 printf("Can't access '%s' (%s)\n", buf, strerror(errno)); 00630 return; 00631 } 00632 00633 if (S_ISDIR(stbuf.st_mode)) 00634 { 00635 strcpy(newcvspath, cvspath); 00636 strcat(newcvspath, entry->d_name); 00637 strcat(newcvspath, "/"); 00638 00639 process_directory(buf, newcvspath); 00640 continue; 00641 } 00642 00643 /* Must be a .c file */ 00644 if (!is_valid_file(buf)) 00645 { 00646 continue; 00647 } 00648 00649 parse_file(buf, cvspath, entry->d_name); 00650 } 00651 closedir(dirp); 00652 } 00653 else 00654 { 00655 printf("Can't open %s\n", path); 00656 exit(1); 00657 } 00658 00659 #endif 00660 } 00661 00662 #endif 00663 00664 /* 00665 * This function compares two API entries. It returns a negative value if p is 00666 * before q, or a positive value if p is after q. 00667 */ 00668 static int 00669 compare_api_order(PAPI_INFO p, PAPI_INFO q) 00670 { 00671 return strcmp(p->name, q->name); 00672 } 00673 00674 char * 00675 get_filename_without_base(char *component_base, 00676 char *filename) 00677 { 00678 return &filename[strlen(component_base)]; 00679 } 00680 00681 static void 00682 generate_xml_for_component(char *component_name, 00683 char *component_base) 00684 { 00685 PAPI_INFO api_info; 00686 char canonical_base[MAX_PATH]; 00687 char buf[200]; 00688 int complete; 00689 int implemented_total; 00690 int unimplemented_total; 00691 00692 // Sort list 00693 api_info_list = sort_linked_list(api_info_list, 0, compare_api_order); 00694 00695 implemented_total = 0; 00696 unimplemented_total = 0; 00697 00698 api_info = api_info_list; 00699 while (api_info != NULL) 00700 { 00701 if (api_info->tag_id == TAG_IMPLEMENTED) 00702 implemented_total ++; 00703 else if (api_info->tag_id == TAG_UNIMPLEMENTED) 00704 unimplemented_total ++; 00705 00706 api_info = api_info->next; 00707 } 00708 00709 if (implemented_total + unimplemented_total > 0) 00710 complete = ((implemented_total) * 100) / (implemented_total + unimplemented_total); 00711 else 00712 complete = 100; 00713 00714 strcpy(canonical_base, component_base); 00715 path_to_url(canonical_base); 00716 00717 sprintf(buf, "<component name=\"%s\" base=\"%s\" complete=\"%d\" implemented_total=\"%d\" unimplemented_total=\"%d\">", 00718 component_name, canonical_base, complete, implemented_total, unimplemented_total); 00719 write_line(buf); 00720 00721 if (api_info_list != NULL) 00722 { 00723 write_line("<functions>"); 00724 00725 api_info = api_info_list; 00726 while (api_info != NULL) 00727 { 00728 sprintf(buf, "<f n=\"%s\" i=\"%s\" f=\"%s\" />", 00729 api_info->name, 00730 api_info->tag_id == TAG_IMPLEMENTED ? "true" : "false", 00731 get_filename_without_base(component_base, 00732 api_info->filename)); 00733 write_line(buf); 00734 api_info = api_info->next; 00735 } 00736 00737 write_line("</functions>"); 00738 } 00739 00740 write_line("</component>"); 00741 } 00742 00743 static void 00744 read_input_file(char *input_file) 00745 { 00746 char component_name[MAX_PATH]; 00747 char component_path[MAX_PATH]; 00748 char *canonical_path; 00749 unsigned int index; 00750 unsigned int start; 00751 PAPI_INFO api_info; 00752 PAPI_INFO next_api_info; 00753 char *buffer; 00754 unsigned int size; 00755 int len; 00756 00757 in = fopen(input_file, "rb"); 00758 if (in == NULL) 00759 { 00760 printf("Cannot open input file"); 00761 exit(1); 00762 } 00763 00764 // Get the size of the file 00765 fseek(in, 0, SEEK_END); 00766 size = ftell(in); 00767 00768 // Load it all into memory 00769 buffer = malloc(size); 00770 if (buffer == NULL) 00771 { 00772 fclose(in); 00773 printf("Out of memory\n"); 00774 exit(1); 00775 } 00776 fseek(in, 0, SEEK_SET); 00777 if (fread (buffer, 1, size, in) < 1) 00778 { 00779 fclose(in); 00780 printf("Read error in file %s\n", input_file); 00781 exit(1); 00782 } 00783 00784 index = 0; 00785 00786 write_line("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>"); 00787 write_line("<?xml-stylesheet type=\"text/xsl\" href=\"rapistatus.xsl\"?>"); 00788 write_line(""); 00789 write_line("<components>"); 00790 00791 while (1) 00792 { 00793 /* Free previous list */ 00794 for (api_info = api_info_list; api_info != NULL; api_info = next_api_info) 00795 { 00796 next_api_info = api_info->next; 00797 free(api_info); 00798 } 00799 api_info_list = NULL; 00800 00801 /* Skip whitespace and eol characters */ 00802 while ((index < size) && (is_whitespace(buffer[index]) || (is_eol_char(buffer[index])))) 00803 index++; 00804 if ((file_pointer < size) && (buffer[index] == '\n')) 00805 index++; 00806 00807 if (buffer[index] == ';') 00808 { 00809 /* Skip comments */ 00810 while ((index < size) && (!is_eol_char(buffer[index]))) 00811 index++; 00812 if ((index < size) && (buffer[index] == '\n')) 00813 index++; 00814 continue; 00815 } 00816 00817 /* Get component name */ 00818 start = index; 00819 while ((index < size) && (!is_whitespace(buffer[index]))) 00820 index++; 00821 if (index >= size) 00822 break; 00823 00824 len = index - start; 00825 strncpy(component_name, &buffer[start], len); 00826 component_name[len] = 0; 00827 00828 /* Skip whitespace */ 00829 while ((index < size) && (is_whitespace(buffer[index]))) 00830 index++; 00831 if (index >= size) 00832 break; 00833 00834 /* Get component path */ 00835 start = index; 00836 while ((index < size) && (!is_whitespace(buffer[index]) && !is_eol_char(buffer[index]))) 00837 index++; 00838 00839 len = index - start; 00840 strncpy(component_path, &buffer[start], len); 00841 component_path[len] = 0; 00842 00843 /* Append directory separator if needed */ 00844 if (component_path[strlen(component_path)] != DIR_SEPARATOR_CHAR) 00845 { 00846 int i = strlen(component_path); 00847 component_path[strlen(component_path)] = DIR_SEPARATOR_CHAR; 00848 component_path[i + 1] = 0; 00849 } 00850 00851 /* Skip to end of line */ 00852 while ((index < size) && (!is_eol_char(buffer[index]))) 00853 index++; 00854 if ((index < size) && (buffer[index] == '\n')) 00855 index++; 00856 00857 canonical_path = convert_path(component_path); 00858 if (canonical_path != NULL) 00859 { 00860 process_directory(canonical_path, canonical_path); 00861 free(canonical_path); 00862 generate_xml_for_component(component_name, 00863 component_path); 00864 } 00865 } 00866 00867 write_line("</components>"); 00868 } 00869 00870 static char HELP[] = 00871 "RGENSTAT input-filename output-filename\n" 00872 "\n" 00873 " input-filename File containing list of components to process\n" 00874 " output-filename File to create\n"; 00875 00876 int main(int argc, char **argv) 00877 { 00878 char *input_file; 00879 char *output_file; 00880 00881 if (argc != 3) 00882 { 00883 puts(HELP); 00884 return 1; 00885 } 00886 00887 input_file = convert_path(argv[1]); 00888 if (input_file[0] == 0) 00889 { 00890 free(input_file); 00891 printf("Missing input-filename\n"); 00892 return 1; 00893 } 00894 00895 output_file = convert_path(argv[2]); 00896 if (output_file[0] == 0) 00897 { 00898 free(input_file); 00899 free(output_file); 00900 printf("Missing output-filename\n"); 00901 return 1; 00902 } 00903 00904 out = fopen(output_file, "wb"); 00905 if (out == NULL) 00906 { 00907 free(input_file); 00908 free(output_file); 00909 printf("Cannot open output file"); 00910 return 1; 00911 } 00912 00913 read_input_file(input_file); 00914 00915 free(input_file); 00916 free(output_file); 00917 fclose(out); 00918 00919 return 0; 00920 } 00921 00922 /* EOF */ Generated on Sat May 19 2012 04:35:43 for ReactOS by
1.7.6.1
|