コード例 #1
0
void
preferences_dialog_init (void)
{
    // General preferences
    init_toggle ("echo_checkbutton", PREF_ECHO);
    init_toggle ("sneak_checkbutton", PREF_AUTO_SNEAK);
    init_toggle ("log_checkbutton", PREF_AUTO_LOG);
    init_spin ("text_buffer_size_spinbutton", PREF_TEXT_BUFFER_SIZE);
    init_spin ("command_size_spinbutton", PREF_COMMAND_SIZE);
    init_spin ("history_size_spinbutton", PREF_COMMAND_HISTORY_SIZE);
    init_entry ("script_prefix_entry", PREF_SCRIPT_PREFIX);

    // Colors
    init_color ("monster_text_box", PREF_MONSTER_TEXT_COLOR);
    init_color ("monster_base_box", PREF_MONSTER_BASE_COLOR);
    init_font ("monster_font_box", PREF_MONSTER_FONT);
    init_color ("title_text_box", PREF_TITLE_TEXT_COLOR);
    init_color ("title_base_box", PREF_TITLE_BASE_COLOR);
    init_font ("title_font_box", PREF_TITLE_FONT);
    init_color ("echo_text_box", PREF_ECHO_TEXT_COLOR);
    init_color ("echo_base_box", PREF_ECHO_BASE_COLOR);
    init_font ("echo_font_box", PREF_ECHO_FONT);
    init_color ("default_text_box", PREF_DEFAULT_TEXT_COLOR);
    init_color ("default_base_box", PREF_DEFAULT_BASE_COLOR);
    init_font ("default_font_box", PREF_DEFAULT_FONT);

    // Paths
    init_file ("script_path_filechooserbutton", PREF_SCRIPT_PATH);
    init_file ("log_path_filechooserbutton", PREF_LOG_PATH);
}
コード例 #2
0
/*
 * Create a new file info object.
 * This function is called by the profile parser.
 */
static struct file_info *
new_file(struct state *cur, const char *name, unsigned int type)
{
	sc_profile_t	*profile = cur->profile;
	file_info	*info;
	sc_file_t	*file;
	unsigned int	df_type = 0, dont_free = 0;

	if ((info = sc_profile_find_file(profile, NULL, name)) != NULL)
		return info;

	/* Special cases for those EFs handled separately
	 * by the PKCS15 logic */
	if (strncasecmp(name, "PKCS15-", 7)) {
		file = init_file(type);
	} else if (!strcasecmp(name+7, "TokenInfo")) {
		file = profile->p15_spec->file_tokeninfo;
		dont_free = 1;
	} else if (!strcasecmp(name+7, "ODF")) {
		file = profile->p15_spec->file_odf;
		dont_free = 1;
	} else if (!strcasecmp(name+7, "UnusedSpace")) {
		file = profile->p15_spec->file_unusedspace;
		dont_free = 1;
	} else if (!strcasecmp(name+7, "AppDF")) {
		file = init_file(SC_FILE_TYPE_DF);
	} else {
		if (map_str2int(cur, name+7, &df_type, pkcs15DfNames))
			return NULL;

		file = init_file(SC_FILE_TYPE_WORKING_EF);
		profile->df[df_type] = file;
	}
	assert(file);
	if (file->type != (int)type) {
		parse_error(cur, "inconsistent file type (should be %s)",
			(file->type == SC_FILE_TYPE_DF)? "DF" : "EF");
		if (strncasecmp(name, "PKCS15-", 7) ||
			!strcasecmp(name+7, "AppDF")) 
			sc_file_free(file);
		return NULL;
	}

	info = add_file(profile, name, file, cur->file);
	if (info == NULL) {
		parse_error(cur, "memory allocation failed");
		return NULL;
	}
	info->dont_free = dont_free;
	return info;
}
コード例 #3
0
ファイル: pwdgrp.c プロジェクト: AlexShiLucky/rtems
/**
 *  Initialize useable but dummy databases
 */
