<commit_before>/**
 * $Id: mofparse.c,v 1.1 2005/03/03 09:08:48 mihajlov Exp $
 *
 * (C) Copyright IBM Corp. 2004
 * 
 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE
 * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
 * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
 *
 * You can obtain a current copy of the Common Public License from
 * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html
 *
 * Author:       <NAME> <<EMAIL>>
 * Contributors: 
 *
 * Description: MOF Compiler Driver
 *
 */

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <hash.h>
#include <symtab.h>
#include <mofdecl.h>
#include "mofc.h"
#include "backend.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#error "config.h missing -- did you run ./configure ?"
#endif


static char * copyright = "(C) Copyright IBM Corp. 2004";

static int opt_verbose = 0; 
static int opt_version = 0;
static int opt_help = 0;
static char inclpath[3000] = {0};
static char outfile[300] = "mofc.out";
static char backendopt[300] = {0};
static char * inclfile = NULL;
static char * valid_options = "b:o:I:i:hvV";

extern class_chain  * cls_chain_current;
extern backend_type * backend_ptr;

static int parse_options(int argc, char * argv[])
{
  char opt;
  while ((opt=getopt(argc,argv,valid_options)) != -1) {
    switch (opt) {
    case 'b': 
      strncpy(backendopt,optarg,sizeof(backendopt));
      break;
    case 'o': 
      strncpy(outfile,optarg,sizeof(outfile));
      break;
    case 'v': 
      opt_verbose = 1;
      break;
    case 'V': 
      opt_version = 1;
      break;
    case 'h':
      opt_help = 1;
      break;
    case 'I':
      if (strlen(inclpath) > 0) {
	strcat(inclpath,":");
      }
      strcat(inclpath,optarg);
      break;
    case 'i':
      inclfile = strdup(optarg);
      break;
    default:
      return -1;
    }
  }
  return optind;
}

static void usage(const char * name)
{
  fprintf(stderr,"usage: %s [-hvV] [-I includepath ...] [-i extrafile] [-o outfile] [-b backendopts] filename ... \n",name);
}

static void version()
{
  printf("MOF Compiler Version %s %s with %s\n",VERSION,
	  copyright,BACKEND_INFO);
}

static void help(const char * name)
{
  usage(name);
  version(name);
  printf(" Allowed options are\n");
  printf("  -h             display this message\n");
  printf("  -v             print some extra information\n");
  printf("  -V             print version information\n");
  printf("  -I includepath directory to search for include files\n");
  printf("  -i extrafile   file to load before parsing\n");
  printf("  -o outfile     output file to generate (default: mofc.out)\n");
  printf("  -b backendopts backend options, see backend documentation\n");<commit_msg>Removed copyright blurb on -v.<commit_after>/**
 * $Id: mofparse.c,v 1.2 2005/06/07 09:05:54 mihajlov Exp $
 *
 * (C) Copyright IBM Corp. 2004
 * 
 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE
 * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
 * CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
 *
 * You can obtain a current copy of the Common Public License from
 * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html
 *
 * Author:       <NAME> <<EMAIL>>
 * Contributors: 
 *
 * Description: MOF Compiler Driver
 *
 */

#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <hash.h>
#include <symtab.h>
#include <mofdecl.h>
#include "mofc.h"
#include "backend.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#error "config.h missing -- did you run ./configure ?"
#endif


static int opt_verbose = 0; 
static int opt_version = 0;
static int opt_help = 0;
static char inclpath[3000] = {0};
static char outfile[300] = "mofc.out";
static char backendopt[300] = {0};
static char * inclfile = NULL;
static char * valid_options = "b:o:I:i:hvV";

extern class_chain  * cls_chain_current;
extern backend_type * backend_ptr;

static int parse_options(int argc, char * argv[])
{
  char opt;
  while ((opt=getopt(argc,argv,valid_options)) != -1) {
    switch (opt) {
    case 'b': 
      strncpy(backendopt,optarg,sizeof(backendopt));
      break;
    case 'o': 
      strncpy(outfile,optarg,sizeof(outfile));
      break;
    case 'v': 
      opt_verbose = 1;
      break;
    case 'V': 
      opt_version = 1;
      break;
    case 'h':
      opt_help = 1;
      break;
    case 'I':
      if (strlen(inclpath) > 0) {
	strcat(inclpath,":");
      }
      strcat(inclpath,optarg);
      break;
    case 'i':
      inclfile = strdup(optarg);
      break;
    default:
      return -1;
    }
  }
  return optind;
}

static void usage(const char * name)
{
  fprintf(stderr,"usage: %s [-hvV] [-I includepath ...] [-i extrafile] [-o outfile] [-b backendopts] filename ... \n",name);
}

static void version()
{
  printf("MOF Compiler Version %s with %s\n",VERSION,BACKEND_INFO);
}

static void help(const char * name)
{
  usage(name);
  version(name);
  printf(" Allowed options are\n");
  printf("  -h             display this message\n");
  printf("  -v             print some extra information\n");
  printf("  -V             print version information\n");
  printf("  -I includepath directory to search for include files\n");
  printf("  -i extrafile   file to load before parsing\n");
  printf("  -o outfile     output file to generate (default: mofc.out)\n");
  printf("  -b backendopts backend options, see backend documentation\n");
{'fraction_non_alphanumeric': 0.13891427526960337, 'fraction_numerical': 0.015719246938402487, 'mean_word_length': 3.1142857142857143, 'pattern_counts': {'":': 2, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5230232', 'n_tokens_mistral': 1976, 'n_tokens_neox': 1889, 'n_words': 553}