void init() { char buf[PNG_BYTES_TO_CHECK]; // read in some of the signature bytes io_error_if( fread( buf, 1, PNG_BYTES_TO_CHECK, get() ) != detail::PNG_BYTES_TO_CHECK, "png_check_validity: fail to read file" ); // compare the first PNG_BYTES_TO_CHECK bytes of the signature. io_error_if( png_sig_cmp( (png_bytep)buf, (png_size_t)0, detail::PNG_BYTES_TO_CHECK ) != 0, "png_check_validity: invalid png file" ); _png_ptr = png_create_read_struct( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL ); io_error_if( _png_ptr == NULL, "png_get_file_size: fail to call png_create_write_struct()" ); // allocate/initialize the image information data _info_ptr = png_create_info_struct( _png_ptr ); if( _info_ptr == NULL ) { png_destroy_read_struct( &_png_ptr, png_infopp_NULL, png_infopp_NULL ); io_error( "png_get_file_size: fail to call png_create_info_struct()" ); } if( setjmp( png_jmpbuf( _png_ptr ) ) ) { //free all of the memory associated with the png_ptr and info_ptr png_destroy_read_struct( &_png_ptr, &_info_ptr, png_infopp_NULL ); io_error( "png_get_file_size: fail to call setjmp()" ); } png_init_io( _png_ptr, get() ); png_set_sig_bytes( _png_ptr, PNG_BYTES_TO_CHECK ); png_read_info( _png_ptr, _info_ptr ); if( little_endian() && png_get_bit_depth( _png_ptr, _info_ptr ) > 8 ) png_set_swap( _png_ptr ); }
stPlainDiskPageManager::stPlainDiskPageManager(const char * fName){ tHeader tmpHeader; // Open file fd = open(fName, O_RDWR|O_BINARY); // Open file if (fd < 0){ throw io_error("Unable to open file."); }//end if // Validate file if ((read(fd, &tmpHeader, sizeof(tmpHeader)) != sizeof(tmpHeader)) || (!IsValidHeader(&tmpHeader))){ throw io_error("invalid file."); }//end if // WARNING!!! If you don't undertand what is going on here, see the // stLockablePage documentation for further info. // Ok, now I must reload the header again. I can not use this->headerPage = new stLockablePage(tmpHeader.PageSize, sizeof(tHeader), 0); this->header = (tHeader *)(this->headerPage->GetTrueData()); // Transfer tmpHeader to header page because I don't like seeks... memcpy((void*)this->headerPage->GetTrueData(), &tmpHeader, sizeof(tHeader)); // Load rest of the header. if (read(fd, (void *)this->headerPage->GetData(), (int)this->headerPage->GetPageSize()) != (int)this->headerPage->GetPageSize()){ delete headerPage; throw io_error("invalid file."); }//end if // Page cache pageInstanceCache = new stPageInstanceCache(STDISKPAGEMANAGER_INSTANCECACHESIZE, new stPageAllocator(header->PageSize)); }//end stPlainDiskPageManager::stPlainDiskPageManager
complex float* create_cfl(const char* name, unsigned int D, const long dimensions[D]) { io_register_output(name); const char *p = strrchr(name, '.'); if ((NULL != p) && (p != name) && (0 == strcmp(p, ".ra"))) return create_zra(name, D, dimensions); if ((NULL != p) && (p != name) && (0 == strcmp(p, ".coo"))) return create_zcoo(name, D, dimensions); char name_bdy[1024]; if (1024 <= snprintf(name_bdy, 1024, "%s.cfl", name)) io_error("Creating cfl file %s", name); char name_hdr[1024]; if (1024 <= snprintf(name_hdr, 1024, "%s.hdr", name)) io_error("Creating cfl file %s", name); int ofd; if (-1 == (ofd = open(name_hdr, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR))) io_error("Creating cfl file %s", name); if (-1 == write_cfl_header(ofd, D, dimensions)) io_error("Creating cfl file %s", name); if (-1 == close(ofd)) io_error("Creating cfl file %s", name); return shared_cfl(D, dimensions, name_bdy); }
complex float* create_zra(const char* name, unsigned int D, const long dims[D]) { int ofd; if (-1 == (ofd = open(name, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR))) io_error("Creating ra file %s", name); if (-1 == write_ra(ofd, D, dims)) io_error("Creating ra file %s", name); long T = md_calc_size(D, dims) * sizeof(complex float); off_t header_size; if (-1 == (header_size = lseek(ofd, 0, SEEK_CUR))) io_error("Creating ra file %s", name); void* data; if (NULL == (data = create_data(ofd, header_size, T))) io_error("Creating ra file %s", name); if (-1 == close(ofd)) io_error("Creating ra file %s", name); return (complex float*)data; }
HFSBTree::HFSBTree(std::shared_ptr<HFSFork> fork, CacheZone* zone, const char* cacheTag) : m_fork(fork) { BTNodeDescriptor desc0; //std::cout << "Tree size: " << fork->length() << std::endl; m_reader.reset(new CachedReader(m_fork, zone, cacheTag)); if (m_reader->read(&desc0, sizeof(desc0), 0) != sizeof(desc0)) throw io_error("Failed to read BTNodeDescriptor zero"); if (desc0.kind != NodeKind::kBTHeaderNode) throw io_error("Wrong kind of BTree header"); if (m_reader->read(&m_header, sizeof(m_header), sizeof(desc0)) != sizeof(m_header)) throw io_error("Failed to read BTHeaderRec"); //std::cout << "leaf records: " << be(m_header.leafRecords) << std::endl; //std::cout << "node size: " << be(m_header.nodeSize) << std::endl; //std::cout << "first leaf node: " << be(m_header.firstLeafNode) << std::endl; //std::cout << "last leaf node: " << be(m_header.lastLeafNode) << std::endl; /*if (m_header.rootNode) { walkTree(be(m_header.rootNode)); }*/ }
static complex float* load_cfl_internal(const char* name, unsigned int D, long dimensions[D], bool priv) { io_register_input(name); const char *p = strrchr(name, '.'); if ((NULL != p) && (p != name) && (0 == strcmp(p, ".ra"))) return load_zra(name, D, dimensions); if ((NULL != p) && (p != name) && (0 == strcmp(p, ".coo"))) return load_zcoo(name, D, dimensions); char name_bdy[1024]; if (1024 <= snprintf(name_bdy, 1024, "%s.cfl", name)) io_error("Loading cfl file %s", name); char name_hdr[1024]; if (1024 <= snprintf(name_hdr, 1024, "%s.hdr", name)) io_error("Loading cfl file %s", name); int ofd; if (-1 == (ofd = open(name_hdr, O_RDONLY))) io_error("Loading cfl file %s", name); if (-1 == read_cfl_header(ofd, D, dimensions)) io_error("Loading cfl file %s", name); if (-1 == close(ofd)) io_error("Loading cfl file %s", name); return (priv ? private_cfl : shared_cfl)(D, dimensions, name_bdy); }
unsigned int read_int() { char ch; // skip whitespaces, tabs, and new lines do { ch = read_char(); } while (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r'); if( ch < '0' || ch > '9' ) { io_error( "Unexpected characters reading decimal digits" ); } unsigned val = 0; do { unsigned dig = ch - '0'; if( val > INT_MAX / 10 - dig ) { io_error( "Integer too large" ); } val = val * 10 + dig; ch = read_char(); } while( '0' <= ch && ch <= '9' ); return val; }
/* * Read complete callback. * Change read iocb into a write iocb and start it. */ static void rd_done(io_context_t ctx, struct iocb *iocb, long res, long res2) { /* library needs accessors to look at iocb? */ int iosize = iocb->u.c.nbytes; char *buf = iocb->u.c.buf; off_t offset = iocb->u.c.offset; if (res2 != 0) io_error("aio read", res2); if (res != iosize) { fprintf(stderr, "read missing bytes expect %lu got %ld\n", iocb->u.c.nbytes, res); exit(1); } /* turn read into write */ if (no_write) { --tocopy; --busy; free_iocb(iocb); } else { io_prep_pwrite(iocb, dstfd, buf, iosize, offset); io_set_callback(iocb, wr_done); if (1 != (res = io_submit(ctx, 1, &iocb))) io_error("io_submit write", res); } if (debug) write(2, "r", 1); if (debug > 1) printf("%d", iosize); }
int32_t DMGPartition::read(void* buf, int32_t count, uint64_t offset) { int32_t done = 0; while (done < count) { std::map<uint64_t, uint32_t>::iterator itRun = m_sectors.upper_bound((offset + done) / SECTOR_SIZE); uint64_t offsetInSector = 0; int32_t thistime; if (offset+done > length()) break; // read beyond EOF if (itRun == m_sectors.begin()) throw io_error("Invalid run sector data"); itRun--; // move to the sector we want to read //std::cout << "Reading from offset " << offset << " " << count << " bytes\n"; //std::cout << "Run sector " << itRun->first << " run index=" << itRun->second << std::endl; if (!done) offsetInSector = offset - itRun->first*SECTOR_SIZE; thistime = readRun(((char*)buf) + done, itRun->second, offsetInSector, count-done); if (!thistime) throw io_error("Unexpected EOF from readRun"); done += thistime; } return done; }
int COpenTest::delete_random(BonTimer &timer) { random_sort(timer.random_source); timer.start(); int i; Duration dur; for(i = 0; i < m_number; i++) { dur.start(); if(unlink(m_file_names[i])) { fprintf(stderr, "Can't delete file %s\n", m_file_names[i]); return -1; } if(m_sync && m_sync_dir) { if(fsync(m_directoryHandles[m_dirIndex[i]])) { fprintf(stderr, "Can't sync directory, turning off dir-sync.\n"); m_sync_dir = false; } } dur.stop(); } if(m_number_directories > 1) { char buf[6]; for(i = 0; i < m_number_directories; i++) { sprintf(buf, "%05d", i); if(m_sync) { close(m_directoryHandles[i]); } if(rmdir(buf)) { io_error("rmdir"); return -1; } } } else { if(m_sync) { close(m_directoryHandles[0]); } } if(chdir("..") || rmdir(m_dirname)) { io_error("rmdir"); return -1; } delete m_dirname; m_dirname = NULL; sync(); timer.stop_and_record(DelRand); timer.add_latency(DelRand, dur.getMax()); return 0; }
static enum status_code load_option_file(const char *path) { struct config_state config = { path, 0, FALSE }; struct io io; char buf[SIZEOF_STR]; /* Do not read configuration from stdin if set to "" */ if (!path || !strlen(path)) return SUCCESS; if (!prefixcmp(path, "~/")) { const char *home = getenv("HOME"); if (!home || !string_format(buf, "%s/%s", home, path + 2)) return error("Failed to expand ~ to user home directory"); path = buf; } /* It's OK that the file doesn't exist. */ if (!io_open(&io, "%s", path)) { /* XXX: Must return ERROR_FILE_DOES_NOT_EXIST so missing * system tigrc is detected properly. */ if (io_error(&io) == ENOENT) return ERROR_FILE_DOES_NOT_EXIST; return error("Error loading file %s: %s", path, strerror(io_error(&io))); } if (io_load_span(&io, " \t", &config.lineno, read_option, &config) == ERR || config.errors == TRUE) warn("Errors while loading %s.", path); return SUCCESS; }
explicit pid_file(const char* a_filename, mode_t a_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) throw (io_error) : m_filename(a_filename) { m_fd = open(a_filename, O_CREAT | O_RDWR | O_TRUNC, a_mode); if (m_fd < 0) throw io_error(errno, "Cannot open file:", a_filename); pid_t pid = ::getpid(); std::string s = int_to_string(pid); if (::write(m_fd, s.c_str(), s.size()) < 0) throw io_error(errno, "Cannot write to file:", a_filename); }
static void print_time(time_format time_format) { enum { buffer_max = 32 }; char buffer[buffer_max]; time_t rawtime; time(&rawtime); struct tm timeinfo; time_format(&rawtime, &timeinfo); const size_t len = strftime(buffer, buffer_max, format, &timeinfo); if(len != fwrite(buffer, 1, len, stdout)){ io_error(stdout); } if (fputc('\t', stdout) == EOF) { io_error(stdout); } }
/// /// Constructor /// writer_backend( const Device& io_dev , const image_write_info< png_tag >& info ) : png_struct_info_wrapper( false ) , _io_dev( io_dev ) , _info( info ) { // Create and initialize the png_struct with the desired error handler // functions. If you want to use the default stderr and longjump method, // you can supply NULL for the last three parameters. We also check that // the library version is compatible with the one used at compile time, // in case we are using dynamically linked libraries. REQUIRED. get()->_struct = png_create_write_struct( PNG_LIBPNG_VER_STRING , nullptr // user_error_ptr , nullptr // user_error_fn , nullptr // user_warning_fn ); io_error_if( get_struct() == nullptr , "png_writer: fail to call png_create_write_struct()" ); // Allocate/initialize the image information data. REQUIRED get()->_info = png_create_info_struct( get_struct() ); if( get_info() == nullptr ) { png_destroy_write_struct( &get()->_struct , nullptr ); io_error( "png_writer: fail to call png_create_info_struct()" ); } // Set error handling. REQUIRED if you aren't supplying your own // error handling functions in the png_create_write_struct() call. if( setjmp( png_jmpbuf( get_struct() ))) { //free all of the memory associated with the png_ptr and info_ptr png_destroy_write_struct( &get()->_struct , &get()->_info ); io_error( "png_writer: fail to call setjmp()" ); } init_io( get_struct() ); }
/* * Do a typical-of-something random I/O. Any serious application that * has a random I/O bottleneck is going to be smart enough to operate * in a page mode, and not stupidly pull individual words out at * odd offsets. To keep the cache from getting too clever, some * pages must be updated. However an application that updated each of * many random pages that it looked at is hard to imagine. * However, it would be wrong to put the update percentage in as a * parameter - the effect is too nonlinear. Need a profile * of what Oracle or Ingres or some such actually does. * Be warned - there is a *sharp* elbow in this curve - on a 1-MiB file, * most substantial unix systems show >2000 random I/Os per second - * obviously they've cached the whole thing and are just doing buffer * copies. */ int CFileOp::doseek(unsigned int where, bool update) { if (seek(where, SEEK_SET) == -1) return -1; if (read_block(PVOID(m_buf)) == -1) return -1; /* every so often, update a block */ if (update) { /* update this block */ /* touch a byte */ m_buf[where % m_chunk_size]--; if(seek(where, SEEK_SET) == -1) return io_error("lseek in doseek update"); if (write_block(PVOID(m_buf)) == -1) return -1; if(m_sync) { if(fsync(m_fd)) { fprintf(stderr, "Can't sync file.\n"); return -1; } } } /* update this block */ return 0; }
int CFileOp::read_block(PVOID buf) { int total = 0; bool printed_error = false; while(total != m_chunk_size) { int rc = read(m_fd, buf, m_chunk_size - total); if(rc == -1) { io_error("re-write read"); // exits program } else if(rc != m_chunk_size) { if(!printed_error) { fprintf(stderr, "Can't read a full block, only got %d bytes.\n", rc); printed_error = true; if(rc == 0) return -1; } } total += rc; } return total; }
void primitive_fwrite(void) { FILE *file = unbox_alien(); F_BYTE_ARRAY *text = untag_byte_array(dpop()); F_FIXNUM length = array_capacity(text); char *string = (char *)(text + 1); if(length == 0) return; for(;;) { size_t written = fwrite(string,1,length,file); if(written == length) break; else { if(feof(file)) break; else io_error(); /* Still here? EINTR */ length -= written; string += written; } } }
/** * Reads the next buffer from the input. An invalid buffer signals * end-of-file. After end-of-file all read() calls will return an * invalid buffer. An invalid buffer is also always returned if * osmium::osm_entity_bits::nothing was set when the Reader was * constructed. * * @returns Buffer. * @throws Some form of osmium::io_error if there is an error. */ osmium::memory::Buffer read() { osmium::memory::Buffer buffer; if (m_status != status::okay || m_read_which_entities == osmium::osm_entity_bits::nothing) { throw io_error("Can not read from reader when in status 'closed', 'eof', or 'error'"); } try { // m_input_format.read() can return an invalid buffer to signal EOF, // or a valid buffer with or without data. A valid buffer // without data is not an error, it just means we have to // keep getting the next buffer until there is one with data. while (true) { buffer = m_osmdata_queue_wrapper.pop(); if (detail::at_end_of_data(buffer)) { m_status = status::eof; m_read_thread_manager.close(); return buffer; } if (buffer.committed() > 0) { return buffer; } } } catch (...) { close(); m_status = status::error; throw; } }
void apply( const View& /* view */ , const Info& /* info */ , const mpl::false_ ) { io_error( "dynamic_io: unsupported view type for the given file format" ); }
void send_request(unsigned request, size_t par_len, void *par) { iscsid_request_t *req; size_t len; ssize_t ret; int req_temp; len = sizeof(iscsid_request_t) + par_len; /* alloc buffer if static one is too small to hold request */ req_temp = len > sizeof(buf); if (req_temp) { req = malloc(len); if (req == NULL) gen_error("Out of memory allocating %zu bytes\n", len); } else req = (iscsid_request_t *)(void *)buf; /* setup request */ req->request = request; req->parameter_length = (uint32_t)par_len; if (par_len) memcpy(req->parameter, par, par_len); /* and send it out */ ret = sendto(sock, req, len, 0, (struct sockaddr *)(void *)&daemon_name, (socklen_t)sizeof(struct sockaddr_un)); if ((size_t)ret != len) { io_error("Sending daemon message"); } if (req_temp) free(req); }
/* * Read complete callback. * Change read iocb into a write iocb and start it. */ static void rd_done(io_context_t ctx, struct iocb *iocb, long res, long res2) { /* library needs accessors to look at iocb? */ int iosize = iocb->u.c.nbytes; char *buf = iocb->u.c.buf; off_t offset = iocb->u.c.offset; if (res2 != 0) io_error("aio read", res2); if (res != iosize) { fprintf(stderr, "read missing bytes expect %d got %d\n", \ iocb->u.c.nbytes, res); exit(1); } free(buf); free(iocb); --tocopy; --busy; return; }
/** * Common function to handle parsing the HTTP stream for both v0 and v1 io * implementations. */ static void read_common(http_provider *http) { lcb_error_t err; lcb_connection_t conn = &http->connection; int old_generation = http->stream.generation; lcb_log(LOGARGS(http, TRACE), "Received %d bytes on HTTP stream", conn->input->nbytes); lcb_timer_rearm(http->io_timer, PROVIDER_SETTING(&http->base, config_node_timeout)); lcb_string_rbappend(&http->stream.chunk, conn->input, 1); err = htvb_parse(&http->stream, http->base.parent->settings->conntype); if (http->stream.generation != old_generation) { lcb_log(LOGARGS(http, DEBUG), "Generation %d -> %d", old_generation, http->stream.generation); set_new_config(http); } else { lcb_log(LOGARGS(http, TRACE), "HTTP not yet done. Err=0x%x", err); } if (err != LCB_BUSY && err != LCB_SUCCESS) { io_error(http, err); return; } lcb_sockrw_set_want(conn, LCB_READ_EVENT, 1); lcb_sockrw_apply_want(conn); }
static void connect_done_handler(lcb_connection_t conn, lcb_error_t err) { http_provider *http = (http_provider *)conn->data; const lcb_host_t *host = lcb_connection_get_host(conn); if (err != LCB_SUCCESS) { lcb_log(LOGARGS(http, ERR), "Connection to REST API @%s:%s failed with code=0x%x", host->host, host->port, err); io_error(http, err); return; } lcb_log(LOGARGS(http, DEBUG), "Successfuly connected to REST API %s:%s", host->host, host->port); lcb_connection_reset_buffers(conn); ringbuffer_strcat(conn->output, http->request_buf); lcb_assert(conn->output->nbytes > 0); lcb_sockrw_set_want(conn, LCB_RW_EVENT, 0); lcb_sockrw_apply_want(conn); lcb_timer_rearm(http->io_timer, PROVIDER_SETTING(&http->base, config_node_timeout)); }
static void protocol_error(http_provider *http, lcb_error_t err) { int can_retry = 1; lcb_log(LOGARGS(http, ERROR), "Got protocol-level error 0x%x", err); PROVIDER_SET_ERROR(&http->base, err); /** * XXX: We only want to retry on some errors. Things which signify an * obvious user error should be left out here; we only care about * actual "network" errors */ if (err == LCB_AUTH_ERROR || err == LCB_PROTOCOL_ERROR || err == LCB_BUCKET_ENOENT) { can_retry = 0; } if (http->retry_on_missing && (err == LCB_BUCKET_ENOENT || err == LCB_AUTH_ERROR)) { LOG(http, INFO, "Retrying on AUTH||BUCKET_ENOENT"); can_retry = 1; } if (!can_retry) { close_current(http); lcb_confmon_provider_failed(&http->base, err); } else { io_error(http); } }
static int io_load_file(struct io *io, const char *separators, size_t *lineno, io_read_fn read_property, void *data) { struct buffer buf; int state = OK; while (state == OK && io_get_line(io, &buf, '\n', lineno, TRUE)) { char *name; char *value; size_t namelen; size_t valuelen; name = chomp_string(buf.data); namelen = strcspn(name, separators); if (name[namelen]) { name[namelen] = 0; value = chomp_string(name + namelen + 1); valuelen = strlen(value); } else { value = ""; valuelen = 0; } state = read_property(name, namelen, value, valuelen, data); } if (state != ERR && io_error(io)) state = ERR; io_done(io); return state; }
static void timeout_handler(lcb_timer_t tm, lcb_t i, const void *cookie) { http_provider *http = (http_provider *)cookie; const lcb_host_t *curhost = lcb_connection_get_host(&http->connection); lcb_log(LOGARGS(http, ERR), "HTTP Provider timed out on host %s:%s waiting for I/O", curhost->host, curhost->port); /** * If we're not the current provider then ignore the timeout until we're * actively requested to do so */ if (&http->base != http->base.parent->cur_provider || lcb_confmon_is_refreshing(http->base.parent) == 0) { lcb_log(LOGARGS(http, DEBUG), "Ignoring timeout because we're either not in a refresh " "or not the current provider"); return; } io_error(http, LCB_ETIMEDOUT); (void)tm; (void)i; }
bool is_allowed( const image_read_info< targa_tag >& info , mpl::true_ // is read_and_no_convert ) { targa_depth::type src_bits_per_pixel = 0; switch( info._bits_per_pixel ) { case 24: case 32: { src_bits_per_pixel = info._bits_per_pixel; break; } default: { io_error( "Pixel size not supported." ); break; } } typedef typename channel_traits< typename element_type< typename View::value_type >::type >::value_type channel_t; targa_depth::type dst_bits_per_pixel = detail::unsigned_integral_num_bits< channel_t >::value * num_channels< View >::value; return ( dst_bits_per_pixel == src_bits_per_pixel ); }
/* Reads data from io->sock into io->read_meta_buf. If @to_blank is * %TRUE, it reads up until a blank line ("CRLF CRLF" or "LF LF"). * Otherwise, it reads up until a single CRLF or LF. * * This function is used to read metadata, and read_body_chunk() is * used to read the message body contents. * * read_metadata, read_body_chunk, and write_data all use the same * convention for return values: if they return %TRUE, it means * they've completely finished the requested read/write, and the * caller should move on to the next step. If they return %FALSE, it * means that either (a) the socket returned SOUP_SOCKET_WOULD_BLOCK, * so the caller should give up for now and wait for the socket to * emit a signal, or (b) the socket returned an error, and io_error() * was called to process it and cancel the I/O. So either way, if the * function returns %FALSE, the caller should return immediately. */ static gboolean read_metadata (SoupMessage *msg, gboolean to_blank) { SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg); SoupMessageIOData *io = priv->io_data; SoupSocketIOStatus status; guchar read_buf[RESPONSE_BLOCK_SIZE]; gsize nread; gboolean got_lf; GError *error = NULL; while (1) { status = soup_socket_read_until (io->sock, read_buf, sizeof (read_buf), "\n", 1, &nread, &got_lf, NULL, &error); switch (status) { case SOUP_SOCKET_OK: g_byte_array_append (io->read_meta_buf, read_buf, nread); break; case SOUP_SOCKET_ERROR: case SOUP_SOCKET_EOF: io_error (io->sock, msg, error); return FALSE; case SOUP_SOCKET_WOULD_BLOCK: return FALSE; } if (got_lf) { if (!to_blank) break; if (nread == 1 && !strncmp ((char *)io->read_meta_buf->data + io->read_meta_buf->len - 2, "\n\n", 2)) break; else if (nread == 2 && !strncmp ((char *)io->read_meta_buf->data + io->read_meta_buf->len - 3, "\n\r\n", 3)) break; } } if (soup_socket_is_ssl (io->sock)) { gboolean trusted_certificate; g_object_get (io->sock, SOUP_SOCKET_TRUSTED_CERTIFICATE, &trusted_certificate, NULL); if (trusted_certificate) soup_message_set_flags (msg, priv->msg_flags | SOUP_MESSAGE_CERTIFICATE_TRUSTED); } return TRUE; }
void factor_vm::safe_fclose(FILE* stream) { for (;;) { if (fclose(stream) == EOF) io_error(); else break; } }
void factor_vm::safe_fputc(int c, FILE* stream) { for (;;) { if (putc(c, stream) == EOF) io_error(); else break; } }