static void pwdgrp_init(void)
{
  mkdir("/etc", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);

  /*
   *  Initialize /etc/passwd
   */
  init_file("/etc/passwd", "root::0:0::::\n");

  /*
   *  Initialize /etc/group
   */
  init_file("/etc/group", "root::0:\n");
}
コード例 #4
0
ファイル: ls.c プロジェクト: cmgnn/42
t_file	*ft_open(char *name, int deep)
{
	t_dir	*entry;
	t_file	*file;
	t_file	*ret;
	DIR		*d;
	char	*tmp = NULL;

	d = opendir(name);
	ret = NULL;
	if (d)
	{
		while ((entry = readdir(d)))
		{
			if (ft_strcmp(entry->d_name, "..") && ft_strcmp(entry->d_name, "."))
			{
				file = init_file(entry->d_name);
				printf("%s\n", entry->d_name);
				if (entry->d_type & DT_DIR && deep != 0)
				{
					tmp = set_name_path(name, entry->d_name);
					file->dir = ft_open(tmp, deep - 1);
					ft_memdel((void**)&tmp);
				}
				addfile(&ret, file);
			}
		}
		closedir(d);
	}
	else
		printf("cannot acces to %s\n", name);
	return (ret);
}
コード例 #5
0
ファイル: video_capture.c プロジェクト: RuanJG/cameratoh264
void v4l2_init(struct camera *cam) {
	open_camera(cam);
	init_camera(cam);
	start_capturing(cam);
	init_encoder(cam);
	init_file();
}
コード例 #6
0
ファイル: port6_trans.c プロジェクト: barlesh/ISG
void main(){
	int fd; 
	char buffer2[66];	
	char buffer3[]="massage number X\n";
	char buffer[]={1,0,0,0,0,6,7,8,9,0,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,10,10};

	unsigned short i=48,j=0, m_len=0, flag=0, len=0, len2=0;
	int payload = 64, header_size =2; 
	printf("starting.....(termios)\n");
	init_file(src);
	fd = init_modem();

	len = sizeof(buffer);
	
	while(1){
		sleep(5);
		buffer[len - 3] = i;
		printf("sending massage of length %d, msg is:", len);
		showMsg(buffer, len);
		printf("\n");
		
		sendToModem(fd, buffer, len);
		i++;
		if(i==58) i=48;
	}//while(1)

}//main
コード例 #7
0
void
Restore::execRESTORE_LCP_REQ(Signal* signal){
  jamEntry();

  Uint32 err= 0;
  RestoreLcpReq* req= (RestoreLcpReq*)signal->getDataPtr();
  Uint32 senderRef= req->senderRef;
  Uint32 senderData= req->senderData;
  do
  {
    FilePtr file_ptr;
    if (!m_file_list.seizeFirst(file_ptr))
    {
      err= RestoreLcpRef::NoFileRecord;
      break;
    }

    if((err= init_file(req, file_ptr)))
    {
      break;
    }

    open_file(signal, file_ptr);
    return;
  } while(0);

  RestoreLcpRef* ref= (RestoreLcpRef*)signal->getDataPtrSend();
  ref->senderData= senderData;
  ref->senderRef= reference();
  ref->errorCode = err;
  sendSignal(senderRef, GSN_RESTORE_LCP_REF, signal, 
	     RestoreLcpRef::SignalLength, JBB);
}
コード例 #8
0
ファイル: luci-bwc.c プロジェクト: 8devices/luci
static int update_ifstat(
	const char *ifname, uint32_t rxb, uint32_t rxp, uint32_t txb, uint32_t txp
) {
	char path[1024];

	struct stat s;
	struct traffic_entry e;

	snprintf(path, sizeof(path), DB_IF_FILE, ifname);

	if (stat(path, &s))
	{
		if (init_file(path, sizeof(struct traffic_entry)))
		{
			fprintf(stderr, "Failed to init %s: %s\n",
					path, strerror(errno));

			return -1;
		}
	}

	e.time = htonl(time(NULL));
	e.rxb  = htonl(rxb);
	e.rxp  = htonl(rxp);
	e.txb  = htonl(txb);
	e.txp  = htonl(txp);

	return update_file(path, &e, sizeof(struct traffic_entry));
}
コード例 #9
0
/**
 *  Constructor Function: allocate memories for the pools 
 *                        and init the variable values
 *
*/
BufferManager::BufferManager():total_block(0),total_file(0),fileHead(NULL)
{
    for (int i = 0; i < MAX_FILE_NUM; i ++)
    {
        file_pool[i].fileName = new char[MAX_FILE_NAME];
        if(file_pool[i].fileName == NULL)
        {
            printf("Can not allocate memory in initing the file pool!\n");
            exit (1);
        }
        init_file(file_pool[i]);
    }
    for (int i = 0; i < MAX_BLOCK_NUM; i ++) {
        block_pool[i].address = new char[BLOCK_SIZE];
        if(block_pool[i].address == NULL)
        {
            printf("Can not allocate memory in initing the block pool!\n");
            exit (1);
        }
        block_pool[i].fileName = new char[MAX_FILE_NAME];
        if(block_pool[i].fileName == NULL)
        {
            printf("Can not allocate memory in initing the block pool!\n");
            exit (1);
        }
        init_block(block_pool[i]);
    }
}
コード例 #10
0
ファイル: ldb_cache_stat.cpp プロジェクト: xiangyong/platform
      bool CacheStat::start(const char* dir, int64_t max_file_size)
      {
        bool ret = true;
        if (file_ != NULL)
        {
          log_info("cache stat already start");
        }
        else if (dir != NULL)
        {
          char file_name[PATH_MAX];
          snprintf(file_name, sizeof(file_name), "%s/ldb_cache_stat", dir);
          if (init_file(file_name) != TAIR_RETURN_SUCCESS)
          {
            log_error("start cache stat file %s fail. error: %s", file_name, strerror(errno));
            delete file_;
            file_ = NULL;
            ret = false;
          }
          else
          {
            int64_t file_size = file_->get_file_size();
            file_offset_ = file_size <= RESERVE_SIZE ? RESERVE_SIZE : file_size;
            buf_pos_ = buf_ + CACHE_STAT_SIZE; // for sentinel
            remain_buf_stat_count_ = BUFFER_STAT_COUNT - 1;

            if (max_file_size > max_file_size_)
            {
              max_file_size_ = max_file_size;
            }
            log_info("start cache stat success, file_offset: %"PRI64_PREFIX"d, max_file_size: %"PRI64_PREFIX"d", file_offset_, max_file_size_);
          }
        }
        return ret;
      }
