/**
 * This is the function called from the main program. It makes sure 
 * settings from all the different directions are entered and centered
 * into the main settings in the appropriate manner and order.
 * 
 * Settings are set in this order:
 *  1. Default settings, hardcoded into the program.
 *  2. Global configuration file, /etc/zen/main.conf
 *  3. User configuration file, ~/.zen/main.conf
 *  4. Extra configuration files, given on command line.
 *  5. Environment variables.
 *  6. Command line options. 
 *
 * @param argc The number of arguments given to the program.
 * @param argv An array of strings with the given arguments.
 */
void settings_read(int argc, char *argv[])
{
  char *filename;
  /* Set the program name globally, to simplify for me, and me alone. */
  program_name = argv[0];

  /* 1. Default settings, hardcoded into the program. */
  //set_defaults();

  /* 2. Global configuration file, /etc/zen/main.conf */
  //read_configuration(GLOBAL_CONFIGDIR "\\main.conf", 0);

  /* 3. User configuration file, ~/.zen/main.conf */
  //homedir = find_homedir();
  //filename = (char *)malloc(strlen(homedir) + 32);
  //if(filename != NULL) {
  //  sprintf(filename, "%s/.zen/main.conf", homedir);
  //  read_configuration(filename, 0);
  //  free(filename);
  //}
  //added by wichang

  filename = "index.html";
  //strcpy ( filename, "index.html");
  /* 4. Extra configuration files, given on command line.
   * 5. Environment variables.
   * 6. Command line options.
   */
  interpret_options(argc, argv);
}
Exemple #2
0
// API: open a fancy image
struct fancy_image *fancy_image_open(char *filename, char *options)
{
	// create return struct and its alias
	//struct fancy_image r[1];
	struct fancy_image *r = xmalloc(sizeof*r); // I hate this malloc!
	struct FI *f = (void*)r;

	// process options parameter
	interpret_options(f, options);

	// if "c", do create the file
	if (f->option_creat) {
		if (filename_corresponds_to_tiffo(filename) || f->option_tw > 0)
			create_zero_tiff_file(filename,
					f->option_w, f->option_h,
					f->option_tw, f->option_th,
					f->option_spp, f->option_bps,
					f->option_fmt,
					true, f->option_compressed);
		else
			create_iio_file(filename, f->option_w, f->option_h,
					f->option_spp);
	}

	// read the image
	if (filename_corresponds_to_tiffo(filename)) {
		f->tiffo = true;
		tiff_octaves_init0(f->t, filename, f->megabytes,f->max_octaves);
		if (f->option_write) f->t->option_write = true;
		f->w = f->t->i->w;
		f->h = f->t->i->h;
		f->pd = f->t->i->spp;
		f->no = f->t->noctaves;
	} else {
		f->tiffo = false;
		f->x = iio_read_image_float_vec(filename, &f->w, &f->h, &f->pd);
		f->no = build_pyramid(f, f->max_octaves);
		strncpy(f->x_filename, filename, FILENAME_MAX);
		f->x_changed = false;
	}

	if (f->option_verbose) {
		fprintf(stderr, "FANCY IMAGE \"%s\"\n", filename);
		fprintf(stderr, "\tw = %d\n", f->w);
		fprintf(stderr, "\th = %d\n", f->h);
		fprintf(stderr, "\tpd = %d\n", f->pd);
		fprintf(stderr, "\tno = %d\n", f->no);
		fprintf(stderr, "\n");
		fprintf(stderr, "\tmax_octaves= %d\n", f->max_octaves);
		fprintf(stderr, "\ttiffo = %d\n", f->tiffo);
		fprintf(stderr, "\tmegabytes = %g\n", f->megabytes);
	}

	// return image struct
	return r;
}
int main(int argc, char *argv[])
{
    int retval;

    do {
	retval = interpret_options(&argc, &argv);
    } while ((argc > 0) && strcmp(argv[0], "--") == 0);

    return retval;
}
Exemple #4
0
// API: open a fancy image
struct fancy_image *fancy_image_open(char *filename, char *options)
{
	// create return struct and its alias
	//struct fancy_image r[1];
	struct fancy_image *r = xmalloc(sizeof*r); // I hate this malloc!
	struct FI *f = (void*)r;

	// process options parameter
	interpret_options(f, options);

	if (f->option_verbose)
			fprintf(stderr, "fancy_image_open\n\tf="
				"\"%s\"\n\to=\"%s\"\n", filename, options);

	// if "c", do create the file
	if (f->option_creat)
		generic_create(f, filename);

	// read the image
	f->gdal = f->tiffo = false;
	generic_read(f, filename);

	if (f->option_verbose) {
		fprintf(stderr, "FANCY IMAGE \"%s\"\n", filename);
		fprintf(stderr, "\tw = %d\n", f->w);
		fprintf(stderr, "\th = %d\n", f->h);
		fprintf(stderr, "\tpd = %d\n", f->pd);
		fprintf(stderr, "\tno = %d\n", f->no);
		fprintf(stderr, "\n");
		fprintf(stderr, "\tmax_octaves= %d\n", f->max_octaves);
		fprintf(stderr, "\ttiffo = %d\n", f->tiffo);
		fprintf(stderr, "\tmegabytes = %g\n", f->megabytes);
	}

	// return image struct
	return r;
}