#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "php_parse_tree.h"
Go to the source code of this file.
Functions | |
int | main (int argc, char *argv[]) |
int main | ( | int | argc, | |
char * | argv[] | |||
) |
Definition at line 6 of file parse_tree.c.
References _error, _xml_output, yyin, and yyparse().
00007 { 00008 char filename[512] = ""; 00009 extern FILE* yyin; 00010 extern char* _xml_output; 00011 extern int _error; 00012 00013 if (argc < 2) 00014 return 0; 00015 strncpy(filename, argv[1], 512); 00016 yyin = fopen(filename, "r"); 00017 if (!yyin) { 00018 return 0; 00019 } 00020 yyparse(); 00021 fclose(yyin); 00022 if(_error){ 00023 return 0; 00024 } 00025 char outfname[1024]; 00026 if (argc == 3) { 00027 strncpy(outfname, argv[2], 1024); 00028 } 00029 else { 00030 strncpy(outfname, filename, 512); 00031 strcat(outfname, ".xml"); 00032 } 00033 FILE *temp = (FILE *)NULL; 00034 if ((temp = fopen(outfname, "w"))) 00035 { 00036 fprintf(temp, "%s",_xml_output); 00037 } 00038 fclose(temp); 00039 return 0; 00040 }