1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- /* This file minifies html files */
- #include <argp.h>
- #include "parse.h"
- bool i = false;
- bool o = false;
- char file_name [128];
- char outputFileName [128];
- const char * argp_program_version = "0.1";
- /* mail bug reports to */
- const char * argp_program_bug_address = "jbranso@fastmail.com";
- static const struct argp_option options [] =
- {
- {"input", 'i', "FILE", 0, "delete the trailing whitespace in the file" },
- {"output", 'o', "FILE", OPTION_ARG_OPTIONAL, "output to save the file"},
- { 0 }
- };
- //parse options
- error_t argp_parser (int opt, char *arg, struct argp_state *state) {
- extern bool i, o;
- extern char file_name [128];
- switch (opt)
- {
- // if this parser function is called on an option that it doesn't recognize, then don't do anything.
- default:
- return ARGP_ERR_UNKNOWN;
- case 'i':
- {
- i = true;
- printf ("file is %s\n", arg);
- memcpy (file_name, arg, strlen (arg));
- break;
- }
- case 'o':
- {
- o = true;
- printf ("file is %s\n", arg);
- memcpy (outputFileName, arg, strlen (arg));
- break;
- }
- }
- return 0;
- }
- struct argp argp =
- { options, argp_parser, 0, "Deletes trailing whitespace." };
- int main (int argc, char **argv) {
- argp_parse (&argp, argc, argv, 0, 0, 0);
- FILE * input_file;
- if (file_name == NULL) /* make this check to see if the array has a string... */
- {
- input_file = fopen(file_name, "r+");
- }
- /* if (outputFileName != 0) { */
- /* FILE * outputFile = fopen(outputFileName, "w"); */
- /* } */
- elementptr element = parse_html (file_name);
- print_elements (element);
- printf("\n");
- fclose (input_file);
- /* if (outputFileName != 0) */
- /* fclose (outputFile); */
- // free the memory the compiled memory the regexp was using
- //regfree (®exp);
- return 0;
- }
|