コード例 #1
0
ファイル: conversionview.c プロジェクト: DINKIN/nip2
static void
conversionview_scale_cb( GtkWidget *wid, Conversionview *cv )
{
	Imagemodel *imagemodel = cv->imagemodel;
	double min, max;

	progress_begin();
	if( !conversionview_findmaxmin( imagemodel, &min, &max ) ) {
		progress_end();
		iwindow_alert( wid, GTK_MESSAGE_ERROR );
		return;
	}
	progress_end();

        if( max - min < 1e-20 ) {
                error_top( _( "Unable to scale image." ) );
                error_sub( _( "Maximum and minimum pixel values are equal." ) );
		iwindow_alert( wid, GTK_MESSAGE_ERROR );
                return;
        }

	imagemodel->scale = 255.0 / (max - min);
	imagemodel->offset = -(min * imagemodel->scale);
	iobject_changed( IOBJECT( imagemodel ) );
}
コード例 #2
0
bool liquid_reflection_maps_create(void)
{
	bool			ok;
	char			err_str[256];

	if (os_dialog_confirm("Build Liquid Reflection Maps","Building liquids reflection maps will replace the 6th sets of textures and save the map.\nAre you sure you want to build the liquid reflection maps?",FALSE)!=0) return(FALSE);
	
		// see if there are any liquids
		
	if (map.liquid.nliquid==0) {
		os_dialog_alert("Can not build liquid reflection maps","There are no liquids set to build reflection maps in this map.");
		return(FALSE);
	}

	if (map.liquid.nliquid>max_liquid_reflection_map_textures) {
		os_dialog_alert("Can not build liquid reflection maps","There are too many liquids set to build reflection maps in this map.");
		return(FALSE);
	}
	
		// generate the reflection maps
		
	progress_start("Generating Liquid Reflection Maps...",(2+map.liquid.nliquid));
	ok=liquid_reflection_maps_create_process(map.liquid.nliquid,err_str);
	progress_end();

	if (!ok) {
		os_dialog_alert("Can not build liquid reflection maps",err_str);
		return(FALSE);
	}

	file_save_map();
	
	return(TRUE);
}
コード例 #3
0
ファイル: progress.c プロジェクト: S0043640wipro/RiCRiPInt
static void pop_file_timeline(void)
{
  HQASSERT(!stack_empty(), "file timeline stack empty");

  progress_end(&aReadFile[maxIndex].tl_ref);
  aReadFile[maxIndex].flptr = NULL;
  maxIndex--;
}
コード例 #4
0
ファイル: pflash.c プロジェクト: tomjoseph83/skiboot
static void program_file(const char *file, uint32_t start, uint32_t size)
{
    int fd, rc;
    ssize_t len;
    uint32_t actual_size = 0;

    fd = open(file, O_RDONLY);
    if (fd == -1) {
        perror("Failed to open file");
        exit(1);
    }
    printf("About to program \"%s\" at 0x%08x..0x%08x !\n",
           file, start, start + size);
    check_confirm();

    if (dummy_run) {
        printf("skipped (dummy)\n");
        close(fd);
        return;
    }

    printf("Programming & Verifying...\n");
    progress_init(size >> 8);
    while(size) {
        len = read(fd, file_buf, FILE_BUF_SIZE);
        if (len < 0) {
            perror("Error reading file");
            exit(1);
        }
        if (len == 0)
            break;
        if (len > size)
            len = size;
        size -= len;
        actual_size += len;
        rc = blocklevel_write(bl, start, file_buf, len);
        if (rc) {
            if (rc == FLASH_ERR_VERIFY_FAILURE)
                fprintf(stderr, "Verification failed for"
                        " chunk at 0x%08x\n", start);
            else
                fprintf(stderr, "Flash write error %d for"
                        " chunk at 0x%08x\n", rc, start);
            exit(1);
        }
        start += len;
        progress_tick(actual_size >> 8);
    }
    progress_end();
    close(fd);

    /* If this is a flash partition, adjust its size */
    if (ffsh && ffs_index >= 0) {
        printf("Updating actual size in partition header...\n");
        ffs_update_act_size(ffsh, ffs_index, actual_size);
    }
}
コード例 #5
0
ファイル: pflash.c プロジェクト: tomjoseph83/skiboot
static void erase_range(uint32_t start, uint32_t size, bool will_program)
{
    uint32_t done = 0;
    int rc;

    printf("About to erase 0x%08x..0x%08x !\n", start, start + size);
    check_confirm();

    if (dummy_run) {
        printf("skipped (dummy)\n");
        return;
    }

    printf("Erasing...\n");
    progress_init(size >> 8);
    while(size) {
        /* If aligned to 64k and at least 64k, use 64k erase */
        if ((start & 0xffff) == 0 && size >= 0x10000) {
            rc = blocklevel_erase(bl, start, 0x10000);
            if (rc) {
                fprintf(stderr, "Error %d erasing 0x%08x\n",
                        rc, start);
                exit(1);
            }
            start += 0x10000;
            size -= 0x10000;
            done += 0x10000;
        } else {
            rc = blocklevel_erase(bl, start, 0x1000);
            if (rc) {
                fprintf(stderr, "Error %d erasing 0x%08x\n",
                        rc, start);
                exit(1);
            }
            start += 0x1000;
            size -= 0x1000;
            done += 0x1000;
        }
        progress_tick(done >> 8);
    }
    progress_end();

    /* If this is a flash partition, mark it empty if we aren't
     * going to program over it as well
     */
    if (ffsh && ffs_index >= 0 && !will_program) {
        printf("Updating actual size in partition header...\n");
        ffs_update_act_size(ffsh, ffs_index, 0);
    }
}
コード例 #6
0
ファイル: pflash.c プロジェクト: tomjoseph83/skiboot
static void set_ecc(uint32_t start, uint32_t size)
{
    uint32_t i = start + 8;
    uint8_t ecc = 0;

    printf("About to erase and set ECC bits in region 0x%08x to 0x%08x\n", start, start + size);
    check_confirm();
    erase_range(start, size, true);

    printf("Programming ECC bits...\n");
    progress_init(size);
    while (i < start + size) {
        blocklevel_write(bl, i, &ecc, sizeof(ecc));
        i += 9;
        progress_tick(i - start);
    }
    progress_end();
}
コード例 #7
0
ファイル: pflash.c プロジェクト: tomjoseph83/skiboot
static void do_read_file(const char *file, uint32_t start, uint32_t size)
{
    int fd, rc;
    ssize_t len;
    uint32_t done = 0;

    fd = open(file, O_WRONLY | O_TRUNC | O_CREAT, 00666);
    if (fd == -1) {
        perror("Failed to open file");
        exit(1);
    }
    printf("Reading to \"%s\" from 0x%08x..0x%08x !\n",
           file, start, start + size);

    progress_init(size >> 8);
    while(size) {
        len = size > FILE_BUF_SIZE ? FILE_BUF_SIZE : size;
        rc = blocklevel_read(bl, start, file_buf, len);
        if (rc) {
            fprintf(stderr, "Flash read error %d for"
                    " chunk at 0x%08x\n", rc, start);
            exit(1);
        }
        rc = write(fd, file_buf, len);
        if (rc < 0) {
            perror("Error writing file");
            exit(1);
        }
        start += len;
        size -= len;
        done += len;
        progress_tick(done >> 8);
    }
    progress_end();
    close(fd);
}
コード例 #8
0
ファイル: import.c プロジェクト: USGS-CIDA/migratingToGit
void analyze_masters(int argc, char *argv[], 
			  import_options_t *analyzer, 
			  forest_t *forest)
