本文整理汇总了C++中print_header函数的典型用法代码示例。如果您正苦于以下问题:C++ print_header函数的具体用法?C++ print_header怎么用?C++ print_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_header函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: show_run
static void
show_run(const struct run *run) {
max_line_length = Page_Width / 2 - 1;
max_line_length_UTF8 = max_line_length * FONT_SIZE;
/* The animals came in two by two ... */
const struct chunk *cnk0 = &run->rn_chunk0;
const struct chunk *cnk1 = &run->rn_chunk1;
size_t nl_cnt0 = cnk0->ch_last.ps_nl_cnt - cnk0->ch_first.ps_nl_cnt;
size_t nl_cnt1 = cnk1->ch_last.ps_nl_cnt - cnk1->ch_first.ps_nl_cnt;
FILE *f0;
FILE *f1;
/* display heading of chunk */
if (!is_set_option('d')) {
/* no assumptions about the lengths of the file names! */
size_t size = run->rn_size;
int pos = print_header(cnk0);
print_spaces(max_line_length - pos);
print_char('|');
pos = print_header(cnk1);
print_spaces(max_line_length - pos - length_size_t(size) - 2);
fprintf(Output_File, "[%s]\n", size_t2string(size));
}
else {
/* diff-like format */
(void)print_header(cnk0);
print_char('\n');
(void)print_header(cnk1);
print_char('\n');
}
/* stop if that suffices */
if (is_set_option('n'))
return; /* ... had enough so soon ... */
/* open the files that hold the chunks */
f0 = open_chunk(cnk0);
f1 = open_chunk(cnk1);
/* display the chunks in the required format */
if (!is_set_option('d')) {
/* print 2-column format */
while (nl_cnt0 != 0 || nl_cnt1 != 0) {
int pos_UTF8 = 0;
if (nl_cnt0) {
pos_UTF8 = print_UTF8_line(f0);
nl_cnt0--;
}
print_UTF8_spaces(max_line_length_UTF8 - pos_UTF8);
print_char('|');
if (nl_cnt1) {
(void)print_UTF8_line(f1);
nl_cnt1--;
}
print_char('\n');
}
}
else {
/* display the chunks in a diff(1)-like format */
while (nl_cnt0--) {
show_1C_line(f0, "<");
}
(void)print_string("---\n");
while (nl_cnt1--) {
show_1C_line(f1, ">");
}
}
/* close the pertinent files */
fclose(f0);
fclose(f1);
}
开发者ID:binzhangbin,项目名称:hustoj,代码行数:73,代码来源:pass3.c
示例2: check_gt
static void check_gt(args_t *args)
{
int i,ret, *gt2ipl = NULL, m_gt2ipl = 0, *gt_arr = NULL, ngt_arr = 0;
int fake_pls = args->no_PLs;
// Initialize things: check which tags are defined in the header, sample names etc.
if ( bcf_hdr_id2int(args->gt_hdr, BCF_DT_ID, "GT")<0 ) error("[E::%s] GT not present in the header of %s?\n", __func__, args->files->readers[1].fname);
if ( bcf_hdr_id2int(args->sm_hdr, BCF_DT_ID, "PL")<0 )
{
if ( bcf_hdr_id2int(args->sm_hdr, BCF_DT_ID, "GT")<0 )
error("[E::%s] Neither PL nor GT present in the header of %s\n", __func__, args->files->readers[0].fname);
if ( !args->no_PLs )
fprintf(pysamerr,"Warning: PL not present in the header of %s, using GT instead\n", args->files->readers[0].fname);
fake_pls = 1;
}
FILE *fp = args->plot ? open_file(NULL, "w", "%s.tab", args->plot) : stdout;
print_header(args, fp);
int tgt_isample = -1, query_isample = 0;
if ( args->target_sample )
{
tgt_isample = bcf_hdr_id2int(args->gt_hdr, BCF_DT_SAMPLE, args->target_sample);
if ( tgt_isample<0 ) error("No such sample in %s: [%s]\n", args->files->readers[1].fname, args->target_sample);
}
if ( args->all_sites )
{
if ( tgt_isample==-1 )
{
fprintf(pysamerr,"No target sample selected for comparison, using the first sample in %s: %s\n", args->gt_fname,args->gt_hdr->samples[0]);
tgt_isample = 0;
}
}
if ( args->query_sample )
{
query_isample = bcf_hdr_id2int(args->sm_hdr, BCF_DT_SAMPLE, args->query_sample);
if ( query_isample<0 ) error("No such sample in %s: [%s]\n", args->files->readers[0].fname, args->query_sample);
}
if ( args->all_sites )
fprintf(fp, "# [1]SC, Site by Site Comparison\t[2]Chromosome\t[3]Position\t[4]-g alleles\t[5]-g GT (%s)\t[6]match log LK\t[7]Query alleles\t[8-]Query PLs (%s)\n",
args->gt_hdr->samples[tgt_isample],args->sm_hdr->samples[query_isample]);
// Main loop
float prev_lk = 0;
while ( (ret=bcf_sr_next_line(args->files)) )
{
if ( ret!=2 ) continue;
bcf1_t *sm_line = args->files->readers[0].buffer[0]; // the query file
bcf1_t *gt_line = args->files->readers[1].buffer[0]; // the -g target file
bcf_unpack(sm_line, BCF_UN_FMT);
bcf_unpack(gt_line, BCF_UN_FMT);
// Init mapping from target genotype index to the sample's PL fields
int n_gt2ipl = gt_line->n_allele*(gt_line->n_allele + 1)/2;
if ( n_gt2ipl > m_gt2ipl )
{
m_gt2ipl = n_gt2ipl;
gt2ipl = (int*) realloc(gt2ipl, sizeof(int)*m_gt2ipl);
}
if ( !init_gt2ipl(args, gt_line, sm_line, gt2ipl, n_gt2ipl) ) continue;
// Target genotypes
int ngt, npl;
if ( (ngt=bcf_get_genotypes(args->gt_hdr, gt_line, >_arr, &ngt_arr)) <= 0 )
error("GT not present at %s:%d?", args->gt_hdr->id[BCF_DT_CTG][gt_line->rid].key, gt_line->pos+1);
ngt /= bcf_hdr_nsamples(args->gt_hdr);
if ( ngt!=2 ) continue; // checking only diploid genotypes
// Sample PLs
if ( !fake_pls )
{
if ( (npl=bcf_get_format_int32(args->sm_hdr, sm_line, "PL", &args->pl_arr, &args->npl_arr)) <= 0 )
{
if ( sm_line->n_allele==1 )
{
// PL values may not be present when ALT=. (mpileup/bcftools output), in that case
// switch automatically to GT at these sites
npl = fake_PLs(args, args->sm_hdr, sm_line);
}
else
error("PL not present at %s:%d?\n", args->sm_hdr->id[BCF_DT_CTG][sm_line->rid].key, sm_line->pos+1);
}
else
npl /= bcf_hdr_nsamples(args->sm_hdr);
}
else
npl = fake_PLs(args, args->sm_hdr, sm_line);
// Calculate likelihoods for all samples, assuming diploid genotypes
// For faster access to genotype likelihoods (PLs) of the query sample
int max_ipl, *pl_ptr = args->pl_arr + query_isample*npl;
double sum_pl = 0; // for converting PLs to probs
for (max_ipl=0; max_ipl<npl; max_ipl++)
{
if ( pl_ptr[max_ipl]==bcf_int32_vector_end ) break;
if ( pl_ptr[max_ipl]==bcf_int32_missing ) continue;
sum_pl += pow(10, -0.1*pl_ptr[max_ipl]);
}
if ( sum_pl==0 ) continue; // no PLs present
//.........这里部分代码省略.........
开发者ID:anykine,项目名称:pysam,代码行数:101,代码来源:vcfgtcheck.c.pysam.c
示例3: protocol1
/* void protocol1
* buffer* recv_buffer - buffer containing the message sent by the client to the proxy
* server_stat* status - status and general information from the server
* Processes the recv_buf as the class protocol dictates
*/
void protocol1(buffer* recv_buf, server_stat* status){
struct timeval timeout;
struct timeval timeout_0;
// timeouts
timeout.tv_sec = 1;
timeout.tv_usec = 0;
timeout_0.tv_sec = 0;
timeout_0.tv_usec = 0;
timeout_setup(status->udp_sock, timeout);
// giant mess of conditionals
fprintf(stdout, "\tversion 1 protocol\n");
int error = 0;
header msg_header = extract_header(recv_buf);
if (status->connected == 0) {
if (check_pass(&msg_header, 0)) {
if (get_command(&msg_header) == CONNECT) {
fprintf(stdout, "\tReplying with password\n");
status->connected = 1;
msg_header.data[1] = status->password;
insert_header(recv_buf, msg_header);
if (udp_send(recv_buf, status) < 0) {
fprintf(stderr, "sendto()\n");
}
} else {
fprintf(stderr, "ERROR: Unexpected Command\n");
error = -2;
}
} else {
fprintf(stderr, "ERROR: Incorrect Password\n");
}
} else if (status->connected == 1) {
if (check_pass(&msg_header, status->password)) {
if (get_command(&msg_header) == CONNECT) {
status->connected = 2;
timeout_setup(status->udp_sock, timeout_0);
fprintf(stdout, "\tConnected to a client\n");
} else {
fprintf(stderr, "ERROR: Unexpected Command\n");
error = -2;
}
} else {
fprintf(stderr, "ERROR: Incorrect Password\n");
error = -2;
}
} else {
if (!check_pass(&msg_header, status->password)) {
fprintf(stderr, "ERROR: Incorrect Password\n");
error = -2;
} else {
fprintf(stdout, "\t\tReceived Message:\n");
print_header(recv_buf);
switch (get_command(&msg_header)) {
case CONNECT:
fprintf(stderr, "ERROR: Unexpected Command\n");
error = -2;
break;
case QUIT:
quit(recv_buf, status);
timeout_setup(status->udp_sock, timeout_0);
break;
default:
error = request_command(recv_buf, status);
break;
}
}
}
if (error == -2) {
fprintf(stderr, "ERROR: Invalid client request\n");
send_error(status, CLIENT_ERROR);
} else if (error == -1) {
fprintf(stderr, "ERROR: Problem with http response\n");
send_error(status, HTTP_ERROR);
}
}
开发者ID:aephynsa,项目名称:remy2015,代码行数:81,代码来源:server.c
示例4: main
int main(int argc,
char **argv)
{
int rval = 0;
double *x = 0;
struct CG *cg = 0;
struct LP lp;
char *column_types = 0;
rval = parse_args(argc, argv);
if (rval) return 1;
if (LOG_FILENAME[0])
{
LOG_FILE = fopen(LOG_FILENAME, "w");
abort_if(!LOG_FILE, "could not open log file");
}
print_header(argc, argv);
STATS_init();
STATS_set_input_filename(PROBLEM_FILENAME);
rval = LP_open(&lp);
abort_if(rval, "LP_open failed");
rval = LP_create(&lp, "multirow");
abort_if(rval, "LP_create failed");
rval = LP_read_problem(&lp, PROBLEM_FILENAME);
abort_if(rval, "LP_read_problem failed");
int ncols = LP_get_num_cols(&lp);
int nrows = LP_get_num_rows(&lp);
log_info(" %d rows, %d cols\n", nrows, ncols);
x = (double *) malloc(ncols * sizeof(double));
abort_if(!x, "could not allocate x");
if (!KEEP_INTEGRALITY)
{
column_types = (char *) malloc(ncols * sizeof(char));
abort_if(!column_types, "could not allocate column_types");
log_info("Storing column types...\n");
rval = LP_get_column_types(&lp, column_types);
abort_if(rval, "LP_get_column_types failed");
log_info("Relaxing integrality...\n");
rval = LP_relax(&lp);
abort_if(rval, "LP_relax failed");
log_info("Disabling presolve...\n");
LP_disable_presolve(&lp);
}
if(BASIS_FILENAME[0])
{
rval = LP_read_basis(&lp, BASIS_FILENAME);
abort_if(rval, "LP_read_basis failed");
}
log_info("Optimizing...\n");
int infeasible;
rval = LP_optimize(&lp, &infeasible);
abort_if(rval, "LP_optimize failed");
double obj;
rval = LP_get_obj_val(&lp, &obj);
abort_if(rval, "LP_get_obj_val failed");
log_info(" opt = %lf\n", obj);
STATS_set_obj_value(obj);
STATS_finish_round();
if(OUTPUT_BASIS_FILENAME[0])
{
rval = LP_write_basis(&lp, OUTPUT_BASIS_FILENAME);
abort_if(rval, "LP_write_basis failed");
}
if(GENERATE_MIR || GENERATE_GREEDY)
{
cg = (struct CG *) malloc(sizeof(struct CG));
abort_if(!cg, "could not allocate cg");
log_info("Reading tableau rows...\n");
rval = CG_init(&lp, column_types, cg);
abort_if(rval, "CG_init failed");
if (strlen(KNOWN_SOLUTION_FILENAME) > 0)
{
rval = LP_read_solution(&lp, KNOWN_SOLUTION_FILENAME, x);
abort_if(rval, "LP_read_solution failed");
rval = CG_set_integral_solution(cg, x);
abort_if(rval, "CG_set_integral_solution failed");
//.........这里部分代码省略.........
开发者ID:iSoron,项目名称:multirow,代码行数:101,代码来源:main-greedy.c
示例5: main
//.........这里部分代码省略.........
if (cd.cd_ctflen < sizeof (ctf_preamble_t))
die("%s does not contain a CTF preamble\n", filename);
/* LINTED - pointer alignment */
pp = (const ctf_preamble_t *)cd.cd_ctfdata;
if (pp->ctp_magic != CTF_MAGIC)
die("%s does not appear to contain CTF data\n", filename);
if (pp->ctp_version == CTF_VERSION) {
/* LINTED - pointer alignment */
hp = (ctf_header_t *)cd.cd_ctfdata;
cd.cd_ctfdata = (caddr_t)cd.cd_ctfdata + sizeof (ctf_header_t);
if (cd.cd_ctflen < sizeof (ctf_header_t)) {
die("%s does not contain a v%d CTF header\n", filename,
CTF_VERSION);
}
} else {
die("%s contains unsupported CTF version %d\n", filename,
pp->ctp_version);
}
/*
* If the data buffer is compressed, then malloc a buffer large enough
* to hold the decompressed data, and use zlib to decompress it.
*/
if (hp->cth_flags & CTF_F_COMPRESS) {
z_stream zstr;
void *buf;
int rc;
if ((buf = malloc(hp->cth_stroff + hp->cth_strlen)) == NULL)
die("failed to allocate decompression buffer");
bzero(&zstr, sizeof (z_stream));
zstr.next_in = (void *)cd.cd_ctfdata;
zstr.avail_in = cd.cd_ctflen;
zstr.next_out = buf;
zstr.avail_out = hp->cth_stroff + hp->cth_strlen;
if ((rc = inflateInit(&zstr)) != Z_OK)
die("failed to initialize zlib: %s\n", zError(rc));
if ((rc = inflate(&zstr, Z_FINISH)) != Z_STREAM_END)
die("failed to decompress CTF data: %s\n", zError(rc));
if ((rc = inflateEnd(&zstr)) != Z_OK)
die("failed to finish decompression: %s\n", zError(rc));
if (zstr.total_out != hp->cth_stroff + hp->cth_strlen)
die("CTF data is corrupt -- short decompression\n");
cd.cd_ctfdata = buf;
cd.cd_ctflen = hp->cth_stroff + hp->cth_strlen;
}
if (flags & F_HDR)
error |= print_header(hp, &cd);
if (flags & (F_LABEL))
error |= print_labeltable(hp, &cd);
if (flags & (F_DATA | F_STATS))
error |= read_data(hp, &cd);
if (flags & (F_FUNC | F_STATS))
error |= read_funcs(hp, &cd);
if (flags & (F_TYPES | F_STATS))
error |= read_types(hp, &cd);
if (flags & (F_STR | F_STATS))
error |= read_strtab(hp, &cd);
if (flags & F_STATS)
error |= print_stats();
/*
* If the -u option is specified, write the uncompressed CTF data to a
* raw CTF file. CTF data can already be extracted compressed by
* applying elfdump -w -N .SUNW_ctf to an ELF file, so we don't bother.
*/
if (ufile != NULL) {
ctf_header_t h;
bcopy(hp, &h, sizeof (h));
h.cth_flags &= ~CTF_F_COMPRESS;
if ((ufd = open(ufile, O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0 ||
write(ufd, &h, sizeof (h)) != sizeof (h) ||
write(ufd, cd.cd_ctfdata, cd.cd_ctflen) != cd.cd_ctflen) {
warn("failed to write CTF data to '%s'", ufile);
error |= E_ERROR;
}
(void) close(ufd);
}
if (elf != NULL)
(void) elf_end(elf);
(void) close(fd);
return (error);
}
开发者ID:andreiw,项目名称:polaris,代码行数:101,代码来源:dump.c
示例6: newwin
int snake_game::start_game()
{
std::vector<std::pair<int, int> > vSnakeBody;
std::map<int, std::map<int, bool> > mSnakeBody;
int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX - FULL_SCREEN_WIDTH) / 2 : 0;
int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY - FULL_SCREEN_HEIGHT) / 2 : 0;
WINDOW *w_snake = newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, iOffsetY, iOffsetX);
print_header(w_snake);
//Snake start position
vSnakeBody.push_back(std::make_pair(FULL_SCREEN_HEIGHT / 2, FULL_SCREEN_WIDTH / 2));
mSnakeBody[FULL_SCREEN_HEIGHT / 2][FULL_SCREEN_WIDTH / 2] = true;
mvwputch(w_snake, vSnakeBody[vSnakeBody.size() - 1].first, vSnakeBody.back().second, c_white, '#');
//Snake start direction
int iDirY = 0;
int iDirX = 1;
//Snake start length
size_t iSnakeBody = 10;
//GameSpeed aka inputdelay/timeout
int iGameSpeed = 100;
//Score
int iScore = 0;
int iFruitPosY = 0;
int iFruitPosX = 0;
//Draw Score
print_score(w_snake, iScore);
long ch;
InputEvent input;
do {
//Check if we hit a border
if (vSnakeBody[vSnakeBody.size() - 1].first + iDirY == 0) {
vSnakeBody.push_back(std::make_pair(vSnakeBody[vSnakeBody.size() - 1].first +
iDirY + FULL_SCREEN_HEIGHT - 2,
vSnakeBody[vSnakeBody.size() - 1].second + iDirX));
} else if (vSnakeBody[vSnakeBody.size() - 1].first + iDirY == FULL_SCREEN_HEIGHT - 1) {
vSnakeBody.push_back(std::make_pair(vSnakeBody[vSnakeBody.size() - 1].first +
iDirY - FULL_SCREEN_HEIGHT + 2,
vSnakeBody[vSnakeBody.size() - 1].second + iDirX));
} else if (vSnakeBody[vSnakeBody.size() - 1].second + iDirX == 0) {
vSnakeBody.push_back(std::make_pair(vSnakeBody[vSnakeBody.size() - 1].first + iDirY,
vSnakeBody[vSnakeBody.size() - 1].second +
iDirX + FULL_SCREEN_WIDTH - 2));
} else if (vSnakeBody[vSnakeBody.size() - 1].second + iDirX == FULL_SCREEN_WIDTH - 1) {
vSnakeBody.push_back(std::make_pair(vSnakeBody[vSnakeBody.size() - 1].first + iDirY,
vSnakeBody[vSnakeBody.size() - 1].second +
iDirX - FULL_SCREEN_WIDTH + 2));
} else {
vSnakeBody.push_back(std::make_pair(vSnakeBody[vSnakeBody.size() - 1].first + iDirY,
vSnakeBody[vSnakeBody.size() - 1].second + iDirX));
}
//Check if we hit ourself
if (mSnakeBody[vSnakeBody[vSnakeBody.size() - 1].first][vSnakeBody[vSnakeBody.size() - 1].second]) {
//We are dead :(
break;
} else {
//Add new position to map
mSnakeBody[vSnakeBody[vSnakeBody.size() - 1].first][vSnakeBody[vSnakeBody.size() - 1].second] = true;
}
//Have we eaten the forbidden fruit?
if (vSnakeBody[vSnakeBody.size() - 1].first == iFruitPosY &&
vSnakeBody[vSnakeBody.size() - 1].second == iFruitPosX) {
iScore += 500;
iSnakeBody += 10;
iGameSpeed -= 3;
print_score(w_snake, iScore);
iFruitPosY = 0;
iFruitPosX = 0;
}
//Check if we are longer than our max size
if (vSnakeBody.size() > iSnakeBody) {
mSnakeBody[vSnakeBody[0].first][vSnakeBody[0].second] = false;
mvwputch(w_snake, vSnakeBody[0].first, vSnakeBody[0].second, c_black, ' ');
vSnakeBody.erase(vSnakeBody.begin(), vSnakeBody.begin() + 1);
}
//Draw Snake
mvwputch(w_snake, vSnakeBody[vSnakeBody.size() - 1].first,
vSnakeBody[vSnakeBody.size() - 1].second, c_white, '#');
mvwputch(w_snake, vSnakeBody[vSnakeBody.size() - 2].first,
vSnakeBody[vSnakeBody.size() - 2].second, c_ltgray, '#');
//On full length add a fruit
//.........这里部分代码省略.........
开发者ID:Agnososyk,项目名称:Cataclysm-DDA,代码行数:101,代码来源:iuse_software_snake.cpp
示例7: dr_writer_init
int
dr_writer_init (FILE * pfile)
{
print_header (pfile);
return 0;
}
开发者ID:paudirac,项目名称:codi-antic,代码行数:6,代码来源:dr_writer.c
示例8: main
int main ()
{
int file_size , padding = 0;
HEADER bmp_header;
INFO_HEADER bmp_info_header;
COLOR_PALLET *bgr_pallete = malloc (sizeof( COLOR_PALLET ) * CHAR_RANGE);
unsigned char *data_buffer , *out_buffer ;
char *file_name ;
FILE *in_file = NULL;
file_name = get_file_name ();
in_file = fopen ( file_name , "rb" );
if (in_file == NULL)
{
printf("file opening failed\n");
return 1;
}
if ( fread ( &bmp_header , sizeof ( HEADER ) , 1 , in_file) < 1 )
{
printf("Some issue in reading file\n");
return 0;
}
if ( fread ( &bmp_info_header , sizeof ( INFO_HEADER ) , 1 , in_file) < 1 )
{
printf("Some issue in reading file\n");
return 1;
}
print_header( bmp_header , bmp_info_header );
//checking if the image is bmp or not
if ( bmp_header.signature != BMP_SIGNATURE )
{
printf("no a bmp\n");
return 1;
}
if ( bmp_info_header.bits_per_pixel != RGB_SIZE )
{
printf("already in greysacle\n");
return 1;
}
if ( fseek ( in_file , bmp_header.offset , SEEK_SET ) == -1 )
{
printf("file operation failed\n");
return 1;
}
file_size = bmp_info_header.image_data_size ;
//based on file_size allocate memory
data_buffer = malloc (sizeof (char) * file_size + 1 );
if (data_buffer == NULL)
{
printf("malloc Failed\n");
return 1;
}
*(data_buffer + file_size) = CHAR_NULL;
//read the data into buffer
if ( fread ( data_buffer , sizeof(char) , file_size , in_file ) < file_size )
{
printf("Some issue in reading file\n");
fclose (in_file);
free (data_buffer);
return 1;
}
if ( fclose ( in_file ) == 0 )
{
printf("File not closing\n" );
}
out_buffer = covert_to_mono ( data_buffer , file_size , bmp_info_header);
if ( ( bmp_info_header.image_width * 3 ) % 4 != 0)
padding = 4 - ( ( bmp_info_header.image_width * 3 ) % 4 );
//change the header details
bmp_header.offset = COLOR_PALLET_SIZE + HEADER_SIZE;
bmp_header.bmp_file_size = HEADER_SIZE + ( bmp_info_header.image_width * bmp_info_header.image_height ) + ( padding * bmp_info_header.image_height ) + COLOR_PALLET_SIZE;
bmp_info_header.bits_per_pixel = 8;
bmp_info_header.image_data_size =( bmp_info_header.image_width * bmp_info_header.image_height ) + ( padding * bmp_info_header.image_height );
print_header( bmp_header , bmp_info_header );
//get bgr pallete
get_color_pallet ( bgr_pallete );
to_file (out_buffer, bmp_header , bmp_info_header , bgr_pallete , bmp_info_header.image_data_size) ;
free (data_buffer);
data_buffer = NULL;
free ( out_buffer );
out_buffer = NULL;
free (bgr_pallete);
bgr_pallete = NULL;
return 0;
}
开发者ID:mohanen,项目名称:simple-image-processing-c-programs,代码行数:100,代码来源:rgb_to_mono.c
示例9: print_program
void print_program()
{
#ifdef DEBUG
fprintf(stdout, "starting print program...\n");
#endif
output = fopen("output_a.out.c", "w");
if(!output){
fprintf(stderr, "error in print_program\n");
exit(0);
}
print_header();
print_func_decaration();
print_safety_guard();
print_print_pc();
//yang
unsigned instsize = 0;
unsigned int globalsize = 0;
globalsize = print_dependence_data_to_file();
////////
for(PROGRAM::iterator it = g_current_program->begin();//dump functions
it != g_current_program->end();it++){
#ifdef WINDOWS_NAKED
fprintf(output, "__declspec( naked ) ");
#endif
if(g_main_pc == it->first){
fprintf(output, "void main(){\n");
//Hush.b
//extern variables in dst
#ifdef DEBUG
fprintf(stderr, "----dst_map size is %d\n", dst_map.size());
#endif
#if 0
if(!dst_map.empty()){
for(map<unsigned int, Dst_item*>::iterator it= dst_map.begin();
it!=dst_map.end();it++){
fprintf(output, "extern %s;\n", it->second->name);
}
}
#endif
fprintf(output, "output=fopen(\"log\", \"w\");\n");
//Hush.e
}else{
fprintf(output, "int func_0x%x(){\n", it->first);
}
#ifdef DEBUG
fprintf(stderr, "----function start pc:%x\t%x\n", it->first, it->second);
#endif
g_current_func = it->second;
print_func(it->second);
fprintf(output, "}\n");
instsize += it->second->size();
}
fclose(output);
#ifdef STATISTICS
fprintf(stderr, "program:%s\n", PEMU_binary_name);
fprintf(stderr, "number of executed inst:\t%d\n", g_inst_num);
fprintf(stderr, "symbolized addresses %d\n", g_symbol_nums);
fprintf(stderr, "direct jmp:\t%d\njcc:\t%d\ndirect call:\t%d\ndata:\t%d\ndis:\t%d\nimm:\t%d\n",
g_jmp_num, g_jcc_num, g_call_num, g_dump_data, g_dis_nums, g_imm_nums);
fprintf(stderr, "checks num:%d\n", g_check_nums);
#endif
}
开发者ID:jzeng4,项目名称:top,代码行数:69,代码来源:print_inst.cpp
示例10: main
//.........这里部分代码省略.........
ParserContext pc = create_parser_context( btc );
set_extra( pc, &pi );
set_current( pc, pi.m_Name );
returnCode = parse( pc, &pcf );
destroy( pc );
if( pi.m_File )
fclose( pi.m_File );
if( returnCode != 0 )
break;
include = include->m_Next;
}
include = get_first_include( btc );
while( returnCode == 0 && include && g_printIncludes )
{
printf( "%s\n", include->m_Name );
include = include->m_Next;
}
if( g_outputHeaderName && returnCode == 0 )
{
FILE* header = fopen( g_outputHeaderName, "w" );
if( !header )
{
fprintf( stderr, "%s(0): error: Unable to open output file %s for writing.\n",
g_inputFileName, g_outputHeaderName );
returnCode = -1;
}
else
{
returnCode = print_header( header, g_inputFileName, btc );
if( returnCode != 0 )
fprintf( stderr, "%s(0): error: unspecified error when writing header %s.\n",
g_inputFileName, g_outputHeaderName );
fclose( header );
}
}
if( g_outputFileName && returnCode == 0 )
{
Program p;
unsigned int debug_hash = hashlittle( "debug_info" );
Parameter* debug_param = find_by_hash( get_options( btc ), debug_hash );
if( debug_param )
p.m_I.SetGenerateDebugInfo( as_integer( *debug_param ) );
returnCode = setup( btc, &p );
if( returnCode == 0 )
{
returnCode = generate( &p );
if( returnCode != 0 )
fprintf( stderr, "%s(0): error: Internal compiler error in generate.\n", g_inputFileName );
}
else
{
fprintf( stderr, "%s(0): error: Internal compiler error in setup.\n", g_inputFileName );
}
teardown( &p );
if( returnCode == 0 )
{
开发者ID:AntonioModer,项目名称:calltree,代码行数:67,代码来源:main.cpp
示例11: diff_archive
void
diff_archive (void)
{
struct stat stat_data;
int name_length;
int status;
errno = EPIPE; /* FIXME: errno should be read-only */
/* FIXME: remove perrors */
set_next_block_after (current_header);
decode_header (current_header, ¤t_stat, ¤t_format, 1);
/* Print the block from `current_header' and `current_stat'. */
if (verbose_option)
{
if (now_verifying)
fprintf (stdlis, _("Verify "));
print_header ();
}
switch (current_header->header.typeflag)
{
default:
WARN ((0, 0, _("Unknown file type '%c' for %s, diffed as normal file"),
current_header->header.typeflag, current_file_name));
/* Fall through. */
case AREGTYPE:
case REGTYPE:
case GNUTYPE_SPARSE:
case CONTTYPE:
/* Appears to be a file. See if it's really a directory. */
name_length = strlen (current_file_name) - 1;
if (current_file_name[name_length] == PATHSEP)
goto really_dir;
if (!get_stat_data (&stat_data))
{
if (current_header->oldgnu_header.isextended)
skip_extended_headers ();
skip_file ((long) current_stat.st_size);
goto quit;
}
if (!S_ISREG (stat_data.st_mode))
{
report_difference (_("Not a regular file"));
skip_file ((long) current_stat.st_size);
goto quit;
}
stat_data.st_mode &= 07777;
if (stat_data.st_mode != current_stat.st_mode)
report_difference (_("Mode differs"));
#if !MSDOS && !WIN32
/* stat() in djgpp's C library gives a constant number of 42 as the
uid and gid of a file. So, comparing an FTP'ed archive just after
unpack would fail on MSDOS. */
if (stat_data.st_uid != current_stat.st_uid)
report_difference (_("Uid differs"));
if (stat_data.st_gid != current_stat.st_gid)
report_difference (_("Gid differs"));
#endif
if (stat_data.st_mtime != current_stat.st_mtime)
report_difference (_("Mod time differs"));
if (current_header->header.typeflag != GNUTYPE_SPARSE &&
stat_data.st_size != current_stat.st_size)
{
report_difference (_("Size differs"));
skip_file ((long) current_stat.st_size);
goto quit;
}
diff_handle = open (current_file_name, O_NDELAY | O_RDONLY | O_BINARY);
if (diff_handle < 0 && !absolute_names_option)
{
char *tmpbuf = xmalloc (strlen (current_file_name) + 2);
*tmpbuf = PATHSEP;
strcpy (tmpbuf + 1, current_file_name);
diff_handle = open (tmpbuf, O_NDELAY | O_RDONLY);
free (tmpbuf);
}
if (diff_handle < 0)
{
ERROR ((0, errno, _("Cannot open %s"), current_file_name));
if (current_header->oldgnu_header.isextended)
skip_extended_headers ();
skip_file ((long) current_stat.st_size);
report_difference (NULL);
goto quit;
}
//.........这里部分代码省略.........
开发者ID:redwinner,项目名称:unxutils,代码行数:101,代码来源:compare.c
示例12: results_lcl
unsigned int results_lcl ( const char * filename, /* output filename */
struct TSeq * t, /* text */
unsigned int n, /* length of t */
struct TSeq * p, /* pattern */
unsigned int m, /* length of p */
double max_score,
unsigned int * gaps_pos,
unsigned int l,
unsigned int * gaps_len,
unsigned int * where,
unsigned int istart,
unsigned int iend,
unsigned int jstart,
unsigned int jend,
unsigned int swap,
unsigned int matrix,
double gap_penalty,
double ext_penalty, int L )
{
FILE * output;
char * seqa; //sequence a with the inserted gaps
unsigned int aa;
unsigned int ii;
char * seqb; //sequence b with the inserted gaps
unsigned int bb;
unsigned int jj;
char * mark_mis; //a string with the mismatches marked as '|' (and the matches as ' ')
unsigned int min_mis = 0; //the number of mismatches in the alignment
unsigned int mm = 0;
char * Cmark_mis; //cropped sequences
char * Cseqa;
char * Cseqb;
unsigned int i;
/* Here we calculate the number of gaps and their total length */
unsigned int numgaps = 0;
unsigned int gapslength = 0;
for ( i = 0; i < l; i ++ )
{
if ( gaps_len[i] > 0 )
{
numgaps++;
gapslength += gaps_len[i];
}
}
/* dynamic memory allocation for the 3 sequences */
if ( ! ( seqa = ( char * ) calloc ( n + gapslength + 1, sizeof ( char ) ) ) )
{
fprintf ( stderr, "Error: seqa could not be allocated!!!\n" );
return ( 0 );
}
if ( ! ( seqb = ( char * ) calloc ( n + gapslength + 1, sizeof ( char ) ) ) )
{
fprintf ( stderr, "Error: seqb could not be allocated!!!\n" );
return ( 0 );
}
if ( ! ( mark_mis = ( char* ) calloc ( n + gapslength + 1, sizeof( char ) ) ) )
{
fprintf ( stderr, "Error: mark_mis could not be allocated!!!\n" );
return ( 0 );
}
if ( ! ( Cseqa = ( char * ) calloc ( n + gapslength + 1, sizeof ( char ) ) ) )
{
fprintf ( stderr, "Error: seqa could not be allocated!!!\n" );
return ( 0 );
}
if ( ! ( Cseqb = ( char * ) calloc ( n + gapslength + 1, sizeof ( char ) ) ) )
{
fprintf ( stderr, "Error: seqb could not be allocated!!!\n" );
return ( 0 );
}
if ( ! ( Cmark_mis = ( char* ) calloc ( n + gapslength + 1, sizeof( char ) ) ) )
{
fprintf ( stderr, "Error: mark_mis could not be allocated!!!\n" );
return ( 0 );
}
/* Here we open the output file */
if ( ! ( output = fopen ( filename, "w" ) ) )
{
fprintf ( stderr, "Error: cannot open file %s!!!\n", filename );
return ( 0 );
}
/* Here we print the header */
print_header ( output, filename, matrix, gap_penalty, ext_penalty, L );
#if 0
fprintf ( stderr, "%s\n", t->data );
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:gapsmis,代码行数:101,代码来源:output.c
示例13: main
int main(int argc, char **argv)
{
char id[UUID_STR_LEN + 1];
int cf_index, ret, type;
Octstr *os, *store_type, *store_location, *status;
Msg *msg;
CfgGroup *grp;
conf_file = NULL;
gwlib_init();
//This can be overwritten with the -v flag at runtime
log_set_output_level(DEFAULT_LOG_LEVEL);
cf_index = get_and_set_debugs(argc, argv, check_args);
if (argv[cf_index] == NULL) {
print_usage(argv[0]);
goto error;
}
if (conf_file == NULL)
conf_file = octstr_create("kannel.conf");
cfg = cfg_create(conf_file);
if (cfg_read(cfg) == -1)
panic(0, "Couldn't read configuration from `%s'.", octstr_get_cstr(conf_file));
info(0, "1");
grp = cfg_get_single_group(cfg, octstr_imm("core"));
if (grp == NULL) {
printf("FATAL: Could not load Kannel's core group. Exiting.\n");
return 2;
}
store_location = cfg_get(grp, octstr_imm("store-location"));
store_type = cfg_get(grp, octstr_imm("store-type"));
store_init(store_type, store_location, -1, msg_pack, msg_unpack_wrapper);
switch (command) {
case COMMAND_LIST:
printf("Listing records %d -> %d\n", list_from+1, list_limit);
print_header();
store_load(print_msg);
if (counter == 0) {
printf("|%60s%14s%60s|\n", "", "Store is Empty", "");
}
print_sep();
break;
case COMMAND_DELETE:
store_load(msg_count);
msg = msg_create(ack);
msg->ack.nack = ack_failed;
msg->ack.time = time(NULL);
uuid_parse(octstr_get_cstr(param_1), msg->ack.id);
ret = store_save(msg);
if (ret == 0) {
printf("Deleted message %s\n", octstr_get_cstr(param_1));
counter--;
} else {
printf("Could not delete message %s\n", octstr_get_cstr(param_1));
}
msg_destroy(msg);
break;
case COMMAND_EXPORT:
counter = 0;
type = 0;
list = gwlist_create();
store_load(msg_push);
printf("Exporting %ld messages...\n", gwlist_len(list));
if ((octstr_compare(param_1, octstr_imm("file")) == 0) ||
(octstr_compare(param_1, octstr_imm("spool")) == 0)) {
store_shutdown();
store_init(param_1, param_2, -1, msg_pack, msg_unpack_wrapper);
store_load(msg_count);
while ((os = gwlist_extract_first(list)) != NULL) {
msg = msg_unpack_wrapper(os);
if (msg != NULL) {
ret = store_save(msg);
if (ret == 0) {
counter++;
} else {
printf("Error saving message\n");
}
} else {
printf("Error extracting message\n");
}
msg_destroy(msg);
}
status = NULL;
} else if (octstr_compare(param_1, octstr_imm("text")) == 0) {
status = store_status(BBSTATUS_TEXT);
} else if (octstr_compare(param_1, octstr_imm("html")) == 0) {
status = store_status(BBSTATUS_HTML);
} else if (octstr_compare(param_1, octstr_imm("xml")) == 0) {
status = store_status(BBSTATUS_XML);
} else {
status = NULL;
//.........这里部分代码省略.........
开发者ID:blinohod,项目名称:kannel-altlinux,代码行数:101,代码来源:store_tools.c
示例14: results
/* Creates the output file with the alignment */
unsigned int results ( const char * filename, /* output filename */
struct TSeq * t, /* text */
unsigned int n, /* length of t */
struct TSeq * p, /* pattern */
unsigned int m, /* length of p */
double max_score,
unsigned int * gaps_pos,
unsigned int l,
unsigned int * gaps_len,
unsigned int * where,
unsigned int swap,
unsigned int matrix,
double gap_penalty,
double ext_penalty, int L )
{
FILE * output;
unsigned int min_mis = 0; //the number of mismatches in the alignment
char * seqa; //sequence a with the inserted gaps
unsigned int aa = 0;
unsigned int ii = 0;
char * seqb; //sequence b with the inserted gaps
unsigned int bb = 0;
unsigned int jj = 0;
char * mark_mis; //a string with the mismatches marked as '|' (and the matches as ' ')
unsigned int mm = 0;
unsigned int i;
/* Here we calculate the number of gaps and their total length */
unsigned int numgaps = 0;
unsigned int gapslength = 0;
for ( i = 0; i < l; i ++ )
{
if ( gaps_len[i] > 0 )
{
numgaps++;
gapslength += gaps_len[i];
}
}
//fprintf( stderr, "Score: %.2f Gaps: %d Length: %d\n", max_score, numgaps, gapslength );
/* dynamic memory allocation for the 3 sequences */
if ( ! ( seqa = ( char * ) calloc ( n + gapslength + 1, sizeof ( char ) ) ) )
{
fprintf ( stderr, "Error: seqa could not be allocated!!!\n" );
return ( 0 );
}
if ( ! ( seqb = ( char * ) calloc ( n + gapslength + 1, sizeof ( char ) ) ) )
{
fprintf ( stderr, "Error: seqb could not be allocated!!!\n" );
return ( 0 );
}
if ( ! ( mark_mis = ( char* ) calloc ( n + gapslength + 1, sizeof( char ) ) ) )
{
fprintf ( stderr, "Error: mark_mis could not be allocated!!!\n" );
return ( 0 );
}
/* Here we open the output file */
if ( ! ( output = fopen ( filename, "w" ) ) )
{
fprintf ( stderr, "Error: cannot open file %s!!!\n", filename );
return ( 0 );
}
/* Here we print the header */
print_header ( output, filename, matrix, gap_penalty, ext_penalty, L );
/* Here we go through the gaps to create the 2 sequences */
int g;
unsigned int gapsuma = 0; //currently added gap length in seqa
unsigned int gapsumb = 0; //currently added gap length in seqb
for ( g = numgaps - 1; g >=0; g-- )
{
if ( gaps_len[g] > 0 )
{
unsigned int gpos = gaps_pos[g];
unsigned int glen = gaps_len[g];
if ( where[g] == 1 )
{
/* Add the letters before the gap */
for ( ; ii < gpos; ii++, aa++ )
seqa[aa] = t -> data[ii];
/* Add the gap */
for ( ; aa < ii + gapsuma + glen; aa++ )
seqa[aa] = '-';
gapsuma += glen;
}
if ( where[g] == 2 )
{
/* Add the letters before the gap */
for ( ; jj < gpos; jj++, bb++ )
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:gapsmis,代码行数:101,代码来源:output.c
示例15: readFile
void* readFile(void *arg) {
struct readThreadArgs *rTA = (struct readThreadArgs*) arg;
LASReaderH reader = NULL;
LASHeaderH header = NULL;
LASPointH p = NULL;
unsigned int index = 0;
int read_index = 0;
char *file_name_in = NULL;
int i, j;
while(1) {
file_name_in = NULL;
/*Get next file to read*/
MT_set_lock(&dataLock);
file_name_in = files_name_in[files_in_index];
if (file_name_in == NULL) {
MT_unset_lock(&dataLock);
return NULL;
}
read_index = (files_in_index % rTA->num_read_threads);
files_in_index++;
struct writeT *dataWriteTT = (struct writeT*) malloc(sizeof(struct writeT)*rTA->num_of_entries);
/*Lets read the data*/
reader = LASReader_Create(file_name_in);
if (!reader) {
LASError_Print("Unable to read file");
MT_unset_lock(&dataLock);
exit(1);
}
MT_unset_lock(&dataLock);
header = LASReader_GetHeader(reader);
if (!header) {
LASError_Print("Unable to fetch header for file");
exit(1);
}
if (verbose)
{
print_header(stderr, header, file_name_in);
}
/*Allocate arrays for the columns*/
long num_points = LASHeader_GetPointRecordsCount(header);
for (i = 0; i < rTA->num_of_entries; i++) {
dataWriteTT[i].num_points = num_points;
dataWriteTT[i].values = malloc(entriesType[i]*num_points);
dataWriteTT[i].type = entriesType[i];
}
/*Changes for Oscar's new Morton code function*/
//unsigned int factorX = (unsigned int) (LASHeader_GetOffsetX(header) / LASHeader_GetScaleX(header));
//unsigned int factorY = (unsigned int) (LASHeader_GetOffsetY(header) / LASHeader_GetScaleY(header));
/*Compute factors to add to X and Y and cehck sanity of generated codes*/
double file_scale_x = LASHeader_GetScaleX(header);
double file_scale_y = LASHeader_GetScaleY(header);
double file_scale_z = LASHeader_GetScaleZ(header);
//printf("The scales are x:%lf y:%lf z:%lf\n", file_scale_x, file_scale_y, file_scale_z);
/* scaled offsets to add for the morton encoding */
int64_t factorX = ((int64_t) (LASHeader_GetOffsetX(header) / file_scale_x)) - rTA->global_offset_x;
int64_t factorY = ((int64_t) (LASHeader_GetOffsetY(header) / file_scale_y)) - rTA->global_offset_y;
if (rTA->check)
{
// Check specified scales are like in the LAS file
if (fabs(rTA->scale_x - file_scale_x) > TOLERANCE){
fprintf(stderr, "ERROR: x scale in input file (%lf) does not match specified x scale (%lf)\n",file_scale_x, rTA->scale_x);
exit(1);
}
if (fabs(rTA->scale_y - file_scale_y)
|
请发表评论