radare2/shlr/spp
pancake 4327d8322f
Bring back the mingw32 builds ##windows
* Massage conflicting function signatures spotted by mingw
* Fix the spp visibility issue
* Enable 32 and 64bit mingw builds in the CI
2021-11-28 22:10:51 +01:00
..
bin Update spp to 1.2.0 (#17243) 2020-07-09 17:20:06 +08:00
p Bring back the mingw32 builds ##windows 2021-11-28 22:10:51 +01:00
BUGS Add spp to r2 utils build (#6334) 2016-12-18 09:46:10 +01:00
config.def.h Make SPP less dependent on system(3) and popen(3) 2018-12-15 18:32:24 +01:00
config.mk.acr Update spp to 1.2.0 (#17243) 2020-07-09 17:20:06 +08:00
configure Update spp to 1.2.0 (#17243) 2020-07-09 17:20:06 +08:00
configure.acr Update spp to 1.2.0 (#17243) 2020-07-09 17:20:06 +08:00
LICENSE Add spp to r2 utils build (#6334) 2016-12-18 09:46:10 +01:00
Makefile Bring back the mingw32 builds ##windows 2021-11-28 22:10:51 +01:00
meson.build Fix the windows build regressions 2021-10-19 22:17:47 +02:00
r_api.c Update spp to 1.2.0 (#17243) 2020-07-09 17:20:06 +08:00
r_api.h Bring back the mingw32 builds ##windows 2021-11-28 22:10:51 +01:00
README.md commandline -> command-line 2021-05-25 10:51:18 +02:00
spp.1 commandline -> command-line 2021-05-25 10:51:18 +02:00
spp.c Bring back the mingw32 builds ##windows 2021-11-28 22:10:51 +01:00
spp.h Bring back the mingw32 builds ##windows 2021-11-28 22:10:51 +01:00

spp

Description

SPP stands for Simple Pre-Processor.

The primary use of spp is as a templating language, with similarities to PHP and CPP. Allowing to embed scripts in any language in some specific places of the document.

Build

You can tweak some options with ./configure (or copying your favourite config.mk)

Optional Features:
  --without-fork         build without depending on fork syscall
  --enable-r2            compile against r2 r_util

The way to build is as easy as in any GNU program:

$ ./configure --prefix=/usr
$ make
$ make install

Usage

The spp program can be used like cat, but it will evaluate the tokenized expressions specified by the preprocessors.

  • Use spp -l to list the available preprocessors (default is spp)
  • Use spp -t cpp to select the cpp preprocessor

Input can be stdin or all the files passed as argument.

$ echo 'Hello <{system uname}>' | spp
Hello Darwin

Embedding

There are no embedding issues with the MIT license and the amount if code is pretty low (~400 LOC), and use the apis:

$ cat test.c
#include "spp.c"

int main() {
	char *p = spp_eval_str (&spp_proc, "Hello <{system uname}>");
	printf ("%s\n", p);
	free (p);
}

$ gcc test.c
$ ./a.out
Hello Darwin

Commandline

SPP is also a command-line tool that takes N files as arguments and evaluates them using the selected preprocessor:

$ ./spp -h
Usage: ./spp [-othesv] [file] [...]
  -o [file]     set output file (stdout)
  -t [type]     define processor type (spp,cpp,pod,acr,sh)
  -e [str]      evaluate this string with the selected proc
  -s [str]      show this string before anything
  -l            list all built-in preprocessors
  -L            list keywords registered by the processor
  -n            do not read from stdin
  -v            show version information
spp specific flags:
 -I   add include directory
 -D   define value of variable

Preprocessors

There are 5 preprocessors that are available in spp by default. You can write your own and just pass the struct reference as argument.

SPP

<{ set arch x86-32 }>

hello <{echo world}>
path=<{system echo $PATH}>
arch = <{ get arch }>

<{ ifeq arch x86-32 }>
FOO IS ENABLED
<{ endif }>

CPP

#define FOO 1
#define MAX(x,y) (x>y)?x:y

main() {
	printf ("%d\n", MAX (3,10));
}

ASM

.include t/syscalls.asm
int3

...