/* main entry point; collect and parse CVS masters */
{
    char	    name[PATH_MAX];
    const char      *last = NULL;
    char	    *file;
    size_t	    i, j = 1;
    int		    c;
#ifdef THREADS
    pthread_attr_t  attr;

    /* Initialize and reinforce default thread non-detached attribute */
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
#endif /* THREADS */

    striplen = analyzer->striplen;

    forest->textsize = forest->filecount = 0;
    progress_begin("Reading file list...", NO_MAX);
    for (;;)
    {
	struct stat stb;
	int l;
	if (argc < 2) {
	    /* coverity[tainted_data] Safe, never handed to exec */
	    if (fgets(name, sizeof(name), stdin) == NULL)
		break;
	    l = strlen(name);
	    if (name[l-1] == '\n')
		name[l-1] = '\0';
	    file = name;
	} else {
	    file = argv[j++];
	    if (!file)
		break;
	}

	if (stat(file, &stb) != 0)
	    continue;
	else if (S_ISDIR(stb.st_mode) != 0)
	    continue;
	else if (!analyzer->promiscuous)
	{
	    char *end = file + strlen(file);
	    if (end - file < 2 || end[-1] != 'v' || end[-2] != ',')
		continue;
	    if (strstr(file, "CVSROOT") != NULL)
		continue;
	}
	forest->textsize += stb.st_size;

	fn = xcalloc(1, sizeof(rev_filename), "filename gathering");
	*fn_tail = fn;
	fn_tail = (rev_filename **)&fn->next;
	if (striplen > 0 && last != NULL) {
	    c = strcommonendingwith(file, last, '/');
	    if (c < striplen)
		striplen = c;
	} else if (striplen < 0) {
	    striplen = 0;
	    for (i = 0; i < strlen(file); i++)
		if (file[i] == '/')
		    striplen = i + 1;
	}
	fn->file = atom(file);
	last = fn->file;
	total_files++;
	if (progress && total_files % 100 == 0)
	    progress_jump(total_files);
    }
    forest->filecount = total_files;

    generators = xcalloc(sizeof(generator_t), total_files, "Generators");
    sorted_files = xmalloc(sizeof(rev_file) * total_files, "sorted_files");
    cvs_masters = xcalloc(total_files, sizeof(cvs_master), "cvs_masters");
    rev_masters = xmalloc(sizeof(rev_master) * total_files, "rev_masters");
    fn_n = total_files;
    i = 0;
    rev_filename *tn;
    for (fn = fn_head; fn; fn = tn) {
	tn = fn->next;
	sorted_files[i].name = fn->file;
	sorted_files[i++].rectified = atom_rectify_name(fn->file);
	free(fn);
    }
#ifdef FILESORT
    /*
     * Sort list of files in path_deep_compare order of output name.
     * cvs_masters and rev_masters will be mainteined in this order.
     * This causes commits to come out in correct pack order.
     * It also causes operations to come out in correct fileop_sort order.
     * Note some output names are different to input names.
     * e.g. .cvsignore becomes .gitignore
     */
    qsort(sorted_files, total_files, sizeof(rev_file), file_compare);
#endif /*FILESORT */
	
    progress_end("done, %.3fKB in %d files",
		 (forest->textsize/1024.0), forest->filecount);

    /* things that must be visible to inner functions */
    load_current_file = 0;
    verbose = analyzer->verbose;

    /*
     * Analyze the files for CVS revision structure.
     *
     * The result of this analysis is a rev_list, each element of
     * which corresponds to a CVS master and points at a list of named
     * CVS branch heads (rev_refs), each one of which points at a list
     * of CVS commit structures (cvs_commit).
     */
#ifdef THREADS
    if (threads > 1)
	snprintf(name, sizeof(name), 
		 "Analyzing masters with %d threads...", threads);
    else
#endif /* THREADS */
	strcpy(name, "Analyzing masters...");
    progress_begin(name, total_files);
#ifdef THREADS
    if (threads > 1)
    {
	int i;

	workers = (pthread_t *)xcalloc(threads, sizeof(pthread_t), __func__);
	for (i = 0; i < threads; i++)
	    pthread_create(&workers[i], &attr, worker, NULL);

        /* Wait for all the threads to die off. */
	for (i = 0; i < threads; i++)
          pthread_join(workers[i], NULL);
        
	pthread_mutex_destroy(&enqueue_mutex);
	pthread_mutex_destroy(&revlist_mutex);
    }
    else
#endif /* THREADS */
	worker(NULL);

    progress_end("done, %d revisions", (int)total_revisions);
    free(sorted_files);

    forest->errcount = err;
    forest->total_revisions = total_revisions;
    forest->skew_vulnerable = skew_vulnerable;
    forest->cvs = cvs_masters;
    forest->generators = (generator_t *)generators;
}