コード例 #11
0
ファイル: luci-bwc.c プロジェクト: 8devices/luci
static int update_radiostat(
	const char *ifname, uint16_t rate, uint8_t rssi, uint8_t noise
) {
	char path[1024];

	struct stat s;
	struct radio_entry e;

	snprintf(path, sizeof(path), DB_RD_FILE, ifname);

	if (stat(path, &s))
	{
		if (init_file(path, sizeof(struct radio_entry)))
		{
			fprintf(stderr, "Failed to init %s: %s\n",
					path, strerror(errno));

			return -1;
		}
	}

	e.time  = htonl(time(NULL));
	e.rate  = htons(rate);
	e.rssi  = rssi;
	e.noise = noise;

	return update_file(path, &e, sizeof(struct radio_entry));
}
コード例 #12
0
ファイル: duffdriver.c プロジェクト: carriercomm/duff
/* Processes a single file.
 */
static void process_file(const char* path, struct stat* sb)
{
    if (sb->st_size == 0)
    {
        if (ignore_empty_flag)
        return;
    }

    /* NOTE: Check for duplicate arguments? */

    if (physical_flag)
    {
        /* TODO: Make this less pessimal */

        size_t i, bucket = BUCKET_INDEX(sb->st_size);

        for (i = 0;  i < buckets[bucket].allocated;  i++)
        {
            if (buckets[bucket].files[i].device == sb->st_dev &&
                buckets[bucket].files[i].inode == sb->st_ino)
            {
                return;
            }
        }
    }

    init_file(alloc_file(&buckets[BUCKET_INDEX(sb->st_size)]), path, sb);
}
コード例 #13
0
ファイル: luci-bwc.c プロジェクト: 8devices/luci
static int update_cnstat(uint32_t udp, uint32_t tcp, uint32_t other)
{
	char path[1024];

	struct stat s;
	struct conn_entry e;

	snprintf(path, sizeof(path), DB_CN_FILE);

	if (stat(path, &s))
	{
		if (init_file(path, sizeof(struct conn_entry)))
		{
			fprintf(stderr, "Failed to init %s: %s\n",
					path, strerror(errno));

			return -1;
		}
	}

	e.time  = htonl(time(NULL));
	e.udp   = htonl(udp);
	e.tcp   = htonl(tcp);
	e.other = htonl(other);

	return update_file(path, &e, sizeof(struct conn_entry));
}
コード例 #14
0
ファイル: posix_api.c プロジェクト: b409/b409
int _CreateFile(char* path,u32 perm,int mode)
{   
	/* 1) create cache file
	 * 2) create data_center file
	 * 3) init_file
	 * 4) open cache file with 'mode' 
	 * */
	int fd;
	char dst_path[MAX_PATH];
	get_cache_path(path,dst_path);
	if((fd = creat(dst_path,perm)) == -1){
		perror("create cache file");
		return fd;
	}
	close(fd);
	get_data_path(path,dst_path);
	if((fd = creat(dst_path,perm)) == -1){
		perror("create data center file");
		return fd;
	}
	close(fd);
	/* init file */
	if(init_file(path) != 0){
		fprintf(stderr,"init_file fail!\n");
		return -1;
	}
	fd = open(dst_path,mode);
	return fd;
}
コード例 #15
0
ファイル: luci-bwc.c プロジェクト: 8devices/luci
static int update_ldstat(uint16_t load1, uint16_t load5, uint16_t load15)
{
	char path[1024];

	struct stat s;
	struct load_entry e;

	snprintf(path, sizeof(path), DB_LD_FILE);

	if (stat(path, &s))
	{
		if (init_file(path, sizeof(struct load_entry)))
		{
			fprintf(stderr, "Failed to init %s: %s\n",
					path, strerror(errno));

			return -1;
		}
	}

	e.time   = htonl(time(NULL));
	e.load1  = htons(load1);
	e.load5  = htons(load5);
	e.load15 = htons(load15);

	return update_file(path, &e, sizeof(struct load_entry));
}
コード例 #16
0
ファイル: vfs.c プロジェクト: kvnallsn/fat32
int filecreate(const char *name) {
    int pos = get_next_table_pos(filetable, FILE_LIMIT);
    init_file(&filetable[pos], name);
    
    mount_t *mp = mount_table[filetable[pos].device];
    fs_table[mp->fs_type].createfile(pos, &filetable[pos]);
    return 0;
}
コード例 #17
0
ファイル: x264_encoder.c プロジェクト: c1111f1/msc-p1
void X264_init()
{
	g_ImgWidth = opt.width;
	g_ImgHeight = opt.height;
	YUVframe = (uint8_t *) malloc(sizeof(uint8_t) * g_ImgWidth * g_ImgHeight * 2);
	encode_init(&g_X264Encoder, g_ImgWidth, g_ImgHeight);
	init_file();
}
コード例 #18
0
static gboolean
plugin_load(GaimPlugin *plugin)
{
	init_file();
	check = g_timeout_add(5000, (GSourceFunc) check_file, NULL);

	return TRUE;
}
コード例 #19
0
SgObject Sg_MakeFileFromFD(uintptr_t handle)
{
  SgFile *f = SG_NEW(SgFile);
  init_file(f, (int)handle);
  f->name = UC("fd");
  SG_FILE_VTABLE(f) = &vtable;
  return SG_OBJ(f);
}
コード例 #20
0
int file::size_alignment() const
{
#if defined TORRENT_WINDOWS
    init_file();
    return m_page_size;
#else
    return pos_alignment();
#endif
}
コード例 #21
0
ファイル: ldb_cache_stat.cpp プロジェクト: xiangyong/platform
      int CacheStat::load_file(const char* file_name)
      {
        int ret = init_file(file_name);
        if (ret != TAIR_RETURN_SUCCESS)
        {
          log_error("init file fail. %s", file_name);
        }

        is_load_ = true;
        return ret;
      }
