コード例 #1
0
ファイル: test-cast-table.c プロジェクト: AkioKanno/groonga
void
cut_setup(void)
{
  logger = setup_grn_logger();
  grn_ctx_init(&context, 0);
  GRN_VOID_INIT(&src);
  GRN_VOID_INIT(&dest);

  setup_database();
  setup_tables();
}
コード例 #2
0
ファイル: mkfs.c プロジェクト: FrancoisGautrais/elks
int main(int argc, char ** argv)
{
	int i;
	char * tmp;
	struct stat statbuf;
	char * listfile = NULL;

	if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE)
		die("bad inode size");

	if ((argc == 3) && (argv[1][0] != '-') && (argv[2][0] != '-')) {
		BLOCKS = strtol(argv[2],&tmp,0);
		if (*tmp) {
			usage();
		}
		device_name = argv[1];
	} else
		usage();
	if (!device_name || BLOCKS<10L || BLOCKS > 65535L) {
		usage();
	}
	tmp = root_block;
	tmp[0] = 1;
	tmp[1] = 0;
	strcpy(tmp+2,".");
	tmp += dirsize;
	tmp[0] = 1;
	tmp[1] = 0;
	strcpy(tmp+2,"..");
	tmp += dirsize;
	tmp[0] = 2;
	tmp[1] = 0;
	strcpy(tmp+2,".badblocks");
	DEV = open(device_name,O_RDWR );
	if (DEV<0)
		die("unable to open %s");
	if (fstat(DEV,&statbuf)<0)
		die("unable to stat %s");
	else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
		die("Will not try to make filesystem on '%s'");

	setup_tables();
	make_root_inode();
	write_tables();
	return 0;
}
コード例 #3
0
ファイル: cpu-rs-log-exp-2.c プロジェクト: yszheda/GPU-RSCode
int main(int argc, char *argv[])
{
    int nativeBlockNum = 4;
    int parityBlockNum = 2;
    char *inFile = NULL;
    char *confFile = NULL;
    char *outFile = NULL;

    enum func
    {
        encode,
        decode
    };
    enum func op;

    nativeBlockNum = atoi(argv[1]);
    parityBlockNum = atoi(argv[2]);

    if( strcmp(argv[3], "-e") == 0 )
    {
        op = encode;
    }
    else if( strcmp(argv[3], "-d") == 0 )
    {
        op = decode;
    }
    else
    {
        printf("Invalid option!\n");
        exit(-1);
    }

    // setup table for GF(2^8)
    setup_tables(8);

    switch(op)
    {
        case encode:
            inFile = argv[4];
            encode_file(inFile, nativeBlockNum, parityBlockNum);
            break;

        case decode:
            if(argc == 5)
            {
                confFile = argv[4];
            }
            else if(argc == 7 && strcmp(argv[5], "-o") == 0)
            {
                confFile = argv[4];
                outFile = argv[6];
            }
            else
            {
                printf("Invalid command!\n");
                exit(-1);
            }
            decode_file(confFile, outFile, nativeBlockNum, parityBlockNum);
            break;
    }

    return 0;

}
コード例 #4
0
ファイル: RS.c プロジェクト: samirsd/misc-past-projects
int main () {
	setup_tables(67);
	printf ("Hello World!\n");
}
コード例 #5
0
ファイル: test-seq.c プロジェクト: csuhawk/GPU-RSCode
int main(int argc, char *argv[])
{
	int nativeBlockNum = 4;
	int parityBlockNum = 2;
//	int chunkSize = sizeof(uint8_t);
	int chunkSize = 1;

//	char[] file_name_src = argv[1];
	FILE *fp_in;
	FILE *fp_out;
	int i;
	if( ( fp_in = fopen(argv[1],"rb") ) == NULL )
	{
		printf("Can not open source file!\n");
		exit(0);
	}

	fseek(fp_in, 0L, SEEK_END);
	chunkSize = ftell(fp_in)/nativeBlockNum; //ftell() get the total size of the file

	uint8_t *dataBuf;
	uint8_t *codeBuf;
	dataBuf = (unsigned char*) malloc( nativeBlockNum*chunkSize*sizeof(uint8_t) );
	codeBuf = (unsigned char*) malloc( parityBlockNum*chunkSize*sizeof(uint8_t) );

	for(i=0; i<nativeBlockNum; i++)
	{
		if( fseek(fp_in, i*chunkSize, SEEK_SET) == -1 )
		{
			printf("fseek error!\n");
			exit(0);
		}

		if( fread(dataBuf+i*chunkSize, sizeof(uint8_t), chunkSize, fp_in ) != sizeof(uint8_t)*chunkSize )
		{
			printf("fread error!\n");
			exit(0);
		}
	}
	fclose(fp_in);

	// setup table for GF(2^8)
	setup_tables(8);
	gen_encoding_matrix(parityBlockNum, nativeBlockNum);
	encode_chunk(dataBuf, encodingMatrix, codeBuf, nativeBlockNum, parityBlockNum, chunkSize);

#ifdef DEBUG
	show_code_chunk(codeBuf, parityBlockNum, chunkSize);
#endif

	char output_file_name[10];
	for(i=0; i<parityBlockNum; i++)
	{
		sprintf(output_file_name, "code_%d", i);
		if( ( fp_out = fopen(output_file_name, "wb") ) == NULL )
		{
			printf("Can not open source file!\n");
			exit(0);
		}
		if( fwrite(codeBuf+i*chunkSize, sizeof(uint8_t), chunkSize, fp_out ) != sizeof(uint8_t)*chunkSize )
		{
			printf("fwrite error!\n");
			exit(0);
		}
		fclose(fp_out);
	}



//	uint8_t testData[4] = {9,1,2,0};
//	uint8_t *testCode;
//
//	// setup table for GF(2^8)
//	setup_tables(8);
//	gen_encoding_matrix(parityBlockNum, nativeBlockNum);
//	testCode = (unsigned char*)malloc(parityBlockNum*chunkSize);
//	encode_chunk(testData, encodingMatrix, testCode, nativeBlockNum, parityBlockNum, chunkSize);
//
//#ifdef DEBUG
//showgflog();
//printf("\n");
//showgfilog();
//printf("\n");
//#endif
//	show_code_chunk(testCode, parityBlockNum, chunkSize);
//#ifdef DEBUG
//printf("\n");
//show_encoding_matrix(parityBlockNum, nativeBlockNum);
//#endif

free(encodingMatrix);

}
コード例 #6
0
bool mysqld_help(THD *thd, const char *mask)
{
  Protocol *protocol= thd->protocol;
  SQL_SELECT *select;
  st_find_field used_fields[array_elements(init_used_fields)];
  TABLE_LIST *leaves= 0;
  TABLE_LIST tables[4];
  List<String> topics_list, categories_list, subcategories_list;
  String name, description, example;
  int count_topics, count_categories, error;
  uint mlen= strlen(mask);
  size_t i;
  MEM_ROOT *mem_root= thd->mem_root;
  DBUG_ENTER("mysqld_help");

  bzero((char *)((uchar*)tables),sizeof(tables));
  tables[0].alias= tables[0].table_name= (char*) "help_topic";
  tables[0].lock_type= TL_READ;
  tables[0].next_global= tables[0].next_local= 
    tables[0].next_name_resolution_table= &tables[1];
  tables[1].alias= tables[1].table_name= (char*) "help_category";
  tables[1].lock_type= TL_READ;
  tables[1].next_global= tables[1].next_local= 
    tables[1].next_name_resolution_table= &tables[2];
  tables[2].alias= tables[2].table_name= (char*) "help_relation";
  tables[2].lock_type= TL_READ;
  tables[2].next_global= tables[2].next_local= 
    tables[2].next_name_resolution_table= &tables[3];
  tables[3].alias= tables[3].table_name= (char*) "help_keyword";
  tables[3].lock_type= TL_READ;
  tables[0].db= tables[1].db= tables[2].db= tables[3].db= (char*) "mysql";

  Open_tables_state open_tables_state_backup;
  if (open_system_tables_for_read(thd, tables, &open_tables_state_backup))
    goto error2;

  /*
    Init tables and fields to be usable from items
    tables do not contain VIEWs => we can pass 0 as conds
  */
  thd->lex->select_lex.context.table_list=
    thd->lex->select_lex.context.first_name_resolution_table= &tables[0];
  if (setup_tables(thd, &thd->lex->select_lex.context,
                   &thd->lex->select_lex.top_join_list,
                   tables, &leaves, FALSE))
    goto error;
  memcpy((char*) used_fields, (char*) init_used_fields, sizeof(used_fields));
  if (init_fields(thd, tables, used_fields, array_elements(used_fields)))
    goto error;
  for (i=0; i<sizeof(tables)/sizeof(TABLE_LIST); i++)
    tables[i].table->file->init_table_handle_for_HANDLER();

  if (!(select=
	prepare_select_for_name(thd,mask,mlen,tables,tables[0].table,
				used_fields[help_topic_name].field,&error)))
    goto error;

  count_topics= search_topics(thd,tables[0].table,used_fields,
			      select,&topics_list,
			      &name, &description, &example);
  delete select;

  if (count_topics == 0)
  {
    int UNINIT_VAR(key_id);
    if (!(select=
          prepare_select_for_name(thd,mask,mlen,tables,tables[3].table,
                                  used_fields[help_keyword_name].field,
                                  &error)))
      goto error;

    count_topics= search_keyword(thd,tables[3].table, used_fields, select,
                                 &key_id);
    delete select;
    count_topics= (count_topics != 1) ? 0 :
                  get_topics_for_keyword(thd,tables[0].table,tables[2].table,
                                         used_fields,key_id,&topics_list,&name,
                                         &description,&example);
  }

  if (count_topics == 0)
  {
    int16 category_id;
    Field *cat_cat_id= used_fields[help_category_parent_category_id].field;
    if (!(select=
          prepare_select_for_name(thd,mask,mlen,tables,tables[1].table,
                                  used_fields[help_category_name].field,
                                  &error)))
      goto error;

    count_categories= search_categories(thd, tables[1].table, used_fields,
					select,
					&categories_list,&category_id);
    delete select;
    if (!count_categories)
    {
      if (send_header_2(protocol,FALSE))
	goto error;
    }
    else if (count_categories > 1)
    {
      if (send_header_2(protocol,FALSE) ||
	  send_variant_2_list(mem_root,protocol,&categories_list,"Y",0))
	goto error;
    }
    else
    {
      Field *topic_cat_id= used_fields[help_topic_help_category_id].field;
      Item *cond_topic_by_cat=
	new Item_func_equal(new Item_field(topic_cat_id),
			    new Item_int((int32)category_id));
      Item *cond_cat_by_cat=
	new Item_func_equal(new Item_field(cat_cat_id),
			    new Item_int((int32)category_id));
      if (!(select= prepare_simple_select(thd, cond_topic_by_cat,
                                          tables[0].table, &error)))
        goto error;
      get_all_items_for_category(thd,tables[0].table,
				 used_fields[help_topic_name].field,
				 select,&topics_list);
      delete select;
      if (!(select= prepare_simple_select(thd, cond_cat_by_cat,
                                          tables[1].table, &error)))
        goto error;
      get_all_items_for_category(thd,tables[1].table,
				 used_fields[help_category_name].field,
				 select,&subcategories_list);
      delete select;
      String *cat= categories_list.head();
      if (send_header_2(protocol, TRUE) ||
	  send_variant_2_list(mem_root,protocol,&topics_list,       "N",cat) ||
	  send_variant_2_list(mem_root,protocol,&subcategories_list,"Y",cat))
	goto error;
    }
  }
  else if (count_topics == 1)
  {
    if (send_answer_1(protocol,&name,&description,&example))
      goto error;
  }
  else
  {
    /* First send header and functions */
    if (send_header_2(protocol, FALSE) ||
	send_variant_2_list(mem_root,protocol, &topics_list, "N", 0))
      goto error;
    if (!(select=
          prepare_select_for_name(thd,mask,mlen,tables,tables[1].table,
                                  used_fields[help_category_name].field,&error)))
      goto error;
    search_categories(thd, tables[1].table, used_fields,
		      select,&categories_list, 0);
    delete select;
    /* Then send categories */
    if (send_variant_2_list(mem_root,protocol, &categories_list, "Y", 0))
      goto error;
  }
  my_eof(thd);

  close_system_tables(thd, &open_tables_state_backup);
  DBUG_RETURN(FALSE);

error:
  close_system_tables(thd, &open_tables_state_backup);

error2:
  DBUG_RETURN(TRUE);
}
コード例 #7
0
ファイル: vco.c プロジェクト: BackupTheBerlios/galan
PUBLIC void init_plugin_vco(void) {
  setup_tables();
  setup_class();
}