int main ()
{
	People_t people[MAX_SIZE];
	Appointment_t appointment[MAX_SIZE];
	char fpeople[]="people.txt";
	char fpeoplereqs[]="peoplereqs.txt";
	char foutput[]="output.txt";
	int size;
	int app_size;
	int i;
	size = get_people(fpeople,people,MAX_SIZE);
	app_size = get_appointments(fpeoplereqs,appointment,MAX_SIZE);

	if(app_size == size)
	{	
		write_names(appointment,app_size,people,size);
		size = check_appointments(appointment,size);
		sort_appointments(appointment,size);
		write_appointments(foutput,appointment,size);
			
	}
	else printf("appointments size and people size are not the same please check it \n");
	
	return 0;
}
int main(void)
{
	char file1[STRING_SIZE]="People.txt";
	char file2[STRING_SIZE]="AppointmentReqs.txt";
	char file3[STRING_SIZE]="Appointments.txt";
	int size_appoint,
		size_peop,
		new_size;
	People_t people[SIZE_OF_ARRAY];
	Appointment_t appointments[SIZE_OF_ARRAY];
	
	size_peop=get_people(file1,people,MAX_SIZE);
	
	size_appoint=get_appointments(file2,appointments,MAX_SIZE);
	
	write_names(appointments,size_appoint,people,size_peop);
	
	new_size=check_appointments(appointments,size_appoint);
	
	sort_appointments(appointments,new_size);
	
	write_appointments(file3,appointments,new_size);
	
	return 0;
}
Пример #3
0
int main (int argc, char *argv[]) {
	FILE *fp;
	char **person[MAX_SIZE];
	int num_names, *order;

	fp = fopen (argv[1], "r");
	num_names = read_names(fp, person);
	order = sort(person, num_names);
	write_names (person, order, num_names);

	free_memory(person);
	fclose(fp);

	return 0;
} //main()
int
main(void)
{
	People_t people[5];
	Appointment_t appointments[5];
	int size_people,size_app,new_size_app;

	size_people=get_people("People.txt",people,5);
	size_app=get_appointments("AppointmentReqs.txt",appointments,5);

	write_names(appointments,size_app,people,size_people);

	new_size_app=check_appointments(appointments,size_app);

	sort_appointments(appointments,new_size_app);

	write_appointments("Appointments.txt",appointments,new_size_app);

	return 0;
}
Пример #5
0
/* 
 * main function - reads instantaneous power values (in W) from a trace
 * file (e.g. "gcc.ptrace") and outputs instantaneous temperature values (in C) to
 * a trace file("gcc.ttrace"). also outputs steady state temperature values
 * (including those of the internal nodes of the model) onto stdout. the
 * trace files are 2-d matrices with each column representing a functional
 * functional block and each row representing a time unit(sampling_intvl).
 * columns are tab-separated and each row is a separate line. the first
 * line contains the names of the functional blocks. the order in which
 * the columns are specified doesn't have to match that of the floorplan 
 * file.
 */