コード例 #22
0
ファイル: vfs.c プロジェクト: kvnallsn/fat32
int fileopen(const char *fname, int mode) {
    int pos = get_next_table_pos(filetable, FILE_LIMIT);
    init_file(&filetable[pos], fname);
        
    mount_t *mp = mount_table[filetable[pos].device];
    int npos = fs_table[mp->fs_type].openfile(pos, &filetable[pos], 0);
    
    if (npos == -1) close_file(pos);    
    if (mode == APPEND) filetable[pos].offset += filetable[pos].size;
    
    return npos;
}
コード例 #23
0
void capture_start(GtkWidget *widget,gpointer data)
{
	GtkWidget *isenable;
	uint8_t i = 0;
	guint text_len = 0;

	pthread_mutex_lock(&capture_state_mtx);
	if (capture_state == 0)
		capture_state = 1;
	pthread_mutex_unlock(&capture_state_mtx);

	init_file();
	capture_packet();

	pthread_mutex_lock(&packet_stat_mtx);
	tot_packet = 0;
	ip_packet = 0;
	tcp_packet = 0;
	udp_packet = 0;
	arp_packet = 0;
	icmp_packet = 0;
	igmp_packet = 0;
	capture_pre_packet = 0;
	pthread_mutex_unlock(&packet_stat_mtx);

	isenable = capture_menu[0].widget;
	gtk_widget_set_sensitive(isenable,FALSE);
	isenable = capture_menu[1].widget;
	gtk_widget_set_sensitive(isenable,TRUE);
	gtk_clist_clear((GtkCList *)clist);

	for (i = 0;i < 5;i++)
	{
		if (item[i]) {
			gtk_tree_item_remove_subtree((GtkTreeItem *)item[i]);
			gtk_container_remove (GTK_CONTAINER(tree), item[i]);
			item[i] = NULL;
		}
	}

	gtk_text_freeze(GTK_TEXT(hex_text));
	text_len = gtk_text_get_length(GTK_TEXT(hex_text));
	gtk_text_backward_delete(GTK_TEXT(hex_text),text_len);
	gtk_text_thaw(GTK_TEXT(hex_text));

	gtk_text_freeze(GTK_TEXT(hex_text));
	text_len = gtk_text_get_length(GTK_TEXT(hex_text));
	gtk_text_backward_delete(GTK_TEXT(hex_text),text_len);
	gtk_text_thaw(GTK_TEXT(hex_text));
}
コード例 #24
0
/*
 * Initialize profile
 */
