void do_a_filespec(char *filespec)
{
   char *fs, *p;

   free_compchain(ccroot);
   ccroot = NULL;
   fs = filespec;
   p = strrchr(filespec, '.');
   if (p)                      /* If their's a dot in the file spec */
     {                         /* Check and see if the suffix is .exe, .com */
                               /* or .cmd                                   */
        if ( (stricmp(p, exesuff) != 0) && (stricmp(p, cmdsuff) != 0)
                                        && (stricmp(p, comsuff) != 0) )  //@1a
          {                    /* If it is not one of those                 */
            if (*(p+1) == 0)   /* Delete the dot if it is terminal.         */
              *p = 0;          /* then use the whole string as the 'name'   */
            if (*(p+1) == '*')
              *p = 0;
            fs = (char *)malloc(strlen(filespec) + 5);
            strcpy(fs, filespec);
            tryboth = 1;       /* We will add .exe, .com and .cmd to the end*/
          }
     }
   else                        /* If there is no dot */
     {                         /* again we use the while string for the name */
        fs = (char *)malloc(strlen(filespec) + 5);
        strcpy(fs, filespec);
        tryboth = 1;
     }
   do_a_file(fs);                                               //@1a
}
void do_a_filespec(char *filespec)
{
   char filename[MAXPATHLEN];
   int  attrib;
   FILE *f;

   if (fmf_init(filespec, FMF_ALL_FILES, FMF_NO_SUBDIR) == FMF_NO_ERROR)
     while (fmf_return_next(filename, &attrib) == FMF_NO_ERROR)
       {
          if (f = fopen(filename, "r"))
            do_a_file(f);
          fclose(f);
       }
}
예제 #3
0
/* ----------------------------------------------------------------------- */
void do_a_filespec(char *filespec)
{
   char filename[MAXPATHLEN];
   int  attrib;
   FILE *f;
   int fh;

   if (fmf_init(filespec, FMF_ALL_FILES, FMF_NO_SUBDIR) == FMF_NO_ERROR)
     while (fmf_return_next(filename, &attrib) == FMF_NO_ERROR)
       {
          fh = sopen(filename, O_RDONLY|O_BINARY, SH_DENYNO, S_IWRITE);
          if (f = fdopen(fh, "rb"))
            do_a_file(f);
          fclose(f);
       }
}
예제 #4
0
int main(int argc,char * argv[]) 
{
  FailureType fail = 0 ;
  FailureType should_fail_on = 0;
  int i;
  boolean doinfo = FALSE;
  boolean noaddnumbers = FALSE;
  MethodTypeSet * mts;
  MethodTypeSet * cp;
  boolean no_config_mts = FALSE;
  int prot_level = 0;
  int should_hard_link = 0;
  boolean should_warn_undoc = FALSE;
  char * prot_str;
  char * runner;
  char *config_dir=NULL;
  char buffer[64]; /** really for removing files **/
  char * telegraph;
  
  APIpara api;

  char * pack;
	
  /** we no longer read in configs **/

  mts = standard_dynamite_MethodTypeSet();


  if( strip_out_boolean_argument(&argc,argv,"h") == TRUE 
      || strip_out_boolean_argument(&argc,argv,"u") == TRUE /* arve */
      || argc == 1 ) {
	show_usage(stdout);
	exit(1);
	}

  noaddnumbers   = strip_out_boolean_argument(&argc,argv,"m");
  doinfo        = strip_out_boolean_argument(&argc,argv,"i");
  no_config_mts = strip_out_boolean_argument(&argc,argv,"U");
  should_hard_link = strip_out_boolean_argument(&argc,argv,"l");
  prot_str      = strip_out_assigned_argument(&argc,argv,"P");
  should_warn_undoc = strip_out_boolean_argument(&argc,argv,"D");
  telegraph    = strip_out_assigned_argument(&argc,argv,"tele");

  pack = strip_out_assigned_argument(&argc,argv,"n");

  api.xs_ext = NULL;
  api.typemap_ext = NULL;
  api.pod_ext = NULL;

  api.c_extension_name = strip_out_assigned_argument(&argc,argv,"a");
  api.t_extension_name = strip_out_assigned_argument(&argc,argv,"b");
  api.pfdoc_ext = strip_out_assigned_argument(&argc,argv,"p");
  api.xs_ext = strip_out_assigned_argument(&argc,argv,"x");
  api.typemap_ext = strip_out_assigned_argument(&argc,argv,"tym");
  api.all_callable = strip_out_boolean_argument(&argc,argv,"c");
  api.make_perl = strip_out_boolean_argument(&argc,argv,"perl");
  api.latex_ext = strip_out_assigned_argument(&argc,argv,"exttex");
  api.make_latex = strip_out_boolean_argument(&argc,argv,"latex");


  if( api.make_perl == TRUE) {
   
    if( api.xs_ext == NULL ) {
      api.xs_ext = ".xs";
    }
    if( api.typemap_ext == NULL ) {
      api.typemap_ext = ".typemap";
    }
    if( api.pod_ext == NULL ) {
      api.pod_ext = ".pod";
    }
  }


  if( strip_out_boolean_argument(&argc,argv,"F") == TRUE) {
    should_fail_on = FailureType_dyc_All;
  }

  /* do DPImplementation */

  dpi = new_DPImplementation_from_argstr(&argc,argv);

  if( prot_str != NULL ) {
      if( is_integer_string(prot_str,&prot_level) == FALSE ) {
	  warn("Protection level %s is no integer!");
	  prot_level = 0;
      }
  }

				/* Override/set WISECONFIGDIR on the cmdline. (arve) */
  config_dir = strip_out_assigned_argument(&argc, argv, "I");
  if (config_dir != NULL) {
      set_config_dir(config_dir); 
  }

  if( read_into_MethodTypeSet_filename(mts,"methods") == FALSE){
    warn("You have no config file called 'methods'. This is bad news for dynamite matrices. I will attempt to compile, but you cannot use logical types. 'methods' should be either in the current directory, the $WISECONFIGDIR or your $WISEPERSONALDIR");
  }



  /*** ok,loop over and do it ***/

  if( argc < 1 ) {
    warn("You must have at least one dynamite source file to compile!");
    show_usage(stdout);
    exit(1);
  }

  if( telegraph != NULL ) {
    tele_file= fopen(telegraph,"w");
  }

  
  for(i=1;i<argc;i++) {
    if( mts != NULL) 
      cp = copy_MethodTypeSet(mts); /* actually very cheap */
    if( do_a_file(argv[i],mts,FALSE,prot_level,should_hard_link,should_warn_undoc,noaddnumbers == TRUE ? FALSE : TRUE,pack,&api,&fail) == FALSE ) {
      
      fatal("Terminated dyc one %d argument %s",i,argv[i]);
    }
    if( (should_fail_on == 01 && fail != 0) || (fail & should_fail_on) ) {

      /*** remove files which fail ****/

      /*** ugh this should be done better ***/

      for(runner=argv[i]+strlen(argv[i]) - 1;runner > argv[i] && *runner != '.';runner--)
	;
      if( runner != argv[i] ) {
	*runner = '\0';
	sprintf(buffer,"%s.c",argv[i]);
	if( remove_file(buffer) == FALSE ) {
	  warn("Could not remove file %s from filesystem",buffer);
	}
	sprintf(buffer,"%s.h",argv[i]);
	if( remove_file(buffer) == FALSE ) {
	  warn("Could not remove file %s from filesystem",buffer);
	}
      }
      /* else - well - something bad has happened */
      
      fatal("Failed on file %s due to user defined fails",argv[i]);
    }

    if( mts != NULL ) {
      free_MethodTypeSet(mts);
      mts = cp;
    }
  }

  free_MethodTypeSet(mts);

  return 0;
}  
예제 #5
0
/* ----------------------------------------------------------------------- */
void do_stdin()
{
   do_a_file(stdin);
}
예제 #6
0
static mcxstatus collectMain
(  int                  argc
,  const char*          argv[]
)
   {  aggr* collect = NULL
   ;  int a
   ;  dim i, collect_n = 0
   ;  mclTab* tab = NULL
   ;  double avg = 0.0
   ;  mclx* aggr = NULL, *mx = NULL
                                               /*  mcxHash* map = NULL */
   ;  mcxIO* xfout = mcxIOnew(out_g, "w")
   ;  mcxIOopen(xfout, EXIT_ON_FAIL)

   ;  if
      (  transform_spec
      && (!(transform = mclgTFparse(NULL, transform_spec)))
      )
      mcxDie(1, me, "input -tf spec does not parse")

   ;  if (xftab_g)
         tab = mclTabRead(xftab_g, NULL, EXIT_ON_FAIL)
            /* map not used; perhaps someday we want to map labels to indexes?
             * in that case, we could also simply reverse the tab when reading ..
      ,  map = mclTabHash(tab)
            */

   ;  if (!collect_g)
      mcxDie(1, me, "require one of --paste, --add-column, --add-matrix")

   ;  if (argc)
      {  if (collect_g == 'm')
         {  mcxIO* xf = mcxIOnew(argv[0], "r")
         ;  mcxIOopen(xf, EXIT_ON_FAIL)
         ;  aggr = mclxRead(xf, EXIT_ON_FAIL)
         ;  mcxIOfree(&xf)
      ;  }
         else
         collect_n = do_a_file(&collect, argv[0], 0)
   ;  }

      if (tab && collect_n != N_TAB(tab) + (header_g ? 1 : 0))
      mcxErr
      (  me
      ,  "tab has differing size (%lu vs %lu), continuing anyway"
      ,  (ulong) N_TAB(tab)
      ,  (ulong) (collect_n ? collect_n -1 : 0)
      )

   ;  for (a=1;a<argc;a++)
      {  if (collect_g == 'm')
         {  mcxIO* xf = mcxIOnew(argv[a], "r")
         ;  mcxIOopen(xf, EXIT_ON_FAIL)
         ;  mx = mclxRead(xf, EXIT_ON_FAIL)
         ;  mclxAugment(aggr, mx, fltop_g)
         ;  mcxIOfree(&xf)
         ;  mclxFree(&mx)
      ;  }
         else
         do_a_file(&collect, argv[a], collect_n)
   ;  }

      if (collect_g == 'm')
      {  if (transform)
         mclgTFexec(aggr, transform)
      ;  if (mcx_wb_g)
         mclxbWrite(aggr, xfout, EXIT_ON_FAIL)
      ;  else
         mclxWrite(aggr, xfout, MCLXIO_VALUE_GETENV, EXIT_ON_FAIL)
      ;  mcxIOclose(xfout)
      ;  exit(0)
   ;  }

   /* fimxe: dispatch on binary_g */

      for (i=0;i<collect_n;i++)
      {  const char* lb = collect[i].label

      ;  if (!i && collect[i].columns && collect_g != 'p')
         {  fprintf(xfout->fp, "%s\t%s\n", lb, collect[i].columns->str)
         ;  continue
      ;  }

         if (tab && (!header_g || i > 0))
         {  unsigned u = atoi(lb)
         ;  lb = mclTabGet(tab, u, NULL)
         ;  if (TAB_IS_NA(tab, lb))
            mcxDie(1, me, "no label found for index %ld - abort", (long) u)
      ;  }
         if (summary_g)
         avg += collect[i].val
      ;  else
         {  if (collect_g == 'p')
            fprintf(xfout->fp, "%s%s\n", lb, collect[i].columns->str)
         ;  else
            fprintf(xfout->fp, "%s\t%.8g\n", lb, collect[i].val)
      ;  }
      }
      if (summary_g && collect_n)
      {  dim middle1 = (collect_n-1)/2, middle2 = collect_n/2
      ;  qsort(collect, collect_n, sizeof collect[0], aggr_cmp_val)
      ;  avg /= collect_n
      ;  fprintf                    /* --summary option is a bit rubbish interface-wise */
         (  xfout->fp
         ,  "%g %g %g %g\n"
         ,  collect[0].val
         ,  (collect[middle1].val + collect[middle2].val) / 2
         ,  collect[collect_n-1].val
         ,  avg
         )
   ;  }
      return STATUS_OK
;  }