Пример #1
0
		bool XUI_Window::SaveToXMLNode( TiXmlNode* pNode )
		{
			TiXmlElement* pElement = pNode->ToElement();

			TiXmlElement Attribute( "attribute" );
			if( save_file( &Attribute ) == false ) return false;
			pNode->InsertEndChild( Attribute );


			std::vector<XUI_Wnd*>::const_iterator citer = m_pChildren.begin();
			while( citer != m_pChildren.end() )
			{
				XUI_Wnd* pXUI_Wnd = *citer;
				TiXmlElement XmlElement("control");
				XmlElement.SetAttribute( "lable", typeid( pXUI_Wnd ).name() );
				if( typeid( pXUI_Wnd ) == typeid(XUI_Window) )
					((XUI_Window*)pXUI_Wnd)->SaveToXMLNode( (TiXmlNode*)&XmlElement );
				else
				{
					//if( pXUI_Wnd->SavePropertys( &XmlElement ) == false ) return false;
					TiXmlElement Attribute( "attribute" );
					if( pXUI_Wnd->save_file( &Attribute ) == false ) return false;
					XmlElement.InsertEndChild( Attribute );
				}

				pNode->InsertEndChild( XmlElement );
				++citer;
			}
			return true;
		}
Пример #2
0
si_t save_window_ok_button_callback(void* btn, void* msg)
{
    union message* m = (union message*)msg;
	switch(m->base.type)
	{
    case MESSAGE_TYPE_MOUSE_SINGLE_CLICK:
		if(0 == save_file(text_line_get_buf(save_text_line), text_line_get_buf(file_context_text_line)))
		{
			sprintf(log_label->text, "save successfully!");
		}
		else
		{
			sprintf(log_label->text, "failed to save file!");
		}
		application_del_window(save_window);
		sprintf(file_label->text, "%s", text_line_get_buf(save_text_line));
		save_window = NULL;
		save_text_line = NULL;
		break;
    default:
        button_default_callback(btn, msg);
        return 0;
        break;
	}
    label_repaint(log_label);
    label_show(log_label);
    return 0;
}
Пример #3
0
int
write_file(char *file)
{
    int return_val = OK;

    if (ignore_prev == 1)
	/* if user wants to ignore previous version, we remove it *
	 * ( fcron daemon remove files no longer wanted before
	 *   adding new ones ) */
	remove_fcrontab(0);

    if ( file_base->cf_line_base == NULL ) {
	/* no entries */
	explain("%s's fcrontab contains no entries : removed.", user);
	remove_fcrontab(0);
    } 
    else {
	/* write the binary fcrontab on disk */
	snprintf(buf, sizeof(buf), "new.%s", user);
	if ( save_file(buf) != OK )
	    return_val = ERR;
    }

    /* copy original file to fcrontabs dir */
    snprintf(buf, sizeof(buf), "%s.orig", user);
    if ( copy(file, buf) == ERR )
	return_val = ERR;

    return return_val;
}
Пример #4
0
//-----------------------------------------------------------------------------
static void target_cm0p_read(char *name)
{
  uint32_t size = device->flash_size;
  uint32_t addr = device->flash_start;
  uint32_t offs = 0;
  uint8_t *buf;

  if (dap_read_word(DSU_CTRL_STATUS) & 0x00010000)
    error_exit("devices is locked, unable to read");

  buf = buf_alloc(device->flash_size);

  verbose("Reading...");

  while (size)
  {
    dap_read_block(addr, &buf[offs], device->row_size);

    addr += device->row_size;
    offs += device->row_size;
    size -= device->row_size;

    verbose(".");
  }

  save_file(name, buf, device->flash_size);

  buf_free(buf);

  verbose(" done.\n");
}
Пример #5
0
main ()
{
	load_file (IN_FILE);
	code_file ();
	save_file (OUT_FILE);
	free_mem ();
}
Пример #6
0
static int
scramble (const char *src, uint32_t sz, char *dst)
{
    unsigned char *ptr = NULL;
    FILE *fh;

    if ((fh = fopen (src, "rb")) == NULL)
        return -1;

    if ((ptr = (unsigned char *) malloc (sz)) == NULL)
        return -1;

    if (fread (ptr, 1, sz, fh) != sz)
        return -1;

    fclose (fh);

    if (!(fh == fopen (dst, "wb")))
        return -1;
    save_file (fh, ptr, sz);

    fclose (fh);

    free (ptr);
    return 0;
}
Пример #7
0
int		get_next_line(int const fd, char **line)
{
	static t_list	*file;
	unsigned int	index;
	char			*content;

	if (!line || fd < 0 || fd == 1)
		return (-1);
	if ((!file || fd == 0) && (file = ft_lstnew(NULL, 0)))
		if ((save_file(fd, &file)) < 1)
			return (-1);
	*line = "\0";
	while (file)
	{
		index = 0;
		content = file->content;
		while (content[index] && content[index] != '\n')
			index++;
		*line = ft_strjoin(*line, ft_strsub(content, 0, index));
		if (content[index] == '\n' && content[index + 1])
			return (file->content = &content[index + 1], 1);
		else if ((content[index] == '\n' && !content[index + 1]) || !file->next)
			return (file = file->next, 1);
		file = file->next;
	}
	return (0);
}
static void
e_book_backend_vcf_dispose (GObject *object)
{
	EBookBackendVCF *bvcf;

	bvcf = E_BOOK_BACKEND_VCF (object);

	if (bvcf->priv) {

		g_mutex_lock (bvcf->priv->mutex);

		if (bvcf->priv->flush_timeout_tag) {
			g_source_remove (bvcf->priv->flush_timeout_tag);
			bvcf->priv->flush_timeout_tag = 0;
		}

		if (bvcf->priv->dirty)
			save_file (bvcf);

		g_hash_table_destroy (bvcf->priv->contacts);
		g_list_foreach (bvcf->priv->contact_list, (GFunc)g_free, NULL);
		g_list_free (bvcf->priv->contact_list);

		g_free (bvcf->priv->filename);

		g_mutex_unlock (bvcf->priv->mutex);

		g_mutex_free (bvcf->priv->mutex);

		g_free (bvcf->priv);
		bvcf->priv = NULL;
	}

	G_OBJECT_CLASS (e_book_backend_vcf_parent_class)->dispose (object);
}
Пример #9
0
void save_settings::save(error_code& ec) const
{
	// back-up current settings file as .bak before saving the new one
	std::string backup = m_settings_file + ".bak";
	bool has_settings = exists(m_settings_file);
	bool has_backup = exists(backup);

	if (has_settings && has_backup)
		remove(backup, ec);

	if (has_settings)
		rename(m_settings_file, backup, ec);

	ec.clear();

	entry sett;
	m_ses.save_state(sett);

	for (std::map<std::string, int>::const_iterator i = m_ints.begin()
		, end(m_ints.end()); i != end; ++i)
	{
		sett[i->first] = i->second;
	}

	for (std::map<std::string, std::string>::const_iterator i = m_strings.begin()
		, end(m_strings.end()); i != end; ++i)
	{
		sett[i->first] = i->second;
	}
	std::vector<char> buf;
	bencode(std::back_inserter(buf), sett);
	save_file(m_settings_file, buf, ec);
}
Пример #10
0
log::log(string filename=string("all.log"))
{
    int ret = access("log",0);
    if(ret == -1)

#ifdef WINDOWSCODE
        mkdir("log");
#else
        mkdir("log", 0777);
#endif

    if(m_fp==NULL)
    {
        //m_fp=fopen(filename.c_str(), "a");
        //日志文件打开的模式  对文件的大小是否变换起决定性的作用, a方式 一直会增大,

        if(access("all.log", 0) == 0)
            save_file();

        m_fp=fopen(filename.c_str(), "wb");
        if(m_fp==NULL)
        {
            printf("open file error \n");
            exit(-1);
        }
    }
}
Пример #11
0
static void file_check_data(	struct file_info *file,
				int fd,
				struct write_info *w)
{
	size_t remains, block, i;
	off_t r;
	char buf[BUFFER_SIZE];

