Rizin
unix-like reverse engineering framework and cli tools
io_http.c File Reference
#include <rz_io.h>
#include <rz_lib.h>
#include <rz_socket.h>
#include <stdio.h>
#include <stdlib.h>
#include "../io_memory.h"

Go to the source code of this file.

Functions

static bool __check (RzIO *io, const char *pathname, bool many)
 
static RzIODesc__open (RzIO *io, const char *pathname, int rw, int mode)
 

Variables

RzIOPlugin rz_io_plugin_http
 
RZ_API RzLibStruct rizin_plugin
 

Function Documentation

◆ __check()

static bool __check ( RzIO io,
const char *  pathname,
bool  many 
)
static

Definition at line 11 of file io_http.c.

11  {
12  return (!strncmp(pathname, "http://", 7));
13 }
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char pathname
Definition: sflib.h:66

References pathname.

Referenced by __open().

◆ __open()

static RzIODesc* __open ( RzIO io,
const char *  pathname,
int  rw,
int  mode 
)
static

Definition at line 15 of file io_http.c.

15  {
16  if (__check(io, pathname, 0)) {
17  int rlen, code;
19  if (!mal) {
20  return NULL;
21  }
22  mal->offset = 0;
23  mal->buf = (ut8 *)rz_socket_http_get(pathname, &code, &rlen);
24  if (mal->buf && rlen > 0) {
25  mal->size = rlen;
27  }
28  eprintf("No HTTP response\n");
29  free(mal);
30  }
31  return NULL;
32 }
#define NULL
Definition: cris-opc.c:27
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
static bool __check(RzIO *io, const char *pathname, bool many)
Definition: io_http.c:11
const char int mode
Definition: ioapi.h:137
uint8_t ut8
Definition: lh5801.h:11
const char * code
Definition: pal.c:98
#define eprintf(x, y...)
Definition: rlcc.c:7
RZ_API RzIODesc * rz_io_desc_new(RzIO *io, RzIOPlugin *plugin, const char *uri, int flags, int mode, void *data)
Definition: io_desc.c:11
RzIOPlugin rz_io_plugin_malloc
Definition: io_malloc.c:50
RZ_API char * rz_socket_http_get(const char *url, int *code, int *rlen)
Definition: socket_http.c:287
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_PERM_RW
Definition: rz_types.h:96
Definition: inftree9.h:24
static struct @626 mal

References __check(), code, eprintf, free(), mal, NULL, pathname, rz_io_desc_new(), rz_io_plugin_malloc, RZ_NEW0, RZ_PERM_RW, and rz_socket_http_get().

Variable Documentation

◆ rizin_plugin

RZ_API RzLibStruct rizin_plugin
Initial value:
= {
.type = RZ_LIB_TYPE_IO,
}
RzIOPlugin rz_io_plugin_http
Definition: io_http.c:34
@ RZ_LIB_TYPE_IO
Definition: rz_lib.h:69
#define RZ_VERSION
Definition: rz_version.h:8
const char * version
Definition: rz_io.h:117

Definition at line 48 of file io_http.c.

◆ rz_io_plugin_http

RzIOPlugin rz_io_plugin_http
Initial value:
= {
.name = "http",
.desc = "Make http get requests",
.uris = "http://",
.license = "LGPL3",
.open = __open,
.close = io_memory_close,
.read = io_memory_read,
.check = __check,
.lseek = io_memory_lseek,
.write = io_memory_write,
}
static RzIODesc * __open(RzIO *io, const char *pathname, int rw, int mode)
Definition: io_http.c:15
int io_memory_read(RzIO *io, RzIODesc *fd, ut8 *buf, int count)
Definition: io_memory.c:97
int io_memory_write(RzIO *io, RzIODesc *fd, const ut8 *buf, int count)
Definition: io_memory.c:56
ut64 io_memory_lseek(RzIO *io, RzIODesc *fd, ut64 offset, int whence)
Definition: io_memory.c:125
int io_memory_close(RzIODesc *fd)
Definition: io_memory.c:114

Definition at line 34 of file io_http.c.