Rizin
unix-like reverse engineering framework and cli tools
sh.h File Reference

Go to the source code of this file.

Functions

static TAG_CALLBACK (sh_default)
 
static TAG_CALLBACK (sh_pipe)
 
static TAG_CALLBACK (sh_endpipe)
 
static PUT_CALLBACK (sh_fputs)
 

Variables

static int sh_pipe_enabled = 0
 
static char * sh_pipe_cmd = NULL
 
static struct Tag sh_tags []
 
static struct Arg sh_args []
 
DLL_LOCAL struct Proc sh_proc
 

Function Documentation

◆ PUT_CALLBACK()

static PUT_CALLBACK ( sh_fputs  )
static

Definition at line 53 of file sh.h.

53  {
54  if (sh_pipe_enabled) {
55  char str[1024]; // XXX
56  sprintf (str, "echo '%s' | %s", buf, sh_pipe_cmd); // XXX
57 #if HAVE_FORK
58  int r = system (str);
59  if (errno) {
60  printf ("system '%s' (%d) failed: %s\n", str, r, strerror (errno));
61  }
62 #endif
63  } else {
64  out_printf (out, "%s", buf);
65  }
66  return 0;
67 }
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
#define r
Definition: crypto_rc6.c:12
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
Definition: cs_driver.c:93
voidpf void * buf
Definition: ioapi.h:138
sprintf
Definition: kernel.h:365
void out_printf(Output *out, char *str,...) __attribute__((format(printf
static int sh_pipe_enabled
Definition: sh.h:36
static char * sh_pipe_cmd
Definition: sh.h:37

References out, out_printf(), printf(), r, sh_pipe_cmd, sh_pipe_enabled, sprintf, and cmd_descs_generate::str.

◆ TAG_CALLBACK() [1/3]

static TAG_CALLBACK ( sh_default  )
static

Definition at line 10 of file sh.h.

10  {
11  //if (out != stdout) {
12  // pipe stdout to out fd
13  //}
14 #if 0
15  ptr = strstr(buf, "<<");
16  if (ptr) {
17  *ptr='\0';
18  for(ptr = ptr+2;*ptr==' ';ptr=ptr+1);
19  free(eof);
20  eof = strdup(ptr);
21  return;
22  }
23 
24  // printf("system(%s)\n", buf);
25  if (eof)
26 #endif
27 #if HAVE_FORK
28  int r = system (buf);
29  if (errno) {
30  printf ("system '%s' (%d) failed: %s\n", buf, r, strerror (errno));
31  }
32 #endif
33  return 0;
34 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
return strdup("=PC pc\n" "=SP r15\n" "=BP r14\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr pc .32 64 0\n" "gpr pr .32 68 0\n" "gpr sr .32 72 0\n" "gpr gbr .32 76 0\n" "gpr mach .32 80 0\n" "gpr macl .32 84 0\n")

References free(), printf(), r, and strdup().

◆ TAG_CALLBACK() [2/3]

static TAG_CALLBACK ( sh_endpipe  )
static

Definition at line 46 of file sh.h.

46  {
47  sh_pipe_enabled = 0;
48  free (sh_pipe_cmd);
49  sh_pipe_cmd = NULL;
50  return 0;
51 }
#define NULL
Definition: cris-opc.c:27

References free(), NULL, sh_pipe_cmd, and sh_pipe_enabled.

◆ TAG_CALLBACK() [3/3]

static TAG_CALLBACK ( sh_pipe  )
static

Definition at line 39 of file sh.h.

39  {
40  sh_pipe_enabled = 1;
41  free (sh_pipe_cmd);
43  return 0;
44 }

References free(), sh_pipe_cmd, sh_pipe_enabled, and strdup().

Variable Documentation

◆ sh_args

struct Arg sh_args[]
static
Initial value:
= {
{ NULL }
}

Definition at line 53 of file sh.h.

◆ sh_pipe_cmd

char* sh_pipe_cmd = NULL
static

Definition at line 37 of file sh.h.

Referenced by PUT_CALLBACK(), and TAG_CALLBACK().

◆ sh_pipe_enabled

int sh_pipe_enabled = 0
static

Definition at line 36 of file sh.h.

Referenced by PUT_CALLBACK(), and TAG_CALLBACK().

◆ sh_proc

DLL_LOCAL struct Proc sh_proc
Initial value:
= {
.name = "sh",
.tags = (struct Tag **)sh_tags,
.args = (struct Arg **)sh_args,
.eof = NULL,
.token = NULL,
.tag_pre = "{{",
.tag_post = "}}",
.fputs = sh_fputs,
.multiline = "\\\n",
.default_echo = 1,
.chop = 0,
.tag_begin = 0,
}
int args
Definition: mipsasm.c:18
static struct Arg sh_args[]
Definition: sh.h:76
static struct Tag sh_tags[]
Definition: sh.h:69
Definition: spp.h:121
Definition: spp.h:116

Definition at line 80 of file sh.h.

◆ sh_tags

struct Tag sh_tags[]
static
Initial value:
= {
{ "pipe", sh_pipe },
{ "endpipe", sh_endpipe },
{ NULL, sh_default },
{ NULL }
}

Definition at line 53 of file sh.h.