这篇教程C++ write_header函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中write_header函数的典型用法代码示例。如果您正苦于以下问题:C++ write_header函数的具体用法?C++ write_header怎么用?C++ write_header使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了write_header函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: main//.........这里部分代码省略......... { case 0: if (!strcmp("mo", long_options[option_index].name)) { opt_multi_out = 1; mo_prefix = optarg; } if (!strcmp("interp", long_options[option_index].name)) { opt_interp_proj = 1; } else if (!strcmp("scale", long_options[option_index].name)) { if (!strcmp("mult", optarg)) opt_scale = SCALE_MULT; else if (!strcmp("diag", optarg)) opt_scale = SCALE_DIAG; else if (!strcmp("none", optarg)) opt_scale = SCALE_NONE; else error("Unrecognized scale type."); } else if (!strcmp("sort", long_options[option_index].name)) { if (!strcmp("ev", optarg)) opt_sort = SORT_EV; else if (!strcmp("lc", optarg)) opt_sort = SORT_LC; else error("Unrecognized sort type."); } else if (!strcmp("header", long_options[option_index].name)) { write_header(err); exit(0); } else if (!strcmp("add-back-mean", long_options[option_index].name)) { opt_add_back_mean = 1; } else if (!strcmp("format", long_options[option_index].name)) {fprintf(err, "/n""#BEGIN INPUT/n""<PixeLens input text line 0>/n""<PixeLens input text line 1>/n"" .../n""<PixeLens input text line n>/n""#END INPUT/n""#BEGIN ENSEM /n""#BEGIN MODEL/n""<point 0>/n""<point 1>/n"" .../n""<point m>/n""#END MODEL/n"" .../n""#END ENSEM/n""/n""Blank lines are allowed and any line beginning with a '#' that is/n""not mentioned above is interpretted as a comment. It may be the case/n""that there are no models. /n""/n"); exit(0);
开发者ID:jpcoles,项目名称:jcode,代码行数:67,
示例2: write_headerconst char * Nes_File_Writer::write_block_header( nes_tag_t tag, long size ){ write_remain = size; return write_header( tag, size );}
开发者ID:Sir-Ironic,项目名称:QuickNES_Core,代码行数:5,
示例3: begin_commentstd::ostream& CPPCodeGenerator::operator ()(std::ostream &os) const{ begin_comment(os); write_header(os); end_comment(os); os << std::endl <<std::endl; std::set< shared_ptr<model::Class> > class_dependencies; m_Class->visit(bind(&CPPCodeGenerator::collect_class_dependencies, this, _1, ref(class_dependencies))); os << "#ifndef J2CPP_INCLUDE_IMPLEMENTATION" << std::endl << std::endl; std::string strIFNDEF=m_Class->get_cxx_include_path(); algorithm::to_upper(strIFNDEF); algorithm::replace_all(strIFNDEF,"/","_"); os << "#ifndef J2CPP_" << strIFNDEF << "_HPP_DECL" << std::endl; os << "#define J2CPP_" << strIFNDEF << "_HPP_DECL" << std::endl; os << std::endl << std::endl; BOOST_FOREACH(shared_ptr<model::Class> dependend_class, class_dependencies) { if(dependend_class==m_Class) continue; std::vector< shared_ptr<model::Entity> > parentEntities; if(shared_ptr<model::Entity> parentEntity=dependend_class->get_parent()) { do { parentEntities.push_back(parentEntity); parentEntity=parentEntity->get_parent(); } while(parentEntity && parentEntity!=m_RootNS); } os << "namespace j2cpp { "; for(std::size_t ns=0;ns<parentEntities.size();++ns) { if(shared_ptr<model::Namespace> enclosingNamespace=shared_ptr<model::Namespace>(parentEntities[parentEntities.size()-ns-1],detail::dynamic_cast_tag())) { os << "namespace " << enclosingNamespace->get_name() << " { "; } else if(shared_ptr<model::Class> enclosingClass=shared_ptr<model::Class>(parentEntities[parentEntities.size()-ns-1],detail::dynamic_cast_tag())) { os << "namespace " << enclosingClass->get_name() << "_ { "; } } os << "class " << dependend_class->get_name() << ";"; for(std::size_t ns=0;ns<parentEntities.size();++ns) os << " }"; os << " }" << std::endl; } os << std::endl << std::endl; std::set<std::string> dependenciesIncludes; BOOST_FOREACH(shared_ptr<model::Class> dependend_class, class_dependencies) { if(dependend_class==m_Class) continue; dependenciesIncludes.insert(dependend_class->get_cxx_include_path()); } BOOST_FOREACH(std::string incPath, dependenciesIncludes) { os << "#include <" << incPath << ".hpp>" << std::endl; }
开发者ID:Laeeth,项目名称:android-cpp-sdk,代码行数:72,
示例4: ordered_map_file_openint ordered_map_file_open(const char *path, OrderedMapFile **out_omf) { *out_omf = nullptr; OrderedMapFile *omf = create_zero<OrderedMapFile>(); if (!omf) { ordered_map_file_close(omf); return GenesisErrorNoMem; } if (omf->queue.error() || omf->cond.error() || omf->mutex.error()) { ordered_map_file_close(omf); return omf->queue.error() || omf->cond.error() || omf->mutex.error(); } omf->list = create_zero<List<OrderedMapFileEntry *>>(); if (!omf->list) { ordered_map_file_close(omf); return GenesisErrorNoMem; } omf->map = create_zero<HashMap<ByteBuffer, OrderedMapFileEntry *, ByteBuffer::hash>>(); if (!omf->map) { ordered_map_file_close(omf); return GenesisErrorNoMem; } omf->running = true; int err = omf->write_thread.start(run_write, omf); if (err) { ordered_map_file_close(omf); return err; } bool open_for_writing = false; omf->file = fopen(path, "rb+"); if (omf->file) { int err = read_header(omf); if (err == GenesisErrorEmptyFile) { open_for_writing = true; } else if (err) { ordered_map_file_close(omf); return err; } } else { open_for_writing = true; } if (open_for_writing) { omf->file = fopen(path, "wb+"); if (!omf->file) { ordered_map_file_close(omf); return GenesisErrorFileAccess; } int err = write_header(omf); if (err) { ordered_map_file_close(omf); return err; } } // read everything into list omf->write_buffer.resize(TRANSACTION_METADATA_SIZE); omf->transaction_offset = UUID_SIZE; for (;;) { size_t amt_read = fread(omf->write_buffer.raw(), 1, TRANSACTION_METADATA_SIZE, omf->file); if (amt_read != TRANSACTION_METADATA_SIZE) { // partial transaction. ignore it and we're done. break; } uint8_t *transaction_ptr = (uint8_t*)omf->write_buffer.raw(); int transaction_size = read_uint32be(&transaction_ptr[4]); omf->write_buffer.resize(transaction_size); transaction_ptr = (uint8_t*)omf->write_buffer.raw(); size_t amt_to_read = transaction_size - TRANSACTION_METADATA_SIZE; amt_read = fread(&transaction_ptr[TRANSACTION_METADATA_SIZE], 1, amt_to_read, omf->file); if (amt_read != amt_to_read) { // partial transaction. ignore it and we're done. break; } uint32_t computed_crc = crc32(0, &transaction_ptr[4], transaction_size - 4); uint32_t crc_from_file = read_uint32be(&transaction_ptr[0]); if (computed_crc != crc_from_file) { // crc check failed. ignore this transaction and we're done. break; } int put_count = read_uint32be(&transaction_ptr[8]); int del_count = read_uint32be(&transaction_ptr[12]); int offset = TRANSACTION_METADATA_SIZE; for (int i = 0; i < put_count; i += 1) { int key_size = read_uint32be(&transaction_ptr[offset]); offset += 4; int val_size = read_uint32be(&transaction_ptr[offset]); offset += 4; OrderedMapFileEntry *entry = create_zero<OrderedMapFileEntry>(); if (!entry) { ordered_map_file_close(omf); return GenesisErrorNoMem; } entry->key = ByteBuffer((char*)&transaction_ptr[offset], key_size); offset += key_size; entry->offset = omf->transaction_offset + offset;//.........这里部分代码省略.........
开发者ID:pabalexa,项目名称:genesis,代码行数:101,
示例5: mainint main(int argc, char *argv[])/********************************************************************** vicNl.c Dag Lohmann January 1996 This program controls file I/O and variable initialization as well as being the primary driver for the model. For details about variables, input files and subroutines check: http://ce.washington.edu/~hydro/Lettenmaier/Models/VIC/VIC_home.html UNITS: unless otherwise marked: all water balance components are in mm all energy balance components are in mks depths, and lengths are in m modifications: 1997-98 Model was updated from simple 2 layer water balance to an extension of the full energy and water balance 3 layer model. KAC 02-27-01 added controls for lake model KAC 11-18-02 Updated storage of lake water for water balance calculations. LCB 03-12-03 Modifed to add AboveTreeLine to soil_con_struct so that the model can make use of the computed treeline. KAC 04-10-03 Modified to initialize storm parameters using the state file. KAC 04-10-03 Modified to start the model by skipping records until the state file date is found. This replaces the previous method of modifying the global file start date, which can change the interpolation of atmospheric forcing data. KAC 04-15-03 Modified to store wet and dry fractions when intializing water balance storage. This accounts for changes in model state initialization, which now stores wet and dry fractions rather than just averagedvalues. KAC 29-Oct-03 Modified the version display banner to print the version string defined in global.h. TJB 01-Nov-04 Updated arglist for make_dist_prcp(), as part of fix for QUICK_FLUX state file compatibility. TJB 02-Nov-04 Updated arglist for read_lakeparam(), as part of fix for lake fraction readjustment. TJB 2005-Apr-13 OUTPUT_FORCE option now calls close_files(). TJB 2006-Sep-23 Implemented flexible output configuration; uses the new out_data, out_data_files, and save_data structures. TJB 2006-Oct-16 Merged infiles and outfiles structs into filep_struct; This included merging builtnames into filenames. TJB 2006-Nov-07 Removed LAKE_MODEL option. TJB 2006-Nov-07 Changed statefile to init_state in call to check_state_file(). TJB 2007-Jan-15 Added PRT_HEADER option; added call to write_header(). TJB 2007-Apr-04 Added option to continue run after a cell fails. GCT/KAC 2007-Apr-21 Added calls to free_dmy(), free_out_data_files(), free_out_data(), and free_veglib(). Added closing of all parameter files. TJB 2007-Aug-21 Return ErrorFlag from initialize_model_state. JCA 2007-Sep-14 Excluded calls to free_veglib() and closing of parameter files other than the soil param file for the case when OUTPUT_FORCE=TRUE. TJB 2007-Nov-06 Moved computation of cell_area from read_lakeparam() to read_soilparam() and read_soilparam_arc(). TJB 2008-May-05 Added prcp fraction (mu) to initial water storage computation. This solves water balance errors for the case where DIST_PRCP is TRUE. TJB 2009-Jan-16 Added soil_con.avgJulyAirTemp to argument list of initialize_atmos(). TJB 2009-Jun-09 Modified to use extension of veg_lib structure to contain bare soil information. TJB 2009-Jul-07 Added soil_con.BandElev[] to read_snowband() arg list. TJB 2009-Jul-31 Replaced references to N+1st veg tile with references to index of lake/wetland tile. TJB 2009-Sep-28 Replaced initial water/energy storage computations and calls to calc_water_balance_error/calc_energy_balance_error with an initial call to put_data. Modified the call to read_snowband(). TJB 2009-Dec-11 Removed save_data structure from argument list of initialize_model_state(). TJB 2010-Mar-31 Added cell_area to initialize_atmos(). TJB 2010-Apr-28 Removed individual soil_con variables from argument list of initialize_atmos() and replaced with *soil_con. TJB 2010-Nov-10 Added closing of state files. TJB 2011-Jan-04 Made read_soilparam_arc() a sub-function of read_soilparam(). TJB 2012-Jan-16 Removed LINK_DEBUG code BN**********************************************************************/{ extern veg_lib_struct *veg_lib; extern option_struct options; extern Error_struct Error; extern global_param_struct global_param; /** Variable Declarations **/ char NEWCELL; char LASTREC; char MODEL_DONE; char RUN_MODEL; char *init_STILL_STORM; char ErrStr[MAXSTRING]; int rec, i, j;//.........这里部分代码省略.........
开发者ID:BeijingNormalUniversity,项目名称:VIC,代码行数:101,
示例6: write_data void write_data( t_uint8 id, t_uint16 data ) { write_header( id, XTYPE_DATA, data ); }
开发者ID:xomniversex,项目名称:foo_gep,代码行数:4,
示例7: write_headervoid VrmlExporter::begin() { file_.open(file_name_, std::ios::out); write_header();}
开发者ID:ptierney,项目名称:MeshConsole,代码行数:4,
示例8: main//.........这里部分代码省略......... /********************************************** * BUILDING THE HMM **********************************************/ /* Build the motif-based HMM. */ if (hmm_type == LINEAR_HMM) { if (order_spacing != NULL) { reorder_motifs(order_spacing, &num_motifs, motifs); } else { die("No order specified for the motifs./n" "For the linear model the motif file must contain motif occurence/n" "data or the motif order must be specified using " "the --order option."); } build_linear_hmm( background, order_spacing, spacer_states, motifs, num_motifs, fim, &the_hmm ); } else if (hmm_type == COMPLETE_HMM) { build_complete_hmm( background, spacer_states, motifs, num_motifs, transp_freq, spacer_ave, fim, &the_hmm ); } else if (hmm_type == STAR_HMM) { build_star_hmm( background, spacer_states, motifs, num_motifs, fim, &the_hmm ); } // Add some global information. copy_string(&(the_hmm->motif_file), meme_filename); /********************************************** * WRITING THE HMM **********************************************/ /* Print the header. */ if (print_header) write_header( program, "", description, meme_filename, NULL, NULL, stdout ); /* Write the HMM. */ write_mhmm(verbosity, the_hmm, stdout); /* Print the program parameters. */ if (print_params) { printf("Program parameters for mhmm/n"); printf(" MEME file: %s/n", meme_filename); printf(" Motifs:"); write_string_list(" ", requested_motifs, stdout); printf("/n"); printf(" Model topology: %s/n", convert_enum_type(hmm_type, HMM_STRS, NUM_HMM_T)); printf(" States per spacer: %d/n", spacer_states); printf(" Spacers are free-insertion modules: %s/n", boolean_to_string(fim)); printf("/n"); } free_array(background); free_string_list(requested_motifs); free_order(order_spacing); free_matrix(transp_freq); free_matrix(spacer_ave); for (i_motif = 0; i_motif < num_motifs; i_motif++) free_motif(&(motifs[i_motif])); free_mhmm(the_hmm); return(0);}
开发者ID:PanosFirmpas,项目名称:gimmemotifs,代码行数:101,
示例9: write_type_header/*=== write_type_header =================================================== * <Description Text> * * Assumes: ? * * Returns: nothing * * Modifies: ? * * Calls: nothing * * Called By: ? * * History: MM/DD/YY MRH Created initial version based on function * 'func()' in motif/csr/file.c */voidwrite_type_header(FILE *header){ char description[512]; FIELD *field; char define_name[80]; /* * Write header comment */ sprintf(description, "/Public interface to the '%s' Abstract Datatype. /This file was automatically generated.", gAPIType); write_header(header, gTypeHeaderName, description); fprintf(header, "#ifndef _%s_/n", gTypeHeaderNameUC); fprintf(header, "#define _%s_/n", gTypeHeaderNameUC); /* * extern "C" if a C++ compiler. */ fprintf(header, "/n#ifdef %s/n", CPLUSPLUS); fprintf(header, "extern /"C/"/n{/n"); fprintf(header, "#endif/n"); /* * #Defines for string lengths of objects. */ sprintf(description, "/n/n/The following are '#define's of the string lengths of each of the %s /field objects.", gAPIType); write_comment(header, 0, description); for (field = gFields; field; field = field->next) { if (field->exclude || (field->join && ! field->is_master_join)) continue; if (field->field_type == FIELD_STRING_TYPE) { sprintf(define_name, "GAL_%s_%s_LEN", gAPINameUC, ((field->has_alias) ? field->alias_uc : field->name_uc)); write_define(header, define_name, field->field_length + 1); } } /* * Insert type prototype. The key is public knowledge. */ sprintf(description, "/n/n/%s provides a unique key interface to the %s abstract datatype.", gAPIKeyType, gAPIType); write_comment(header, 0, description); fprintf(header, "typedef struct _gal_%s_key_data_/n{/n", gAPIName); for (field = gFields; field; field = field->next) if (field->is_key) write_object_field(header, field); fprintf(header, "/n}"); fprintf(header, " %s,/n", gAPIKeyTypeData); fprintf(header, " *%s;/n", gAPIKeyType); /* * extern "C" if a C++ compiler. */ fprintf(header, "/n#ifdef %s/n", CPLUSPLUS); fprintf(header, "}/n"); fprintf(header, "#endif/n/n"); fprintf(header, "#endif /* #ifndef _%s_ *//n", gTypeHeaderNameUC);}
开发者ID:huilang22,项目名称:Projects,代码行数:92,
示例10: cipher_filter_cfb/* * This filter is used to en/de-cipher data with a symmetric algorithm */intcipher_filter_cfb (void *opaque, int control, iobuf_t a, byte *buf, size_t *ret_len){ cipher_filter_context_t *cfx = opaque; size_t size = *ret_len; int rc = 0; if (control == IOBUFCTRL_UNDERFLOW) /* decrypt */ { rc = -1; /* not yet used */ } else if (control == IOBUFCTRL_FLUSH) /* encrypt */ { log_assert (a); if (!cfx->wrote_header) write_header (cfx, a); if (cfx->mdc_hash) gcry_md_write (cfx->mdc_hash, buf, size); gcry_cipher_encrypt (cfx->cipher_hd, buf, size, NULL, 0); if (cfx->short_blklen_warn) { cfx->short_blklen_count += size; if (cfx->short_blklen_count > (150 * 1024 * 1024)) { log_info ("WARNING: encrypting more than %d MiB with algorithm " "%s should be avoided/n", 150, openpgp_cipher_algo_name (cfx->dek->algo)); cfx->short_blklen_warn = 0; /* Don't show again. */ } } rc = iobuf_write (a, buf, size); } else if (control == IOBUFCTRL_FREE) { if (cfx->mdc_hash) { byte *hash; int hashlen = gcry_md_get_algo_dlen (gcry_md_get_algo(cfx->mdc_hash)); byte temp[22]; log_assert (hashlen == 20); /* We must hash the prefix of the MDC packet here. */ temp[0] = 0xd3; temp[1] = 0x14; gcry_md_putc (cfx->mdc_hash, temp[0]); gcry_md_putc (cfx->mdc_hash, temp[1]); gcry_md_final (cfx->mdc_hash); hash = gcry_md_read (cfx->mdc_hash, 0); memcpy(temp+2, hash, 20); gcry_cipher_encrypt (cfx->cipher_hd, temp, 22, NULL, 0); gcry_md_close (cfx->mdc_hash); cfx->mdc_hash = NULL; if (iobuf_write( a, temp, 22)) log_error ("writing MDC packet failed/n"); } gcry_cipher_close (cfx->cipher_hd); } else if (control == IOBUFCTRL_DESC) { mem2str (buf, "cipher_filter_cfb", *ret_len); } return rc;}
开发者ID:larryv,项目名称:gnupg,代码行数:70,
示例11: write_arduino_code_verbose/* Same as write_arduino_code(), but uses the verbose versions of functions */void write_arduino_code_verbose(FILE *output_file, MuxPipe *pipes, size_t total_pipes){ write_header(output_file); write_setup_verbose(output_file, pipes, total_pipes); write_loop_verbose(output_file);}
开发者ID:Chobbes,项目名称:HubGen,代码行数:7,
示例12: gzip/* =========================================================================== Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb"). The file is given either by file descriptor or path name (if fd == -1). az_open returns NULL if the file could not be opened or if there was insufficient memory to allocate the (de)compression state; errno can be checked to distinguish the two cases (if errno is zero, the zlib error is Z_MEM_ERROR).*/int az_open (azio_stream *s, const char *path, int Flags, File fd){ int err; int level = Z_DEFAULT_COMPRESSION; /* compression level */ int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ s->stream.zalloc = (alloc_func)0; s->stream.zfree = (free_func)0; s->stream.opaque = (voidpf)0; memset(s->inbuf, 0, AZ_BUFSIZE_READ); memset(s->outbuf, 0, AZ_BUFSIZE_WRITE); s->stream.next_in = s->inbuf; s->stream.next_out = s->outbuf; s->stream.avail_in = s->stream.avail_out = 0; s->z_err = Z_OK; s->z_eof = 0; s->in = 0; s->out = 0; s->back = EOF; s->crc = crc32(0L, Z_NULL, 0); s->transparent = 0; s->mode = 'r'; s->version = (unsigned char)az_magic[1]; /* this needs to be a define to version */ s->minor_version= (unsigned char) az_magic[2]; /* minor version */ s->dirty= AZ_STATE_CLEAN; /* We do our own version of append by nature. We must always have write access to take card of the header. */ DBUG_ASSERT(Flags | O_APPEND); DBUG_ASSERT(Flags | O_WRONLY); if (Flags & O_RDWR) s->mode = 'w'; if (s->mode == 'w') { err = deflateInit2(&(s->stream), level, Z_DEFLATED, -MAX_WBITS, 8, strategy); /* windowBits is passed < 0 to suppress zlib header */ s->stream.next_out = s->outbuf; if (err != Z_OK) { destroy(s); return Z_NULL; } } else { s->stream.next_in = s->inbuf; err = inflateInit2(&(s->stream), -MAX_WBITS); /* windowBits is passed < 0 to tell that there is no zlib header. * Note that in this case inflate *requires* an extra "dummy" byte * after the compressed stream in order to complete decompression and * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are * present after the compressed stream. */ if (err != Z_OK) { destroy(s); return Z_NULL; } } s->stream.avail_out = AZ_BUFSIZE_WRITE; errno = 0; s->file = fd < 0 ? my_open(path, Flags, MYF(0)) : fd; if (s->file < 0 ) { destroy(s); return Z_NULL; } if (Flags & O_CREAT || Flags & O_TRUNC) { s->rows= 0; s->forced_flushes= 0; s->shortest_row= 0; s->longest_row= 0; s->auto_increment= 0; s->check_point= 0; s->comment_start_pos= 0; s->comment_length= 0; s->frm_start_pos= 0; s->frm_length= 0; s->dirty= 1; /* We create the file dirty */ s->start = AZHEADER_SIZE + AZMETA_BUFFER_SIZE; write_header(s); my_seek(s->file, 0, MY_SEEK_END, MYF(0));//.........这里部分代码省略.........
开发者ID:Ihon,项目名称:mysql-5.5-debian,代码行数:101,
示例13: print_data_button/*######################### print_data_button() #########################*/voidprint_data_button(Widget w, XtPointer client_data, XtPointer call_data){ char message[MAX_MESSAGE_LENGTH], sum_sep_line[MAX_OUTPUT_LINE_LENGTH + SHOW_LONG_FORMAT + 1]; /* Prepare separator line. */ (void)memset(sum_sep_line, '=', sum_line_length); sum_sep_line[sum_line_length] = '/0'; if (range_type == SELECTION_TOGGLE) { int no_selected, *select_list; if (XmListGetSelectedPos(listbox_w, &select_list, &no_selected) == False) { show_message(statusbox_w, "No data selected for printing!"); XtPopdown(printshell); return; } else { int fd, prepare_status; char *line, line_buffer[256]; XmStringTable all_items; if (device_type == PRINTER_TOGGLE) { prepare_status = prepare_printer(&fd); } else { prepare_status = prepare_file(&fd, (device_type == MAIL_TOGGLE) ? 0 : 1); if ((prepare_status != SUCCESS) && (device_type == MAIL_TOGGLE)) { prepare_tmp_name(); prepare_status = prepare_file(&fd, 1); } } if (prepare_status == SUCCESS) { register int i, length; write_header(fd, sum_sep_line); XtVaGetValues(listbox_w, XmNitems, &all_items, NULL); for (i = 0; i < no_selected; i++) { XmStringGetLtoR(all_items[select_list[i] - 1], XmFONTLIST_DEFAULT_TAG, &line); length = sprintf(line_buffer, "%s/n", line); if (write(fd, line_buffer, length) != length) { (void)fprintf(stderr, "write() error : %s (%s %d)/n", strerror(errno), __FILE__, __LINE__); XtFree(line); exit(INCORRECT); } XtFree(line); XmListDeselectPos(listbox_w, select_list[i]); } write_summary(fd, sum_sep_line); /* * Remember to insert the correct summary, since all files * have now been deselected. */ (void)strcpy(summary_str, total_summary_str); SHOW_SUMMARY_DATA(); if (device_type == PRINTER_TOGGLE) { int status; char buf; /* Send Control-D to printer queue. */ buf = CONTROL_D; if (write(fd, &buf, 1) != 1) { (void)fprintf(stderr, "write() error : %s (%s %d)/n", strerror(errno), __FILE__, __LINE__); XtFree(line); exit(INCORRECT); } if ((status = pclose(fp)) < 0) { (void)sprintf(message, "Failed to send printer command (%d) : %s", status, strerror(errno)); } else { (void)sprintf(message, "Send job to printer (%d)", status); }//.........这里部分代码省略.........
开发者ID:hfs,项目名称:afd,代码行数:101,
示例14: BX_DEBUG/* This could be done much better, I'm sure. In fact, the whole header doesn't * need to be re-written each time a new tlb is allocated nor does the whole * slb need to be re-written (most of the time) but that can be changed whenever * it becomes an issue... image I/O is not a bottleneck. */bool vmware3_image_t::sync(){ if(current->synced) return true; unsigned relative_offset = (unsigned)(current->offset - current->min_offset); unsigned i = relative_offset >> FL_SHIFT; unsigned j = (relative_offset & ~FL_MASK) / tlb_size; if (current->slb[i][j] == 0) { if (current->flb[i] == 0) { unsigned slb_size = slb_count * 4; /* Re-write the FLB */ current->flb[i] = current->header.next_sector_to_allocate; if(::lseek(current->fd, current->header.flb_offset_sectors * 512, SEEK_SET) < 0) { BX_DEBUG(("could not seek vmware3 COW image to flb on sync")); return false; } if(write_ints(current->fd, current->flb, current->header.flb_count) < 0) { BX_DEBUG(("could not re-write flb to vmware3 COW image on sync")); return false; } current->header.next_sector_to_allocate += (slb_size / 512) + ((slb_size % 512) ? 1 : 0); } /* Re-write the SLB */ current->slb[i][j] = current->header.next_sector_to_allocate; if(::lseek(current->fd, current->flb[i] * 512, SEEK_SET) < 0) { BX_DEBUG(("could not seek vmware3 COW image to slb on sync")); return false; } if(write_ints(current->fd, current->slb[i], slb_count) < 0) { BX_DEBUG(("could not re-write slb to vmware3 COW image on sync")); return false; } current->header.next_sector_to_allocate += current->header.tlb_size_sectors; /* Update the header */ if(::lseek(current->fd, 0, SEEK_SET) < 0) { BX_DEBUG(("could not seek to vmware3 COW image to offset 0 on sync")); return false; } if(write_header(current->fd, current->header) < 0) { BX_DEBUG(("could not re-write header to vmware3 COW image on sync")); return false; } } if(::lseek(current->fd, current->slb[i][j] * 512, SEEK_SET) < 0) { BX_DEBUG(("could not seek vmware3 COW image to offset %d on sync", current->slb[i][j] * 512)); return false; } if(::write(current->fd, current->tlb, tlb_size) < 0) { BX_DEBUG(("could not write tlb to vmware3 COW image on sync")); return false; } current->synced = true; return true;}
开发者ID:iver6,项目名称:BA,代码行数:74,
示例15: csa_new_from_bwt//.........这里部分代码省略......... if (csa.D >= csa.n) { printf("D=%d >= n=%ld/n",csa.D,csa.n); exit(0); } if (csa.D2 >= csa.n) { printf("D2=%d >= n=%ld/n",csa.D2,csa.n); exit(0); } if (idx_id >= 0) { n = csa.n; k = csa.k; //// compute SA and ISA if (csa.D > 0) csa.SA = (uchar *) mymalloc(((n-1)/csa.D+1+1)*k); if (csa.D2 > 0) csa.ISA = (uchar *) mymalloc(((n-1)/csa.D2+1+1)*k); if (csa.D == 0 && csa.D2 == 0) goto brk; switch (psi_id & 0x3f) { case ID_DIFF_GAMMA: case ID_DIFF_GAMMA_RL: case ID_DIFF_GAMMA_SPARSE: case ID_DIFF_GAMMA_RL_SPARSE: case ID_SPARSE4: case ID_DIFF_GAMMA_RR: j = 0; for (i=0; i<=n; i++) { display_progressbar("making sa ",i,n); j = csa.psi(&csa,j); // sa[j] = i; if (csa.D > 0 && j % csa.D == 0) { putuint(csa.SA,j / csa.D,i,k); } if (csa.D2 > 0 && i % csa.D2 == 0) { putuint(csa.ISA,i / csa.D2,j,k); } } // putuint(csa.SA,0,n,k); break; case ID_BWT_DNA: case ID_BWT_BIT: case ID_BWT_WT: case ID_BWT_WT_HUF: case ID_BWT_WT_DENSE: case ID_BWT_WT_SPARSE4: case ID_BWT_WT_RR: case ID_BWT_HUF: j = 0; for (i=n-1; i>=0; i--) { display_progressbar("making sa ",i,n); v = csa.LF(&csa,j); // printf("LF[%ld] = %ld/n",j,v); j = v; if (csa.D > 0 && j % csa.D == 0) putuint(csa.SA, j/csa.D , i, k); if (csa.D2 > 0 && i % csa.D2 == 0) putuint(csa.ISA, i/csa.D2, j, k); } putuint(csa.SA,0,n,k); break; default: break; }brk: //// write idx f2 = fopen(fidx,"wb"); /* directory */ if (f2 == NULL) { perror("csa2_new1: "); exit(1); } isize = 0; writeint(4,VERSION,f2); /* version */ isize += 4; writeint(1,ID_HEADER,f2); // header ID isize += 1; isize = write_header(&csa, f2, isize); if (csa.D > 0) { writeint(1,ID_SA,f2); isize += 1; isize = write_sa(&csa, f2, isize); } if (csa.D2 > 0) { writeint(1,ID_ISA,f2); isize += 1; isize = write_isa(&csa, f2, isize); } fclose(f2); if (csa.D > 0) free(csa.SA); if (csa.D2 > 0) free(csa.ISA); printf("Total %ld bytes (%1.3f bpc)/n",(psize+isize), (double)(psize+isize)*8/csa.n); } free(fidx);}
开发者ID:josator,项目名称:gnu-bwt-aligner,代码行数:101,
示例16: write_header/**@details-# This restart is targetted at DMTCP restarts where we only need to rewrite the header.*/int Trick::DataRecordGroup::dmtcp_restart() { return write_header() ;}
开发者ID:lonnell,项目名称:trick,代码行数:7,
示例17: write_headervoid SamWriter::add_header(const SamHeader& header) { m_header = header; write_header();}
开发者ID:droazen,项目名称:gamgee,代码行数:4,
示例18: main/** * @brief In the main we can choose these options without any argument: * c for compress, d for decompress, h for help, v for verbose; * and these options with the relative argument: * i with the name of the input file, o with the name of the output file and * s with the size of the dictionary. */int main(int argc, char *argv []) { int fd, s = 0, v = 0, compr = 0, h = 0; //compr is set to 1 if we want to compress, set to 2 if we want to decompress char *source = NULL, *dest = NULL; unsigned int dict_size = DICT_SIZE, d_dict_size; struct bitio *fd_bitio; int opt; while ((opt = getopt(argc,argv,"cdhvi:o:s:")) != -1) { switch (opt) { case 'c': compr = (compr==2?compr:1); break; case 'd': compr = (compr==1?compr:2); break; case 'i': source = optarg; //take the input name from optarg break; case 'o': dest = optarg; //take the output name from optarg break; case 's': dict_size = atoi(optarg); s = 1; break; case 'h': h = 1; print_help(); break; case 'v': v = 1; break; case '?': if(optopt == 'i'){ fprintf(stderr,"An input file is required/n"); exit(1); } else if (optopt == 'o'){ fprintf(stderr,"No name specified for destination file/n"); exit(1); } else if (optopt == 's'){ fprintf(stderr,"No dimension specified for dictionary size/n"); exit(1); } else { fprintf(stderr,"Try -h for help/n"); exit(1); } break; default: fprintf(stderr,"Try -h for help/n"); exit(1); } //switch (opt) } //while () /* Checking if either -d or -c option has been set */ if (compr == 0 && h == 0) { fprintf(stderr, "Error: you must specify either -c to compress or -d to decompress/n"); print_help(); exit(1); } if(compr == 1) { //compressing if ((fd = open(source, O_RDONLY)) < 0) { perror("Error opening file in read mode: "); exit(1); } if ((fd_bitio = bitio_open(dest, 'w')) == NULL) { perror("Error opening file in write mode: "); close(fd); exit(1); } if (dict_size < 512) { //fprintf(stderr, "Warning: for better results, you should use a dictionary size greater than 512 elements./nThe dictionary size has been set to 512/n"); //dict_size = 512; } write_header(fd,fd_bitio,source,dict_size); if(v == 1){ printf("Compressing.../n"); } compress(fd,fd_bitio,dict_size,v); if (v == 1){ printf("Compress completed/n"); } } //if (compr == 1) if (compr == 2) { //decompressing if (s == 1) { //if s is set on the decompressor we return an error fprintf(stderr,"Error on specifying dictionary size/n"); exit(1); } if ((fd = open (dest, (O_CREAT | O_TRUNC | O_WRONLY) , 0666)) < 0) { perror("Error opening file in write mode: "); exit(1);//.........这里部分代码省略.........
开发者ID:LoBiagio,项目名称:LZ78,代码行数:101,
示例19: write_int void write_int( t_uint8 id, t_uint32 value ) { write_header( id, XTYPE_INT, 4 ); m_file->write_lendian_t( value, m_abort ); }
开发者ID:xomniversex,项目名称:foo_gep,代码行数:5,
示例20: write_av_packetint write_av_packet(AppContext *para, am_packet_t *pkt){ int write_bytes = 0, len = 0, ret; unsigned char *buf; int size ; if (pkt->avpkt_newflag) { if (pkt->type != CODEC_SUBTITLE) { if (pkt->avpkt_isvalid) { ret = check_in_pts(para, pkt); if (ret != PLAYER_SUCCESS) { log_error("check in pts failed/n"); return PLAYER_WR_FAILED; } } if (write_header(para, pkt) == PLAYER_WR_FAILED) { log_error("[%s]write header failed!/n", __FUNCTION__); return PLAYER_WR_FAILED; } } else { // process_es_subtitle(para, pkt); } pkt->avpkt_newflag = 0; } buf = pkt->data; size = pkt->data_size ; if (size == 0 && pkt->avpkt_isvalid) { if ((pkt->type == CODEC_VIDEO)) { para->write_size.vpkt_num++; } if (pkt->avpkt) { av_free_packet(pkt->avpkt); } pkt->avpkt_isvalid = 0; } while (size > 0 && pkt->avpkt_isvalid) { write_bytes = codec_write(pkt->codec, (char *)buf, size); if (write_bytes < 0 || write_bytes > size) { if (-errno != AVERROR(EAGAIN)) { para->playctrl_info.check_lowlevel_eagain_cnt = 0; log_print("write codec data failed!/n"); return PLAYER_WR_FAILED; } else { // EAGAIN to see if buffer full or write time out too much if (check_avbuffer_enough(para, pkt)) { para->playctrl_info.check_lowlevel_eagain_cnt++; } else { para->playctrl_info.check_lowlevel_eagain_cnt = 0; } if (para->playctrl_info.check_lowlevel_eagain_cnt > 50) { // reset decoder para->playctrl_info.check_lowlevel_eagain_cnt = 0; para->playctrl_info.reset_flag = 1; para->playctrl_info.end_flag = 1; if (para->state.start_time != -1) { para->playctrl_info.time_point = (para->state.pts_video - para->state.start_time)/ PTS_FREQ; } else { para->playctrl_info.time_point = para->state.pts_video/ PTS_FREQ; } log_print("$$$$$$[type:%d] write blocked, need reset decoder!$$$$$$/n", pkt->type); } pkt->data += len; pkt->data_size -= len; usleep(RW_WAIT_TIME); if (para->playctrl_info.check_lowlevel_eagain_cnt > 0) { log_print("[%s]eagain:data_size=%d type=%d rsize=%lld wsize=%lld cnt=%d/n", / __FUNCTION__, pkt->data_size, pkt->type, para->read_size.total_bytes, / para->write_size.total_bytes, para->playctrl_info.check_lowlevel_eagain_cnt); } return PLAYER_SUCCESS; } } else { para->playctrl_info.check_lowlevel_eagain_cnt = 0; len += write_bytes; if (len == pkt->data_size) { if ((pkt->type == CODEC_VIDEO)) { para->write_size.vpkt_num++; } if (pkt->avpkt) { av_free_packet(pkt->avpkt); } pkt->avpkt_isvalid = 0; pkt->data_size = 0; //log_print("[%s:%d]write finish pkt->data_size=%d/r",__FUNCTION__, __LINE__,pkt->data_size); break; } else if (len < pkt->data_size) { buf += write_bytes; size -= write_bytes; } else { return PLAYER_WR_FAILED; } } } if (check_write_finish(para, pkt) == PLAYER_WR_FINISH) { return PLAYER_WR_FINISH; }//.........这里部分代码省略.........
开发者ID:achellies,项目名称:xbmc-android-old,代码行数:101,
示例21: merge_log/*---------------------------------------------------------------------------*/static intmerge_log(coffee_page_t file_page, int extend){ struct file_header hdr, hdr2; int fd, n; cfs_offset_t offset; coffee_page_t max_pages; struct file *new_file; int i; read_header(&hdr, file_page); fd = cfs_open(hdr.name, CFS_READ); if(fd < 0) { return -1; } /* * The reservation function adds extra space for the header, which has * already been accounted for in the previous reservation. */ max_pages = hdr.max_pages << extend; new_file = reserve(hdr.name, max_pages, 1, 0); if(new_file == NULL) { cfs_close(fd); return -1; } offset = 0; do { char buf[hdr.log_record_size == 0 ? COFFEE_PAGE_SIZE : hdr.log_record_size]; n = cfs_read(fd, buf, sizeof(buf)); if(n < 0) { remove_by_page(new_file->page, !REMOVE_LOG, !CLOSE_FDS, ALLOW_GC); cfs_close(fd); return -1; } else if(n > 0) { COFFEE_WRITE(buf, n, absolute_offset(new_file->page, offset)); offset += n; } } while(n != 0); for(i = 0; i < COFFEE_FD_SET_SIZE; i++) { if(coffee_fd_set[i].flags != COFFEE_FD_FREE && coffee_fd_set[i].file->page == file_page) { coffee_fd_set[i].file = new_file; new_file->references++; } } if(remove_by_page(file_page, REMOVE_LOG, !CLOSE_FDS, !ALLOW_GC) < 0) { remove_by_page(new_file->page, !REMOVE_LOG, !CLOSE_FDS, !ALLOW_GC); cfs_close(fd); return -1; } /* Copy the log configuration and the EOF hint. */ read_header(&hdr2, new_file->page); hdr2.log_record_size = hdr.log_record_size; hdr2.log_records = hdr.log_records; write_header(&hdr2, new_file->page); new_file->flags &= ~COFFEE_FILE_MODIFIED; new_file->end = offset; cfs_close(fd); return 0;}
开发者ID:zzuzpb,项目名称:contiki-2.7-xc8,代码行数:70,
示例22: main//.........这里部分代码省略......... } if ( handle->num_fonts == 0 ) PanicZ( "could not open any font file" ); display = FTDemo_Display_New( gr_pixel_mode_gray, status.width, status.height ); display->back_color.value = 0; display->fore_color.value = 0xff; if ( !display ) PanicZ( "could not allocate display surface" ); grSetTitle( display->surface, "FreeType String Viewer - press ? for help" ); event_gamma_change( 0 ); event_font_change( 0 ); status.header = 0; for ( ;; ) { FTDemo_Display_Clear( display ); switch ( status.render_mode ) { case RENDER_MODE_STRING: status.sc.center = 1L << 15; error = FTDemo_String_Draw( handle, display, &status.sc, display->bitmap->width / 2, display->bitmap->rows / 2 ); break; case RENDER_MODE_KERNCMP: { FTDemo_String_Context sc = status.sc; FT_Int x, y; FT_Int height; x = 55; height = ( status.ptsize * status.res / 72 + 32 ) >> 6; if ( height < CELLSTRING_HEIGHT ) height = CELLSTRING_HEIGHT; /* First line: none */ sc.center = 0; sc.kerning_mode = 0; sc.kerning_degree = 0; sc.vertical = 0; sc.matrix = NULL; y = CELLSTRING_HEIGHT * 2 + display->bitmap->rows / 4 + height; grWriteCellString( display->bitmap, 5, y - ( height + CELLSTRING_HEIGHT ) / 2, "none", display->fore_color ); error = FTDemo_String_Draw( handle, display, &sc, x, y ); /* Second line: track kern only */ sc.kerning_degree = status.sc.kerning_degree; y += height; grWriteCellString( display->bitmap, 5, y - ( height + CELLSTRING_HEIGHT ) / 2, "track", display->fore_color ); error = FTDemo_String_Draw( handle, display, &sc, x, y ); /* Third line: track kern + pair kern */ sc.kerning_mode = status.sc.kerning_mode; y += height; grWriteCellString( display->bitmap, 5, y - ( height + CELLSTRING_HEIGHT ) / 2, "both", display->fore_color ); error = FTDemo_String_Draw( handle, display, &sc, x, y ); } break; } if ( !error && status.sc.gamma_ramp ) gamma_ramp_draw( status.gamma_ramp, display->bitmap ); write_header( error ); status.header = 0; grListenSurface( display->surface, 0, &event ); if ( Process_Event( &event ) ) break; } printf( "Execution completed successfully./n" ); FTDemo_Display_Done( display ); FTDemo_Done( handle ); exit( 0 ); /* for safety reasons */ /* return 0; */ /* never reached */ }
开发者ID:tamaskenez,项目名称:freetype2-demos,代码行数:101,
示例23: au_rewritestatic int au_rewrite(struct ast_filestream *s, const char *comment){ if (write_header(s->f)) return -1; return 0;}
开发者ID:axiatp,项目名称:asterisk,代码行数:6,
示例24: gen_multy_bakup_files//.........这里部分代码省略......... hdr_rec.fl_name[indx] = BLANK; FILE_DESC output_fl_desc = 0; bool end_of_input = false, flush_done = false; const TEXT* file_name = NULL; SLONG io_size = 0; b_fil* fl_ptr = file_list; SINT64 byte_read = 0; SINT64 file_size = 0; while (true) { if (fl_ptr != NULL) { byte_read = 0; byte_write = 0; if (!fl_ptr->b_fil_next && (fl_ptr->b_fil_size == 0)) { fl_ptr->b_fil_size = MIN_FILE_SIZE; } file_size = fl_ptr->b_fil_size - header_rec_len; file_name = fl_ptr->b_fil_name; output_fl_desc = open_platf(file_name, 1); if (output_fl_desc == INVALID_HANDLE_VALUE) { free(io_buffer); fprintf(stderr, "can not open back up file %s/n", file_name); return FB_FAILURE; } ret_cd = write_header(fl_ptr, hdr_rec, output_fl_desc, header_str); if (ret_cd == FB_FAILURE) { free(io_buffer); fprintf(stderr, "could not write header record to file %s/n", file_name); return FB_FAILURE; } fl_ptr = fl_ptr->b_fil_next; } if (file_size < IO_BUFFER_SIZE) io_size = (SLONG) file_size; else io_size = IO_BUFFER_SIZE; if (!fl_ptr) { while (!end_of_input) { ret_cd = final_read_and_write(input_file_desc, output_fl_desc, file_name, io_size, &io_buffer, &end_of_input); if (ret_cd == FB_FAILURE) { free(io_buffer); return FB_FAILURE; } if (end_of_input) { free(io_buffer); return FB_SUCCESS; }
开发者ID:sukumarb,项目名称:firebird,代码行数:67,
示例25: gl_error//.........这里部分代码省略......... group_recorder requires a filename. If none is provided, a filename will be generated using a combination of the classname and the core-assigned ID number. */ } } // check valid write interval write_interval = (int64)(dInterval); if(-1 > write_interval){ gl_error("group_recorder::init(): invalid write_interval of %i, must be -1 or greater", write_interval); /* TROUBLESHOOT The group_recorder interval must be -1, 0, or a positive number of seconds. */ return 0; } // all flush intervals are valid flush_interval = (int64)dFlush_interval; // build group // * invariant? // * non-empty set? items = gl_find_objects(FL_GROUP, group_def); if(0 == items){ if(strict){ gl_error("group_recorder::init(): unable to construct a set with group definition"); /* TROUBLESHOOT An error occured while attempting to build and populate the find list with the specified group definition. */ return 0; } else { gl_warning("group_recorder::init(): unable to construct a set with group definition"); tape_status = TS_ERROR; return 1; // nothing more to do } } if(1 > items->hit_count){ if(strict){ gl_error("group_recorder::init(): the defined group returned an empty set"); /* TROUBLESHOOT Placeholder. */ return 0; } else { gl_warning("group_recorder::init(): the defined group returned an empty set"); tape_status = TS_ERROR; return 1; } } // open file rec_file = fopen(filename, "w"); if(0 == rec_file){ if(strict){ gl_error("group_recorder::init(): unable to open file '%s' for writing", filename); return 0; } else { gl_warning("group_recorder::init(): unable to open file '%s' for writing", filename); /* TROUBLESHOOT If the group_recorder cannot open the specified output file, it will */ tape_status = TS_ERROR; return 1; } } // turn list into objlist, count items obj_count = 0; for(gr_obj = gl_find_next(items, 0); gr_obj != 0; gr_obj = gl_find_next(items, gr_obj) ){ prop_ptr = gl_get_property(gr_obj, property_name); // might make this a 'strict-only' issue in the future if(prop_ptr == NULL){ gl_error("group_recorder::init(): unable to find property '%s' in an object of type '%s'", property_name, gr_obj->oclass->name); /* TROUBLESHOOT An error occured while reading the specified property in one of the objects. */ return 0; } ++obj_count; if(obj_list == 0){ obj_list = new quickobjlist(gr_obj, prop_ptr); } else { obj_list->tack(gr_obj, prop_ptr); } } tape_status = TS_OPEN; if(0 == write_header()){ gl_error("group_recorder::init(): an error occured when writing the file header"); /* TROUBLESHOOT Unexpected IO error. */ tape_status = TS_ERROR; return 0; } return 1;}
开发者ID:devendrashelar7,项目名称:gridnetd,代码行数:101,
注:本文中的write_header函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ write_history函数代码示例 C++ write_full函数代码示例 |