struct sc_profile *
sc_profile_new(void)
{
	struct sc_pkcs15_card *p15card;
	struct sc_profile *pro;

	pro = (struct sc_profile *) calloc(1, sizeof(*pro));
	if (pro == NULL)
		return NULL;
	pro->p15_spec = p15card = sc_pkcs15_card_new();

	pro->protect_certificates = 1;
	pro->pkcs15.do_last_update = 1;

	if (p15card) {
		p15card->label = strdup("OpenSC Card");
		p15card->manufacturer_id = strdup("OpenSC Project");
		p15card->serial_number = strdup("0000");
		p15card->flags = SC_PKCS15_CARD_FLAG_EID_COMPLIANT;
		p15card->version = 1;

		/* Set up EF(TokenInfo) and EF(ODF) */
		p15card->file_tokeninfo = init_file(SC_FILE_TYPE_WORKING_EF);
		p15card->file_odf = init_file(SC_FILE_TYPE_WORKING_EF);
		p15card->file_unusedspace = init_file(SC_FILE_TYPE_WORKING_EF);
	}

	/* Assume card does RSA natively, but no DSA */
	pro->rsa_access_flags = DEF_PRKEY_RSA_ACCESS;
	pro->dsa_access_flags = DEF_PRKEY_DSA_ACCESS;
	pro->pin_encoding = 0x01;
	pro->pin_minlen = 4;
	pro->pin_maxlen = 8;
	pro->keep_public_key = 1;

	return pro;
}
コード例 #25
0
ファイル: filereader.c プロジェクト: je-so/js-projekt
/* function: initfile_filereader
 * Opens file for reading.
 *
 * The caller must free all out variables even in case of error ! */