int main(int argc, char **argv)
{
	int i, j, idx, base = 0, count = 0, n = 0;
	int num, size, lines = 0, do_transient = TRUE;
	char **names;
	double *vals;
	/* trace file pointers	*/
	FILE *pin, *tout = NULL;
	/* floorplan	*/
	flp_t *flp;
	/* hotspot temperature model	*/
	RC_model_t *model;
	/* instantaneous temperature and power values	*/
	double *temp = NULL, *power;
	double total_power = 0.0;
	
	/* steady state temperature and power values	*/
	double *overall_power, *steady_temp;
	/* thermal model configuration parameters	*/
	thermal_config_t thermal_config;
	/* global configuration parameters	*/
	global_config_t global_config;
	/* table to hold options and configuration */
	str_pair table[MAX_ENTRIES];
	
	/* variables for natural convection iterations */
	int natural = 0; 
	double avg_sink_temp = 0;
	int natural_convergence = 0;
	double r_convec_old;

	if (!(argc >= 5 && argc % 2)) {
		usage(argc, argv);
		return 1;
	}
	
	size = parse_cmdline(table, MAX_ENTRIES, argc, argv);
	global_config_from_strs(&global_config, table, size);

	/* no transient simulation, only steady state	*/
	if(!strcmp(global_config.t_outfile, NULLFILE))
		do_transient = FALSE;

	/* read configuration file	*/
	if (strcmp(global_config.config, NULLFILE))
		size += read_str_pairs(&table[size], MAX_ENTRIES, global_config.config);

	/* 
	 * earlier entries override later ones. so, command line options 
	 * have priority over config file 
	 */
	size = str_pairs_remove_duplicates(table, size);

	/* get defaults */
	thermal_config = default_thermal_config();
	/* modify according to command line / config file	*/
	thermal_config_add_from_strs(&thermal_config, table, size);
	
	/* if package model is used, run package model */
	if (((idx = get_str_index(table, size, "package_model_used")) >= 0) && !(table[idx].value==0)) {
		if (thermal_config.package_model_used) {
			avg_sink_temp = thermal_config.ambient + SMALL_FOR_CONVEC;
			natural = package_model(&thermal_config, table, size, avg_sink_temp);
			if (thermal_config.r_convec<R_CONVEC_LOW || thermal_config.r_convec>R_CONVEC_HIGH)
				printf("Warning: Heatsink convection resistance is not realistic, double-check your package settings...\n"); 
		}
	}

	/* dump configuration if specified	*/
	if (strcmp(global_config.dump_config, NULLFILE)) {
		size = global_config_to_strs(&global_config, table, MAX_ENTRIES);
		size += thermal_config_to_strs(&thermal_config, &table[size], MAX_ENTRIES-size);
		/* prefix the name of the variable with a '-'	*/
		dump_str_pairs(table, size, global_config.dump_config, "-");
	}

	/* initialization: the flp_file global configuration 
	 * parameter is overridden by the layer configuration 
	 * file in the grid model when the latter is specified.
	 */
	flp = read_flp(global_config.flp_file, FALSE);

	/* allocate and initialize the RC model	*/
	model = alloc_RC_model(&thermal_config, flp);
	populate_R_model(model, flp);
	
	if (do_transient)
		populate_C_model(model, flp);

	#if VERBOSE > 2
	debug_print_model(model);
	#endif

	/* allocate the temp and power arrays	*/
	/* using hotspot_vector to internally allocate any extra nodes needed	*/
	if (do_transient)
		temp = hotspot_vector(model);
	power = hotspot_vector(model);
	steady_temp = hotspot_vector(model);
	overall_power = hotspot_vector(model);
	
	/* set up initial instantaneous temperatures */
	if (do_transient && strcmp(model->config->init_file, NULLFILE)) {
		if (!model->config->dtm_used)	/* initial T = steady T for no DTM	*/
			read_temp(model, temp, model->config->init_file, FALSE);
		else	/* initial T = clipped steady T with DTM	*/
			read_temp(model, temp, model->config->init_file, TRUE);
	} else if (do_transient)	/* no input file - use init_temp as the common temperature	*/
		set_temp(model, temp, model->config->init_temp);

	/* n is the number of functional blocks in the block model
	 * while it is the sum total of the number of functional blocks
	 * of all the floorplans in the power dissipating layers of the 
	 * grid model. 
	 */
	if (model->type == BLOCK_MODEL)
		n = model->block->flp->n_units;
	else if (model->type == GRID_MODEL) {
		for(i=0; i < model->grid->n_layers; i++)
			if (model->grid->layers[i].has_power)
				n += model->grid->layers[i].flp->n_units;
	} else 
		fatal("unknown model type\n");

	if(!(pin = fopen(global_config.p_infile, "r")))
		fatal("unable to open power trace input file\n");
	if(do_transient && !(tout = fopen(global_config.t_outfile, "w")))
		fatal("unable to open temperature trace file for output\n");

	/* names of functional units	*/
	names = alloc_names(MAX_UNITS, STR_SIZE);
	if(read_names(pin, names) != n)
		fatal("no. of units in floorplan and trace file differ\n");

	/* header line of temperature trace	*/
	if (do_transient)
		write_names(tout, names, n);

	/* read the instantaneous power trace	*/
	vals = dvector(MAX_UNITS);
	while ((num=read_vals(pin, vals)) != 0) {
		if(num != n)
			fatal("invalid trace file format\n");

		/* permute the power numbers according to the floorplan order	*/
		if (model->type == BLOCK_MODEL)
			for(i=0; i < n; i++)
				power[get_blk_index(flp, names[i])] = vals[i];
		else
			for(i=0, base=0, count=0; i < model->grid->n_layers; i++) {
				if(model->grid->layers[i].has_power) {
					for(j=0; j < model->grid->layers[i].flp->n_units; j++) {
						idx = get_blk_index(model->grid->layers[i].flp, names[count+j]);
						power[base+idx] = vals[count+j];
					}
					count += model->grid->layers[i].flp->n_units;
				}	
				base += model->grid->layers[i].flp->n_units;	
			}

		/* compute temperature	*/
		if (do_transient) {
			/* if natural convection is considered, update transient convection resistance first */
			if (natural) {
				avg_sink_temp = calc_sink_temp(model, temp);
				natural = package_model(model->config, table, size, avg_sink_temp);
				populate_R_model(model, flp);
			}
			/* for the grid model, only the first call to compute_temp
			 * passes a non-null 'temp' array. if 'temp' is  NULL, 
			 * compute_temp remembers it from the last non-null call. 
			 * this is used to maintain the internal grid temperatures 
			 * across multiple calls of compute_temp
			 */
			if (model->type == BLOCK_MODEL || lines == 0)
				compute_temp(model, power, temp, model->config->sampling_intvl);
			else
				compute_temp(model, power, NULL, model->config->sampling_intvl);
	
			/* permute back to the trace file order	*/
			if (model->type == BLOCK_MODEL)
				for(i=0; i < n; i++)
					vals[i] = temp[get_blk_index(flp, names[i])];
			else
				for(i=0, base=0, count=0; i < model->grid->n_layers; i++) {
					if(model->grid->layers[i].has_power) {
						for(j=0; j < model->grid->layers[i].flp->n_units; j++) {
							idx = get_blk_index(model->grid->layers[i].flp, names[count+j]);
							vals[count+j] = temp[base+idx];
						}
						count += model->grid->layers[i].flp->n_units;	
					}	
					base += model->grid->layers[i].flp->n_units;	
				}
		
			/* output instantaneous temperature trace	*/
			write_vals(tout, vals, n);
		}		
	
		/* for computing average	*/
		if (model->type == BLOCK_MODEL)
			for(i=0; i < n; i++)
				overall_power[i] += power[i];
		else
			for(i=0, base=0; i < model->grid->n_layers; i++) {
				if(model->grid->layers[i].has_power)
					for(j=0; j < model->grid->layers[i].flp->n_units; j++)
						overall_power[base+j] += power[base+j];
				base += model->grid->layers[i].flp->n_units;	
			}

		lines++;
	}    
	if(!lines)
		fatal("no power numbers in trace file\n");
		
	/* for computing average	*/
	if (model->type == BLOCK_MODEL)
		for(i=0; i < n; i++) {
			overall_power[i] /= lines;
			//overall_power[i] /=150; //reduce input power for natural convection
			total_power += overall_power[i];
		}
	else
		for(i=0, base=0; i < model->grid->n_layers; i++) {
			if(model->grid->layers[i].has_power)
				for(j=0; j < model->grid->layers[i].flp->n_units; j++) {
					overall_power[base+j] /= lines;
					total_power += overall_power[base+j];
				}
			base += model->grid->layers[i].flp->n_units;	
		}
		
	/* natural convection r_convec iteration, for steady-state only */ 		
	natural_convergence = 0;
	if (natural) { /* natural convection is used */
		while (!natural_convergence) {
			r_convec_old = model->config->r_convec;
			/* steady state temperature	*/
			steady_state_temp(model, overall_power, steady_temp);
			avg_sink_temp = calc_sink_temp(model, steady_temp) + SMALL_FOR_CONVEC;
			natural = package_model(model->config, table, size, avg_sink_temp);
			populate_R_model(model, flp);
			if (avg_sink_temp > MAX_SINK_TEMP)
				fatal("too high power for a natural convection package -- possible thermal runaway\n");
			if (fabs(model->config->r_convec-r_convec_old)<NATURAL_CONVEC_TOL) 
				natural_convergence = 1;
		}
	}	else /* natural convection is not used, no need for iterations */
	/* steady state temperature	*/
	steady_state_temp(model, overall_power, steady_temp);

	/* print steady state results	*/
	fprintf(stdout, "Unit\tSteady(Kelvin)\n");
	dump_temp(model, steady_temp, "stdout");

	/* dump steady state temperatures on to file if needed	*/
	if (strcmp(model->config->steady_file, NULLFILE))
		dump_temp(model, steady_temp, model->config->steady_file);

	/* for the grid model, optionally dump the most recent 
	 * steady state temperatures of the grid cells	
	 */
	if (model->type == GRID_MODEL &&
		strcmp(model->config->grid_steady_file, NULLFILE))
		dump_steady_temp_grid(model->grid, model->config->grid_steady_file);

	#if VERBOSE > 2
	if (model->type == BLOCK_MODEL) {
		if (do_transient) {
			fprintf(stdout, "printing temp...\n");
			dump_dvector(temp, model->block->n_nodes);
		}
		fprintf(stdout, "printing steady_temp...\n");
		dump_dvector(steady_temp, model->block->n_nodes);
	} else {
		if (do_transient) {
			fprintf(stdout, "printing temp...\n");
			dump_dvector(temp, model->grid->total_n_blocks + EXTRA);
		}
		fprintf(stdout, "printing steady_temp...\n");
		dump_dvector(steady_temp, model->grid->total_n_blocks + EXTRA);
	}
	#endif

	/* cleanup	*/
	fclose(pin);
	if (do_transient)
		fclose(tout);
	delete_RC_model(model);
	free_flp(flp, FALSE);
	if (do_transient)
		free_dvector(temp);
	free_dvector(power);
	free_dvector(steady_temp);
	free_dvector(overall_power);
	free_names(names);
	free_dvector(vals);

	return 0;
}
Пример #6
0
int
main(int argc, char **argv)
{
   int /*ch, */ i, ii, ret, err_flag = 0;

   clock_t beg, end, Beg, End;

   int files = 0;

   struct tms ts;

   char buf[256];

   char *e;

   prgname = strrchr(argv[0], '/');

   if (prgname)
      prgname++;
   else
      prgname = argv[0];

   e = getenv("CLIP_HOSTCS");
   if (e && *e)
   {
      sourceCharset = targetCharset = strdup(e);
   }
   else if (!e)
   {
      e = getenv("CLIP_LANG");
      if (e == NULL)
	 e = getenv("LANG");
      if (!e || !*e || !strcmp(e, "C"))
	 e = getenv("LC_MESSAGES");
      if (!e || !*e || !strcmp(e, "C"))
	 e = getenv("LC_ALL");
      if (e && *e)
      {
	 char *s = strrchr(e, '.');

	 if (s)
	 {
	    snprintf(buf, sizeof(buf), "%s", s + 1);
	    for (s = buf; *s; s++)
	       *s = tolower(*s);
	    sourceCharset = targetCharset = strdup(buf);
	 }
      }
   }

   {
      e = getenv("CLIP_LANG");
      if (e == NULL)
	 e = getenv("LANG");
      if (!e || !*e || !strcmp(e, "C"))
	 e = getenv("LC_MESSAGES");
      if (!e || !*e || !strcmp(e, "C"))
	 e = getenv("LC_ALL");
      if (e && *e)
      {
	 char *s = strrchr(e, '.');

	 if (s)
	 {
	    snprintf(buf, sizeof(buf), "%s", s + 1);
	    for (s = buf; *s; s++)
	       *s = tolower(*s);
	    out_charset = strdup(buf);
	 }
      }
   }

   {
      char *locale;

      locale = getenv("CLIP_LANG");
      if (!locale || !*locale)
	 locale = getenv("LANG");
      /*if (locale && *locale &&
         strcasecmp(locale, "C") && strcasecmp(locale, "POSIX")) */
      /*
         setlocale(LC_ALL, locale);
       */
   }

   if (!sourceCharset)
      sourceCharset = targetCharset = strdup("c");

   getEnvironment();

   init_Coll(&includePaths, NULL, NULL);
   init_Coll(&lib_dirs, NULL, NULL);
   init_Coll(&arglibs, NULL, NULL);

#if 1
   insert_Coll(&includePaths, ".");
   snprintf(buf, sizeof(buf), "%s/include", CLIPROOT);
   insert_Coll(&includePaths, strdup(buf));
#ifdef STD_LIBDIR
   snprintf(buf, sizeof(buf), STD_LIB_DIR);
   insert_Coll(&lib_dirs, strdup(buf));
#endif
   snprintf(buf, sizeof(buf), "%s/lib", CLIPROOT);
   insert_Coll(&lib_dirs, strdup(buf));
#endif
   init_Coll(&predefines, NULL, NULL);
   init_Coll(&poName, NULL, NULL);
   init_Coll(&paName, NULL, NULL);
   init_Coll(&include_files, NULL, NULL);

   snprintf(buf, sizeof(buf), "__CLIP__=\"%s\"", CLIP_VERSION);
   append_Coll(&predefines, strdup(buf));

   init_module();

   {
      char buf[256], *s;

      s = getenv("HOME");
      if (s && *s)
      {
	 snprintf(buf, sizeof(buf), "%s/.cliprc", s);
	 getrc(buf);
      }

   }

   getrc(".cliprc");

   {
      char buf[256], *s;

      DIR *dp;

      s = CLIPROOT;
      if (s && *s)
      {
	 snprintf(buf, sizeof(buf), "%s/.cliprc", s);
	 getrc(buf);
      }

      snprintf(buf, sizeof(buf), "%s/cliprc", CLIPROOT);
      dp = opendir(buf);
      if (dp)
      {
	 struct dirent *ep;

	 struct stat st;

	 Coll files;

	 int i;

	 init_Coll(&files, free, strcmp);
	 while ((ep = readdir(dp)))
	 {
	    snprintf(buf, sizeof(buf), "%s/cliprc/%s", CLIPROOT, ep->d_name);
	    if (stat(buf, &st))
	       continue;
	    if (!S_ISREG(st.st_mode))
	       continue;
	    if (access(buf, R_OK))
	       continue;
	    insert_Coll(&files, strdup(buf));
	 }
	 closedir(dp);

	 for (i = 0; i < files.count_of_Coll; i++)
	 {
		 char *name = (char *) files.items_of_Coll[i];

	    getrc(name);
	 }

	 destroy_Coll(&files);
      }
   }

   argc--;
   argv++;
   get_opt(argc, argv);

   argc -= optind;
   argv += optind;

   if (err_flag)
      return 1;

#if 0
   insert_Coll(&includePaths, ".");
   snprintf(buf, sizeof(buf), "%s/include", CLIPROOT);
   insert_Coll(&includePaths, strdup(buf));
#ifdef STD_LIBDIR
   snprintf(buf, sizeof(buf), STD_LIBDIR);
   insert_Coll(&lib_dirs, strdup(buf));
#endif
   snprintf(buf, sizeof(buf), "%s/lib", CLIPROOT);
   insert_Coll(&lib_dirs, strdup(buf));
#endif

   if (syntax_tree_flag)
   {
      write_obj_flag = 0;
      codegen_flag = 1;
      compile_flag = 0;
      pcode_flag = 0;
      pc_flag = 0;
      asm_flag = 0;
      exec_flag = 0;
   }

   if (!write_obj_flag)
   {
      /*codegen_flag = 0; */
      compile_flag = 0;
   }
   if (preproc_flag)
   {
      write_obj_flag = 0;
      codegen_flag = 0;
      syntax_tree_flag = 0;
      compile_flag = 0;
      exec_flag = 0;
      pcode_flag = 0;
      pc_flag = 0;
      asm_flag = 0;
      shared_flag = 0;
   }

   if (pcode_flag)
   {
      pc_flag = 0;
      asm_flag = 0;
      shared_flag = 0;
   }

   if (pc_flag)
   {
      pcode_flag = 1;
#ifdef USE_AS
      if (use_asm)
	 asm_flag = 1;
      else
	 asm_flag = 0;
#endif
   }

   if (xpc_flag)
   {
      pcode_flag = 1;
      pc_flag = 1;
#ifdef USE_AS
      if (use_asm)
	 asm_flag = 0;
      else
	 asm_flag = 1;
#endif
   }

#if 0
   if (shared_flag && pcode_flag)
   {
      v_printf(0, "conflict between -s and -p flags\n");
      exit(1);
   }
#endif

   if (pcode_flag && c_flag)
   {
      v_printf(0, "conflict between -c and -p flags\n");
      exit(1);
   }

   /*if ( exec_flag && !main_flag && !shared_flag)
      {
      v_printf(0, "-e(xec) flag without -M(ain) or -s(hared) flags\n");
      exit(2);
      } */

   if (pcode_flag)
   {
      compile_flag = 0;
   }

   if (nomain_flag && main_flag)
   {
      v_printf(0, "conflict between -n and -m flags\n");
      exit(1);
   }

   if (!exec_flag && oname)
   {
      char *e;

      if (oname[0] == '/')
	 snprintf(buf, sizeof(buf), "%s", oname);
      else
	 snprintf(buf, sizeof(buf), "%s%s%s", outdir ? outdir : "", outdir ? "/" : "", oname);
      e = strrchr(buf, '/');
      if (e)
      {
	 *e = 0;
	 outdir = strdup(buf);
      }
   }

   if (!outdir)
      outdir = ".";

   if (outdir)
   {
      char cdir[256];

      getcwd(cdir, sizeof(cdir));

      if (!chdir(outdir))
      {
	 getcwd(buf, sizeof(buf));
	 outdir = strdup(buf);
	 chdir(cdir);
      }
      else
      {
	 yyerror("cannot change to output dir '%s': %s", outdir, strerror(errno));
	 exit(1);
      }
   }

   if (!preproc_flag)
   {
      v_printf(2, "set source charset to %s\n", sourceCharset);
      v_printf(2, "set target charset to %s\n", targetCharset);
   }

   init_lex();
   init_parser();

   if (argc < 1)
      ii = -1;
   else
      ii = 0;

   Beg = times(&ts);
   if (argc > 0)
   {
      for (i = 0; i < argc; i++)
      {
	 char *e;

	 e = argv[i];
	 if (e[0] == '-' && e[1] == 'L')
	 {
	    insert_Coll(&lib_dirs, strdup(e + 2));
	    continue;
	 }
	 e = strrchr(argv[i], '.');
	 if (!e)
	 {
	    e = argv[i];
	    if (e[0] == '-' && e[1] == 'l')
	       /*append_Coll(&arglibs, strdup(e+2)) */ ;
	    else
	       yyerror("unknown file type '' file '%s'", argv[i]);
	    continue;
	 }
	 else if (!strcasecmp(e, ".po"))
	    insert_Coll(&poName, strdup(argv[i]));
	 else if (!strcasecmp(e, ".pa"))
	    insert_Coll(&paName, strdup(argv[i]));
	 else if (strcasecmp(e, ".prg") && strcasecmp(e, ".c") && strcasecmp(e, ".cc") && strcasecmp(e, OBJSUF) && strcasecmp(e, SOBJSUF) && strcasecmp(e, ".a") && strcasecmp(e, ".lib"))
	 {
	    /*yywarning("unknown file type '%s' file '%s'", e, argv[i]); */
	    continue;
	 }
      }
   }

   for (; clic_errorcount == 0 && ii < argc; ii++)
   {
      ++files;
      if (ii < 0)
      {
	 v_printf(1, "no input files, so use stdin; -h will help\n");
	 fflush(stderr);
	 set_locale_name("stdin");
	 ret = clic_parse("stdin", stdin);
	 add_name("stdin");
      }
      else
      {
	 char *e;

	 e = strrchr(argv[ii], '.');
	 add_name(argv[ii]);

	 if (!e)
	    continue;
	 else if (!strcasecmp(e, ".c") || !strcasecmp(e, ".cc") || !strcasecmp(e, ".cpp"))
	 {
	    if (!preproc_flag)
	    {
	       v_printf(1, "process file '%s' ..", argv[ii]);
	       v_neednl = 1;
	    }

	    beg = times(&ts);
	    compile_CFile(argv[ii]);
	    end = times(&ts);

	    if (!preproc_flag)
	    {
	       v_neednl = 0;
	       if (clic_errorcount == 0)
		  v_printf(1, ".. done, %s\n", diff_clock(beg, end));
	       else
		  pr_errorcount(1);
	    }
	    continue;
	 }
	 else if (strcasecmp(e, ".prg"))
	 {
	    continue;
	 }

	 if (ii > 0)
	    main_flag = 0;

	 if (!preproc_flag)
	 {
	    v_printf(1, "parsing file '%s' ..", argv[ii]);
	    v_neednl = 1;
	 }
	 beg = times(&ts);
	 set_locale_name(argv[ii]);
	 ret = clic_parse(argv[ii], 0);
	 end = times(&ts);

	 if (!preproc_flag)
	 {
	    v_neednl = 0;
	    if (clic_errorcount == 0)
	       v_printf(1, ".. done (%d/%d %s, %d %s, %s)\n",
			clic_line, all_lines, _clic_ngettext("line", "lines", clic_line), clic_warncount, _clic_ngettext("warning", "warnings", clic_warncount), diff_clock(beg, end));
	    else
	       vr_printf(1, "%d %s, %d %s\n", clic_errorcount, _clic_ngettext("error", "errors", clic_errorcount), clic_warncount, _clic_ngettext("warning", "warnings", clic_warncount));
	 }
      }
      if (ret)
	 break;

      if (clic_errorcount == 0 && codegen_flag)
      {
	 v_printf(2, "codegen file '%s' ..", curFile->name_of_File);
	 v_neednl = 1;
	 beg = times(&ts);
	 codegen_File(curFile);
	 end = times(&ts);
	 v_neednl = 0;
	 if (clic_errorcount == 0)
	    v_printf(2, ".. done, %s\n", diff_clock(beg, end));
	 else
	    pr_errorcount(2);
      }
      if (clic_errorcount == 0 && syntax_tree_flag)
      {
	 print_File(curFile);
      }
      if (clic_errorcount == 0 && write_obj_flag)
      {
	 if (pcode_flag)
	 {
	    long len;

	    v_printf(1, "writing file '%s' ..", curFile->s_cname_of_File);
	    v_neednl = 1;
	    beg = times(&ts);
	    write_OFile(curFile, &len);
	    write_names(curFile);
	    end = times(&ts);
	    v_neednl = 0;
	    if (clic_errorcount == 0)
	       v_printf(1, ".. done, %ld %s ,%s\n", len, _clic_ngettext("byte", "bytes", len), diff_clock(beg, end));
	    else
	       pr_errorcount(1);
	 }
	 else
	 {
	    v_printf(2, "writing file '%s' ..", curFile->s_cname_of_File);
	    v_neednl = 1;
	    write_File(curFile);
	    write_names(curFile);
	    v_neednl = 0;
	    if (clic_errorcount == 0)
	       v_printf(2, ".. done\n");
	    else
	       pr_errorcount(2);
	 }
      }

      if (clic_errorcount == 0 && (compile_flag || pc_flag))
      {
	 if (ii)
	    main_flag = 0;
	 v_printf(1, "compile file '%s' ..", curFile->s_cname_of_File);
	 v_neednl = 1;
	 beg = times(&ts);
	 compile_File(curFile->cname_of_File);
	 end = times(&ts);
	 v_neednl = 0;
	 if (clic_errorcount == 0)
	    v_printf(1, ".. done, %s\n", diff_clock(beg, end));
	 else
	    pr_errorcount(1);

	 if (clic_errorcount == 0 && shared_flag && !exec_flag)
	 {
	    v_printf(1, "make shared object '%s' ..", curFile->s_cname_of_File);
	    v_neednl = 1;
	    beg = times(&ts);
	    share_File(curFile->cname_of_File);
	    end = times(&ts);
	    v_neednl = 0;
	    if (clic_errorcount == 0)
	       v_printf(1, ".. done, %s\n", diff_clock(beg, end));
	    else
	       pr_errorcount(1);

	 }
      }

      if (ii < 0)
	 break;

      delete_File(curFile);
      curFile = NULL;
   }

   if (clic_errorcount == 0 && exec_flag)
   {
      char cmd[1024 * 8], *e;

      char cfuncname[256], ofuncname[256];

      char *libroot;

      int i;

      Coll ex, nm;

      init_Coll(&ex, free, strcasecmp);
      init_Coll(&nm, free, strcasecmp);
#ifdef STD_LIBDIR
      libroot = 0;
#else
      libroot = CLIPROOT;
#endif

      ++files;
#ifdef STD_LIBDIR
      if (eshared_flag || shared_flag)
      {
	 snprintf(cmd, sizeof(cmd), "-lclip");
	 add_name(cmd);
      }
      else
#endif
      {
	 e = (eshared_flag || shared_flag) ? CLIPSLIB : CLIPLIB;
	 lib_name(cmd, sizeof(cmd), libroot, "lib", e, strlen(e));
	 add_name(cmd);
      }
      for (e = CLIPLIBS; *e;)
      {
	 int l;

	 l = strspn(e, " \t");
	 e += l;
	 l = strcspn(e, " \t");
	 if (!l)
	    break;
	 lib_name(cmd, sizeof(cmd), libroot, "lib", e, l);
	 add_name(cmd);
	 e += l;
      }
      for (e = ADDLIBS; *e;)
      {
	 int l;

	 l = strspn(e, " \t");
	 e += l;
	 l = strcspn(e, " \t");
	 if (!l)
	    break;
	 memcpy(cmd, e, l);
	 cmd[l] = 0;
	 add_name(cmd);
	 e += l;
      }
      add_name(MATHLIB);
      add_name(DLLIB);

      /* generate _cfunctions */
      if (asm_flag)
	 sprintf(cfuncname, "%s_ref.s", oname);
      else
	 sprintf(cfuncname, "%s_ref.c", oname);
      sprintf(ofuncname, "%s_ref.o", oname);
      v_printf(1, "generate reference file '%s' ..", cfuncname);
      v_neednl = 1;
      beg = times(&ts);
      write_Cfunc(cfuncname, onum, ovect, &ex, &nm);
      check_names(&ex, &nm);
      end = times(&ts);
      v_neednl = 0;
      if (clic_errorcount == 0)
	 v_printf(1, ".. done, %s\n", diff_clock(beg, end));
      else
	 pr_errorcount(1);
      if (clic_errorcount)
	 goto end;

      v_printf(1, "compile file '%s' ..", cfuncname);
      v_neednl = 1;
      beg = times(&ts);
      compile_File(cfuncname);
      end = times(&ts);
      v_neednl = 0;
      if (clic_errorcount == 0)
	 v_printf(1, ".. done, %s\n", diff_clock(beg, end));
      else
	 pr_errorcount(1);

#ifdef USE_LD
      if (use_asm && (shared_flag || eshared_flag))
      {
	 int ll;

	 const char *ld_prg, *ld_end;

	 if (shared_flag || eshared_flag)
	 {
	    ld_prg = LD_PRG;
	    ld_end = LD_END;
	 }
	 else
	 {
	    ld_prg = LDS_PRG;
	    ld_end = LDS_END;
	 }

	 snprintf(cmd, sizeof(cmd), "%s", ld_prg);
	 ll = strlen(cmd);
	 for (e = cmd + ll, i = 0; i < lib_dirs.count_of_Coll; ++i)
	 {
		 snprintf(e, sizeof(cmd) - ll, " -L%s", (char *) lib_dirs.items_of_Coll[i]);
	    ll = strlen(cmd);
	    e = cmd + ll;
	 }
	 ll = strlen(cmd);
	 snprintf(cmd + ll, sizeof(cmd) - ll, " %s %s %s -o %s", optLevel ? COPT : "", genDebug ? CDBG : "", ofuncname, oname);
	 ll = strlen(cmd);
	 for (e = cmd + ll, i = 0; i < onum; ++i)
	 {
	    snprintf(e, sizeof(cmd) - ll, " %s", ovect[i]);
	    ll = strlen(cmd);
	    e = cmd + ll;
	 }
	 ll = strlen(cmd);
	 snprintf(cmd + ll, sizeof(cmd) - ll, " %s", ld_end);
      }
      else
#endif
      {
	 sprintf(cmd, "%s", CC);
	 for (e = cmd + strlen(cmd), i = 0; i < includePaths.count_of_Coll; ++i)
	 {
		 sprintf(e, " %s %s", INCLUDE_FLAG, (char *) includePaths.items_of_Coll[i]);
	    e = cmd + strlen(cmd);
	 }

	 for (e = cmd + strlen(cmd), i = 0; i < lib_dirs.count_of_Coll; ++i)
	 {
		 sprintf(e, " -L%s", (char *) lib_dirs.items_of_Coll[i]);
	    e = cmd + strlen(cmd);
	 }

	 sprintf(cmd + strlen(cmd), " %s %s %s %s %s %s %s", optLevel ? COPT : "", genDebug ? CDBG : "", CFLAGS, ADDCFLAGS, ofuncname, OUT_FLAG, oname);
	 for (e = cmd + strlen(cmd), i = 0; i < onum; ++i)
	 {
	    sprintf(e, " %s", ovect[i]);
	    e = cmd + strlen(cmd);
	 }
      }

      v_printf(1, "make file '%s' ..", oname);
      v_neednl = 1;
      beg = times(&ts);
      v_printf(2, "%s\n", cmd);
      if (system(cmd))
	 yyerror("C level error in command: %s", cmd);
      else if (rmc_flag)
      {
	 unlink(cfuncname);
	 unlink(ofuncname);
      }

      end = times(&ts);
      v_neednl = 0;
      if (clic_errorcount == 0)
	 v_printf(1, ".. done, %s\n", diff_clock(beg, end));
      else
	 pr_errorcount(1);
   }

 end:
   End = times(&ts);

   resume_parser();
   resume_lex();
   resume_locale();

   if (!preproc_flag)
      v_printf(1, "clip: %d %s, %s\n", files, _clic_ngettext("file", "files", files), diff_clock(Beg, End));
   return clic_errorcount == 0 ? 0 : 1;
}