	srand(w->random_seed);
	for (r = 0; r < w->random_offset; ++r)
		rand();
	CHECK(lseek(fd, w->offset, SEEK_SET) != (off_t) -1);
	remains = w->size;
	while (remains) {
		if (remains > BUFFER_SIZE)
			block = BUFFER_SIZE;
		else
			block = remains;
		CHECK(read(fd, buf, block) == block);
		for (i = 0; i < block; ++i) {
			char c = (char) rand();
			if (buf[i] != c) {
				fprintf(stderr, "file_check_data failed at %u "
					"checking data at %u size %u\n",
					(unsigned) (w->size - remains + i),
					(unsigned) w->offset,
					(unsigned) w->size);
				file_info_display(file);
				save_file(fd, file);
			}
			CHECK(buf[i] == c);
		}
		remains -= block;
	}
}
Пример #12
0
static void file_check_hole(	struct file_info *file,
				int fd, off_t offset,
				size_t size)
{
	size_t remains, block, i;
	char buf[BUFFER_SIZE];

	CHECK(lseek(fd, offset, SEEK_SET) != (off_t) -1);
	remains = size;
	while (remains) {
		if (remains > BUFFER_SIZE)
			block = BUFFER_SIZE;
		else
			block = remains;
		CHECK(read(fd, buf, block) == block);
		for (i = 0; i < block; ++i) {
			if (buf[i] != 0) {
				fprintf(stderr, "file_check_hole failed at %u "
					"checking hole at %u size %u\n",
					(unsigned) (size - remains + i),
					(unsigned) offset,
					(unsigned) size);
				file_info_display(file);
				save_file(fd, file);
			}
			CHECK(buf[i] == 0);
		}
		remains -= block;
	}
}
Пример #13
0
void pce_shutdown(void)
{
    if(save_bram) save_file("pce.brm", bram, 0x2000);
#ifdef DEBUG
    error("PC:%04X\n", h6280_get_pc());
#endif
}
Пример #14
0
mlx_name()
{
	int nblocks,block;
	GLOBRECORD *blockptr[MAXNBLOCKS+1];
	long addr[32],leng[32];	/* oversized */

	/* load multi-block file containing block to be renamed */
	Dsetdrv(mlt_drive); dsetpath(mlt_path);
	if (!readdatafile(MLXNAMTITL,mlxfile,mlxpath,MLX_EXT,0)) return;
	mlt_drive= Dgetdrv(); Dgetpath(mlt_path,mlt_drive+1);
	mlx_mem= tempmem;

	/* choose block from it */
	nblocks= scan_blocks(heap[mlx_mem].start,blockptr);
	if (!nblocks) return;	/* can't happen? */
	block= select_block(BLOCK2NAM,nblocks,blockptr);
	if ( (block<0) || (block>=nblocks) ) return;

	/* edit the comment field in the selected block, and replace file
		without warning */
	if (_mlx_name(blockptr[block]->comment))
	{
		addr[0]= heap[mlx_mem].start;
		leng[0]= heap[mlx_mem].nbytes;
		save_file(mlxfile,mlxpath,-1,addr,leng);
	}

}	/* end mlx_name() */
Пример #15
0
void
GIFFManager::save_file(TArray<char> & data)
{
  GP<ByteStream> gstr=ByteStream::create();
  save_file(gstr);
  data=gstr->get_data();
}
Пример #16
0
//*******************************************************************
// QBtFileEditor                                         CONSTRUCTOR
//*******************************************************************
QBtFileEditor::QBtFileEditor( QWidget* const in_parent, const QString& in_path ) : QDialog( in_parent )
, path_    ( QString() )
, editor_  ( new QTextEdit )
, reload_  ( new QPushButton( tr( RELOAD ) ) )
, save_    ( new QPushButton( tr( SAVE   ) ) )
, cancel_  ( new QPushButton( tr( CANCEL ) ) )
{
   setWindowTitle( tr( CAPTION ) );

   path_ = QFile::symLinkTarget( in_path );
   if( path_.isEmpty() ) path_ = in_path;
   
   static const QString my_font = "Monospace,9,-1,5,50,0,0,0,0,0";
   QFont fnt;
   fnt.fromString( my_font );
   editor_->setFont( fnt );   

   QHBoxLayout* const btn_layout = new QHBoxLayout;
   btn_layout->addStretch();
   btn_layout->addWidget( reload_ );
   btn_layout->addWidget( save_   );
   btn_layout->addWidget( cancel_ );

   QVBoxLayout* const main_layout = new QVBoxLayout;
   main_layout->addWidget( editor_ );
   main_layout->addLayout( btn_layout );
   setLayout( main_layout );

   connect( reload_, SIGNAL( clicked() ), this, SLOT( reload_file() ) );
   connect( save_  , SIGNAL( clicked() ), this, SLOT( save_file  () ) );
   connect( cancel_, SIGNAL( clicked() ), this, SLOT( accept     () ) );

   cancel_->setDefault( true );
}
Пример #17
0
static void
do_save_as (GtkAction *action)
{
  GtkWidget *dialog;
  gint response;
  char *save_filename;
  
  dialog = gtk_file_chooser_dialog_new ("Select file",
					GTK_WINDOW (main_window),
					GTK_FILE_CHOOSER_ACTION_SAVE,
					GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
					GTK_STOCK_SAVE, GTK_RESPONSE_OK,
					NULL);
  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
  response = gtk_dialog_run (GTK_DIALOG (dialog));

  if (response == GTK_RESPONSE_OK)
    {
      save_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
      save_file (save_filename);
      g_free (save_filename);
    }
  
  gtk_widget_destroy (dialog);
}
Пример #18
0
//********************************************************
void WordsEdit::closeEvent( QCloseEvent *e )
{
  
  if(changed){
      
    switch ( QMessageBox::warning( this, "WORDS.TOK edit",
                                   "Save changes to WORDS.TOK ?",
                                   "Yes",
                                   "No",
                                   "Cancel",
                                   0, 2) ) {
    case 0: // yes
      save_file() ;
        deinit();
        e->accept();

        //      else
        // e->ignore();
      break;
    case 1: // no
      deinit();
      e->accept();
      break;
    default: // cancel
      e->ignore();
      break;
    }    
  }
  else{
    deinit();
    e->accept();
  }

}
Пример #19
0
void Top_Menu::save()
{
    if (window_->mode_flag_ == DRAW_2_CURVES && window_->input_menu_->choose_coloring_box_2_->currentIndex() == T_IMAGE
            && show_save_image_warning_)
    {
        QMessageBox message_box;
        message_box.setWindowTitle("Save...");
        message_box.setIcon(QMessageBox::Information);
        QString message = QString("Saving the image is not supported.");
        message_box.setText(message);
        message_box.setInformativeText("You may need to set an image again when you load the file.");
        message_box.setStandardButtons(QMessageBox::Ok);
        message_box.exec();

        show_save_image_warning_ = false;
    }


    if(last_loaded_file_.isEmpty())
    {
        save_as();
    }
    std::ofstream save_file(last_loaded_file_.toStdString().c_str(), std::ios::out | std::ios::trunc);
    window_->configuration_->update_parameters();
    window_->configuration_->write_in_file(save_file);
    save_file.close();
    return;
}
Пример #20
0
void main() {

	GOODS goods[MAX];
	int choice, sum;
	
	sum = read_file(goods);

	if (sum == 0) {

		printf ("Key in the goods information~********\n");
		getchar();
		sum = input (goods);

	}

	do {

		clrscr();

		printf ("\n\n		**********the managed system of supermarket***********");

		printf ("	1.Append the goods information	\n\n");
		printf ("	2.Modify the goods information	\n\n");
		printf ("	3.Delete the goods information	\n\n");
		printf ("	4.Print the informationof stock goods	\n\n");
		printf ("	5.Inquire the goods information	\n\n");
		printf ("	6.Count the goods information	\n\n");
		printf ("	7.Sort the goods information	\n\n");
		printf ("	0.Exit the system of goods information	\n\n");
		
		printf ("	Please choose that you want(0~7):");
		
		scanf ("%d", &choice);	

		switch (choice)	{

			case 1:append();
			       break;
			case 2:modify(goods, sum);
		       	       break;
			case 3:delete();
			       break;
			case 4:output(goods, sum);
			       break;
			case 5:inquire();
			       break;
			case 6:count();
			       break;
			case 7:sort(goods, sum);
			       break;
			case 0:break;

		}

	   }while (choice != 0);

	save_file(goods, sum);

}
Пример #21
0
static void
do_save (GtkAction *action)
{
  if (filename == NULL)
    do_save_as (action);
  else
    save_file (filename);
}
Пример #22
0
void save_cb() {
  if (filename[0] == '\0') {
    // No filename - get one!
    saveas_cb();
    return;
  }
  else save_file(filename);
}
Пример #23
0
int st_linklist(st_info *buf_head,char *data_name)
{
	st_info *p1 = NULL,*p2 = buf_head,*p3 = buf_head;
	int flag_link = 0,i = 0;

	system("cls");
	p1 = (st_info *)malloc(N);
	while(p2->next)
	{
		p2 = p2->next;
	}
	p2->next = p1;
	printf(menu_print);
	printf("\n Tips:-----输入示例:小豆豆 30130 12 0 123.52 15.9 800.2\n\n");
	fflush(stdin);
	scanf("%14s",p1->name);
	if(strcmp(p1->name,"quit") != 0 || strcmp(p1->name,"QUIT") != 0)
	{
		while(((scanf(ST_SIX_INFO)) != 6) || CHECK_INFO)
		{
			printf("\n Error!-----格式错误!(注意:性别1代表男,0代表女)请重新输入:\n");
			fflush(stdin);
			scanf("%14s",p1->name);
		}
		++i;
		printf("\n OK!-----录入成功!结束录入请输入quit或者QUIT\n");
		while(1)
		{
			p2->next = p1;
			p2 = p1; 
			p1 = (st_info *)malloc(N);
			while(1)
			{
				fflush(stdin);
				scanf("%14s",p1->name);
				if(strcmp(p1->name,"quit") == 0 || strcmp(p1->name,"QUIT") == 0)
				{
					flag_link = 1;
					break;
				}
				if(scanf(ST_SIX_INFO)==6 && (p1->sex == 0 || p1->sex == 1))
				{
					printf("\n OK!-----录入成功!结束录入请输入quit或者QUIT\n");
					++i;
					break;
				}
				printf("\n Error!-----格式错误!(注意:性别1代表男,0代表女)请重新输入:\n");
			}
			if(flag_link == 1)
				break;
		}
	}
	p2->next = NULL;
	free(p1);
	printf("\n Tips:-----录入结束,共录入信息%d条!按任意键继续!",i);
	save_file(buf_head,data_name,N);
	return 0;
}
Пример #24
0
static void file_check(struct file_info *file, int fd)
{
	int open_and_close = 0, link_count = 0;
	char *path = NULL;
	off_t pos;
	struct write_info *w;
	struct dir_entry_info *entry;
	struct stat st;

	/* Do not check files that have errored */
	if (!check_nospc_files && file->no_space_error)
		return;
	/* Do not check the same file twice */
	if (file->check_run_no == check_run_no)
		return;
	file->check_run_no = check_run_no;
	if (fd == -1)
		open_and_close = 1;
	if (open_and_close) {
		/* Open file */
		path = dir_path(file->links->parent, file->links->name);
		fd = open(path, O_RDONLY);
		CHECK(fd != -1);
	}
	/* Check length */
	pos = lseek(fd, 0, SEEK_END);
	if (pos != file->length) {
		fprintf(stderr, "file_check failed checking length "
			"expected %u actual %u\n",
			(unsigned) file->length,
			(unsigned) pos);
		file_info_display(file);
		save_file(fd, file);
	}
	CHECK(pos == file->length);
	/* Check each write */
	pos = 0;
	for (w = file->writes; w; w = w->next) {
		if (w->offset > pos)
			file_check_hole(file, fd, pos, w->offset - pos);
		file_check_data(file, fd, w);
		pos = w->offset + w->size;
	}
	if (file->length > pos)
		file_check_hole(file, fd, pos, file->length - pos);
	CHECK(fstat(fd, &st) != -1);
	CHECK(file->link_count == st.st_nlink);
	if (open_and_close) {
		CHECK(close(fd) != -1);
		free(path);
	}
	entry = file->links;
	while (entry) {
		link_count += 1;
		entry = entry->next_link;
	}
	CHECK(link_count == file->link_count);
}
IonDetector::result_type IonDetector::blob_detector( const image_type& img ) {
	Kernel logs[3];
	float sigmas[3];

	logs[0] = Kernel::LoG( 4, 0.6 );
	sigmas[0] = 0.85;

	logs[1] = Kernel::LoG( 6, 1.0 );
	sigmas[1] = 1.0;

	logs[2] = Kernel::LoG( 20, 5.0 );
	sigmas[2] = 2.;

	image_type img_result( img.extents );
	result_type results;

	const size_t hsize = 2000;
	std::vector< size_t > histogram( hsize, 0 );

	size_t g = 2;
	logs[g].apply_kernel( img, img_result );
	save_file( "log.fits", img_result );

	float img_max = *std::max_element( img_result.ptr(), 
		img_result.ptr() + img.num_elements() );
	for( 	float* iter = img_result.ptr(); 
			iter != img_result.ptr() + img.num_elements(); 
			++iter ) {

		int p = (size_t)( ( *iter + img_max ) / 2 / img_max * hsize ); 
		if( p >= (int)hsize ) 	p = hsize-1;
		if( p < 0 )				p = 0;
		histogram[ p ] ++;
	}

	size_t nelems = 0, counter = hsize-1;
	while( nelems < (size_t)blob_threshold )
		nelems += histogram[ counter-- ];

	float thresh = (float)counter / hsize * img_max - img_max / 2.;
	for( image_type::index i = 12; i < img.extents.first-12; ++i ) 
	for( image_type::index j = 12; j < img.extents.second-12; ++j ) {
		if( img_result( i, j ) > thresh &&
			img_result( i, j ) > img_result( i+1, j ) &&
			img_result( i, j ) > img_result( i-1, j ) &&
			img_result( i, j ) > img_result( i, j+1 ) &&
			img_result( i, j ) > img_result( i, j-1 ) &&
			img_result( i, j ) > img_result( i+1, j+1 ) &&
			img_result( i, j ) > img_result( i+1, j-1 ) &&
			img_result( i, j ) > img_result( i-1, j+1 ) &&
			img_result( i, j ) > img_result( i-1, j-1 ) ) {

			results.push_back( IonData( i, j, sigmas[g] ) );
		}
	}

	return results;
}
Пример #26
0
void
xexit(int exit_value)
    /* exit after having freed memory and removed lock file */
{
    cf_t *f = NULL;

    now = time(NULL);

    /* we save all files now and after having waiting for all
     * job being executed because we might get a SIGKILL
     * if we don't exit quickly */
    save_file(NULL);

#ifdef FCRONDYN
    close_socket();
#endif

    f = file_base;
    while (f != NULL) {
        if (f->cf_running > 0) {
            /* */
            debug("waiting jobs for %s ...", f->cf_user);
            /* */
            wait_all(&f->cf_running);
            save_file(f);
        }
        delete_file(f->cf_user);

        /* delete_file remove the f file from the list :
         * next file to remove is now pointed by file_base. */
        f = file_base;
    }

    remove(pidfile);

    exe_list_destroy(exe_list);
    lavg_list_destroy(lavg_list);
    free_conf();

    Free_safe(orig_tz_envvar);

    explain("Exiting with code %d", exit_value);
    exit(exit_value);

}
Пример #27
0
static void write_file(char *filename, unsigned char *ptr, unsigned long sz) {
	FILE *fh = fopen(filename, "wb");
	if(fh == NULL) {
		ds_printf("DS_ERROR: Can't open \"%s\".\n", filename); 
		return; 
	}
	save_file(fh, ptr, sz);
	fclose(fh);
}
Пример #28
0
void
saveCB( Widget w, XtPointer client_data, 
 		XtPointer call_data)
{
	if (NULL == get_save_path())
		manage_widget(w, "saveCB", "saveAsFileSelectionBox");
	else 
		save_file(w, "saveCB");
}
Пример #29
0
void kronecker(FILE *arquivo_input, FILE *arquivo_output)
{

    int pares_de_matrizes;

    fscanf(arquivo_input, "%d", &pares_de_matrizes);
    fprintf(arquivo_output, "%d\n", pares_de_matrizes);

    int lin_mat1, col_mat1, lin_mat2, col_mat2;
    int **matriz_um, **matriz_dois, **matriz_result;

    int par_itr;

    for (par_itr = 0; par_itr<pares_de_matrizes; par_itr++ )
    {
        //cria matriz_um
        fscanf(arquivo_input, "%d", &lin_mat1);
        fscanf(arquivo_input, "%d", &col_mat1);

        //preenche matriz 1
        matriz_um = preenche(arquivo_input, lin_mat1, col_mat1);

        //cria matriz_dois
        fscanf(arquivo_input, "%d", &lin_mat2);
        fscanf(arquivo_input, "%d", &col_mat2);
        //aloca matriz 2
        matriz_dois = preenche(arquivo_input, lin_mat2, col_mat2);

        //calculo matematico kronecker
        fprintf(arquivo_output, "%d", lin_mat1*lin_mat2);
        fprintf(arquivo_output, " %d\n", col_mat1*col_mat2);
        matriz_result = calcula_kronecker(matriz_um, lin_mat1, col_mat1, matriz_dois, lin_mat2, col_mat2);


        save_file(arquivo_output, lin_mat1*lin_mat2, col_mat1*col_mat2, matriz_result);



        int i;
        for (i=0; i<lin_mat1; i++) {
            free(matriz_um[i]);
        }
        free(matriz_um);

        for (i=0; i<lin_mat2; i++) {
            free(matriz_dois[i]);
        }
        free(matriz_dois);

        for (i=0; i<lin_mat1*lin_mat2; i++) {
            free(matriz_result[i]);
        }
        free(matriz_result);
    }


}
Пример #30
0
int stage_1_prep (libusb_device_handle *handle, uchar *buf)
{
    int  x;

    ShowURB (5);
    version = aw_fel_get_version (handle);

    if (IsA10 (version))                            // 0x1623 = A10
      {
        printf ("Detected A10 (ID 0x%04X)\n", version);
        FN = &FN_sun4i;
      }
    else if (IsA20 (version))                       // 0x1651 = A20
      {
        printf ("Detected A20 (ID 0x%04X)\n", version);
        FN = &FN_sun7i;
      }
    else if (IsH3 (version))                        // 0x1680 = H3
        printf ("Detected H3 (ID 0x%04X)\n", version);
    else
      {
        printf ("Unknown processor ID 0x%04X\n", version);
        PerhapsQuit ();
      }

    ShowURB (14);
    version = aw_fel_get_version (handle);

            // URB 23 - 27

    ShowURB (23);
    aw_fel_read (handle, 0x7e00, buf, 256);         // get 256 0xCC

    for (x = 0; x < 256; x++)
      {
        if (buf [x] != 0xCC)
          {
            printf ("Non 0xCC at entry %d\n", x);
            hexdump (buf, 0, 256);
            save_file ((char *) "Dump1_000023", buf, 256);
            PerhapsQuit ();
            break;
          }
      }

    ShowURB (32);
    version = aw_fel_get_version (handle);

    ShowURB (41);
    PutNulls (buf, 4);
    aw_fel_write (handle, 0x7e00, buf, 256);

    ShowURB (50);
    version = aw_fel_get_version (handle);

    return 0;
}