static int initfile_filereader(/*out*/file_t * fd, /*out*/off_t * filesize, const char * filepath, const struct directory_t * relative_to/*0 => current working dir*/)
{
   int err;

   err = init_file(fd, filepath, accessmode_READ, relative_to);
   if (err) return err;

   err = size_file(*fd, filesize);
   if (err) return err;

   err = advisereadahead_file(*fd, 0, *filesize);
   if (err) return err;

   return 0;
}
コード例 #26
0
ファイル: testing.cpp プロジェクト: FacundoGFlores/NSL
void test_Jacobi()
{
	long tiempo_cuda;
	long tiempo_c;

	init_file(RUTA_JACOBI);

	const float error = 0.001f;
	const int iter = 500;

	int N = 1000;
	run_jacobi(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_JACOBI);

	N = 2500;
	run_jacobi(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_JACOBI);

	N = 4000;
	run_jacobi(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_JACOBI);

	N = 5500;
	run_jacobi(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_JACOBI);

	N = 7000;
	run_jacobi(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_JACOBI);

	N = 8500;
	run_jacobi(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_JACOBI);

	N = 10000;
	run_jacobi(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_JACOBI);

	printf("Jacobi Test Finished!\n");

}
コード例 #27
0
ファイル: testing.cpp プロジェクト: FacundoGFlores/NSL
void test_bicg()
{
	long tiempo_cuda;
	long tiempo_c;

	init_file(RUTA_BICG);

	const float error = 0.001f;
	const int iter = 500;

	int N = 1000;
	run_bicg(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_BICG);

	N = 2500;
	run_bicg(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_BICG);

	N = 4000;
	run_bicg(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_BICG);

	N = 5500;
	run_bicg(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_BICG);

	N = 7000;
	run_bicg(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_BICG);

	N = 8500;
	run_bicg(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_BICG);

	N = 10000;
	run_bicg(N, 0.001f, 500, tiempo_c, tiempo_cuda);
	show_times(N, tiempo_c, tiempo_cuda);
	save_times(N, tiempo_c, tiempo_cuda, RUTA_BICG);

	printf("BICG Test Finished!\n");

}
コード例 #28
0
ファイル: reader.c プロジェクト: hanmouse/test
void *read_msgs( void *param)
{
	int thread_id = (int) param;
	int e;
	unsigned int count = 0U;
	unsigned int int_data;
	unsigned char data[MAX_QUEUE_DATA_SIZE];
	size_t data_size;
	queue_t *queue = &readers[thread_id].queue;
	file_info_t *file = &readers[thread_id].file;

	printf( "thread %d created\n", thread_id);

	e = init_queue( queue, MAX_QUEUE_SIZE);
	if (e < 0) {
		fprintf( stderr, "init_queue() failed\n");
		return NULL;
	}

	e = init_file( file, thread_id);
	if (e < 0) {
		fprintf( stderr, "init_file() failed\n");
		return NULL;
	}

	while (should_thread_keep_alive() && (count < MAX_QUEUE_SIZE)) {
		e = get_queue_data( queue, data, &data_size);
		if (e < 0) {
			fprintf( stderr, "get_queue_data() failed\n");
			continue;
		} else {
			if (data_size == 0) {
				continue;
			}
		}

		memcpy( &int_data, data, data_size);
		printf( "[thread %d] data=%u, data_size=%zu\n", thread_id, int_data, data_size);

		fprintf( file->fp, "data=%d\n", int_data);
		count++;
		printf( "[thread %d] count=%u\n", thread_id, count);
	}

	finish_file( file->fp);

	return NULL;
}
コード例 #29
0
ファイル: DiskManager.cpp プロジェクト: deadok22/shredder-db
bool DiskManager::update_context(string const & fname)
{
  if( fname != fname_){
#ifdef IO_DISK_M
    Utils::log("[DiskManager] update context(file):"+fname_+"->"+fname);
#endif
    if(file_ != NULL && fclose(file_) != 0){
      Utils::log("[DiskManager] Unable to close file: "+fname_,ERROR);
      Utils::critical_error();
    }
    file_ = NULL;
    fname_ = fname;
    return init_file();
  }
  return true;
}
コード例 #30
0
inline void init(const std::string &given_pathname,
                 const std::string &given_filename) 
{
    #pragma omp parallel sections num_threads(2)
    {
        #pragma omp section
        {
            input = init_file(given_filename, given_pathname);
        }
        #pragma omp section
        {
            disk_info = init_path(given_pathname);
        }
    }
    update();
};