Rizin
unix-like reverse engineering framework and cli tools
zstream.h File Reference
#include <strstream.h>
#include <string.h>
#include <stdio.h>
#include "zlib.h"

Go to the source code of this file.

Classes

class  zstringlen
 
struct  zstringlen::Val
 
class  izstream
 
class  ozstream
 

Macros

#define SET_BINARY_MODE(file)
 

Functions

template<class T , class Items >
int read (izstream &zs, T *x, Items items)
 
template<class T >
izstreamoperator> (izstream &zs, T &x)
 
izstreamoperator> (izstream &zs, char *x)
 
char * read_string (izstream &zs)
 
template<class T , class Items >
int write (ozstream &zs, const T *x, Items items)
 
template<class T >
ozstreamoperator< (ozstream &zs, const T &x)
 
ozstreamoperator< (ozstream &zs, const char *x)
 
template<class T >
ostream & operator<< (ozstream &zs, const T &x)
 

Macro Definition Documentation

◆ SET_BINARY_MODE

#define SET_BINARY_MODE (   file)

Definition at line 37 of file zstream.h.

Function Documentation

◆ operator<() [1/2]

ozstream& operator< ( ozstream zs,
const char *  x 
)
inline

Definition at line 286 of file zstream.h.

286  {
287  zstringlen len(zs, x);
288  ::gzwrite(zs.fp(), (voidp) x, len.value());
289  return zs;
290 }
size_t len
Definition: 6502dis.c:15
gzFile fp()
Definition: zstream.h:234
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len)
Definition: gzwrite.c:255
int x
Definition: mipsasm.c:20
Byte * voidp
Definition: zconf.h:414

References ozstream::fp(), gzwrite(), len, and x.

◆ operator<() [2/2]

template<class T >
ozstream& operator< ( ozstream zs,
const T x 
)
inline

Definition at line 272 of file zstream.h.

272  {
273  ::gzwrite(zs.fp(), (voidp) &x, sizeof(T));
274  return zs;
275 }
#define T(op)

References ozstream::fp(), gzwrite(), T, and x.

◆ operator<<()

template<class T >
ostream& operator<< ( ozstream zs,
const T x 
)
inline

Definition at line 302 of file zstream.h.

302  {
303  zs.os_flush();
304  return zs.os() << x;
305 }
void os_flush()
Definition: zstream.h:241
ostream & os()
Definition: zstream.h:236

References ozstream::os(), ozstream::os_flush(), and x.

◆ operator>() [1/2]

izstream& operator> ( izstream zs,
char *  x 
)
inline

Definition at line 138 of file zstream.h.

138  {
139  zstringlen len(zs);
140  ::gzread(zs.fp(), x, len.value());
141  x[len.value()] = '\0';
142  return zs;
143 }
gzFile fp()
Definition: zstream.h:101
int ZEXPORT gzread(gzFile file, voidp buf, unsigned len)
Definition: gzread.c:375

References izstream::fp(), gzread(), len, and x.

◆ operator>() [2/2]

template<class T >
izstream& operator> ( izstream zs,
T x 
)
inline

Definition at line 123 of file zstream.h.

123  {
124  ::gzread(zs.fp(), &x, sizeof(T));
125  return zs;
126 }

References izstream::fp(), gzread(), T, and x.

◆ read()

template<class T , class Items >
int read ( izstream zs,
T x,
Items  items 
)
inline

Definition at line 115 of file zstream.h.

115  {
116  return ::gzread(zs.fp(), x, items*sizeof(T));
117 }

References izstream::fp(), gzread(), T, and x.

Referenced by __read(), apprentice_map(), assemble(), binutils_assemble(), bload(), bochs_open(), bochs_wait(), bskip(), buf_file_read(), calculate_decrypt(), calculate_encrypt(), calculate_hash(), cdb_init(), cdb_read(), clusterReadHandler(), dex_parse(), dex_string_new(), esil_peek_some(), file_or_fd(), go_string(), go_uvariant(), gz_load(), gzlog_compress(), gzscan(), gztack(), in(), info(), io_read(), kwajd_extract(), lang_pipe_run(), langFromHashbang(), load_buffer(), log_compress(), log_head(), log_last(), log_recover(), lzh_read_input(), lzss_decompress(), mkdtemp(), parse_go_build_info(), parse_pointer(), parseOperand(), print_instruction_ops(), process_constructors(), procfs_pid_slurp(), read_bin(), read_input(), read_int(), read_to_strbuf(), readin(), rz_buf_fwd_scan(), rz_cons_get_cur_line(), rz_cons_readchar(), rz_cons_yesno(), rz_diff_hex_visual(), rz_diff_slurp_file(), rz_io_cache_read(), rz_line_readchar_utf8(), rz_main_rz_asm(), RZ_PACKED(), rz_sign_flirt_parse_string_pattern_from_buffer(), rz_stdin_slurp(), rzpipe_open(), rzpipe_read(), sdb_journal_load(), sdb_text_load(), sigchld_th(), slurp(), sp_blocking_read(), test_decompress(), type_match(), use_stdin(), uv__async_io(), uv__fs_read(), uv__fs_sendfile_emul(), uv__fs_work(), uv__inotify_read(), uv__random_readpath(), uv__read(), uv__signal_event(), uv__signal_lock(), uv__slurp(), uv_process_reqs(), uv_resident_set_memory(), uv_spawn(), and zip_secure_random().

◆ read_string()

char* read_string ( izstream zs)
inline

Definition at line 145 of file zstream.h.

145  {
146  zstringlen len(zs);
147  char* x = new char[len.value()+1];
148  ::gzread(zs.fp(), x, len.value());
149  x[len.value()] = '\0';
150  return x;
151 }

References izstream::fp(), gzread(), len, and x.

Referenced by main().

◆ write()

template<class T , class Items >
int write ( ozstream zs,
const T x,
Items  items 
)
inline

Definition at line 264 of file zstream.h.

264  {
265  return ::gzwrite(zs.fp(), (voidp) x, items*sizeof(T));
266 }

References ozstream::fp(), gzwrite(), T, and x.