static void gio_source_skip(j_decompress_ptr cinfo, long num_bytes) { struct jpeg_source_mgr* src = (struct jpeg_source_mgr*)cinfo->src; GioSource *self = (GioSource *)cinfo->client_data; if (num_bytes < src->bytes_in_buffer) { // just skip inside buffer src->next_input_byte += (size_t)num_bytes; src->bytes_in_buffer -= (size_t)num_bytes; } else { // skip in stream, discard whole buffer GError *err = NULL; const gssize bytes_to_skip = num_bytes-src->bytes_in_buffer; const gssize skipped = g_input_stream_skip(self->stream, bytes_to_skip, NULL, &err); if (err) { g_printerr("%s: skipped=%ld, err=%s\n", __PRETTY_FUNCTION__, skipped, err->message); g_error_free(err); } src->bytes_in_buffer = 0; src->next_input_byte = NULL; } }
static gssize byzanz_queue_input_stream_skip (GInputStream *input_stream, gsize count, GCancellable *cancellable, GError ** error) { ByzanzQueueInputStream *stream = BYZANZ_QUEUE_INPUT_STREAM (input_stream); gssize result; retry: if (!byzanz_queue_input_stream_ensure_input (stream, cancellable, error)) return -1; /* No more data to read from the queue */ if (stream->input == NULL) return 0; result = g_input_stream_skip (stream->input, count, cancellable, error); if (result == -1) return -1; /* no data in file. Let's wait for more. */ if (result == 0) { if (!byzanz_queue_input_stream_wait (stream, cancellable, error)) return -1; goto retry; } stream->input_bytes += result; return result; }
static void _hwp_hwp3_parser_parse_info_block (HwpHWP3Parser *parser, HwpHWP3File *file, GError **error) { g_return_if_fail (HWP_IS_HWP3_FILE (file)); GInputStream *stream = file->priv->stream; g_input_stream_skip (stream, file->info_block_len, NULL, error); }
static gssize g_resource_file_input_stream_skip (GInputStream *stream, gsize count, GCancellable *cancellable, GError **error) { GResourceFileInputStream *file = G_RESOURCE_FILE_INPUT_STREAM (stream); return g_input_stream_skip (file->stream, count, cancellable, error); }
gssize skip (GInputStream *stream, gsize count, GCancellable *cancellable, GError **error) { GFilterInputStream *filter_stream = G_FILTER_INPUT_STREAM (stream); GInputStream *base_stream = filter_stream->base_stream; return g_input_stream_skip (base_stream, count, cancellable, error); }
static void client_fill_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { BroadwayClient *client = user_data; gssize res; res = g_buffered_input_stream_fill_finish (client->in, result, NULL); if (res > 0) { guint32 size; gsize count, remaining; guint8 *buffer; buffer = (guint8 *)g_buffered_input_stream_peek_buffer (client->in, &count); remaining = count; while (remaining >= sizeof (guint32)) { memcpy (&size, buffer, sizeof (guint32)); if (size <= remaining) { client_handle_request (client, (BroadwayRequest *)buffer); remaining -= size; buffer += size; } } /* This is guaranteed not to block */ g_input_stream_skip (G_INPUT_STREAM (client->in), count - remaining, NULL, NULL); g_buffered_input_stream_fill_async (client->in, 4*1024, 0, NULL, client_fill_cb, client); } else { client_disconnected (client); } }
static VALUE rg_skip(int argc, VALUE *argv, VALUE self) { VALUE count, cancellable; GError *error = NULL; gssize bytes_skipped; rb_scan_args(argc, argv, "11", &count, &cancellable); bytes_skipped = g_input_stream_skip(_SELF(self), RVAL2GSIZE(count), RVAL2GCANCELLABLE(cancellable), &error); if (bytes_skipped == -1) rbgio_raise_error(error); return GSSIZE2RVAL(bytes_skipped); }
static gssize g_filter_input_stream_skip (GInputStream *stream, gsize count, GCancellable *cancellable, GError **error) { GFilterInputStream *filter_stream; GInputStream *base_stream; gssize nskipped; filter_stream = G_FILTER_INPUT_STREAM (stream); base_stream = filter_stream->base_stream; nskipped = g_input_stream_skip (base_stream, count, cancellable, error); return nskipped; }
static void _ghwp_file_v3_parse_info_block (GHWPDocument *doc) { g_return_if_fail (doc != NULL); GInputStream *stream = GHWP_FILE_V3 (doc->file)->priv->stream; g_input_stream_skip (stream, GHWP_FILE_V3 (doc->file)->info_block_len, NULL, NULL); if (GHWP_FILE_V3 (doc->file)->is_compress) { GZlibDecompressor *zd; GInputStream *cis; zd = g_zlib_decompressor_new (G_ZLIB_COMPRESSOR_FORMAT_RAW); cis = g_converter_input_stream_new ((GInputStream*) stream, (GConverter*) zd); g_object_unref (GHWP_FILE_V3 (doc->file)->priv->stream); g_object_ref (cis); /* NOTE 기존의 스트림은 어떻게 ? */ GHWP_FILE_V3 (doc->file)->priv->stream = G_INPUT_STREAM (cis); g_object_unref (zd); } }
static gboolean read_gzip_header (GInputStream *is, time_t *modification_time) { guchar buffer[GZIP_HEADER_SIZE]; gssize bytes, to_skip; guint mode; guint flags; bytes = g_input_stream_read (is, buffer, GZIP_HEADER_SIZE, NULL, NULL); if (bytes == -1) { return FALSE; } if (bytes != GZIP_HEADER_SIZE) return FALSE; if (buffer[0] != GZIP_MAGIC_1 || buffer[1] != GZIP_MAGIC_2) return FALSE; mode = buffer[2]; if (mode != 8) /* Mode: deflate */ return FALSE; flags = buffer[3]; if (flags & GZIP_FLAG_RESERVED) return FALSE; if (flags & GZIP_FLAG_EXTRA_FIELD) { guchar tmp[2]; bytes = g_input_stream_read (is, tmp, 2, NULL, NULL); if (bytes != 2) { return FALSE; } to_skip = tmp[0] | (tmp[0] << 8); bytes = g_input_stream_skip (is, to_skip, NULL, NULL); if (bytes != to_skip) { return FALSE; } } if (flags & GZIP_FLAG_ORIG_NAME) { if (!skip_string (is)) { return FALSE; } } if (flags & GZIP_FLAG_COMMENT) { if (!skip_string (is)) { return FALSE; } } if (flags & GZIP_FLAG_HEAD_CRC) { bytes = g_input_stream_skip (is, 2, NULL, NULL); if (bytes != 2) { return FALSE; } } *modification_time = (buffer[4] | (buffer[5] << 8) | (buffer[6] << 16) | (buffer[7] << 24)); return TRUE; }