Пример #1
0
static void add_deps (PzModule *mod) 
{
    PzModule **pdep;
    struct dep *cur;

    if (mod->ordered) return;
    mod->ordered = 1;

    if (mod->deps) {
        for (pdep = mod->deps; *pdep; pdep++) {
            add_deps (*pdep);
        }
    }

    if (load_order) {
        cur = load_order;
        while (cur->next) cur = cur->next;
        cur->next = malloc (sizeof (struct dep));
        cur = cur->next;
    } else {
        cur = load_order = malloc (sizeof (struct dep));
    }
    cur->mod = mod;
    cur->next = 0;
}
Пример #2
0
/* returns in a human-readable format the file size */
static char *tag_file_size (int argc, char *argv[])
{
  if (argc >= 1) {
    char *filename = process_text (argv[0]);
    int size = get_filesize (filename);
    char format[256];
    /* add a dependency */
    if (size >= 0)
      add_deps (filename);
    /* make the file size in a human-readable format */
    if (size < 0)
      sprintf (format, "%d", size);
    else if (size < 1024)
      sprintf (format, "%d byte%c", size, size == 1 ? 0 : 's');
    else if (size < 1024 * 1024)
      sprintf (format, "%0.1f KB", (float)size / 1024.0);
    else if (size < 1024 * 1024 * 1024)
      sprintf (format, "%0.2f MB", (float)size / 1024.0 / 1024.0);
    else
      sprintf (format, "%0.2f GB", (float)size / 1024.0 / 1024.0 / 1024.0);
    free (filename);
    return strdup (format);
  }
  else
    return NULL;
}
Пример #3
0
/* adds a dependency */
static char *tag_dep (int argc, char *argv[])
{
  /* at least one argument: the file name */
  if (argc >= 1) {
    char *filename = process_text (argv[0]);
    /* add a dependency */
    add_deps (filename);
    free (filename);
  }
  /* nothing to add */
  return NULL;
}
Пример #4
0
static char *tag_include (int argc, char *argv[])
{
  /* at least one argument: the file name */
  if (argc >= 1) {
    char *old_args[MAX_ARGS];
    char *new_args[MAX_ARGS];
    int old_nargs;
    int new_nargs;
    STREAM *in;
    char *s;
    int c;
    /* open the file */
    s = process_text (argv[0]);
    in = try_sopen (s, "r");
    free (s);
    /* warning, file not found */
    if (!in) {
      /* WARNING */
      return NULL;
    }
    /* add a dependency */
    add_deps (success_path);
    /* save the active arguments */
    old_nargs = nargs;
    for (c = 0; c < old_nargs; c++)
      old_args[c] = args[c];
    /* new arguments for the input file */
    new_nargs = argc - 1;
    for (c = 0; c < new_nargs; c++) {
      new_args[c] = process_text (argv[c + 1]);
      /* put the new arguments to the active */
      args[c] = new_args[c];
    }
    nargs = new_nargs;
    /* process the file and close it, the output directly
       to the active file */
    process_file (in, _o_stream);
    stclose (in);
    /* delete the new arguments */
    for (c = 0; c < new_nargs; c++)
      if (new_args[c])
	free (new_args[c]);
    /* restore the arguments by the old ones */
    nargs = old_nargs;
    for (c = 0; c < nargs; c++)
      args[c] = old_args[c];
  }
  /* nothing to add */
  return NULL;
}
Пример #5
0
void add_deps(alpm_pkg_t *pkg)
{
	alpm_list_t *i;
	for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) {
		char *depstring = alpm_dep_compute_string(i->data);
		alpm_pkg_t *p = alpm_find_satisfier(pkgcache, depstring);
		if(p && !alpm_list_find_ptr(packages, p)) {
			packages = alpm_list_add(packages, p);
			add_deps(p);
		}
		free(depstring);
	}
	if(checks & CHECK_OPT_DEPENDS) {
		for(i = alpm_pkg_get_optdepends(pkg); i; i = alpm_list_next(i)) {
			char *depstring = alpm_dep_compute_string(i->data);
			alpm_pkg_t *p = alpm_find_satisfier(pkgcache, depstring);
			if(p && !alpm_list_find_ptr(packages, p)) {
				packages = alpm_list_add(packages, p);
				add_deps(p);
			}
			free(depstring);
		}
	}
}
Пример #6
0
void
do_deps(_jc_env *env, _jc_classfile *cf, int flags)
{
	_jc_splay_tree tree;

	/* Build tree */
	_jc_splay_init(&tree, _jc_dep_cmp, _JC_OFFSETOF(_jc_dep, node));
	add_deps(env, &tree, cf, flags);

	/* Dump tree */
	dump_deps(&tree, tree.root, flags);

	/* Free tree */
	while (tree.root != NULL) {
		_jc_dep *const dep = _JC_NODE2ITEM(&tree, tree.root);

		_jc_splay_remove(&tree, dep);
		free(dep);
	}
}
Пример #7
0
void pz_modules_init(char *path) 
{
#ifdef IPOD
#define MODULEDIR "/opt/Base:/opt/Emulators:/opt/Media:/opt/Tools:/opt/Zillae"
#else
#define MODULEDIR "modules"
#endif

    /* Used for the progress bar */
    TWindow * sliderwin;
    TWidget  * slider;
    int sliderVal=0;
    int verbosity = pz_get_int_setting( pz_global_config, VERBOSITY );
    #define MAXSLIDERVAL (100)
    #define SETUPSECTIONS (6)

    PzModule *last, *cur;
    int i;
    int modCount=0;

    if (module_head) {
	pz_error (_("modules_init called more than once"));
	return;
    }

    /* set up the screen to show a pretty progress bar */
    sliderwin = ttk_new_window();
    ttk_window_hide_header(sliderwin);
    sliderwin->x = sliderwin->y = 0;
    slider = ttk_new_slider_widget(2, ttk_screen->h/3, ttk_screen->w - 8, 0,
		    MAXSLIDERVAL, &sliderVal, 0);
    slider->x = (sliderwin->w - slider->w)/2;
    ttk_add_widget(sliderwin, slider);

    sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 1;
    updateprogress(sliderwin, slider, sliderVal, _("Scanning For Modules"), NULL);
    if (!path)
	path = MODULEDIR;

    path = strtok(strdupa(path), ":");
    while (path) {
	find_modules (path);
	path = strtok(NULL, ":");
    }

    sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 2;
    updateprogress(sliderwin, slider, sliderVal, _("Reading Modules"), NULL);
    for (i = 0; i < __pz_builtin_number_of_init_functions; i++) {
	int found = 0;
	const char *name = __pz_builtin_names[i];

	cur = module_head;
	while (cur) {
	    char *p = strrchr (cur->podpath, '/');
	    if (!p) p = cur->podpath;
	    else p++;

	    if (!strncmp (p, name, strlen (name)) && !isalpha (p[strlen (name)])) {
		found = 1;
		break;
	    }
	    cur = cur->next;
	}
	if (!found) {
	    if (module_head) {
		cur = module_head; while (cur->next) cur = cur->next;
		cur->next = calloc (1, sizeof(PzModule));
		cur = cur->next;
	    } else {
		cur = module_head = calloc (1, sizeof(PzModule));
	    }

	    cur->podpath = 0;
	    cur->name = strdup (__pz_builtin_names[i]);
	    cur->init = __pz_builtin_init_functions[i];
	    cur->to_load = -1;
            cur->ordered = 0;
	    cur->next = 0;
	}
    }
    
    if (!module_head) {
        pz_message_title (_("Warning"), _("No modules. podzilla will probably be very boring."));
        return;
    }

    /* Used to initialize the window + progressbar used in loading the modules*/
    cur = module_head;
    while (cur) {
    	modCount++;
	cur = cur->next;
    }

    sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 3;
    updateprogress(sliderwin, slider, sliderVal, _("Mounting Modules"), NULL);
    // Mount 'em
    cur = module_head;
    last = 0;
    while (cur) {
        if (cur->podpath && cur->extracted) {
            cur->mountpt = strdup (cur->podpath);
            last = cur;
            cur = cur->next;
        } else if (cur->podpath && mount_pod (cur) == -1) {
	    if (last) last->next = cur->next;
	    else module_head = cur->next;
	    free (cur->podpath);
	    free (cur);
	    cur = last? last->next : module_head;
	} else {
	    last = cur;
	    cur = cur->next;
	}
    }

    sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 4;
    updateprogress(sliderwin, slider, sliderVal, _("Scanning Module Info"), NULL);
    // Load the module.inf's
    cur = module_head;
    while (cur) {
	load_modinf (cur);
	cur = cur->next;
    }

    sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 5;
    updateprogress(sliderwin, slider, sliderVal, _("Module Dependencies"), NULL);
    // Figure out the dependencies
    cur = module_head;
    last = 0;
    while (cur) {
	if (fix_dependencies (cur, 1, SOFTDEP) == -1 ||
			fix_dependencies(cur, 1, HARDDEP) == -1) {
	    if (last) last->next = cur->next;
	    else module_head = cur->next;
	    free_module (cur);
	    cur = last? last->next : module_head;
	} else {
	    last = cur;
	    cur = cur->next;
	}
    }

    // Check which ones are linked in
    cur = module_head;
    last = 0;
    while (cur) {
	for (i = 0; i < __pz_builtin_number_of_init_functions; i++) {
	    if (!strcmp (__pz_builtin_names[i], cur->name)) {
		cur->init = __pz_builtin_init_functions[i];
		cur->to_load = -1;
                cur->ordered = 0;
	    }
	}
	cur = cur->next;
    }

    // XXX. For now, we use a slow method for deps, and it'll crash
    // for circular deps. davidc__ is working on a 
    // better solution.
    cur = module_head;
    while (cur) {
        add_deps (cur);
        cur = cur->next;
    }

    sliderVal = (MAXSLIDERVAL/SETUPSECTIONS) * 6;
    updateprogress(sliderwin, slider, sliderVal, _("Loading Modules"), NULL);

    struct dep *c = load_order;
    while (c) {
	if (c->mod->to_load > 0) {
	    do_load (c->mod);
	}
	if( verbosity < VERBOSITY_ERRORS && c->mod->longname ) {
	    updateprogress(sliderwin, slider, sliderVal, _("Loading Modules"), 
			    c->mod->longname );
	}
	c = c->next;        
    }
    c = load_order;


    sliderVal = 0;
    updateprogress(sliderwin, slider, sliderVal, _("Initializing Modules"), NULL);

    /* trigger the sliders to switch to init mode, restting the slider */
    sliderVal = 0;

    /* initialize the modules */
    while (c) {
	sliderVal += MAXSLIDERVAL / modCount;
        current_module = c->mod;

	updateprogress(sliderwin, slider, sliderVal, 
			_("Initializing Modules"), 
			(verbosity < 2)?  c->mod->longname : NULL );

        do_init (c->mod);
        c = c->next;
    }

    sliderVal = MAXSLIDERVAL;
    updateprogress(sliderwin, slider, sliderVal, 
		_("Finishing Up..."), NULL);
    // Any modules with unrecoverable errors on loading set mod->to_free.
    // Oblige them.
    cur = module_head;
    last = 0;
    while (cur) {
        if (cur->to_free) {
	    if (last) last->next = cur->next;
	    else module_head = cur->next;
            free_module (cur);
	    cur = last? last->next : module_head;
	} else {
	    last = cur;
	    cur = cur->next;
        }
    }

    ttk_free_window (sliderwin);
}
Пример #8
0
/* main function */
int main (int argc, char *argv[])
{
  STREAM *in, *out;
  char *in_files[MAX_FILES];
  char *out_files[MAX_FILES];
  int in_nfiles = 0;
  int out_nfiles = 0;
  int compile_next = FALSE;
  int output_next = FALSE;
  int argument_next = FALSE;
  int include_next = FALSE;
  int html_extension_next = FALSE;
  char *stdout_source = NULL;
  int quit = -1;
  char buf[512];
  int i, j;

  /**********************************************************************
   * Reset variables
   **********************************************************************/

  nargs = 0;
  _i_stream = NULL;
  _o_stream = NULL;
  current_line = NULL;
  current_col = NULL;
  ntoken = 0;
  kill_comments = FALSE;
  verbose_level = 0;
  htmlex_name = argv[0];
  calculating_deps = FALSE;
  depstream = NULL;
  html_extension = "html";
  npaths = 0;

  /**********************************************************************
   * Preprocess arguments
   **********************************************************************/

  for (i = 1; i < argc; i++) {
    if (argv[i][0] == '-') {
      for (j = 1; argv[i][j]; j++) {
	switch (argv[i][j]) {
	  case 'c':
	  case 'o':
	  case 'a':
	  case 'i':
	  case 'I':
	  case 'E':
	    break;
	  case 'k':
	    kill_comments = TRUE;
	    break;
	  case 'd':
	    calculating_deps = TRUE;
	    break;
	  case 'v':
	  case 'V':
	    verbose_level = (argv[i][j] == 'v')? 1: 2;
	    break;
	  case 'h':
	    quit = 0;
	    break;
	  case '-':
	    break;
	  default:
	    log_printf (0, "in \"%s\", unknown option '%c'\n", argv[i], argv[i][j]);
	    quit = 1;
	    break;
	}
      }
    }
  }

  if (quit >= 0) {
    if (!quit)
      usage ();
    else
      log_printf (0, "try \"htmlex -h\"\n");

    exit (quit);
  }

  if (verbose_level > 0)
    log_printf (verbose_level, "verbose level: %d\n", verbose_level);

  /**********************************************************************
   * Process arguments
   **********************************************************************/

  log_printf (1, "processing arguments ---\n");

  for (i = 1; i < argc; i++) {
    if (argv[i][0] == '-') {
      compile_next = FALSE;
      output_next = FALSE;
      argument_next = FALSE;
      include_next = FALSE;
      html_extension_next = FALSE;

      for (j = 1; argv[i][j]; j++) {
	switch (argv[i][j]) {
	  case 'c':
	    compile_next = TRUE;
	    break;
	  case 'o':
	    output_next = TRUE;
	    break;
	  case 'a':
	    argument_next = TRUE;
	    break;
	  case 'i':
	  case 'I':
	    include_next = TRUE;
	    break;
	  case 'E':
	    html_extension_next = TRUE;
	    break;
	  case '-':
	    break;
	}
      }
    }
    /* new input file */
    else if (compile_next) {
      in_files[in_nfiles++] = argv[i];
      log_printf (1, "new input: \"%s\"\n", argv[i]);
    }
    /* new output file */
    else if (output_next) {
      out_files[out_nfiles++] = argv[i];
      log_printf (1, "new output: \"%s\"\n", argv[i]);
    }
    /* new arguments for the input files */
    else if (argument_next) {
      args[nargs++] = argv[i];
      log_printf (1, "new argument: \"%s\"\n", argv[i]);
    }
    /* new path for inclusion of files */
    else if (include_next) {
      paths[npaths++] = argv[i];
      log_printf (1, "new include: \"%s\"\n", argv[i]);
    }
    /* new path for inclusion of files */
    else if (html_extension_next) {
      html_extension = argv[i];
      log_printf (1, "html extension: \"%s\"\n", argv[i]);
    }
    /* default source file to put in STDOUT */
    else {
      stdout_source = argv[i];
      argument_next = TRUE;
      log_printf (1, "main input file: \"%s\"\n", stdout_source);
    }
  }

  log_printf (1, "arguments processed ---\n");

  /**********************************************************************
   * Process STDIN
   **********************************************************************/

  if ((in_nfiles == 0) && (!stdout_source) && (!calculating_deps)) {
    log_printf (1, "STDIN: compiling\n");

    /* open stdin */
    in = stfile (stdin);

    /* get output file */
    if (out_nfiles > 0) {
      log_printf (1, "STDIN: output to %s\n", out_files[0]);

      out = try_sopen (out_files[0], "w");
      if (!out) {
	log_printf (0, "%s: can't create file\n", out_files[0]);
	exit (1);
      }
    }
    else {
      log_printf (1, "STDIN: output to STDOUT\n");

      out = stfile (stdout);
    }

    prepare_processing ();
    process_file (in, out);
    release_processing ();

    stclose (in);
    stclose (out);

    log_printf (1, "STDIN: done\n");
  }

  /**********************************************************************
   * Process one file (output to STDOUT if there aren't output files)
   **********************************************************************/

  else if (stdout_source) {
    log_printf (1, "%s: compiling\n", stdout_source);

    /* open the input file */
    in = try_sopen (stdout_source, "r");
    if (!in) {
      log_printf (0, "%s: file not found\n", stdout_source);
      exit (1);
    }

    /* get output file */
    if (calculating_deps) {
      out = NULL;
    }
    else {
      if (out_nfiles > 0) {
	log_printf (1, "%s: output to %s\n", stdout_source, out_files[0]);

	out = try_sopen (out_files[0], "w");
	if (!out) {
	  log_printf (0, "%s: can't create file\n", out_files[0]);
	  exit (1);
	}
      }
      else {
	log_printf (1, "%s: output to STDOUT\n", stdout_source, stdout_source);

	out = stfile (stdout);
      }
    }

    update_state ();
    add_deps (stdout_source);

    prepare_processing ();
    process_file (in, out);
    release_processing ();

    stclose (in);
    stclose (out);

    out_deps ();
  }

  /**********************************************************************
   * Process all input files (never output to STDOUT)
   **********************************************************************/

  else {
    for (i=0; i<in_nfiles; i++) {
      log_printf (1, "%s: compiling\n", in_files[i]);

      /* open the input file */
      in = try_sopen (in_files[i], "r");
      if (!in) {
	log_printf (0, "%s: file not found\n", in_files[i]);
	exit (1);
      }

      /* get an output file name */
      if (i < out_nfiles)
	strcpy (buf, out_files[i]);
      /* auto generate output file name */
      else {
	if (*html_extension) {
	  char ext[32];
	  sprintf (ext, ".%s", html_extension);
	  replace_extension (buf, success_path, ext);
	}
	else
	  replace_extension (buf, success_path, "");
      }

      log_printf (1, "%s: output to %s\n", in_files[i], buf);

      if (calculating_deps) {
	out = NULL;
      }
      else {
	out = try_sopen (buf, "w");
	if (!out) {
	  log_printf (0, "%s: can't create file\n", buf);
	  exit (1);
	}
      }

      update_state ();
      add_deps (buf);
      add_deps (in_files[i]);

      prepare_processing ();
      process_file (in, out);
      release_processing ();

      stclose (in);
      stclose (out);

      out_deps ();
    }
  }

  log_printf (1, "all done\n");

  return 0;
}
Пример #9
0
int main(int argc, char **argv)
{
	alpm_list_t *i;
	int ret = 0;

	if(!(config = parse_opts(argc, argv))) {
		ret = 1;
		goto cleanup;
	}

	if(checks == 0) {
		checks = CHECK_DEPENDS | CHECK_FILES;
	}

	if(!(handle = pu_initialize_handle_from_config(config))) {
		fprintf(stderr, "error: failed to initialize alpm.\n");
		ret = 1;
		goto cleanup;
	}

	localdb = alpm_get_localdb(handle);
	pkgcache = alpm_db_get_pkgcache(localdb);

	for(; optind < argc; ++optind) {
		if(load_pkg(argv[optind]) == NULL) { ret = 1; }
	}
	if(!isatty(fileno(stdin)) && errno != EBADF) {
		char *buf = NULL;
		size_t len = 0;
		ssize_t read;

		while((read = getdelim(&buf, &len, isep, stdin)) != -1) {
			if(buf[read - 1] == isep) { buf[read - 1] = '\0'; }
			if(load_pkg(buf) == NULL) { ret = 1; }
		}
		free(buf);
	}

	if(ret) { goto cleanup; }

	if(packages == NULL) {
		packages = alpm_list_copy(pkgcache);
		recursive = 0;
	} else if(recursive) {
		/* load [opt-]depends */
		alpm_list_t *i, *originals = alpm_list_copy(packages);
		for(i = originals; i; i = alpm_list_next(i)) {
			add_deps(i->data);
		}
		alpm_list_free(originals);
	}

	for(i = packages; i; i = alpm_list_next(i)) {
		int pkgerr = 0;
#define RUNCHECK(t, b) if((checks & t) && b != 0) { pkgerr = ret = 1; }
		RUNCHECK(CHECK_DEPENDS, check_depends(i->data));
		RUNCHECK(CHECK_OPT_DEPENDS, check_opt_depends(i->data));
		RUNCHECK(CHECK_FILES, check_files(i->data));
		RUNCHECK(CHECK_FILE_PROPERTIES, check_file_properties(i->data));
		RUNCHECK(CHECK_MD5SUM, check_md5sum(i->data));
		RUNCHECK(CHECK_SHA256SUM, check_sha256sum(i->data));
#undef RUNCHECK
		if(pkgerr && list_broken) { printf("%s\n", alpm_pkg_get_name(i->data)); }
	}

cleanup:
	alpm_list_free(packages);
	alpm_release(handle);
	pu_config_free(config);

	return ret;
}
Пример #10
0
int main(int argc, char **argv)
{

    remain_size =0;

                /** PART 1 STARTS **/
    int opt;
    char *makefile= NULL;
    int num_threads=1; 
    while ((opt = getopt(argc, argv, "f:j:")) != -1) {
        switch(opt){
            case 'f' : makefile = optarg;
                break;
            case 'j' : num_threads = atoi( optarg );
                break;
            default  : return 0;
        }
    }

    int i ;
    int ind;
    int num = 0;
    char ** targets = malloc( (argc - optind +1 ) * sizeof( char* ) ); //not argc - optind + 1     
    if ( optind <= argc ){
        for( i = 0,ind = optind ; i< argc -optind; i++ , ind++ ){
            targets[i] = malloc( 100 ) ;
            strcpy ( targets[i] , argv[ind] );
            num++;
        }
        targets[num] = NULL;
    }
     
    char * buffer = NULL;
 
    if( makefile == NULL ){
        if (access("./makefile",F_OK) == 0 ){
            strcpy(buffer, "./makefile");
            makefile = buffer;
        }
     
        else if ( access("./Makefile",F_OK) == 0) {
            strcpy(buffer, "./Makefile");
            makefile = buffer;
        }
     
        else return -1;
    } 
    else{
        if(access(makefile,F_OK) == -1)
            return -1;
    }
 
                    /** PART 1 ENDS **/
 
                    /** PART 2 STARTS **/

    queue_init(&q);
    parser_parse_makefile( makefile , targets , parsed_new_target, parsed_new_dependency, parsed_new_command );
  

                    /** PART 2 ENDS **/

                    /** PART 3 STARTS **/
 /*   int m,n;
    rule_t * hold3;
    char * hold4,hold5;
    printf("printing the queue of rules\n");
    for(m=0;m<queue_size(&q);m++){
        hold3 = queue_at (&q,m);
        printf("target %s : deps ",hold3->target);
        for(n=0;n<queue_size(hold3->deps);n++){
            hold4 = queue_at(hold3->deps,n);          
            printf ("%s ",hold4);
        }
       printf("commands ");
        for(n=0;n<queue_size(hold3->commands);n++){
            hold4 = queue_at(hold3->commands,n);          
            printf ("%s ",hold4);
        }
        printf("\n");
    }

 exit(1);*/
      queue_init(&has_ran);
          queue_init(&depend);
      add_deps();
      int no_dep=0;     
      for(i=0;i<queue_size(&q);i++)
        if(has_deps((rule_t*)queue_at(&q,i))==0)
            no_dep++;

    //printf("NUMBER of rules with no deps, initialy %d\n",no_dep);
        /** PARALELLIZATION **/

    pthread_t* threads = malloc(sizeof(pthread_t)*num_threads);
   
    sem_init(&sem_mutex1, 0, no_dep);
   
   
    for(i=0;i<num_threads;i++)
        {   
               pthread_create(&threads[i],NULL,start_run,NULL);
        }
   
        for(i=0;i<num_threads;i++)
        {
                pthread_join(threads[i],NULL);
        }

    sem_destroy(&sem_mutex1);






        /** FREEING STUFF **/
     
    free(threads);
  
  
  

 //   start_run(NULL);

  
    rule_t * rule_hold = NULL;
    int k;
    char * hold2 = NULL;
    for(i=0;i<queue_size(&q);i++){
        rule_hold = queue_at(&q,i);
        for(k=0;k<queue_size(rule_hold->deps);k++)
        {
            hold2 = queue_at(rule_hold->deps,k);
            if(in_depend(hold2)==0)
        free(hold2);

        }
        for(k=0;k<queue_size(rule_hold->commands);k++)
        {
            hold2 = queue_at(rule_hold->commands,k);
            free(hold2);

        }
        free(rule_hold->target);
        rule_destroy(rule_hold);
        free(rule_hold)    ;
    }
    queue_destroy(&q);


    for(i=0;i<queue_size(&depend);i++)
    {  
        hold2 = queue_at(&depend,i);

        free(hold2);
    }
    queue_destroy(&depend);

  
    queue_destroy(&has_ran);  
  
    for( i = 0; i< argc - optind; i++ ){
            free(targets[i]);
    
        }  
      
    free(targets);

  


    return 0;  
}
Пример #11
0
static void
add_deps(_jc_env *env, _jc_splay_tree *tree, _jc_classfile *cf, int flags)
{
	_jc_classbytes *cb = NULL;
	_jc_classfile *scf;
	_jc_class_ref *deps;
	_jc_class_ref ref;
	int num_deps;
	int i;

	/* Already doing this class? */
	ref.name = cf->name;
	ref.len = strlen(cf->name);
	if (_jc_splay_find(tree, &ref) != NULL)
		return;

	/* Add this class */
	add_dep(tree, cf->name, strlen(cf->name));

	/* Dump superclasses' dependencies */
	if (cf->superclass == NULL)
		goto no_superclass;

	if ((cb = _jc_bootcl_find_classbytes(env, cf->superclass, NULL)) == NULL
	    || (scf = _jc_parse_classfile(env, cb, 2)) == NULL) {
		errx(1, "failed to load classfile: %s: %s",
		    _jc_vmex_names[env->ex.num], env->ex.msg);
	}
	_jc_free_classbytes(&cb);
	add_deps(env, tree, scf, flags);
	_jc_destroy_classfile(&scf);

no_superclass:
	/* Dump superinterfaces' dependencies */
	for (i = 0; i < cf->num_interfaces; i++) {
		if ((cb = _jc_bootcl_find_classbytes(env,
		      cf->interfaces[i], NULL)) == NULL
		    || (scf = _jc_parse_classfile(env, cb, 2)) == NULL) {
			errx(1, "failed to load classfile: %s: %s",
			    _jc_vmex_names[env->ex.num], env->ex.msg);
		}
		_jc_free_classbytes(&cb);
		add_deps(env, tree, scf, flags);
		_jc_destroy_classfile(&scf);
	}

	/* If 'supers_only', we're done */
	if ((flags & DUMP_SUPERS_ONLY) != 0)
		return;

	/* Update flags */
	if ((flags & DUMP_TRANS_CLOSURE) == 0)
		flags |= DUMP_SUPERS_ONLY;

	/* Dump this class's direct dependencies and their supers */
	if ((num_deps = _jc_gen_deplist(env, cf, &deps)) == -1)
		errx(1, "failed to generate dependency list: %s: %s",
		    _jc_vmex_names[env->ex.num], env->ex.msg);
	for (i = 0; i < num_deps; i++) {
		_jc_class_ref *const dep = &deps[i];
		char *name;

		if ((name = malloc(dep->len + 1)) == NULL)
			err(1, "malloc");
		memcpy(name, dep->name, dep->len);
		name[dep->len] = '\0';
		if ((cb = _jc_bootcl_find_classbytes(env, name, NULL)) == NULL
		    || (scf = _jc_parse_classfile(env, cb, 2)) == NULL) {
			errx(1, "failed to load classfile: %s: %s",
			    _jc_vmex_names[env->ex.num], env->ex.msg);
		}
		_jc_free_classbytes(&cb);
		add_deps(env, tree, scf, flags);
		_jc_destroy_classfile(&scf);
		free(name);
	}
	_jc_vm_free(&deps);
}