mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-06 18:13:46 +00:00
Completely kill the msvc/ directory and the unix-specific includes workarounds
This commit is contained in:
parent
59cfc2bb3f
commit
e04f31a313
@ -3,8 +3,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
//#include <err.h>
|
||||
#include <string.h>
|
||||
#define assert(x) if (!(x)) { eprintf("assert ##x##\n"); return; }
|
||||
#include <stdarg.h>
|
||||
|
@ -28,8 +28,6 @@
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
//#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* defines which are not function-specific */
|
||||
#ifndef BUFLEN
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* radare - LGPL - Copyright 2009-2016 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2019 - pancake */
|
||||
|
||||
#include <r_cons.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
//TODO: cons_pipe should be using a stack pipe_push, pipe_pop
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
// Copypasta from http://www.linuxquestions.org/questions/programming-9/get-cursor-position-in-c-947833/
|
||||
#include <r_cons.h>
|
||||
|
||||
#if __UNIX__
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <errno.h>
|
||||
|
@ -1,74 +0,0 @@
|
||||
#if 0
|
||||
// XXX dupe in libr/util/getopt.c
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int opterr = 1, /* if error message should be printed */
|
||||
optind = 1, /* index into parent argv vector */
|
||||
optopt, /* character checked for validity */
|
||||
optreset; /* reset getopt */
|
||||
char *optarg; /* argument associated with option */
|
||||
|
||||
#define BADCH (int)'?'
|
||||
#define BADARG (int)':'
|
||||
#define EMSG ""
|
||||
|
||||
/*
|
||||
* getopt --
|
||||
* Parse argc/argv argument vector.
|
||||
*/
|
||||
int getopt (int nargc, char * const nargv[], const char *ostr) {
|
||||
static char *place = EMSG; /* option letter processing */
|
||||
const char *oli; /* option letter list index */
|
||||
|
||||
if (optreset || !*place) { /* update scanning pointer */
|
||||
optreset = 0;
|
||||
if (optind >= nargc || *(place = nargv[optind]) != '-') {
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
if (place[1] && *++place == '-') { /* found "--" */
|
||||
++optind;
|
||||
place = EMSG;
|
||||
return (-1);
|
||||
}
|
||||
} /* option letter okay? */
|
||||
if ((optopt = (int)*place++) == (int)':' ||
|
||||
!(oli = strchr (ostr, optopt))) {
|
||||
/*
|
||||
* if the user didn't specify '-' as an option,
|
||||
* assume it means -1.
|
||||
*/
|
||||
if (optopt == (int)'-')
|
||||
return (-1);
|
||||
if (!*place)
|
||||
++optind;
|
||||
if (opterr && *ostr != ':')
|
||||
(void)printf ("illegal option -- %c\n", optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
optarg = NULL;
|
||||
if (!*place)
|
||||
++optind;
|
||||
}
|
||||
else { /* need an argument */
|
||||
if (*place) /* no white space */
|
||||
optarg = place;
|
||||
else if (nargc <= ++optind) { /* no arg */
|
||||
place = EMSG;
|
||||
if (*ostr == ':')
|
||||
return (BADARG);
|
||||
if (opterr)
|
||||
(void)printf ("option requires an argument -- %c\n", optopt);
|
||||
return (BADCH);
|
||||
}
|
||||
else /* white space */
|
||||
optarg = nargv[optind];
|
||||
place = EMSG;
|
||||
++optind;
|
||||
}
|
||||
return (optopt); /* dump back option letter */
|
||||
}
|
||||
#endif
|
@ -1 +0,0 @@
|
||||
// fake file to build under msvc windows
|
@ -1,2 +0,0 @@
|
||||
//fake include file to avoid error on windows compilation.
|
||||
#include <io.h>
|
@ -33,8 +33,9 @@ extern "C" {
|
||||
#if __WINDOWS__
|
||||
#include <windows.h>
|
||||
#include <wincon.h>
|
||||
#endif
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* constants */
|
||||
#define CONS_MAX_USER 102400
|
||||
|
@ -8,7 +8,6 @@ of getopt to work on any operating system independently of the libc
|
||||
Duplicated code in here:
|
||||
|
||||
* libr/util/getopt.c
|
||||
* libr/include/msvc/getopt.h
|
||||
|
||||
*/
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#if HAVE_PTRACE
|
||||
|
||||
#if __sun
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#else
|
||||
#if DEBUGGER && HAVE_PTRACE
|
||||
|
@ -5,8 +5,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
typedef struct r_cache_t {
|
||||
ut64 base;
|
||||
ut8 *buf;
|
||||
|
@ -5,9 +5,10 @@
|
||||
#include <r_util.h>
|
||||
#include <r_util/r_print.h>
|
||||
|
||||
#if __UNIX__
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#define USE_OWNTIMER 1
|
||||
#if USE_OWNTIMER
|
||||
|
@ -46,9 +46,6 @@
|
||||
#include <memory.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "names.h"
|
||||
|
||||
#define MAXLINELEN 300 /* longest sane line length */
|
||||
|
@ -37,9 +37,6 @@
|
||||
#include <r_magic.h>
|
||||
#include "file.h"
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
/* Since major is a function on SVR4, we cannot use `ifndef major'. */
|
||||
|
@ -94,11 +94,6 @@ R_API int r_magic_errno(RMagic* m) {
|
||||
|
||||
#else
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <sys/param.h> /* for MAXPATHLEN */
|
||||
#endif
|
||||
@ -114,10 +109,6 @@ R_LIB_VERSION (r_magic);
|
||||
#endif
|
||||
#include <limits.h> /* for PIPE_BUF */
|
||||
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h> /* for read() */
|
||||
#endif
|
||||
|
||||
#if __UNIX__
|
||||
#include <netinet/in.h> /* for byte swapping */
|
||||
#else
|
||||
|
@ -39,9 +39,6 @@
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#define SZOF(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
@ -1,12 +1,8 @@
|
||||
/* radare - LGPL - Copyright 2006-2018 - esteve, pancake */
|
||||
/* radare - LGPL - Copyright 2006-2019 - esteve, pancake */
|
||||
|
||||
#include "r_search.h"
|
||||
#include "r_util.h"
|
||||
#include "r_util/r_print.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <r_search.h>
|
||||
#include <r_util.h>
|
||||
#include <r_util/r_print.h>
|
||||
|
||||
#define CTXMINB 5
|
||||
#define BSIZE (1024*1024)
|
||||
|
@ -87,7 +87,6 @@ match value ffffffad (ffffad) at offset 0x454
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <r_socket.h>
|
||||
#include <r_util.h>
|
||||
|
@ -5,14 +5,6 @@
|
||||
#include <r_types.h>
|
||||
#include <r_util.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if EMSCRIPTEN
|
||||
#define NETWORK_DISABLED 1
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include <r_util.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* accessors */
|
||||
static inline RNumCalcValue Nset(ut64 v) { RNumCalcValue n; n.d = (double)v; n.n = v; return n; }
|
||||
|
@ -1,10 +1,9 @@
|
||||
/* radare - LGPL - Copyright 2011-2012 - pancake */
|
||||
/* radare - LGPL - Copyright 2011-2019 - pancake */
|
||||
|
||||
#include <r_util.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if __UNIX__
|
||||
|
@ -3,14 +3,13 @@
|
||||
#include "r_types.h"
|
||||
#include "r_util.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <r_lib.h>
|
||||
#if __UNIX__
|
||||
#include <sys/time.h>
|
||||
#include <sys/mman.h>
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
@ -56,7 +56,6 @@ int proc_pidpath(int pid, void * buffer, ut32 buffersize);
|
||||
# include <sys/stat.h>
|
||||
# include <errno.h>
|
||||
# include <signal.h>
|
||||
# include <unistd.h>
|
||||
extern char **environ;
|
||||
|
||||
#ifdef __HAIKU__
|
||||
|
@ -6,11 +6,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(MINGW32)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <r_util.h>
|
||||
|
||||
#define SZ 1024
|
||||
|
@ -104,7 +104,6 @@ platform_deps = []
|
||||
platform_inc = ['.', 'libr/include']
|
||||
if host_machine.system() == 'windows'
|
||||
platform_deps = [cc.find_library('ws2_32')]
|
||||
platform_inc += ['libr/include/msvc']
|
||||
endif
|
||||
platform_inc = include_directories(platform_inc)
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include <r_types.h>
|
||||
#include <r_util.h>
|
||||
#include <r_bin.h>
|
||||
|
@ -182,15 +182,12 @@ sdb_dep = declare_dependency(
|
||||
include_directories: sdb_inc
|
||||
)
|
||||
|
||||
sdb_platform_inc = []
|
||||
|
||||
# Create sdb_version.h
|
||||
sdb_version = '1.2.0'
|
||||
run_command(py3_exe, '-c', 'with open("sdb/src/sdb_version.h", "w") as f: f.write("#define SDB_VERSION \"' + sdb_version + '\"")')
|
||||
|
||||
sdb_exe = executable('sdb', 'sdb/src/main.c',
|
||||
include_directories: [
|
||||
sdb_platform_inc,
|
||||
include_directories(['sdb/src'])
|
||||
],
|
||||
link_with: [libr2sdb],
|
||||
|
@ -7,7 +7,9 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if __UNIX__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
|
||||
#include "libqnxr.h"
|
||||
|
@ -3,7 +3,6 @@
|
||||
#define PACKET_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "libqnxr.h"
|
||||
@ -13,6 +12,8 @@
|
||||
#if !__CYGWIN__ && !defined(MSC_VER)
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
int qnxr_send_nak (libqnxr_t *instance);
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* MIT (C) pancake (at) nopcode (dot) org */
|
||||
|
||||
#include "spp.h"
|
||||
#include "r_api.h"
|
||||
|
||||
extern struct Proc *procs[];
|
||||
extern struct Proc *proc;
|
||||
|
46
shlr/spp/meson.build
Normal file
46
shlr/spp/meson.build
Normal file
@ -0,0 +1,46 @@
|
||||
project('spp', 'c')
|
||||
spp_version = '1.0.0'
|
||||
|
||||
configure_file(input: 'config.def.h',
|
||||
output: 'config.h',
|
||||
copy: true)
|
||||
|
||||
spp_files = [
|
||||
'spp.c',
|
||||
's_api.c'
|
||||
]
|
||||
|
||||
libspp_static = static_library('spp', spp_files,
|
||||
install: not meson.is_subproject()
|
||||
)
|
||||
|
||||
libspp = shared_library('spp', spp_files,
|
||||
install: not meson.is_subproject(),
|
||||
soversion: spp_version
|
||||
)
|
||||
|
||||
spp_static_dep = declare_dependency(
|
||||
link_with: libspp_static,
|
||||
)
|
||||
|
||||
spp_dep = declare_dependency(
|
||||
link_with: libspp
|
||||
)
|
||||
|
||||
pkgconfig_mod = import('pkgconfig')
|
||||
pkgconfig_mod.generate(libspp,
|
||||
version: spp_version,
|
||||
name: 'spp',
|
||||
subdirs: ['.'],
|
||||
filebase: 'spp',
|
||||
description: 'spp library'
|
||||
)
|
||||
|
||||
if not meson.is_subproject()
|
||||
install_headers('spp.h')
|
||||
|
||||
spp_exe = executable('spp', ['main.c'],
|
||||
dependencies: spp_dep,
|
||||
install: true
|
||||
)
|
||||
endif
|
@ -1,23 +1,23 @@
|
||||
/* CPP */
|
||||
|
||||
static TAG_CALLBACK(cpp_default) {
|
||||
do_printf (out, "DEFAULT: (%s)\n", buf);
|
||||
out_printf (out, "DEFAULT: (%s)\n", buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static TAG_CALLBACK(cpp_error) {
|
||||
do_printf (out, "\n");
|
||||
out_printf (out, "\n");
|
||||
if (state->echo[state->ifl] && buf) {
|
||||
do_printf (out, "ERROR: %s (line=%d)\n", buf, state->lineno);
|
||||
out_printf (out, "ERROR: %s (line=%d)\n", buf, state->lineno);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static TAG_CALLBACK(cpp_warning) {
|
||||
do_printf (out,"\n");
|
||||
out_printf (out,"\n");
|
||||
if (state->echo[state->ifl] && buf != NULL) {
|
||||
do_printf (out, "WARNING: line %d: %s\n", state->lineno, buf);
|
||||
out_printf (out, "WARNING: line %d: %s\n", state->lineno, buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -80,7 +80,7 @@ static PUT_CALLBACK(cpp_fputs) {
|
||||
cpp_macros[i].name);
|
||||
}
|
||||
}
|
||||
do_printf (out, "%s", buf);
|
||||
out_printf (out, "%s", buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -148,7 +148,9 @@ static ARG_CALLBACK(cpp_arg_d) {
|
||||
if (eq) {
|
||||
*eq = '\0';
|
||||
r_sys_setenv (arg, eq + 1);
|
||||
} else r_sys_setenv (arg, "");
|
||||
} else {
|
||||
r_sys_setenv (arg, "");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,28 +1,28 @@
|
||||
/* CPP */
|
||||
|
||||
static TAG_CALLBACK(pod_default) {
|
||||
do_printf (out, "DEFAULT: (%s)\n", buf);
|
||||
out_printf (out, "DEFAULT: (%s)\n", buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static TAG_CALLBACK(pod_cut) {
|
||||
do_printf (out, "\n");
|
||||
out_printf (out, "\n");
|
||||
state->echo[state->ifl] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static TAG_CALLBACK(pod_head1) {
|
||||
state->echo[state->ifl] = 1;
|
||||
do_printf (out, "\n");
|
||||
out_printf (out, "\n");
|
||||
if (!buf) {
|
||||
return 0;
|
||||
}
|
||||
do_printf (out, "%s\n", buf);
|
||||
out_printf (out, "%s\n", buf);
|
||||
int i, len = strlen (buf);
|
||||
for (i = 0; i < len; i++) {
|
||||
do_printf (out, "%c", '=');
|
||||
out_printf (out, "%c", '=');
|
||||
}
|
||||
do_printf (out, "\n");
|
||||
out_printf (out, "\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,10 @@ static TAG_CALLBACK(sh_default) {
|
||||
if (eof)
|
||||
#endif
|
||||
#if HAVE_FORK
|
||||
system (buf);
|
||||
int r = system (buf);
|
||||
if (errno) {
|
||||
printf ("system '%s' (%d) failed: %s\n", buf, r, strerror (errno));
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@ -52,10 +55,13 @@ static PUT_CALLBACK(sh_fputs) {
|
||||
char str[1024]; // XXX
|
||||
sprintf (str, "echo '%s' | %s", buf, sh_pipe_cmd); // XXX
|
||||
#if HAVE_FORK
|
||||
system (str);
|
||||
int r = system (str);
|
||||
if (errno) {
|
||||
printf ("system '%s' (%d) failed: %s\n", str, r, strerror (errno));
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
do_printf (out, "%s", buf);
|
||||
out_printf (out, "%s", buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
/* Mini MCMS :: renamed to 'spp'? */
|
||||
|
||||
#if __UNIX__
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static char *spp_var_get(char *var) {
|
||||
return getenv(var);
|
||||
@ -74,7 +76,7 @@ static TAG_CALLBACK(spp_get) {
|
||||
}
|
||||
var = spp_var_get (buf);
|
||||
if (var) {
|
||||
do_printf (out, "%s", var);
|
||||
out_printf (out, "%s", var);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -90,7 +92,7 @@ static TAG_CALLBACK(spp_getrandom) {
|
||||
if (max > 0) {
|
||||
max = (int)(rand () % max);
|
||||
}
|
||||
do_printf (out, "%d", max);
|
||||
out_printf (out, "%d", max);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -145,7 +147,7 @@ static TAG_CALLBACK(spp_trace) {
|
||||
/* TODO: deprecate */
|
||||
static TAG_CALLBACK(spp_echo) {
|
||||
if (state->echo[state->ifl]) {
|
||||
do_printf (out, "%s", buf);
|
||||
out_printf (out, "%s", buf);
|
||||
}
|
||||
// TODO: add variable replacement here?? not necessary, done by {{get}}
|
||||
return 0;
|
||||
@ -173,7 +175,7 @@ static TAG_CALLBACK(spp_system) {
|
||||
}
|
||||
#if HAVE_SYSTEM
|
||||
char *str = cmd_to_str (buf);
|
||||
do_printf (out, "%s", str);
|
||||
out_printf (out, "%s", str);
|
||||
free(str);
|
||||
#endif
|
||||
return 0;
|
||||
@ -237,7 +239,7 @@ static TAG_CALLBACK(spp_hex) {
|
||||
b = buf[i + 2];
|
||||
buf[i + 2] = '\0';
|
||||
sscanf(buf + i, "%02x", &ch);
|
||||
do_printf (out, "%c", ch);
|
||||
out_printf (out, "%c", ch);
|
||||
buf[i + 2] = b;
|
||||
buf = buf + 2;
|
||||
}
|
||||
@ -264,7 +266,7 @@ static TAG_CALLBACK(spp_grepline) {
|
||||
}
|
||||
}
|
||||
fclose (fd);
|
||||
do_printf (out, "%s", b);
|
||||
out_printf (out, "%s", b);
|
||||
} else {
|
||||
fprintf(stderr, "Unable to open '%s'\n", buf);
|
||||
}
|
||||
@ -369,7 +371,7 @@ static TAG_CALLBACK(spp_endpipe) {
|
||||
}
|
||||
} while (ret > 0);
|
||||
str[len] = '\0';
|
||||
do_printf (out, "%s", str);
|
||||
out_printf (out, "%s", str);
|
||||
if (spp_pipe_fd) {
|
||||
pclose (spp_pipe_fd);
|
||||
}
|
||||
@ -386,7 +388,7 @@ static PUT_CALLBACK(spp_fputs) {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
do_printf (out, "%s", buf);
|
||||
out_printf (out, "%s", buf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,20 +1,19 @@
|
||||
/* radare - LGPL - Copyright 2013-2016 - pancake */
|
||||
|
||||
#if !HAVE_R_UTIL
|
||||
/* radare - LGPL - Copyright 2013-2019 - pancake */
|
||||
|
||||
#include "spp.h"
|
||||
#include "r_api.h"
|
||||
|
||||
RStrBuf *r_strbuf_new(const char *str) {
|
||||
RStrBuf *s = R_NEW0 (RStrBuf);
|
||||
SStrBuf *r_strbuf_new(const char *str) {
|
||||
SStrBuf *s = R_NEW0 (SStrBuf);
|
||||
if (str) r_strbuf_set (s, str);
|
||||
return s;
|
||||
}
|
||||
|
||||
void r_strbuf_init(RStrBuf *sb) {
|
||||
memset (sb, 0, sizeof (RStrBuf));
|
||||
void r_strbuf_init(SStrBuf *sb) {
|
||||
memset (sb, 0, sizeof (SStrBuf));
|
||||
}
|
||||
|
||||
bool r_strbuf_set(RStrBuf *sb, const char *s) {
|
||||
bool r_strbuf_set(SStrBuf *sb, const char *s) {
|
||||
int l;
|
||||
if (!sb) return false;
|
||||
if (!s) {
|
||||
@ -39,7 +38,7 @@ bool r_strbuf_set(RStrBuf *sb, const char *s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int r_strbuf_append(RStrBuf *sb, const char *s) {
|
||||
int r_strbuf_append(SStrBuf *sb, const char *s) {
|
||||
int l = strlen (s);
|
||||
if (l < 1) {
|
||||
return false;
|
||||
@ -72,16 +71,16 @@ int r_strbuf_append(RStrBuf *sb, const char *s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
char *r_strbuf_get(RStrBuf *sb) {
|
||||
char *r_strbuf_get(SStrBuf *sb) {
|
||||
return sb? (sb->ptr? sb->ptr: sb->buf) : NULL;
|
||||
}
|
||||
|
||||
void r_strbuf_free(RStrBuf *sb) {
|
||||
void r_strbuf_free(SStrBuf *sb) {
|
||||
r_strbuf_fini (sb);
|
||||
free (sb);
|
||||
}
|
||||
|
||||
void r_strbuf_fini(RStrBuf *sb) {
|
||||
void r_strbuf_fini(SStrBuf *sb) {
|
||||
if (sb && sb->ptr)
|
||||
R_FREE (sb->ptr);
|
||||
}
|
||||
@ -101,9 +100,7 @@ int r_sys_setenv(const char *key, const char *value) {
|
||||
SetEnvironmentVariable (key, (LPSTR)value);
|
||||
return 0; // TODO. get ret
|
||||
#else
|
||||
#warning r_sys_setenv : unimplemented for this platform
|
||||
#warning s_sys_setenv : unimplemented for this platform
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // NO_UTIL
|
||||
|
@ -1,72 +1,22 @@
|
||||
#if !HAVE_R_UTIL
|
||||
|
||||
#ifndef R_STRBUF_H
|
||||
#define R_STRBUF_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef R_API
|
||||
#undef R_API
|
||||
#endif
|
||||
#if R_SWIG
|
||||
#define R_API export
|
||||
#elif R_INLINE
|
||||
#define R_API inline
|
||||
#else
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define R_API __attribute__((visibility("default")))
|
||||
#elif defined(_MSC_VER)
|
||||
#define R_API __declspec(dllexport)
|
||||
#else
|
||||
#define R_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(EMSCRIPTEN) || defined(__linux__) || defined(__APPLE__) || defined(__GNU__) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#define __BSD__ 0
|
||||
#define __UNIX__ 1
|
||||
#endif
|
||||
#if __KFBSD__ || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
|
||||
#define __BSD__ 1
|
||||
#define __UNIX__ 1
|
||||
#endif
|
||||
#if __WIN32__ || __CYGWIN__ || MINGW32
|
||||
#define __addr_t_defined
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#if __WIN32__ || MINGW32 && !__CYGWIN__
|
||||
#ifndef _MSC_VER
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
typedef int socklen_t;
|
||||
#undef USE_SOCKETS
|
||||
#define __WINDOWS__ 1
|
||||
#undef __UNIX__
|
||||
#undef __BSD__
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int len;
|
||||
char *ptr;
|
||||
int ptrlen;
|
||||
char buf[64];
|
||||
} RStrBuf;
|
||||
#ifndef S_STRBUF_H
|
||||
#define S_STRBUF_H
|
||||
|
||||
#define R_FREE(x) { free(x); x = NULL; }
|
||||
#define R_NEW0(x) (x*)calloc(1,sizeof(x))
|
||||
|
||||
#define R_STRBUF_SAFEGET(sb) (r_strbuf_get (sb) ? r_strbuf_get (sb) : "")
|
||||
RStrBuf *r_strbuf_new(const char *s);
|
||||
bool r_strbuf_set(RStrBuf *sb, const char *s);
|
||||
int r_strbuf_append(RStrBuf *sb, const char *s);
|
||||
char *r_strbuf_get(RStrBuf *sb);
|
||||
void r_strbuf_free(RStrBuf *sb);
|
||||
void r_strbuf_fini(RStrBuf *sb);
|
||||
void r_strbuf_init(RStrBuf *sb);
|
||||
#endif // R_STRBUF_H
|
||||
#ifdef _MSC_VER
|
||||
void out_printf(Output *out, char *str, ...);
|
||||
#else
|
||||
void out_printf(Output *out, char *str, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
#endif
|
||||
|
||||
#endif // NO_UTIL
|
||||
SStrBuf *r_strbuf_new(const char *s);
|
||||
bool r_strbuf_set(SStrBuf *sb, const char *s);
|
||||
int r_strbuf_append(SStrBuf *sb, const char *s);
|
||||
char *r_strbuf_get(SStrBuf *sb);
|
||||
void r_strbuf_free(SStrBuf *sb);
|
||||
void r_strbuf_fini(SStrBuf *sb);
|
||||
void r_strbuf_init(SStrBuf *sb);
|
||||
int r_sys_setenv(const char *key, const char *value);
|
||||
|
||||
#endif
|
||||
|
@ -1,9 +1,10 @@
|
||||
/* MIT (C) pancake (at) nopcode (dot) org - 2009-2017 */
|
||||
/* MIT (C) pancake (at) nopcode (dot) org - 2009-2019 */
|
||||
|
||||
#include "spp.h"
|
||||
#include "r_api.h"
|
||||
#include "config.h"
|
||||
|
||||
R_API int spp_run(char *buf, Output *out) {
|
||||
S_API int spp_run(char *buf, Output *out) {
|
||||
int i, ret = 0;
|
||||
char *tok;
|
||||
|
||||
@ -80,20 +81,6 @@ void lbuf_strcat(SppBuf *dst, char *src) {
|
||||
dst->lbuf_n += len;
|
||||
}
|
||||
|
||||
void do_printf(Output *out, char *str, ...) {
|
||||
va_list ap;
|
||||
va_start (ap, str);
|
||||
if (out->fout) {
|
||||
vfprintf (out->fout, str, ap);
|
||||
} else {
|
||||
char tmp[4096];
|
||||
vsnprintf (tmp, sizeof (tmp), str, ap);
|
||||
tmp[sizeof (tmp) - 1] = 0;
|
||||
r_strbuf_append (out->cout, tmp);
|
||||
}
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
int do_fputs(Output *out, char *str) {
|
||||
int i;
|
||||
int printed = 0;
|
||||
@ -115,7 +102,7 @@ int do_fputs(Output *out, char *str) {
|
||||
return printed;
|
||||
}
|
||||
|
||||
R_API void spp_eval(char *buf, Output *out) {
|
||||
S_API void spp_eval(char *buf, Output *out) {
|
||||
char *ptr, *ptr2;
|
||||
char *ptrr = NULL;
|
||||
int delta;
|
||||
@ -234,7 +221,7 @@ retry:
|
||||
}
|
||||
|
||||
/* TODO: detect nesting */
|
||||
R_API void spp_io(FILE *in, Output *out) {
|
||||
S_API void spp_io(FILE *in, Output *out) {
|
||||
char buf[4096];
|
||||
int lines;
|
||||
if (!proc->buf.lbuf) {
|
||||
@ -248,12 +235,15 @@ R_API void spp_io(FILE *in, Output *out) {
|
||||
proc->buf.lbuf_s = 1024;
|
||||
while (!feof (in)) {
|
||||
buf[0] = '\0'; // ???
|
||||
if (!fgets (buf, 1023, in)) break;
|
||||
if (!fgets (buf, sizeof (buf) - 1, in)) {
|
||||
break;
|
||||
}
|
||||
if (feof (in)) break;
|
||||
lines = 1;
|
||||
if (!memcmp (buf, "#!", 2)) {
|
||||
if (!fgets (buf, 1023, in)) break;
|
||||
if (feof (in)) break;
|
||||
if (!fgets (buf, sizeof (buf) - 1, in) || feof (in)) {
|
||||
break;
|
||||
}
|
||||
lines++;
|
||||
}
|
||||
if (proc->multiline) {
|
||||
@ -279,7 +269,7 @@ R_API void spp_io(FILE *in, Output *out) {
|
||||
(void)do_fputs (out, proc->buf.lbuf);
|
||||
}
|
||||
|
||||
R_API int spp_file(const char *file, Output *out) {
|
||||
S_API int spp_file(const char *file, Output *out) {
|
||||
FILE *in = fopen (file, "r");
|
||||
D fprintf (stderr, "SPP-FILE(%s)\n", file);
|
||||
if (in) {
|
||||
@ -291,21 +281,21 @@ R_API int spp_file(const char *file, Output *out) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
R_API void spp_proc_list_kw() {
|
||||
S_API void spp_proc_list_kw() {
|
||||
int i;
|
||||
for (i = 0; tags[i].name; i++) {
|
||||
printf ("%s\n", tags[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
R_API void spp_proc_list() {
|
||||
S_API void spp_proc_list() {
|
||||
int i;
|
||||
for (i=0; procs[i]; i++) {
|
||||
printf ("%s\n", procs[i]->name);
|
||||
}
|
||||
}
|
||||
|
||||
R_API void spp_proc_set(struct Proc *p, char *arg, int fail) {
|
||||
S_API void spp_proc_set(struct Proc *p, char *arg, int fail) {
|
||||
int i, j;
|
||||
if (arg)
|
||||
for (j = 0; procs[j]; j++) {
|
||||
@ -332,3 +322,17 @@ R_API void spp_proc_set(struct Proc *p, char *arg, int fail) {
|
||||
tags = (struct Tag*)proc->tags;
|
||||
}
|
||||
}
|
||||
|
||||
void out_printf(Output *out, char *str, ...) {
|
||||
va_list ap;
|
||||
va_start (ap, str);
|
||||
if (out->fout) {
|
||||
vfprintf (out->fout, str, ap);
|
||||
} else {
|
||||
char tmp[4096];
|
||||
vsnprintf (tmp, sizeof (tmp), str, ap);
|
||||
tmp[sizeof (tmp) - 1] = 0;
|
||||
r_strbuf_append (out->cout, tmp);
|
||||
}
|
||||
va_end (ap);
|
||||
}
|
||||
|
@ -5,11 +5,47 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#if HAVE_R_UTIL
|
||||
#include <r_util.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef S_API
|
||||
#undef S_API
|
||||
#endif
|
||||
#if R_SWIG
|
||||
#define S_API export
|
||||
#elif R_INLINE
|
||||
#define S_API inline
|
||||
#else
|
||||
#include "r_api.h"
|
||||
int r_sys_setenv(const char *key, const char *value);
|
||||
#if defined(__GNUC__) && __GNUC__ >= 4
|
||||
#define S_API __attribute__((visibility("default")))
|
||||
#elif defined(_MSC_VER)
|
||||
#define S_API __declspec(dllexport)
|
||||
#else
|
||||
#define S_API
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(EMSCRIPTEN) || defined(__linux__) || defined(__APPLE__) || defined(__GNU__) || defined(__ANDROID__) || defined(__QNX__)
|
||||
#define __BSD__ 0
|
||||
#define __UNIX__ 1
|
||||
#endif
|
||||
#if __KFBSD__ || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#define __BSD__ 1
|
||||
#define __UNIX__ 1
|
||||
#endif
|
||||
#if __WIN32__ || __CYGWIN__ || MINGW32
|
||||
#define __addr_t_defined
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#if __WIN32__ || MINGW32 && !__CYGWIN__ || _MSC_VER
|
||||
#ifndef _MSC_VER
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
typedef int socklen_t;
|
||||
#undef USE_SOCKETS
|
||||
#define __WINDOWS__ 1
|
||||
#undef __UNIX__
|
||||
#undef __BSD__
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
@ -24,10 +60,6 @@ int r_sys_setenv(const char *key, const char *value);
|
||||
|
||||
#define MAXIFL 128
|
||||
|
||||
extern int ifl;
|
||||
extern int echo[MAXIFL];
|
||||
extern int lineno;
|
||||
|
||||
#ifndef HAVE_FORK
|
||||
#define HAVE_FORK 1
|
||||
#endif
|
||||
@ -47,12 +79,19 @@ extern int lineno;
|
||||
#define GET_ARG(x,y,i) if (y[i][2]) x = y[i] + 2; else x = y[++i]
|
||||
|
||||
#define DEFAULT_PROC(x) \
|
||||
DLL_LOCAL struct Tag *tags = (struct Tag *)&x##_tags; \
|
||||
DLL_LOCAL struct Arg *args = (struct Arg *)&x##_args; \
|
||||
DLL_LOCAL struct Proc *proc = &x##_proc;
|
||||
struct Tag *tags = (struct Tag *)&x##_tags; \
|
||||
struct Arg *args = (struct Arg *)&x##_args; \
|
||||
struct Proc *proc = &x##_proc;
|
||||
|
||||
typedef struct s_strbuf_t {
|
||||
int len;
|
||||
char *ptr;
|
||||
int ptrlen;
|
||||
char buf[64];
|
||||
} SStrBuf;
|
||||
|
||||
typedef struct {
|
||||
RStrBuf *cout;
|
||||
SStrBuf *cout;
|
||||
FILE *fout;
|
||||
int size;
|
||||
} Output;
|
||||
@ -101,22 +140,16 @@ struct Proc {
|
||||
int tag_begin;
|
||||
int default_echo;
|
||||
SppState state;
|
||||
SppBuf buf;
|
||||
SppBuf buf;
|
||||
};
|
||||
|
||||
R_API int spp_file(const char *file, Output *out);
|
||||
R_API int spp_run(char *buf, Output *out);
|
||||
R_API void spp_eval(char *buf, Output *out);
|
||||
R_API void spp_io(FILE *in, Output *out);
|
||||
#ifdef _MSC_VER
|
||||
void do_printf(Output *out, char *str, ...);
|
||||
#else
|
||||
void do_printf(Output *out, char *str, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
#endif
|
||||
|
||||
R_API void spp_proc_list(void);
|
||||
R_API void spp_proc_list_kw(void);
|
||||
R_API void spp_proc_set(struct Proc *p, char *arg, int fail);
|
||||
S_API int spp_file(const char *file, Output *out);
|
||||
S_API int spp_run(char *buf, Output *out);
|
||||
S_API void spp_eval(char *buf, Output *out);
|
||||
S_API void spp_io(FILE *in, Output *out);
|
||||
S_API void spp_proc_list(void);
|
||||
S_API void spp_proc_list_kw(void);
|
||||
S_API void spp_proc_set(struct Proc *p, char *arg, int fail);
|
||||
|
||||
#if DEBUG
|
||||
#define D if (1)
|
||||
|
@ -42,14 +42,13 @@
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifdef __WINDOWS__
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -34,7 +34,6 @@
|
||||
|
||||
|
||||
#include "zipint.h"
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "zlib.h"
|
||||
#ifdef STDC
|
||||
# include <string.h>
|
||||
@ -38,6 +37,8 @@
|
||||
|
||||
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
|
||||
# include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
|
@ -4,7 +4,6 @@
|
||||
*/
|
||||
|
||||
#include "gzguts.h"
|
||||
#include <unistd.h>
|
||||
|
||||
/* Local functions */
|
||||
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
|
||||
|
@ -472,7 +472,9 @@ typedef uLong FAR uLongf;
|
||||
#endif
|
||||
#ifndef Z_SOLO
|
||||
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
||||
#ifndef _WIN32
|
||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||
#endif
|
||||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
# endif
|
||||
|
@ -194,7 +194,6 @@ def win_dist_libr2(**path_fmt):
|
||||
copy(r'{ROOT}\libr\include\sdb\*.h', r'{DIST}\{R2_INCDIR}\sdb')
|
||||
copy(r'{ROOT}\libr\include\r_util\*.h', r'{DIST}\{R2_INCDIR}\r_util')
|
||||
copy(r'{ROOT}\libr\include\r_crypto\*.h', r'{DIST}\{R2_INCDIR}\r_crypto')
|
||||
copytree(r'{ROOT}\libr\include\msvc', r'{DIST}\{R2_INCDIR}\msvc')
|
||||
makedirs(r'{DIST}\{R2_FORTUNES}')
|
||||
copy(r'{ROOT}\doc\fortunes.*', r'{DIST}\{R2_FORTUNES}')
|
||||
copytree(r'{ROOT}\libr\bin\d', r'{DIST}\{R2_SDB}\format',
|
||||
|
@ -22,9 +22,6 @@ IFS=${_IFS}
|
||||
|
||||
# Use /FS to allow cl.exe to write to the same .pdb file
|
||||
CFLAGS="-FS"
|
||||
# Include msvc directory to provide unistd.h and sys/time.h
|
||||
INC_DIR=$(cygpath -aw $(pwd)/libr/include/msvc)
|
||||
CFLAGS="${CFLAGS} -I\"${INC_DIR}\""
|
||||
|
||||
# export CCCL_OPTIONS="--cccl-verbose"
|
||||
export CFLAGS="${CFLAGS}"
|
||||
|
Loading…
Reference in New Issue
Block a user